♻️ Consolidate PSU_CONTROL (#22304)

This commit is contained in:
Katelyn Schiesser
2021-07-11 22:13:58 -07:00
committed by Scott Lahteine
parent 9741be5966
commit 9ddb4de70a
10 changed files with 215 additions and 176 deletions

View File

@ -29,25 +29,17 @@
#include "../../inc/MarlinConfig.h"
#if ENABLED(PSU_CONTROL)
#include "../queue.h"
#include "../../feature/power.h"
#endif
#if HAS_SUICIDE
#include "../../MarlinCore.h"
#endif
#if ENABLED(PSU_CONTROL)
#if ENABLED(AUTO_POWER_CONTROL)
#include "../../feature/power.h"
#else
void restore_stepper_drivers();
#endif
// Could be moved to a feature, but this is all the data
bool powersupply_on;
#if HAS_TRINAMIC_CONFIG
#include "../../feature/tmc_util.h"
#endif
/**
* M80 : Turn on the Power Supply
* M80 S : Report the current state and exit
@ -56,11 +48,11 @@
// S: Report the current power supply state and exit
if (parser.seen('S')) {
SERIAL_ECHOPGM_P(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
SERIAL_ECHOPGM_P(powerManager.psu_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
return;
}
PSU_ON();
powerManager.power_on();
/**
* If you have a switch on suicide pin, this is useful
@ -71,12 +63,6 @@
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
#endif
#if DISABLED(AUTO_POWER_CONTROL)
safe_delay(PSU_POWERUP_DELAY);
restore_stepper_drivers();
TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
#endif
TERN_(HAS_LCD_MENU, ui.reset_status());
}
@ -110,7 +96,7 @@ void GcodeSuite::M81() {
#if HAS_SUICIDE
suicide();
#elif ENABLED(PSU_CONTROL)
PSU_OFF_SOON();
powerManager.power_off_soon();
#endif
LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));