fix(valve): Start movement timer only if timeout is greater than 0
Ensures that the k_timer for valve movement timeouts is only started if the configured max_opening_time_s or max_closing_time_s is greater than 0. This prevents unnecessary timer activations when timeouts are disabled or zero.
This commit is contained in:
parent
92bb171e85
commit
5fd904de9e
|
|
@ -123,7 +123,9 @@ void valve_open(void)
|
|||
current_state = VALVE_STATE_OPEN;
|
||||
current_movement = VALVE_MOVEMENT_OPENING; /* Security: assume valve open as
|
||||
soons as it starts opening */
|
||||
k_timer_start(&movement_timer, K_SECONDS(max_opening_time_s), K_NO_WAIT);
|
||||
if (max_opening_time_s > 0) {
|
||||
k_timer_start(&movement_timer, K_SECONDS(max_opening_time_s), K_NO_WAIT);
|
||||
}
|
||||
k_work_schedule(&valve_work, K_MSEC(100));
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +134,9 @@ void valve_close(void)
|
|||
vnd7050aj_reset_fault(vnd7050aj_dev);
|
||||
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_OPEN, false);
|
||||
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_CLOSE, true);
|
||||
k_timer_start(&movement_timer, K_SECONDS(max_closing_time_s), K_NO_WAIT);
|
||||
if (max_closing_time_s > 0) {
|
||||
k_timer_start(&movement_timer, K_SECONDS(max_closing_time_s), K_NO_WAIT);
|
||||
}
|
||||
current_movement = VALVE_MOVEMENT_CLOSING;
|
||||
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue