Compare commits

..

No commits in common. "fc0add858362944bd820a2db4b1abe019f71102a" and "32bb77926f4f3a669a2a83196b165a69bcba060e" have entirely different histories.

3 changed files with 14 additions and 11 deletions

View File

@ -17,8 +17,8 @@
#define VALVE_CHANNEL_CLOSE 1
#define VALVE_ENDPOSITION_CHECK_INTERVAL K_MSEC(100)
#define VALVE_OBSTACLE_THRESHOLD_OPEN_MA 200
#define VALVE_OBSTACLE_THRESHOLD_CLOSE_MA 200
#define VALVE_OBSTACLE_THRESHOLD_OPEN_MA 500
#define VALVE_OBSTACLE_THRESHOLD_CLOSE_MA 500
/**
* @brief Represents the static state of the valve (open or closed).

View File

@ -54,7 +54,7 @@ static void valve_work_handler(struct k_work *work)
current_ma);
current_movement = VALVE_MOVEMENT_ERROR;
valve_stop();
return;
goto work_handler_cleanup;
} else if (current_ma > end_current_threshold_open_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
return;
@ -69,7 +69,7 @@ static void valve_work_handler(struct k_work *work)
current_ma);
current_movement = VALVE_MOVEMENT_ERROR;
valve_stop();
return;
goto work_handler_cleanup;
} else if (current_ma > end_current_threshold_close_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
return;
@ -79,7 +79,12 @@ static void valve_work_handler(struct k_work *work)
}
current_movement = VALVE_MOVEMENT_IDLE;
valve_stop();
work_handler_cleanup:
// Reset the movement timer
k_timer_stop(&movement_timer);
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_OPEN, false);
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_CLOSE, false);
}
/**
@ -142,9 +147,9 @@ void valve_open(void)
vnd7050aj_reset_fault(vnd7050aj_dev);
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_CLOSE, false);
vnd7050aj_set_output_state(vnd7050aj_dev, VALVE_CHANNEL_OPEN, true);
current_state =
VALVE_STATE_OPEN; /* Security: assume valve open as soon as it starts opening */
current_movement = VALVE_MOVEMENT_OPENING;
current_state = VALVE_STATE_OPEN;
current_movement = VALVE_MOVEMENT_OPENING; /* Security: assume valve open as
soons as it starts opening */
if (max_opening_time_s > 0) {
k_timer_start(&movement_timer, K_SECONDS(max_opening_time_s), K_NO_WAIT);
}

View File

@ -79,9 +79,7 @@ def poll_status(slave_id, interval):
# Attempt to connect
if client.connect():
reconnect_attempts = 0
with status_lock:
status_data["error"] = None # Clear error in status_data immediately
time.sleep(0.1) # Allow UI to refresh with cleared error
new_data["error"] = None # Clear error on successful reconnect
else:
new_data["error"] = f"Connection lost. Attempting to reconnect ({reconnect_attempts}/{max_reconnect_attempts})..."
time.sleep(reconnect_delay)