Revert "feat(valve): Implement obstacle detection with configurable thresholds"
This reverts commit 3c2235733b.
This commit is contained in:
@@ -55,32 +55,6 @@ static int cmd_valve_set_end_curr_close(const struct shell *sh, size_t argc, cha
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_valve_set_obs_curr_open(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
shell_print(sh, "Usage: valve set_obs_curr_open <milliamps>");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
uint16_t current_ma = (uint16_t)atoi(argv[1]);
|
||||
valve_set_obstacle_current_threshold_open(current_ma);
|
||||
shell_print(sh, "Obstacle current threshold (open) set to %u mA.", current_ma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_valve_set_obs_curr_close(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
shell_print(sh, "Usage: valve set_obs_curr_close <milliamps>");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
uint16_t current_ma = (uint16_t)atoi(argv[1]);
|
||||
valve_set_obstacle_current_threshold_close(current_ma);
|
||||
shell_print(sh, "Obstacle current threshold (close) set to %u mA.", current_ma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_valve_show(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
const int label_width = 30;
|
||||
@@ -98,16 +72,6 @@ static int cmd_valve_show(const struct shell *sh, size_t argc, char **argv)
|
||||
label_width,
|
||||
"End Current Threshold (Close):",
|
||||
valve_get_end_current_threshold_close());
|
||||
shell_print(sh,
|
||||
"%*s %u mA",
|
||||
label_width,
|
||||
"Obstacle Current Threshold (Open):",
|
||||
valve_get_obstacle_current_threshold_open());
|
||||
shell_print(sh,
|
||||
"%*s %u mA",
|
||||
label_width,
|
||||
"Obstacle Current Threshold (Close):",
|
||||
valve_get_obstacle_current_threshold_close());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -122,14 +86,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_valve_settings,
|
||||
NULL,
|
||||
"Set end current threshold for closing (mA)",
|
||||
cmd_valve_set_end_curr_close),
|
||||
SHELL_CMD(set_obs_curr_open,
|
||||
NULL,
|
||||
"Set obstacle current threshold for opening (mA)",
|
||||
cmd_valve_set_obs_curr_open),
|
||||
SHELL_CMD(set_obs_curr_close,
|
||||
NULL,
|
||||
"Set obstacle current threshold for closing (mA)",
|
||||
cmd_valve_set_obs_curr_close),
|
||||
SHELL_CMD(show, NULL, "Show valve configuration", cmd_valve_show),
|
||||
SHELL_SUBCMD_SET_END);
|
||||
|
||||
|
||||
@@ -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, ¤t_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, ¤t_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;
|
||||
|
||||
Reference in New Issue
Block a user