From 9cf1269e0e35f2bd9c4e85618468cdfabeb80771 Mon Sep 17 00:00:00 2001 From: Jilay Pandya Date: Tue, 8 Oct 2024 16:08:23 +0200 Subject: [PATCH] shell: stepper: add further stepper signals to shell This commit adds further signals to stepper shell - STEPPER_SIGNAL_SENSORLESS_STALL_DETECTED - STEPPER_SIGNAL_LEFT_END_STOP_DETECTED - STEPPER_SIGNAL_RIGHT_END_STOP_DETECTED Signed-off-by: Jilay Pandya --- drivers/stepper/stepper_shell.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/stepper/stepper_shell.c b/drivers/stepper/stepper_shell.c index 10ab67fb2c6..f761a26f831 100644 --- a/drivers/stepper/stepper_shell.c +++ b/drivers/stepper/stepper_shell.c @@ -445,10 +445,26 @@ static void stepper_poll_thread(void *p1, void *p2, void *p3) while (1) { k_poll(&stepper_poll_event, 1, K_FOREVER); - if (stepper_poll_event.signal->result == STEPPER_SIGNAL_STEPS_COMPLETED) { - shell_print(sh, "Stepper: All steps completed"); - k_poll_signal_reset(&stepper_signal); + switch (stepper_poll_event.signal->result) { + case STEPPER_SIGNAL_STEPS_COMPLETED: + shell_fprintf_info(sh, "Stepper: All steps completed.\n"); + break; + case STEPPER_SIGNAL_SENSORLESS_STALL_DETECTED: + shell_fprintf_info(sh, "Stepper: Sensorless stall detected.\n"); + break; + case STEPPER_SIGNAL_LEFT_END_STOP_DETECTED: + shell_fprintf_info(sh, "Stepper: Left limit switch pressed.\n"); + break; + case STEPPER_SIGNAL_RIGHT_END_STOP_DETECTED: + shell_fprintf_normal(sh, "Stepper: Right limit switch pressed.\n"); + break; + default: + shell_fprintf_error(sh, "Stepper: Unknown signal received.\n"); + break; } + + k_poll_signal_reset(&stepper_signal); + } }