Revert "feat(valve): Implement obstacle detection with configurable thresholds"

This reverts commit 3c2235733b.
This commit is contained in:
2025-07-11 00:35:19 +02:00
parent 3c2235733b
commit b937c52bcc
6 changed files with 8 additions and 152 deletions

View File

@@ -29,8 +29,6 @@ static uint16_t max_opening_time_s = 10;
static uint16_t max_closing_time_s = 10;
static uint16_t end_current_threshold_open_ma = 10; // Default value for open
static uint16_t end_current_threshold_close_ma = 10; // Default value for close
static uint16_t obstacle_current_threshold_open_ma = 600; // Default value for open
static uint16_t obstacle_current_threshold_close_ma = 600; // Default value for close
static struct k_work_delayable valve_work; // Work item for scheduling valve movement timeouts
static struct k_timer movement_timer;
@@ -49,11 +47,6 @@ static void valve_work_handler(struct k_work *work)
if (current_movement == VALVE_MOVEMENT_OPENING) {
vnd7050aj_read_load_current(vnd7050aj_dev, VALVE_CHANNEL_OPEN, &current_ma);
if (current_ma > obstacle_current_threshold_open_ma) {
LOG_ERR("Obstacle detected during opening! Current: %d mA", current_ma);
current_movement = VALVE_MOVEMENT_OBSTACLE;
goto work_handler_finish;
}
if (current_ma > end_current_threshold_open_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
return;
@@ -61,11 +54,6 @@ static void valve_work_handler(struct k_work *work)
LOG_INF("Valve finished opening");
} else if (current_movement == VALVE_MOVEMENT_CLOSING) {
vnd7050aj_read_load_current(vnd7050aj_dev, VALVE_CHANNEL_CLOSE, &current_ma);
if (current_ma > obstacle_current_threshold_close_ma) {
LOG_ERR("Obstacle detected during closing! Current: %d mA", current_ma);
current_movement = VALVE_MOVEMENT_OBSTACLE;
goto work_handler_finish;
}
if (current_ma > end_current_threshold_close_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
return;
@@ -75,7 +63,6 @@ static void valve_work_handler(struct k_work *work)
}
current_movement = VALVE_MOVEMENT_IDLE;
work_handler_finish:
// Reset the movement timer
k_timer_stop(&movement_timer);
@@ -117,21 +104,13 @@ int valve_init(void)
settings_load_one("valve/end_current_threshold_close",
&end_current_threshold_close_ma,
sizeof(end_current_threshold_close_ma));
settings_load_one("valve/obstacle_current_threshold_open",
&obstacle_current_threshold_open_ma,
sizeof(obstacle_current_threshold_open_ma));
settings_load_one("valve/obstacle_current_threshold_close",
&obstacle_current_threshold_close_ma,
sizeof(obstacle_current_threshold_close_ma));
LOG_INF("Valve initialized: max_open=%us, max_close=%us, end_curr_open=%umA, "
"end_curr_close=%umA, obs_curr_open=%umA, obs_curr_close=%umA",
"end_curr_close=%umA",
max_opening_time_s,
max_closing_time_s,
end_current_threshold_open_ma,
end_current_threshold_close_ma,
obstacle_current_threshold_open_ma,
obstacle_current_threshold_close_ma);
end_current_threshold_close_ma);
valve_close();
return 0;
}
@@ -211,22 +190,6 @@ void valve_set_end_current_threshold_close(uint16_t current_ma)
sizeof(end_current_threshold_close_ma));
}
void valve_set_obstacle_current_threshold_open(uint16_t current_ma)
{
obstacle_current_threshold_open_ma = current_ma;
settings_save_one("valve/obstacle_current_threshold_open",
&obstacle_current_threshold_open_ma,
sizeof(obstacle_current_threshold_open_ma));
}
void valve_set_obstacle_current_threshold_close(uint16_t current_ma)
{
obstacle_current_threshold_close_ma = current_ma;
settings_save_one("valve/obstacle_current_threshold_close",
&obstacle_current_threshold_close_ma,
sizeof(obstacle_current_threshold_close_ma));
}
uint16_t valve_get_max_open_time(void)
{
return max_opening_time_s;
@@ -246,16 +209,6 @@ uint16_t valve_get_end_current_threshold_close(void)
return end_current_threshold_close_ma;
}
uint16_t valve_get_obstacle_current_threshold_open(void)
{
return obstacle_current_threshold_open_ma;
}
uint16_t valve_get_obstacle_current_threshold_close(void)
{
return obstacle_current_threshold_close_ma;
}
int32_t valve_get_opening_current(void)
{
int32_t current;