Skip to content

Commit

Permalink
🩹 Fix M80, 1s delay (#23455)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeleps authored Jan 5, 2022
1 parent c55b66b commit 1fe07bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions Marlin/src/feature/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void Power::power_off() {
}

void Power::checkAutoPowerOff() {
if (TERN1(POWER_OFF_TIMER, !power_off_time) && TERN1(POWER_OFF_WAIT_FOR_COOLDOWN, !power_off_on_cooldown)) return;
if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return;
if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return;
power_off();
Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/gcode/control/M80_M81.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,19 @@ void GcodeSuite::M81() {
ZERO(thermalManager.saved_fan_speed);
#endif

safe_delay(1000); // Wait 1 second before switching off

LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF ".");

bool delayed_power_off = false;

#if ENABLED(POWER_OFF_TIMER)
if (parser.seenval('D')) {
delayed_power_off = true;
powerManager.setPowerOffTimer(SEC_TO_MS(parser.value_ushort()));
uint16_t delay = parser.value_ushort();
if (delay > 1) { // skip already observed 1s delay
delayed_power_off = true;
powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1));
}
}
#endif

Expand All @@ -104,8 +109,6 @@ void GcodeSuite::M81() {

if (delayed_power_off) return;

safe_delay(1000); // Wait 1 second before switching off

#if HAS_SUICIDE
suicide();
#elif ENABLED(PSU_CONTROL)
Expand Down

0 comments on commit 1fe07bf

Please sign in to comment.