From 71f0da35a231f2bf23ac91a37411120b1e59f4d6 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Wed, 23 Jun 2021 18:54:29 +0100 Subject: [PATCH] Added command to notify when stage stops This allows simpler emulation of blocking moves. We may want to improve the way this works... --- src/modules/stage/stage.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/stage/stage.cpp b/src/modules/stage/stage.cpp index 4949ddc..8118aea 100644 --- a/src/modules/stage/stage.cpp +++ b/src/modules/stage/stage.cpp @@ -21,6 +21,7 @@ signed long current_pos[n_motors]; long steps_remaining[n_motors]; bool stage_moving = false; +bool notify_on_stop = false; void stage_setup() { @@ -164,6 +165,11 @@ void stage_loop() } } } + if (!stage_moving && notify_on_stop) + { + Serial.println("stopped"); + notify_on_stop = false; + } } void stage_move_single_axis(uint8_t axis, String command) @@ -273,6 +279,11 @@ void is_stage_moving(String command) Serial.println(stage_moving?"true":"false"); } +void activate_notify_on_stop(String command) +{ + notify_on_stop = true; +} + //TODO: move help strings to program memory //F() cannot be used outside block context though extern const Command stage_commands[] = { @@ -288,4 +299,5 @@ extern const Command stage_commands[] = { {"zero", stage_zero}, {"stop", stage_stop}, {"moving", is_stage_moving}, + {"notify_on_stop", activate_notify_on_stop}, END_COMMAND}; \ No newline at end of file