Skip to content

Commit

Permalink
More useful ENABLED / DISABLED macros (MarlinFirmware#17054)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and mathom committed Apr 16, 2020
1 parent 60763b4 commit a0a950e
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 767 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@
*/
//#define POWER_LOSS_RECOVERY
#if ENABLED(POWER_LOSS_RECOVERY)
//#define PLR_ENABLED_DEFAULT true // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/HAL/HAL_AVR/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
* Templatized 01 October 2018 by Eduardo José Tagle to allow multiple instances
*/

#include "../shared/MarlinSerial.h"

#include <WString.h>

#include "../../inc/MarlinConfigPre.h"

#ifndef SERIAL_PORT
#define SERIAL_PORT 0
#endif
Expand Down Expand Up @@ -261,12 +261,12 @@
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
static constexpr bool XONOFF = bSERIAL_XON_XOFF;
static constexpr bool EMERGENCYPARSER = bEMERGENCY_PARSER;
static constexpr bool DROPPED_RX = bSERIAL_STATS_DROPPED_RX;
static constexpr bool RX_OVERRUNS = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
static constexpr bool XONOFF = ENABLED(SERIAL_XON_XOFF);
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
static constexpr bool DROPPED_RX = ENABLED(SERIAL_STATS_DROPPED_RX);
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;

Expand Down Expand Up @@ -304,7 +304,7 @@
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_OVERRUNS = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_OVERRUNS = HAS_DGUS_LCD && ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS);
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
};
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/HAL/HAL_DUE/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved.
*/

#include "../shared/MarlinSerial.h"

#include <WString.h>

#include "../../inc/MarlinConfigPre.h"

#define DEC 10
#define HEX 16
#define OCT 8
Expand Down Expand Up @@ -163,12 +163,12 @@ struct MarlinSerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = RX_BUFFER_SIZE;
static constexpr unsigned int TX_SIZE = TX_BUFFER_SIZE;
static constexpr bool XONOFF = bSERIAL_XON_XOFF;
static constexpr bool EMERGENCYPARSER = bEMERGENCY_PARSER;
static constexpr bool DROPPED_RX = bSERIAL_STATS_DROPPED_RX;
static constexpr bool RX_OVERRUNS = bSERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_FRAMING_ERRORS = bSERIAL_STATS_RX_FRAMING_ERRORS;
static constexpr bool MAX_RX_QUEUED = bSERIAL_STATS_MAX_RX_QUEUED;
static constexpr bool XONOFF = ENABLED(SERIAL_XON_XOFF);
static constexpr bool EMERGENCYPARSER = ENABLED(EMERGENCY_PARSER);
static constexpr bool DROPPED_RX = ENABLED(SERIAL_STATS_DROPPED_RX);
static constexpr bool RX_OVERRUNS = ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS);
static constexpr bool RX_FRAMING_ERRORS = ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS);
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};

#if SERIAL_PORT >= 0
Expand Down
14 changes: 6 additions & 8 deletions Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
* Because PWM hardware channels all share the same frequency, along with the
* fallback software channels, FAST_PWM_FAN is incompatible with Servos.
*/
#if NUM_SERVOS > 0 && ENABLED(FAST_PWM_FAN)
#error "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards."
#endif
static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards.");

/**
* Test LPC176x-specific configuration values for errors at compile-time.
Expand All @@ -69,13 +67,13 @@
// #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
//#endif

#if IS_RE_ARM_BOARD && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
#if MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF)
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 requires TMC_USE_SW_SPI."
#endif
#endif

#if ENABLED(BAUD_RATE_GCODE)
#error "BAUD_RATE_GCODE is not yet supported on LPC176x."
#endif
static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported on LPC176x.");

/**
* Flag any serial port conflicts
Expand Down
67 changes: 0 additions & 67 deletions Marlin/src/HAL/shared/MarlinSerial.h

This file was deleted.

48 changes: 11 additions & 37 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,8 @@ void setup_powerhold() {
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
#endif
#if ENABLED(PSU_CONTROL)
#if ENABLED(PSU_DEFAULT_OFF)
powersupply_on = true; PSU_OFF();
#else
powersupply_on = false; PSU_ON();
#endif
powersupply_on = ENABLED(PSU_DEFAULT_OFF);
if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
#endif
}

Expand Down Expand Up @@ -425,14 +422,8 @@ void startOrResumeJob() {
switch (card.sdprinting_done_state) {

#if HAS_RESUME_CONTINUE // Display "Click to Continue..."
case 1:
did_state = queue.enqueue_P(PSTR("M0Q1S"
#if HAS_LCD_MENU
"1800" // ...for 30 minutes with LCD
#else
"60" // ...for 1 minute with no LCD
#endif
));
case 1: // 30 min timeout with LCD, 1 min without
did_state = queue.enqueue_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")));
break;
#endif

Expand Down Expand Up @@ -501,31 +492,19 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
}

// Prevent steppers timing-out in the middle of M600
#if BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT)
#define MOVE_AWAY_TEST !did_pause_print
#else
#define MOVE_AWAY_TEST true
#endif
#define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print)

if (stepper_inactive_time) {
static bool already_shutdown_steppers; // = false
if (planner.has_blocks_queued())
gcode.reset_stepper_timeout();
else if (MOVE_AWAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
else if (!STAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) {
if (!already_shutdown_steppers) {
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this
#if ENABLED(DISABLE_INACTIVE_X)
DISABLE_AXIS_X();
#endif
#if ENABLED(DISABLE_INACTIVE_Y)
DISABLE_AXIS_Y();
#endif
#if ENABLED(DISABLE_INACTIVE_Z)
DISABLE_AXIS_Z();
#endif
#if ENABLED(DISABLE_INACTIVE_E)
disable_e_steppers();
#endif
if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X();
if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y();
if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
if (ubl.lcd_map_control) {
ubl.lcd_map_control = false;
Expand Down Expand Up @@ -1191,7 +1170,6 @@ void setup() {
*/
void loop() {
do {

idle();

#if ENABLED(SDSUPPORT)
Expand All @@ -1204,9 +1182,5 @@ void loop() {

endstops.event_handler();

} while (false // Return to caller for best compatibility
#ifdef __AVR__
|| true // Loop forever on slower (AVR) boards
#endif
);
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
}
Loading

0 comments on commit a0a950e

Please sign in to comment.