HIGH/LOW naming of pin state settings (#19089)

This commit is contained in:
Giuliano Zaro 2020-08-22 06:13:43 +02:00 committed by Scott Lahteine
parent a5dc42c47c
commit fe1e880ffe
7 changed files with 21 additions and 17 deletions

View file

@ -330,7 +330,7 @@
//#define PSU_NAME "Power Supply" //#define PSU_NAME "Power Supply"
#if ENABLED(PSU_CONTROL) #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_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 //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power

View file

@ -2851,7 +2851,7 @@
//#define SPINDLE_FEATURE //#define SPINDLE_FEATURE
//#define LASER_FEATURE //#define LASER_FEATURE
#if EITHER(SPINDLE_FEATURE, 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 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 #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower

View file

@ -93,5 +93,5 @@
#define USB_VBOF_GPIO (PIO_PB10_IDX) #define USB_VBOF_GPIO (PIO_PB10_IDX)
#define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT) #define USB_VBOF_FLAGS (PIO_PERIPH_A | PIO_DEFAULT)
/*! Active level of the USB_VBOF output pin. */ /*! Active level of the USB_VBOF output pin. */
#define USB_VBOF_ACTIVE_LEVEL LOW #define USB_VBOF_ACTIVE_STATE LOW
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */

View file

@ -89,8 +89,8 @@ extern bool wait_for_heatup;
#if ENABLED(PSU_CONTROL) #if ENABLED(PSU_CONTROL)
extern bool powersupply_on; 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_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_HIGH); powersupply_on = false; }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) #if ENABLED(AUTO_POWER_CONTROL)
#define PSU_ON() powerManager.power_on() #define PSU_ON() powerManager.power_on()
#define PSU_OFF() powerManager.power_off() #define PSU_OFF() powerManager.power_off()

View file

@ -37,7 +37,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s
SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM
#if ENABLED(MARLIN_DEV_MODE) #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 #endif
#define SPINDLE_LASER_PWM_OFF ((SPINDLE_LASER_PWM_INVERT) ? 255 : 0) #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 // Init the cutter to a safe OFF state
// //
void SpindleLaser::init() { 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) #if ENABLED(SPINDLE_CHANGE_DIR)
OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR ? 255 : 0); // Init rotation to clockwise (M3)
#endif #endif
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
SET_PWM(SPINDLE_LASER_PWM_PIN); 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 #endif
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), 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 * Set the cutter PWM directly to the given ocr value
*/ */
void SpindleLaser::set_ocr(const uint8_t ocr) { 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); analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
#if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY #if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY
set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF);
#endif #endif
} }
void SpindleLaser::ocr_off() { 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 analogWrite(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Only write low byte
} }
#endif #endif
@ -98,7 +98,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) {
isReady = false; isReady = false;
} }
#else #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; isReady = true;
#endif #endif
} }

View file

@ -403,7 +403,7 @@
#ifndef PSU_NAME #ifndef PSU_NAME
#if DISABLED(PSU_CONTROL) #if DISABLED(PSU_CONTROL)
#define PSU_NAME "Generic" // No control #define PSU_NAME "Generic" // No control
#elif PSU_ACTIVE_HIGH #elif PSU_ACTIVE_STATE
#define PSU_NAME "XBox" // X-Box 360 (203W) #define PSU_NAME "XBox" // X-Box 360 (203W)
#else #else
#define PSU_NAME "ATX" // ATX style #define PSU_NAME "ATX" // ATX style

View file

@ -419,8 +419,10 @@
#error "SPINDLE_DIR_CHANGE is now SPINDLE_CHANGE_DIR. Please update your Configuration_adv.h." #error "SPINDLE_DIR_CHANGE is now SPINDLE_CHANGE_DIR. Please update your Configuration_adv.h."
#elif defined(SPINDLE_STOP_ON_DIR_CHANGE) #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." #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) #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) #elif defined(CUTTER_POWER_DISPLAY)
#error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT. Please update your Configuration_adv.h." #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT. Please update your Configuration_adv.h."
#elif defined(CHAMBER_HEATER_PIN) #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." #error "USB_SD_DISABLED is now NO_SD_HOST_DRIVE. Please update your Configuration_adv.h."
#elif defined(USB_SD_ONBOARD) #elif defined(USB_SD_ONBOARD)
#error "USB_SD_ONBOARD is obsolete. Disable NO_SD_HOST_DRIVE instead." #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 #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 #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) #elif defined(POWER_SUPPLY)
#error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h." #error "POWER_SUPPLY is now obsolete. Please remove it from Configuration.h."
#elif defined(MKS_ROBIN_TFT) #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 * Ensure this option is set intentionally
*/ */
#if ENABLED(PSU_CONTROL) #if ENABLED(PSU_CONTROL)
#ifndef PSU_ACTIVE_HIGH #ifndef PSU_ACTIVE_STATE
#error "PSU_CONTROL requires PSU_ACTIVE_HIGH to be defined as 'true' or 'false'." #error "PSU_CONTROL requires PSU_ACTIVE_STATE to be defined as 'HIGH' or 'LOW'."
#elif !PIN_EXISTS(PS_ON) #elif !PIN_EXISTS(PS_ON)
#error "PSU_CONTROL requires PS_ON_PIN." #error "PSU_CONTROL requires PS_ON_PIN."
#endif #endif