Skip to content

Commit

Permalink
馃悰 Fix conditional M81 suicide (MarlinFirmware#23549)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeleps authored and PhilomathJ committed Jul 18, 2022
1 parent 094f849 commit 377f1fc
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Marlin/src/core/language.h
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/feature/power.cpp
Expand Up @@ -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"
Expand All @@ -40,8 +42,6 @@
#include "../gcode/gcode.h"
#endif

#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL)

Power powerManager;
bool Power::psu_on;

Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/gcode/control/M80_M81.cpp
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/libs/MAX31865.cpp
Expand Up @@ -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: {
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h
Expand Up @@ -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
Expand Down

0 comments on commit 377f1fc

Please sign in to comment.