Add external pin to control PSU state M80/M81
This commit is contained in:
parent
e7ebb66200
commit
4448422913
3 changed files with 40 additions and 0 deletions
|
|
@ -231,6 +231,8 @@ PGMSTR(G28_STR, "G28");
|
|||
PGMSTR(M21_STR, "M21");
|
||||
PGMSTR(M23_STR, "M23 %s");
|
||||
PGMSTR(M24_STR, "M24");
|
||||
PGMSTR(M80_STR, "M80");
|
||||
PGMSTR(M81_STR, "M81");
|
||||
PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T");
|
||||
PGMSTR(X_STR, "X"); PGMSTR(Y_STR, "Y"); PGMSTR(Z_STR, "Z"); PGMSTR(E_STR, "E");
|
||||
PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMSTR(E_LBL, "E:");
|
||||
|
|
@ -288,6 +290,13 @@ void setup_powerhold() {
|
|||
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
|
||||
#endif
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
#if PSU_EXT_PIN
|
||||
#if PSU_EXT_PIN_STATE
|
||||
SET_INPUT_PULLDOWN(PSU_EXT_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLUP(PSU_EXT_PIN);
|
||||
#endif
|
||||
#endif
|
||||
powersupply_on = ENABLED(PSU_DEFAULT_OFF);
|
||||
if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
|
||||
#endif
|
||||
|
|
@ -563,6 +572,21 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
#if PSU_EXT_PIN
|
||||
// Handle a standalone PSU_EXT button
|
||||
constexpr millis_t PSU_EXT_DEBOUNCE_DELAY = 750UL;
|
||||
static millis_t next_psu_ext_key_ms; // = 0
|
||||
if (!IS_SD_PRINTING() && psu_ext_state()) {
|
||||
const millis_t ms = millis();
|
||||
if (ELAPSED(ms, next_psu_ext_key_ms)) {
|
||||
next_psu_ext_key_ms = ms + PSU_EXT_DEBOUNCE_DELAY;
|
||||
powersupply_on ? queue.enqueue_now_P(M81_STR) : queue.enqueue_now_P(M80_STR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_HOME
|
||||
// Handle a standalone HOME button
|
||||
constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
|
||||
|
|
@ -1295,6 +1319,11 @@ void setup() {
|
|||
SETUP_RUN(tft_lvgl_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
if (!powersupply_on)
|
||||
LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
|
||||
#endif
|
||||
|
||||
#if ENABLED(PASSWORD_ON_STARTUP)
|
||||
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ extern bool wait_for_heatup;
|
|||
#define PSU_ON() PSU_PIN_ON()
|
||||
#define PSU_OFF() PSU_PIN_OFF()
|
||||
#endif
|
||||
#if PSU_EXT_PIN
|
||||
#ifndef PSU_EXT_PIN_STATE
|
||||
#define PSU_EXT_PIN_STATE LOW
|
||||
#endif
|
||||
inline bool psu_ext_state() { return READ(PSU_EXT_PIN) == PSU_EXT_PIN_STATE; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool pin_is_protected(const pin_t pin);
|
||||
|
|
|
|||
|
|
@ -261,6 +261,11 @@
|
|||
#define PS_ON_PIN 12
|
||||
#endif
|
||||
|
||||
// External pin to control PSU state
|
||||
#ifndef PSU_EXT_PIN
|
||||
#define PSU_EXT_PIN 58
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_ENABLE) && !defined(CASE_LIGHT_PIN) && !defined(SPINDLE_LASER_ENA_PIN)
|
||||
#if NUM_SERVOS <= 1 // Prefer the servo connector
|
||||
#define CASE_LIGHT_PIN 6 // Hardware PWM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue