Skip to content

Commit

Permalink
Make maximum ramp up time a config setting and increase to 5s by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer committed Mar 6, 2021
1 parent b312f27 commit f41b01f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions mos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ config_schema:
- ["wc.idle_power_thr", "d", 10.0, {title: "Power consumption threshold for motor idle detection"}]
- ["wc.move_power", "d", 0.0, {title: "Power consumption during movement, watts"}]
- ["wc.move_time_ms", "i", 0, {title: "Move time, in millseconds"}]
- ["wc.max_ramp_up_time_ms", "i", 5000, {title: "Maximum ramp up time, in millseconds"}]
- ["wc.current_pos", "d", 0.0, {title: "Last position, percent: 0 - fully closed, 100 - fully open."}]

- ["gdo", "o", {title: "Garage door settings", abstract: true}]
Expand Down
8 changes: 4 additions & 4 deletions src/shelly_hap_window_covering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void WindowCovering::RunOnce() {
const float p0 = p0v.ValueOrDie();
LOG_EVERY_N(LL_INFO, 8, ("WC %d: P0 = %.3f", id(), p0));
if (p0 < cfg_->idle_power_thr &&
(mgos_uptime_micros() - begin_ > 1000000)) {
(mgos_uptime_micros() - begin_ > cfg_->max_ramp_up_time_ms * 1000)) {
out_open_->SetState(false, ss);
SetInternalState(State::kPostCal0);
}
Expand Down Expand Up @@ -547,7 +547,7 @@ void WindowCovering::RunOnce() {
break;
}
int elapsed_us = (mgos_uptime_micros() - begin_);
if (elapsed_us > 1000000) {
if (elapsed_us > cfg_->max_ramp_up_time_ms * 1000) {
LOG(LL_ERROR, ("Failed to start moving"));
tgt_state_ = State::kError;
SetInternalState(State::kStop);
Expand Down Expand Up @@ -592,8 +592,8 @@ void WindowCovering::RunOnce() {
(tgt_pos_ == kFullyClosed && moving_dir_ == Direction::kClose)) &&
!reverse) {
LOG_EVERY_N(LL_INFO, 8, ("Moving to %d, p %.2f", (int) tgt_pos_, p));
if (p > cfg_->idle_power_thr ||
(mgos_uptime_micros() - begin_ < 1000000)) {
if (p > cfg_->idle_power_thr || (mgos_uptime_micros() - begin_ <
cfg_->max_ramp_up_time_ms * 1000)) {
// Still moving or ramping up.
break;
} else {
Expand Down

0 comments on commit f41b01f

Please sign in to comment.