From 7b4f5108ace3e4a8891613465e86602f0b2ce5c1 Mon Sep 17 00:00:00 2001 From: John Lagonikas <39417467+zeleps@users.noreply.github.com> Date: Wed, 19 Jan 2022 10:13:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20conditional=20M81=20suicid?= =?UTF-8?q?e=20(#23549)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/language.h | 2 ++ Marlin/src/feature/power.cpp | 10 +++++++--- Marlin/src/gcode/control/M80_M81.cpp | 5 ++++- Marlin/src/libs/MAX31865.cpp | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 +++- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h | 4 +++- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 4 +++- .../src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h | 4 +++- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index c53ebdfbf8..8e0784f70d 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -105,6 +105,7 @@ #define STR_ENQUEUEING "enqueueing \"" #define STR_POWERUP "PowerUp" +#define STR_POWEROFF "PowerOff" #define STR_EXTERNAL_RESET " External Reset" #define STR_BROWNOUT_RESET " Brown out Reset" #define STR_WATCHDOG_RESET " Watchdog Reset" @@ -306,6 +307,7 @@ #define STR_Z_PROBE_OFFSET "Z-Probe Offset" #define STR_TEMPERATURE_UNITS "Temperature Units" #define STR_USER_THERMISTORS "User thermistors" +#define STR_DELAYED_POWEROFF "Delayed poweroff" // // Endstop Names used by Endstops::report_states diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 0e4d5452e4..c2ed169aa8 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -24,7 +24,9 @@ * power.cpp - power control */ -#include "../inc/MarlinConfig.h" +#include "../inc/MarlinConfigPre.h" + +#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) #include "power.h" #include "../module/planner.h" @@ -40,8 +42,6 @@ #include "../gcode/gcode.h" #endif -#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) - Power powerManager; bool Power::psu_on; @@ -97,6 +97,10 @@ void Power::power_on() { * Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled. */ void Power::power_off() { + SERIAL_ECHOLNPGM(STR_POWEROFF); + + TERN_(HAS_SUICIDE, suicide()); + if (!psu_on) return; #ifdef PSU_POWEROFF_GCODE diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index cbb3c85f40..6a3788c4a9 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -107,7 +107,10 @@ void GcodeSuite::M81() { } #endif - if (delayed_power_off) return; + if (delayed_power_off) { + SERIAL_ECHOLNPGM(STR_DELAYED_POWEROFF); + return; + } #if HAS_SUICIDE suicide(); diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp index 6cc8ffca39..1cafbe5f17 100644 --- a/Marlin/src/libs/MAX31865.cpp +++ b/Marlin/src/libs/MAX31865.cpp @@ -300,14 +300,14 @@ uint16_t MAX31865::readRaw() { enableBias(); nextEventStamp = millis() + 11; // wait at least 11msec before enabling 1shot nextEvent = SETUP_1_SHOT_MODE; - DEBUG_ECHOLN("MAX31865 bias voltage enabled"); + DEBUG_ECHOLNPGM("MAX31865 bias voltage enabled"); break; case SETUP_1_SHOT_MODE: oneShot(); nextEventStamp = millis() + 65; // wait at least 65msec before reading RTD register nextEvent = READ_RTD_REG; - DEBUG_ECHOLN("MAX31865 1 shot mode enabled"); + DEBUG_ECHOLNPGM("MAX31865 1 shot mode enabled"); break; case READ_RTD_REG: { diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 592d585982..5fdd37b104 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -193,7 +193,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index 859529c2c3..e057e13c25 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -118,7 +118,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index a738a4faa2..53f207adb7 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -185,7 +185,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PG11 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index 2c191946cd..5b2c1b0f43 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -165,7 +165,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW