From f218405c36d03094f00d867fcebec07072ba7d44 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 25 Aug 2019 05:46:02 -0400 Subject: [PATCH] Fix ExtUI invalid speed, timer (#15031) --- Marlin/src/feature/babystep.cpp | 4 +-- Marlin/src/feature/babystep.h | 4 +-- Marlin/src/feature/pause.cpp | 8 +++--- Marlin/src/feature/prusa_MMU2/mmu2.cpp | 2 +- Marlin/src/gcode/config/M43.cpp | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 6 +--- Marlin/src/gcode/stats/M75-M78.cpp | 3 -- Marlin/src/lcd/extensible_ui/ui_api.cpp | 29 +++++++++++++------- Marlin/src/lcd/extensible_ui/ui_api.h | 6 ++-- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/libs/stopwatch.cpp | 4 +++ Marlin/src/module/probe.cpp | 2 +- 12 files changed, 38 insertions(+), 34 deletions(-) diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index eb6ed046a4..41d7e80075 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -37,7 +37,7 @@ Babystep babystep; volatile int16_t Babystep::todo[BS_TODO_AXIS(Z_AXIS) + 1]; -#if HAS_LCD_MENU +#if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) int16_t Babystep::accum; #if ENABLED(BABYSTEP_DISPLAY_TOTAL) int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; @@ -75,7 +75,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { if (!CAN_BABYSTEP(axis)) return; - #if HAS_LCD_MENU + #if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) accum += distance; // Count up babysteps for the UI #if ENABLED(BABYSTEP_DISPLAY_TOTAL) axis_total[BS_TOTAL_AXIS(axis)] += distance; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index 1969e6c9c3..ff3709e5ff 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -30,7 +30,7 @@ #define BS_TODO_AXIS(A) 0 #endif -#if HAS_LCD_MENU && ENABLED(BABYSTEP_DISPLAY_TOTAL) +#if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(BABYSTEP_DISPLAY_TOTAL) #if ENABLED(BABYSTEP_XY) #define BS_TOTAL_AXIS(A) A #else @@ -41,7 +41,7 @@ class Babystep { public: static volatile int16_t todo[BS_TODO_AXIS(Z_AXIS) + 1]; - #if HAS_LCD_MENU + #if HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI) static int16_t accum; // Total babysteps in current edit #if ENABLED(BABYSTEP_DISPLAY_TOTAL) static int16_t axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; // Total babysteps since G28 diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index aca275b39d..f1b8227b74 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -188,7 +188,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l host_action_prompt_show(); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("Load Filament")); + ExtUI::onUserConfirmRequired(PSTR("Load Filament")); #endif while (wait_for_user) { #if HAS_BUZZER @@ -243,7 +243,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Continuous Purge Running..."), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("Continuous Purge Running...")); + ExtUI::onUserConfirmRequired(PSTR("Continuous Purge Running...")); #endif for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) do_pause_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE); @@ -524,7 +524,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Nozzle Parked"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("Nozzle Parked")); + ExtUI::onUserConfirmRequired(PSTR("Nozzle Parked")); #endif while (wait_for_user) { #if HAS_BUZZER @@ -548,7 +548,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("HeaterTimeout")); + ExtUI::onUserConfirmRequired(PSTR("HeaterTimeout")); #endif // Wait for LCD click or M108 diff --git a/Marlin/src/feature/prusa_MMU2/mmu2.cpp b/Marlin/src/feature/prusa_MMU2/mmu2.cpp index 12f84af3e8..57d0418c4f 100644 --- a/Marlin/src/feature/prusa_MMU2/mmu2.cpp +++ b/Marlin/src/feature/prusa_MMU2/mmu2.cpp @@ -716,7 +716,7 @@ void MMU2::filament_runout() { host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("MMU2 Eject Recover")); + ExtUI::onUserConfirmRequired(PSTR("MMU2 Eject Recover")); #endif while (wait_for_user) idle(); BUZZ(200, 404); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 3f3c48150a..7b048f2190 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -334,7 +334,7 @@ void GcodeSuite::M43() { host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("M43 Wait Called")); + ExtUI::onUserConfirmRequired(PSTR("M43 Wait Called")); #endif #endif diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 67f634ce83..05fb7576fb 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -98,7 +98,7 @@ void GcodeSuite::M0_M1() { host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M0/1 Break Called"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("M0/1 Break Called")); + ExtUI::onUserConfirmRequired(PSTR("M0/1 Break Called")); #endif if (ms > 0) { @@ -108,10 +108,6 @@ void GcodeSuite::M0_M1() { else while (wait_for_user) idle(); - #if ENABLED(EXTENSIBLE_UI) - ExtUI::onUserConfirmRequired(nullptr); - #endif - #if HAS_LEDS_OFF_FLAG printerEventLEDs.onResumeAfterWait(); #endif diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 8749a59868..d8589031ed 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -33,9 +33,6 @@ */ void GcodeSuite::M75() { print_job_timer.start(); - #if ENABLED(EXTENSIBLE_UI) - ExtUI::onPrintTimerStarted(); - #endif } /** diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index cd6d36a800..535556777e 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -320,7 +320,7 @@ namespace ExtUI { #endif constexpr float max_manual_feedrate[XYZE] = MANUAL_FEEDRATE; - setFeedrate_mm_s(max_manual_feedrate[axis]); + setFeedrate_mm_s(MMM_MMS(max_manual_feedrate[axis])); if (!flags.manual_motion) set_destination_from_current(); destination[axis] = clamp(position, min, max); @@ -331,7 +331,7 @@ namespace ExtUI { setActiveTool(extruder, true); constexpr float max_manual_feedrate[XYZE] = MANUAL_FEEDRATE; - setFeedrate_mm_s(max_manual_feedrate[E_AXIS]); + setFeedrate_mm_s(MMM_MMS(max_manual_feedrate[E_AXIS])); if (!flags.manual_motion) set_destination_from_current(); destination[E_AXIS] = position; flags.manual_motion = true; @@ -714,17 +714,26 @@ namespace ExtUI { } #endif - #if HAS_BED_PROBE - float getZOffset_mm() { + float getZOffset_mm() { + #if HAS_BED_PROBE return zprobe_zoffset; - } + #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) + return babystep.axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1]; + #else + return 0.0; + #endif + } - void setZOffset_mm(const float value) { - if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + void setZOffset_mm(const float value) { + #if HAS_BED_PROBE + if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) zprobe_zoffset = value; - } - } - #endif // HAS_BED_PROBE + #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) + babystep.add_mm(Z_AXIS, (value - babystep.axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1])); + #else + UNUSED(value); + #endif + } #if HAS_HOTEND_OFFSET diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index 8d2a98d171..11a60a28a5 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -198,10 +198,8 @@ namespace ExtUI { void normalizeNozzleOffset(const axis_t axis); #endif - #if HAS_BED_PROBE - float getZOffset_mm(); - void setZOffset_mm(const float); - #endif + float getZOffset_mm(); + void setZOffset_mm(const float); #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 3925bfbbb6..b8232ba388 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -60,7 +60,7 @@ void _man_probe_pt(const float &rx, const float &ry) { host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("Delta Calibration in progress")); + ExtUI::onUserConfirmRequired(PSTR("Delta Calibration in progress")); #endif while (wait_for_user) idle(); ui.goto_previous_screen_no_defer(); diff --git a/Marlin/src/libs/stopwatch.cpp b/Marlin/src/libs/stopwatch.cpp index 6a6ea03c1b..49eaa5f2b0 100644 --- a/Marlin/src/libs/stopwatch.cpp +++ b/Marlin/src/libs/stopwatch.cpp @@ -60,6 +60,10 @@ bool Stopwatch::start() { Stopwatch::debug(PSTR("start")); #endif + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onPrintTimerStarted(); + #endif + if (!isRunning()) { if (isPaused()) accumulator = duration(); else reset(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 4f63cdd453..7e2a0deb5f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -378,7 +378,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), PSTR("Continue")); #endif #if ENABLED(EXTENSIBLE_UI) - ExtUI::onStatusChanged(PSTR("Stow Probe")); + ExtUI::onUserConfirmRequired(PSTR("Stow Probe")); #endif while (wait_for_user) idle(); ui.reset_status();