From af214ff121dd977b002c9a9065f84b7ae1a66247 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Oct 2019 15:43:37 -0500 Subject: [PATCH] Fix up PSU_CONTROL checks --- Marlin/src/Marlin.cpp | 4 ++-- Marlin/src/Marlin.h | 2 +- Marlin/src/gcode/control/M80_M81.cpp | 6 +++--- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/Conditionals_post.h | 2 -- Marlin/src/inc/SanityCheck.h | 12 +++++++++--- Marlin/src/lcd/menu/menu_main.cpp | 2 +- Marlin/src/pins/ramps/pins_RAMPS.h | 2 +- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index f13022182..3ef57766e 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -219,7 +219,7 @@ void setup_powerhold() { #if HAS_SUICIDE OUT_WRITE(SUICIDE_PIN, HIGH); #endif - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) #if ENABLED(PS_DEFAULT_OFF) powersupply_on = true; PSU_OFF(); #else @@ -721,7 +721,7 @@ void minkill(const bool steppers_off/*=false*/) { // Power off all steppers (for M112) or just the E steppers steppers_off ? disable_all_steppers() : disable_e_steppers(); - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) PSU_OFF(); #endif diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 391c453e0..b036e8114 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -351,7 +351,7 @@ extern millis_t max_inactive_time, stepper_inactive_time; extern uint8_t controllerfan_speed; #endif -#if HAS_POWER_SWITCH +#if ENABLED(PSU_CONTROL) extern bool powersupply_on; #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0) #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0) diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index d7880358c..9b27b5e4e 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -35,7 +35,7 @@ #include "../../Marlin.h" #endif -#if HAS_POWER_SWITCH +#if ENABLED(PSU_CONTROL) #if ENABLED(AUTO_POWER_CONTROL) #include "../../feature/power.h" @@ -81,7 +81,7 @@ #endif } -#endif // HAS_POWER_SWITCH +#endif // ENABLED(PSU_CONTROL) /** * M81: Turn off Power, including Power Supply, if there is one. @@ -105,7 +105,7 @@ void GcodeSuite::M81() { #if HAS_SUICIDE suicide(); - #elif HAS_POWER_SWITCH + #elif ENABLED(PSU_CONTROL) PSU_OFF(); #endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index cced238dd..3da130774 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -471,7 +471,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #endif // BARICUDA - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) case 80: M80(); break; // M80: Turn on Power Supply #endif case 81: M81(); break; // M81: Turn off Power, including Power Supply, if possible diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 9d2b11a07..9fac07c90 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -548,7 +548,7 @@ private: static void M78(); #endif - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) static void M80(); #endif diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index eb32119ef..8871644ff 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -112,7 +112,7 @@ void GcodeSuite::M115() { // SOFTWARE_POWER (M80, M81) cap_line(PSTR("SOFTWARE_POWER") - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) , true #endif ); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 42965a14f..2987a1e0a 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -120,7 +120,7 @@ #define DOGLCD #define IS_ULTIPANEL #define LED_COLORS_REDUCE_GREEN - #if HAS_POWER_SWITCH && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) + #if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) #define LED_BACKLIGHT_TIMEOUT 10000 #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index a782d4590..f5091aae2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -333,8 +333,6 @@ #endif #endif -#define HAS_POWER_SWITCH (ENABLED(PSU_CONTROL) && PIN_EXISTS(PS_ON)) - /** * Temp Sensor defines */ diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5379f23e6..1cbb09df0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1591,7 +1591,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * LED Backlight Timeout */ -#if defined(LED_BACKLIGHT_TIMEOUT) && !(EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && HAS_POWER_SWITCH) +#if defined(LED_BACKLIGHT_TIMEOUT) && !(EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && ENABLED(PSU_CONTROL)) #error "LED_BACKLIGHT_TIMEOUT requires a FYSETC Mini Panel and a Power Switch." #endif @@ -2467,8 +2467,14 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) /** * Ensure this option is set intentionally */ -#if ENABLED(PSU_CONTROL) && !defined(PSU_ACTIVE_HIGH) - #error "PSU_CONTROL requires PSU_ACTIVE_HIGH to be defined as 'true' or 'false'." +#if ENABLED(PSU_CONTROL) + #ifndef PSU_ACTIVE_HIGH + #error "PSU_CONTROL requires PSU_ACTIVE_HIGH to be defined as 'true' or 'false'." + #elif !PIN_EXISTS(PS_ON) + #error "PSU_CONTROL requires PS_ON_PIN." + #endif +#elif ENABLED(AUTO_POWER_CONTROL) + #error "AUTO_POWER_CONTROL requires PSU_CONTROL." #endif #if HAS_CUTTER diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 86d64bf8b..0d0a6cdc5 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -199,7 +199,7 @@ void menu_main() { // // Switch power on/off // - #if HAS_POWER_SWITCH + #if ENABLED(PSU_CONTROL) if (powersupply_on) GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81")); else diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 0c4070962..be2fb2a84 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -552,7 +552,7 @@ #define BTN_EN2 7 #define BTN_ENC 39 - #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board + #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board #define KILL_PIN 31 #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)