diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index d615f1937..d4d22a619 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -77,6 +77,10 @@ #include "lcd/dwin/e3v2/rotary_encoder.h" #endif +#if ENABLED(EXTENSIBLE_UI) + #include "lcd/extui/ui_api.h" +#endif + #if HAS_ETHERNET #include "feature/ethernet.h" #endif @@ -360,6 +364,8 @@ void enable_all_steppers() { ENABLE_AXIS_Y(); ENABLE_AXIS_Z(); enable_e_steppers(); + + TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled()); } void disable_e_steppers() { @@ -379,6 +385,8 @@ void disable_all_steppers() { DISABLE_AXIS_Y(); DISABLE_AXIS_Z(); disable_e_steppers(); + + TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled()); } #if ENABLED(G29_RETRY_AND_RECOVER) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 9999d92e2..653c632f1 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -177,6 +177,8 @@ G29_TYPE GcodeSuite::G29() { if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); #endif + TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); + const bool seenA = TERN0(PROBE_MANUALLY, parser.seen('A')), no_action = seenA || seenQ, faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index c17d6dcc8..31fc1e1cf 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -50,6 +50,10 @@ #include "../../lcd/dwin/e3v2/dwin.h" #endif +#if ENABLED(EXTENSIBLE_UI) + #include "../../lcd/extui/ui_api.h" +#endif + #if HAS_L64XX // set L6470 absolute position registers to counts #include "../../libs/L64XX/L64XX_Marlin.h" #endif @@ -209,6 +213,8 @@ void GcodeSuite::G28() { TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true); + TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); + #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -462,6 +468,8 @@ void GcodeSuite::G28() { TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming()); + TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete()); + report_current_position(); if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 4a461170b..e4b7054bf 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -96,6 +96,8 @@ void GcodeSuite::M1001() { queue.inject_P(PSTR(SD_FINISHED_RELEASECOMMAND)); #endif + TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); + // Re-select the last printed file in the UI TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); } diff --git a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp index a7f9a7a0c..06baa4c19 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron_lcd.cpp @@ -62,6 +62,10 @@ namespace ExtUI { void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() {} + void onFactoryReset() {} void onStoreSettings(char *buff) { @@ -95,6 +99,8 @@ namespace ExtUI { } #if HAS_MESH + void onMeshLevelingStart() {} + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated //SERIAL_ECHOLNPAIR("onMeshUpdate() x:", xpos, " y:", ypos, " z:", zval); @@ -116,6 +122,9 @@ namespace ExtUI { // Called for temperature PID tuning result } #endif + + void onSteppersDisabled() {} + void onSteppersEnabled() {} } #endif // ANYCUBIC_LCD_CHIRON diff --git a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp index 15526d16f..e2bd96068 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega_lcd.cpp @@ -52,6 +52,11 @@ namespace ExtUI { void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); } void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); } void onStatusChanged(const char * const msg) {} + + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() {} + void onFactoryReset() {} void onStoreSettings(char *buff) { @@ -84,9 +89,14 @@ namespace ExtUI { // whether successful or not. } - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { - // Called when any mesh points are updated - } + #if HAS_MESH + + void onMeshLevelingStart() {} + + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + // Called when any mesh points are updated + } + #endif #if ENABLED(POWER_LOSS_RECOVERY) void onPowerLossResume() { @@ -99,6 +109,9 @@ namespace ExtUI { // Called for temperature PID tuning result } #endif + + void onSteppersDisabled() {} + void onSteppersEnabled() {} } #endif // ANYCUBIC_LCD_I3MEGA diff --git a/Marlin/src/lcd/extui/dgus_lcd.cpp b/Marlin/src/lcd/extui/dgus_lcd.cpp index d175b5aca..33d8bd4d8 100644 --- a/Marlin/src/lcd/extui/dgus_lcd.cpp +++ b/Marlin/src/lcd/extui/dgus_lcd.cpp @@ -76,7 +76,12 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); } + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() {} + void onFactoryReset() {} + void onStoreSettings(char *buff) { // Called when saving to EEPROM (i.e. M500). If the ExtUI needs // permanent data to be stored, it can write up to eeprom_data_size bytes @@ -108,6 +113,8 @@ namespace ExtUI { } #if HAS_MESH + void onMeshLevelingStart() {} + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated } @@ -146,5 +153,8 @@ namespace ExtUI { } #endif + void onSteppersDisabled() {} + void onSteppersEnabled() {} } + #endif // HAS_DGUS_LCD diff --git a/Marlin/src/lcd/extui/example.cpp b/Marlin/src/lcd/extui/example.cpp index 592d67214..dd4b3312e 100644 --- a/Marlin/src/lcd/extui/example.cpp +++ b/Marlin/src/lcd/extui/example.cpp @@ -47,9 +47,9 @@ namespace ExtUI { } void onIdle() {} void onPrinterKilled(PGM_P const error, PGM_P const component) {} - void onMediaInserted() {}; - void onMediaError() {}; - void onMediaRemoved() {}; + void onMediaInserted() {} + void onMediaError() {} + void onMediaRemoved() {} void onPlayTone(const uint16_t frequency, const uint16_t duration) {} void onPrintTimerStarted() {} void onPrintTimerPaused() {} @@ -57,6 +57,11 @@ namespace ExtUI { void onFilamentRunout(const extruder_t extruder) {} void onUserConfirmRequired(const char * const msg) {} void onStatusChanged(const char * const msg) {} + + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() {} + void onFactoryReset() {} void onStoreSettings(char *buff) { @@ -90,6 +95,8 @@ namespace ExtUI { } #if HAS_MESH + void onMeshLevelingStart() {} + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated } @@ -110,6 +117,9 @@ namespace ExtUI { // Called for temperature PID tuning result } #endif + + void onSteppersDisabled() {} + void onSteppersEnabled() {} } #endif // EXTUI_EXAMPLE && EXTENSIBLE_UI diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp index ed7e653af..fc9b5d0a7 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/marlin_events.cpp @@ -87,8 +87,9 @@ namespace ExtUI { InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FINISHED); } - void onPrintTimerPaused() { - } + void onPrintTimerPaused() {} + + void onPrintFinished() {} void onFilamentRunout(const extruder_t extruder) { char lcd_msg[30]; @@ -97,6 +98,9 @@ namespace ExtUI { InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED, FTDI::PLAY_SYNCHRONOUS); } + void onHomingStart() {} + void onHomingComplete() {} + void onFactoryReset() { InterfaceSettingsScreen::defaultSettings(); } @@ -134,6 +138,8 @@ namespace ExtUI { } #if HAS_LEVELING && HAS_MESH + void onMeshLevelingStart() {} + void onMeshUpdate(const int8_t x, const int8_t y, const float val) { BedMeshScreen::onMeshUpdate(x, y, val); } @@ -170,6 +176,9 @@ namespace ExtUI { GOTO_SCREEN(StatusScreen); } #endif // HAS_PID_HEATING + + void onSteppersDisabled() {} + void onSteppersEnabled() {} } #endif // TOUCH_UI_FTDI_EVE diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index 5505a0dff..bdbf3802a 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -511,12 +511,15 @@ namespace ExtUI { // Not needed for Malyan LCD void onStatusChanged(const char * const) {} - void onMediaInserted() {}; - void onMediaError() {}; - void onMediaRemoved() {}; + void onMediaInserted() {} + void onMediaError() {} + void onMediaRemoved() {} void onPlayTone(const uint16_t, const uint16_t) {} void onFilamentRunout(const extruder_t extruder) {} void onUserConfirmRequired(const char * const) {} + void onHomingStart() {} + void onHomingComplete() {} + void onPrintFinished() {} void onFactoryReset() {} void onStoreSettings(char*) {} void onLoadSettings(const char*) {} @@ -524,6 +527,7 @@ namespace ExtUI { void onConfigurationStoreRead(bool) {} #if HAS_MESH + void onMeshLevelingStart() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} #endif @@ -531,6 +535,9 @@ namespace ExtUI { #if ENABLED(POWER_LOSS_RECOVERY) void onPowerLossResume() {} #endif + + void onSteppersDisabled() {} + void onSteppersEnabled() {} } #endif // MALYAN_LCD diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index c429a0aad..cdf9b4412 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -140,6 +140,7 @@ namespace ExtUI { bed_mesh_t& getMeshArray(); float getMeshPoint(const xy_uint8_t &pos); void setMeshPoint(const xy_uint8_t &pos, const float zval); + void onMeshLevelingStart(); void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); inline void onMeshUpdate(const xy_int8_t &pos, const float zval) { onMeshUpdate(pos.x, pos.y, zval); } @@ -344,11 +345,16 @@ namespace ExtUI { void onPrintTimerStarted(); void onPrintTimerPaused(); void onPrintTimerStopped(); + void onPrintFinished(); void onFilamentRunout(const extruder_t extruder); void onUserConfirmRequired(const char * const msg); void onUserConfirmRequired_P(PGM_P const pstr); void onStatusChanged(const char * const msg); void onStatusChanged_P(PGM_P const pstr); + void onHomingStart(); + void onHomingComplete(); + void onSteppersDisabled(); + void onSteppersEnabled(); void onFactoryReset(); void onStoreSettings(char *); void onLoadSettings(const char *);