From fe1e880ffe2ead1bee5734cc563d2f493a9ac871 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sat, 22 Aug 2020 06:13:43 +0200 Subject: [PATCH] HIGH/LOW naming of pin state settings (#19089) --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 2 +- Marlin/src/HAL/DUE/usb/arduino_due_x.h | 2 +- Marlin/src/MarlinCore.h | 4 ++-- Marlin/src/feature/spindle_laser.cpp | 12 ++++++------ Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 14 +++++++++----- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7f7931ae7d..2b36f883cc 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -330,7 +330,7 @@ //#define PSU_NAME "Power Supply" #if ENABLED(PSU_CONTROL) - #define PSU_ACTIVE_HIGH false // Set 'false' for ATX, 'true' for X-Box + #define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 529dcc3091..b27d7c79ea 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2851,7 +2851,7 @@ //#define SPINDLE_FEATURE //#define LASER_FEATURE #if EITHER(SPINDLE_FEATURE, LASER_FEATURE) - #define SPINDLE_LASER_ACTIVE_HIGH false // Set to "true" if the on/off function is active HIGH + #define SPINDLE_LASER_ACTIVE_STATE LOW // Set to "HIGH" if the on/off function is active HIGH #define SPINDLE_LASER_PWM true // Set to "true" if your controller supports setting the speed/power #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower diff --git a/Marlin/src/HAL/DUE/usb/arduino_due_x.h b/Marlin/src/HAL/DUE/usb/arduino_due_x.h index b5be621791..d3b333fb34 100644 --- a/Marlin/src/HAL/DUE/usb/arduino_due_x.h +++ b/Marlin/src/HAL/DUE/usb/arduino_due_x.h @@ -93,5 +93,5 @@ #define USB_VBOF_GPIO (PIO_PB10_IDX) #define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) /*! Active level of the USB_VBOF output pin. */ -#define USB_VBOF_ACTIVE_LEVEL LOW +#define USB_VBOF_ACTIVE_STATE LOW /* ------------------------------------------------------------------------ */ diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 81041c8ee6..69afc7f30e 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -89,8 +89,8 @@ extern bool wait_for_heatup; #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) + #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); powersupply_on = true; }while(0) + #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); powersupply_on = false; }while(0) #if ENABLED(AUTO_POWER_CONTROL) #define PSU_ON() powerManager.power_on() #define PSU_OFF() powerManager.power_off() diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 9d2ee7d9e5..bc387a9334 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -37,7 +37,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM #if ENABLED(MARLIN_DEV_MODE) - cutter_frequency_t SpindleLaser::frequency; // setting PWM frequency; range: 2K - 50K + cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K #endif #define SPINDLE_LASER_PWM_OFF ((SPINDLE_LASER_PWM_INVERT) ? 255 : 0) @@ -45,13 +45,13 @@ cutter_power_t SpindleLaser::menuPower, // Power s // Init the cutter to a safe OFF state // void SpindleLaser::init() { - OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Init spindle to off + OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #if ENABLED(SPINDLE_CHANGE_DIR) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3) #endif #if ENABLED(SPINDLE_LASER_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // set to lowest speed + analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); @@ -64,14 +64,14 @@ void SpindleLaser::init() { * Set the cutter PWM directly to the given ocr value */ void SpindleLaser::set_ocr(const uint8_t ocr) { - WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_HIGH); // turn spindle on + WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Turn spindle on analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); #if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); #endif } void SpindleLaser::ocr_off() { - WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_HIGH); // Turn spindle off + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Turn spindle off analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Only write low byte } #endif @@ -98,7 +98,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) { isReady = false; } #else - WRITE(SPINDLE_LASER_ENA_PIN, enabled() == SPINDLE_LASER_ACTIVE_HIGH); + WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); isReady = true; #endif } diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 5d7322753f..f566643bdb 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -403,7 +403,7 @@ #ifndef PSU_NAME #if DISABLED(PSU_CONTROL) #define PSU_NAME "Generic" // No control - #elif PSU_ACTIVE_HIGH + #elif PSU_ACTIVE_STATE #define PSU_NAME "XBox" // X-Box 360 (203W) #else #define PSU_NAME "ATX" // ATX style diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 01243219c2..ddefcc8b60 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -419,8 +419,10 @@ #error "SPINDLE_DIR_CHANGE is now SPINDLE_CHANGE_DIR. Please update your Configuration_adv.h." #elif defined(SPINDLE_STOP_ON_DIR_CHANGE) #error "SPINDLE_STOP_ON_DIR_CHANGE is now SPINDLE_CHANGE_DIR_STOP. Please update your Configuration_adv.h." +#elif defined(SPINDLE_LASER_ACTIVE_HIGH) + #error "SPINDLE_LASER_ACTIVE_HIGH is now SPINDLE_LASER_ACTIVE_STATE. Please update your Configuration_adv.h." #elif defined(SPINDLE_LASER_ENABLE_INVERT) - #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_HIGH. Please update your Configuration_adv.h." + #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_STATE. Please update your Configuration_adv.h." #elif defined(CUTTER_POWER_DISPLAY) #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT. Please update your Configuration_adv.h." #elif defined(CHAMBER_HEATER_PIN) @@ -441,10 +443,12 @@ #error "USB_SD_DISABLED is now NO_SD_HOST_DRIVE. Please update your Configuration_adv.h." #elif defined(USB_SD_ONBOARD) #error "USB_SD_ONBOARD is obsolete. Disable NO_SD_HOST_DRIVE instead." +#elif defined(PSU_ACTIVE_HIGH) + #error "PSU_ACTIVE_HIGH is now PSU_ACTIVE_STATE. Please update your configuration." #elif POWER_SUPPLY == 1 - #error "Replace POWER_SUPPLY 1 by enabling PSU_CONTROL and setting PSU_ACTIVE_HIGH to 'false'." + #error "Replace POWER_SUPPLY 1 by enabling PSU_CONTROL and setting PSU_ACTIVE_STATE to 'LOW'." #elif POWER_SUPPLY == 2 - #error "Replace POWER_SUPPLY 2 by enabling PSU_CONTROL and setting PSU_ACTIVE_HIGH to 'true'." + #error "Replace POWER_SUPPLY 2 by enabling PSU_CONTROL and setting PSU_ACTIVE_STATE to 'HIGH'." #elif defined(POWER_SUPPLY) #error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h." #elif defined(MKS_ROBIN_TFT) @@ -2923,8 +2927,8 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) * Ensure this option is set intentionally */ #if ENABLED(PSU_CONTROL) - #ifndef PSU_ACTIVE_HIGH - #error "PSU_CONTROL requires PSU_ACTIVE_HIGH to be defined as 'true' or 'false'." + #ifndef PSU_ACTIVE_STATE + #error "PSU_CONTROL requires PSU_ACTIVE_STATE to be defined as 'HIGH' or 'LOW'." #elif !PIN_EXISTS(PS_ON) #error "PSU_CONTROL requires PS_ON_PIN." #endif