From c950f0f5d1e6804365506d1718e0a4029fb232cf Mon Sep 17 00:00:00 2001 From: Scott Lahteine <thinkyhead@users.noreply.github.com> Date: Sun, 19 Feb 2023 11:41:50 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20ExtUI::onPo?= =?UTF-8?q?werLoss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/powerloss.cpp | 7 +++++++ Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp | 3 +++ Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp | 3 +++ Marlin/src/lcd/extui/dgus/dgus_extui.cpp | 3 +++ .../src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp | 3 +++ Marlin/src/lcd/extui/example/example.cpp | 3 +++ .../src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp | 7 ++++++- Marlin/src/lcd/extui/ia_creality/creality_extui.cpp | 9 ++++++--- Marlin/src/lcd/extui/malyan/malyan_extui.cpp | 7 ++++++- Marlin/src/lcd/extui/nextion/nextion_extui.cpp | 3 +++ Marlin/src/lcd/extui/ui_api.h | 1 + Marlin/src/libs/numtostr.h | 2 +- 12 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 1037f823f64..faec893928e 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -31,6 +31,10 @@ #include "powerloss.h" #include "../core/macros.h" +#if ENABLED(EXTENSIBLE_UI) + #include "../lcd/extui/ui_api.h" +#endif + bool PrintJobRecovery::enabled; // Initialized by settings.load() MediaFile PrintJobRecovery::file; @@ -313,6 +317,9 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW // and a flag whether the raise was already done here. if (IS_SD_PRINTING()) save(true, zraise, ENABLED(BACKUP_POWER_SUPPLY)); + // Tell the LCD about the outage, even though it is about to die + TERN_(EXTENSIBLE_UI, ExtUI::onPowerLoss()); + // Disable all heaters to reduce power loss thermalManager.disable_all_heaters(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 75061c162a7..39b328d8081 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -120,6 +120,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } // Called on resume from power-loss void onPowerLossResume() { Chiron.PowerLossRecovery(); } #endif diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index 40a670b5b07..afe88bf583d 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -106,6 +106,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { // Called on resume from power-loss } diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 382c5eb1bef..2f3bbd64cc4 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -126,6 +126,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { // Called on resume from power-loss IF_DISABLED(DGUS_LCD_UI_MKS, ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POWER_LOSS)); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 1ff22da2687..9aecf65f984 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -123,6 +123,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { // Called on resume from power-loss dgus_screen_handler.PowerLossResume(); diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 27269a9bee7..a5e816efd85 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -112,6 +112,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { // Called on resume from power-loss } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index 84de2c58712..159847bde19 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -125,7 +125,12 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) - void onPowerLossResume() {} // Called on resume from power-loss + void onPowerLoss() { + // Called when power-loss state is detected + } + void onPowerLossResume() { + // Called on resume from power-loss + } #endif #if HAS_PID_HEATING diff --git a/Marlin/src/lcd/extui/ia_creality/creality_extui.cpp b/Marlin/src/lcd/extui/ia_creality/creality_extui.cpp index fed5fc7165b..d27d68aad44 100644 --- a/Marlin/src/lcd/extui/ia_creality/creality_extui.cpp +++ b/Marlin/src/lcd/extui/ia_creality/creality_extui.cpp @@ -436,7 +436,7 @@ namespace ExtUI { case DGUS_HEADER2_SEEN: // Waiting for the length byte rx_datagram_len = DWIN_SERIAL.read(); - //DEBUGLCDCOMM_ECHOPAIR(" (", rx_datagram_len, ") "); + //DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") "); // Telegram min len is 3 (command and one word of payload) rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE; @@ -448,14 +448,14 @@ namespace ExtUI { Initialized = true; // We've talked to it, so we defined it as initialized. uint8_t command = DWIN_SERIAL.read(); - //DEBUGLCDCOMM_ECHOPAIR("# ", command); + //DEBUGLCDCOMM_ECHOPGM("# ", command); uint8_t readlen = rx_datagram_len - 1; // command is part of len. uint8_t tmp[rx_datagram_len - 1]; uint8_t *ptmp = tmp; while (readlen--) { receivedbyte = DWIN_SERIAL.read(); - //DEBUGLCDCOMM_ECHOPAIR(" ", receivedbyte); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); *ptmp++ = receivedbyte; } //DEBUGLCDCOMM_ECHOPGM(" # "); @@ -2016,6 +2016,9 @@ namespace ExtUI { } #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { startprogress = 254; InforShowStatus = true; diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index 8ed319e35c8..b978937defd 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -158,7 +158,12 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) - void onPowerLossResume() {} + void onPowerLoss() { + // Called when power-loss state is detected + } + void onPowerLossResume() { + // Called on resume from power-loss + } #endif void onSteppersDisabled() {} diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index 0e84fd33cf4..433bbfbe8b8 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -103,6 +103,9 @@ namespace ExtUI { #endif #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss() { + // Called when power-loss state is detected + } void onPowerLossResume() { // Called on resume from power-loss } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index b48dc94f8fe..46f0891bb70 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -426,6 +426,7 @@ namespace ExtUI { void onSettingsStored(bool success); void onSettingsLoaded(bool success); #if ENABLED(POWER_LOSS_RECOVERY) + void onPowerLoss(); void onPowerLossResume(); #endif #if HAS_PID_HEATING diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index 047b22cd177..0c8ce0f79a1 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -56,7 +56,7 @@ const char* ui16tostr3rj(const uint16_t x); // Convert int16_t to string with 123 format const char* i16tostr3rj(const int16_t x); -// Convert unsigned int to lj string with 123 format +// Convert signed int to lj string with 123 format const char* i16tostr3left(const int16_t xx); // Convert signed int to rj string with _123, -123, _-12, or __-1 format