Extended condition macros (#13419)

Allow `ENABLED`, `DISABLED`, `PIN_EXISTS`, and `BUTTON_EXISTS` to take multiple arguments. Also add:
- Alias `ANY(...)` for `!DISABLED(...)`
- Alias `ANY_PIN(...)` for `PIN_EXISTS(a) || PIN_EXISTS(b) ...`
- Alias `EITHER(A,B)` for `ANY(...)`
- Alias `ALL(...)` and `BOTH(A,B)` for `ENABLED(...)`
- `NONE(...)` for `DISABLED(...)`
This commit is contained in:
Scott Lahteine
2019-03-16 23:43:06 -05:00
committed by GitHub
parent d20eab4f83
commit 49cf92dc36
281 changed files with 1299 additions and 1288 deletions

View File

@ -27,7 +27,7 @@
#include "bedlevel.h"
#include "../../module/planner.h"
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
#include "../../module/motion.h"
#endif
@ -146,7 +146,7 @@ void reset_bed_level() {
#endif
}
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
#if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING)
/**
* Enable to produce output in JSON format suitable
@ -215,7 +215,7 @@ void reset_bed_level() {
#endif // AUTO_BED_LEVELING_BILINEAR || MESH_BED_LEVELING
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
void _manual_goto_xy(const float &rx, const float &ry) {

View File

@ -48,7 +48,7 @@ void reset_bed_level();
void set_z_fade_height(const float zfh, const bool do_report=true);
#endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)
#if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING)
#include <stdint.h>
@ -61,7 +61,7 @@ void reset_bed_level();
#endif
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
void _manual_goto_xy(const float &x, const float &y);
#endif

View File

@ -22,7 +22,7 @@
#include "../../inc/MarlinConfig.h"
#if ENABLED(DIGIPOT_I2C) && ENABLED(DIGIPOT_MCP4018)
#if BOTH(DIGIPOT_I2C, DIGIPOT_MCP4018)
#include "../../core/enum.h"
#include "Stream.h"

View File

@ -52,7 +52,7 @@
);
#endif
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
LEDColor LEDLights::color;
bool LEDLights::lights_on;
#endif
@ -60,7 +60,7 @@
LEDLights leds;
void LEDLights::setup() {
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#if EITHER(RGB_LED, RGBW_LED)
if (PWM_PIN(RGB_LED_R_PIN)) SET_PWM(RGB_LED_R_PIN); else SET_OUTPUT(RGB_LED_R_PIN);
if (PWM_PIN(RGB_LED_G_PIN)) SET_PWM(RGB_LED_G_PIN); else SET_OUTPUT(RGB_LED_G_PIN);
if (PWM_PIN(RGB_LED_B_PIN)) SET_PWM(RGB_LED_B_PIN); else SET_OUTPUT(RGB_LED_B_PIN);
@ -108,7 +108,7 @@ void LEDLights::set_color(const LEDColor &incol
#endif
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#if EITHER(RGB_LED, RGBW_LED)
// This variant uses 3-4 separate pins for the RGB(W) components.
// If the pins can do PWM then their intensity will be set.
@ -131,7 +131,7 @@ void LEDLights::set_color(const LEDColor &incol
RGBsetColor(incol.r, incol.g, incol.b, true);
#endif
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
// Don't update the color when OFF
lights_on = !incol.is_off();
if (lights_on) color = incol;

View File

@ -33,7 +33,7 @@
#include "neopixel.h"
#endif
#define HAS_WHITE_LED (ENABLED(RGBW_LED) || ENABLED(NEOPIXEL_LED))
#define HAS_WHITE_LED EITHER(RGBW_LED, NEOPIXEL_LED)
/**
* LEDcolor type for use with leds.set_color
@ -183,7 +183,7 @@ public:
static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
#endif
#if ENABLED(LED_CONTROL_MENU) || ENABLED(PRINTER_EVENT_LEDS)
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on"
#endif

View File

@ -46,7 +46,7 @@ bool Power::is_power_needed() {
HOTEND_LOOP() if (thermalManager.autofan_speed[e]) return true;
#endif
#if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLER_FAN && ENABLED(USE_CONTROLLER_FAN)
#if ENABLED(AUTO_POWER_CONTROLLERFAN, USE_CONTROLLER_FAN) && HAS_CONTROLLER_FAN
if (controllerfan_speed) return true;
#endif

View File

@ -22,7 +22,7 @@
#include "../inc/MarlinConfig.h"
#if ENABLED(EXT_SOLENOID) || ENABLED(MANUAL_SOLENOID_CONTROL)
#if EITHER(EXT_SOLENOID, MANUAL_SOLENOID_CONTROL)
#include "solenoid.h"
@ -95,4 +95,4 @@ void disable_all_solenoids() {
#endif
}
#endif // EXT_SOLENOID
#endif // EXT_SOLENOID || MANUAL_SOLENOID_CONTROL