From c6774812fa15756c226c879dba4d77f1dff0429a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Mar 2021 05:40:28 -0500 Subject: [PATCH] More IntelliSense-friendly declarations --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 4 +- Marlin/src/feature/caselight.h | 10 +- Marlin/src/feature/joystick.h | 16 +- Marlin/src/feature/meatpack.cpp | 4 +- Marlin/src/feature/mixing.h | 9 +- Marlin/src/feature/powerloss.h | 40 ++- Marlin/src/feature/tmc_util.h | 16 +- Marlin/src/gcode/bedlevel/G35.cpp | 4 +- Marlin/src/gcode/calibrate/G33.cpp | 4 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 +- Marlin/src/gcode/gcode.h | 336 +++++++++++++----- Marlin/src/gcode/queue.h | 14 +- .../lcd/dogm/status_screen_lite_ST7920.cpp | 4 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 8 +- Marlin/src/lcd/dwin/e3v2/dwin.h | 24 +- .../lcd/extui/lib/dgus/DGUSScreenHandler.cpp | 4 +- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 4 +- Marlin/src/lcd/extui/ui_api.cpp | 76 ++-- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/marlinui.h | 20 +- Marlin/src/lcd/menu/game/game.h | 16 +- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 4 +- Marlin/src/lcd/menu/menu_probe_offset.cpp | 4 +- Marlin/src/libs/nozzle.cpp | 12 +- Marlin/src/module/endstops.h | 12 +- Marlin/src/module/planner.cpp | 4 +- Marlin/src/module/planner.h | 4 +- Marlin/src/module/servo.cpp | 4 +- Marlin/src/module/stepper.cpp | 4 +- Marlin/src/module/temperature.h | 84 +++-- Marlin/src/module/tool_change.h | 8 +- Marlin/src/sd/cardreader.cpp | 4 +- 32 files changed, 562 insertions(+), 203 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 42a3018561..06b91002b8 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -303,7 +303,9 @@ void unified_bed_leveling::G29() { const int8_t p_val = parser.intval('P', -1); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'); - TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder); + #if ENABLED(HAS_MULTI_HOTEND) + const uint8_t old_tool_index = active_extruder; + #endif // Check for commands that require the printer to be homed if (may_move) { diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index 25bcb486fa..05385ad0cb 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -34,7 +34,9 @@ class CaseLight { public: static bool on; - TERN_(CASELIGHT_USES_BRIGHTNESS, static uint8_t brightness); + #if ENABLED(CASELIGHT_USES_BRIGHTNESS) + static uint8_t brightness; + #endif static bool pin_is_pwm() { return TERN0(NEED_CASE_LIGHT_PIN, PWM_PIN(CASE_LIGHT_PIN)); } static bool has_brightness() { return TERN0(CASELIGHT_USES_BRIGHTNESS, TERN(CASE_LIGHT_USE_NEOPIXEL, true, pin_is_pwm())); } @@ -50,8 +52,10 @@ public: static inline void update_brightness() { update(false); } static inline void update_enabled() { update(true); } -private: - TERN_(CASE_LIGHT_IS_COLOR_LED, static LEDColor color); + #if ENABLED(CASE_LIGHT_IS_COLOR_LED) + private: + static LEDColor color; + #endif }; extern CaseLight caselight; diff --git a/Marlin/src/feature/joystick.h b/Marlin/src/feature/joystick.h index e8e218b2f9..d1c4fbd314 100644 --- a/Marlin/src/feature/joystick.h +++ b/Marlin/src/feature/joystick.h @@ -32,11 +32,19 @@ class Joystick { friend class Temperature; private: - TERN_(HAS_JOY_ADC_X, static temp_info_t x); - TERN_(HAS_JOY_ADC_Y, static temp_info_t y); - TERN_(HAS_JOY_ADC_Z, static temp_info_t z); + #if ENABLED(HAS_JOY_ADC_X) + static temp_info_t x; + #endif + #if ENABLED(HAS_JOY_ADC_Y) + static temp_info_t y; + #endif + #if ENABLED(HAS_JOY_ADC_Z) + static temp_info_t z; + #endif public: - TERN_(JOYSTICK_DEBUG, static void report()); + #if ENABLED(JOYSTICK_DEBUG) + static void report(); + #endif static void calculate(xyz_float_t &norm_jog); static void inject_jog_moves(); }; diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index 44567ac482..0742f82350 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -57,7 +57,9 @@ uint8_t meatPackLookupTable[16] = { '\0' // Unused. 0b1111 indicates a literal character }; -TERN_(MP_DEBUG, uint8_t chars_decoded = 0); // Log the first 64 bytes after each reset +#if ENABLED(MP_DEBUG) + uint8_t chars_decoded = 0; // Log the first 64 bytes after each reset +#endif void MeatPack::reset_state() { state = 0; diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 65d1f1bf95..5de039985d 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -61,9 +61,6 @@ enum MixTool { #define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255) static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must be <= " STRINGIFY(MAX_VTOOLS) "!"); -#define MIXER_BLOCK_FIELD mixer_comp_t b_color[MIXING_STEPPERS] -#define MIXER_POPULATE_BLOCK() mixer.populate_block(block->b_color) -#define MIXER_STEPPER_SETUP() mixer.stepper_setup(current_block->b_color) #define MIXER_STEPPER_LOOP(VAR) for (uint_fast8_t VAR = 0; VAR < MIXING_STEPPERS; VAR++) #if ENABLED(GRADIENT_MIX) @@ -73,9 +70,11 @@ static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must mixer_comp_t color[MIXING_STEPPERS]; // The current gradient color float start_z, end_z; // Region for gradient int8_t start_vtool, end_vtool; // Start and end virtual tools - mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools + mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools end_mix[MIXING_STEPPERS]; - TERN_(GRADIENT_VTOOL, int8_t vtool_index); // Use this virtual tool number as index + #if ENABLED(GRADIENT_VTOOL) + int8_t vtool_index; // Use this virtual tool number as index + #endif } gradient_t; #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 12d11b141e..7c09c0f3cf 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -55,22 +55,38 @@ typedef struct { float zraise; // Repeat information - TERN_(GCODE_REPEAT_MARKERS, Repeat stored_repeat); + #if ENABLED(GCODE_REPEAT_MARKERS) + Repeat stored_repeat; + #endif - TERN_(HAS_HOME_OFFSET, xyz_pos_t home_offset); - TERN_(HAS_POSITION_SHIFT, xyz_pos_t position_shift); - TERN_(HAS_MULTI_EXTRUDER, uint8_t active_extruder); + #if ENABLED(HAS_HOME_OFFSET) + xyz_pos_t home_offset; + #endif + #if ENABLED(HAS_POSITION_SHIFT) + xyz_pos_t position_shift; + #endif + #if ENABLED(HAS_MULTI_EXTRUDER) + uint8_t active_extruder; + #endif #if DISABLED(NO_VOLUMETRICS) bool volumetric_enabled; float filament_size[EXTRUDERS]; #endif - TERN_(HAS_HOTEND, celsius_t target_temperature[HOTENDS]); - TERN_(HAS_HEATED_BED, celsius_t target_temperature_bed); - TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]); + #if ENABLED(HAS_HOTEND) + celsius_t target_temperature[HOTENDS]; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t target_temperature_bed; + #endif + #if ENABLED(HAS_FAN) + uint8_t fan_speed[FAN_COUNT]; + #endif - TERN_(HAS_LEVELING, float fade); + #if ENABLED(HAS_LEVELING) + float fade; + #endif #if ENABLED(FWRETRACT) float retract[EXTRUDERS], retract_hop; @@ -80,7 +96,9 @@ typedef struct { #if ENABLED(MIXING_EXTRUDER) //uint_fast8_t selected_vtool; //mixer_comp_t color[NR_MIXING_VIRTUAL_TOOLS][MIXING_STEPPERS]; - TERN_(GRADIENT_MIX, gradient_t gradient); + #if ENABLED(GRADIENT_MIX) + gradient_t gradient; + #endif #endif // SD Filename and position @@ -97,7 +115,9 @@ typedef struct { struct { bool dryrun:1; // M111 S8 bool allow_cold_extrusion:1; // M302 P1 - TERN_(HAS_LEVELING, bool leveling:1); + #if ENABLED(HAS_LEVELING) + bool leveling:1; + #endif } flag; uint8_t valid_foot; diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index b21b89f68b..1767313ba2 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -70,9 +70,15 @@ class TMCStorage { } struct { - TERN_(HAS_STEALTHCHOP, bool stealthChop_enabled = false); - TERN_(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0); - TERN_(USE_SENSORLESS, int16_t homing_thrs = 0); + #if ENABLED(HAS_STEALTHCHOP) + bool stealthChop_enabled = false; + #endif + #if ENABLED(HYBRID_THRESHOLD) + uint8_t hybrid_thrs = 0; + #endif + #if ENABLED(USE_SENSORLESS) + int16_t homing_thrs = 0; + #endif } stored; }; @@ -363,7 +369,9 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z struct slow_homing_t { xy_ulong_t acceleration; - TERN_(HAS_CLASSIC_JERK, xy_float_t jerk_xy); + #if ENABLED(HAS_CLASSIC_JERK) + xy_float_t jerk_xy; + #endif }; #endif diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 88f02e6de2..0fab747618 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -72,7 +72,9 @@ void GcodeSuite::G35() { // Disable the leveling matrix before auto-aligning #if HAS_LEVELING - TERN_(RESTORE_LEVELING_AFTER_G35, const bool leveling_was_active = planner.leveling_active); + #if ENABLED(RESTORE_LEVELING_AFTER_G35) + const bool leveling_was_active = planner.leveling_active; + #endif set_bed_leveling_enabled(false); #endif diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 5530bc7089..902711397d 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -63,7 +63,9 @@ enum CalEnum : char { // the 7 main calibration points - #define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP) #define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP) -TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder); +#if ENABLED(HAS_MULTI_HOTEND) + const uint8_t old_tool_index = active_extruder; +#endif float lcd_probe_pt(const xy_pos_t &xy); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index bee6aaedeb..d2075fedce 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -130,7 +130,9 @@ void GcodeSuite::G34() { // Disable the leveling matrix before auto-aligning #if HAS_LEVELING - TERN_(RESTORE_LEVELING_AFTER_G34, const bool leveling_was_active = planner.leveling_active); + #if ENABLED(RESTORE_LEVELING_AFTER_G34) + const bool leveling_was_active = planner.leveling_active; + #endif set_bed_leveling_enabled(false); #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 52570ff83f..7ea2489584 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -418,24 +418,34 @@ public: private: - TERN_(MARLIN_DEV_MODE, static void D(const int16_t dcode)); + #if ENABLED(MARLIN_DEV_MODE) + static void D(const int16_t dcode); + #endif static void G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move=false)); - TERN_(ARC_SUPPORT, static void G2_G3(const bool clockwise)); + #if ENABLED(ARC_SUPPORT) + static void G2_G3(const bool clockwise); + #endif static void G4(); - TERN_(BEZIER_CURVE_SUPPORT, static void G5()); + #if ENABLED(BEZIER_CURVE_SUPPORT) + static void G5(); + #endif - TERN_(DIRECT_STEPPING, static void G6()); + #if ENABLED(DIRECT_STEPPING) + static void G6(); + #endif #if ENABLED(FWRETRACT) static void G10(); static void G11(); #endif - TERN_(NOZZLE_CLEAN_FEATURE, static void G12()); + #if ENABLED(NOZZLE_CLEAN_FEATURE) + static void G12(); + #endif #if ENABLED(CNC_WORKSPACE_PLANES) static void G17(); @@ -448,9 +458,13 @@ private: static void G21(); #endif - TERN_(G26_MESH_VALIDATION, static void G26()); + #if ENABLED(G26_MESH_VALIDATION) + static void G26(); + #endif - TERN_(NOZZLE_PARK_FEATURE, static void G27()); + #if ENABLED(NOZZLE_PARK_FEATURE) + static void G27(); + #endif static void G28(); @@ -474,19 +488,29 @@ private: #endif #endif - TERN_(DELTA_AUTO_CALIBRATION, static void G33()); + #if ENABLED(DELTA_AUTO_CALIBRATION) + static void G33(); + #endif #if ANY(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) static void G34(); #endif - TERN_(Z_STEPPER_AUTO_ALIGN, static void M422()); + #if ENABLED(Z_STEPPER_AUTO_ALIGN) + static void M422(); + #endif - TERN_(ASSISTED_TRAMMING, static void G35()); + #if ENABLED(ASSISTED_TRAMMING) + static void G35(); + #endif - TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode)); + #if ENABLED(G38_PROBE_TARGET) + static void G38(const int8_t subcode); + #endif - TERN_(HAS_MESH, static void G42()); + #if ENABLED(HAS_MESH) + static void G42(); + #endif #if ENABLED(CNC_COORDINATE_SYSTEMS) static void G53(); @@ -498,20 +522,28 @@ private: static void G59(); #endif - TERN_(PROBE_TEMP_COMPENSATION, static void G76()); + #if ENABLED(PROBE_TEMP_COMPENSATION) + static void G76(); + #endif #if SAVED_POSITIONS static void G60(); static void G61(); #endif - TERN_(GCODE_MOTION_MODES, static void G80()); + #if ENABLED(GCODE_MOTION_MODES) + static void G80(); + #endif static void G92(); - TERN_(CALIBRATION_GCODE, static void G425()); + #if ENABLED(CALIBRATION_GCODE) + static void G425(); + #endif - TERN_(HAS_RESUME_CONTINUE, static void M0_M1()); + #if ENABLED(HAS_RESUME_CONTINUE) + static void M0_M1(); + #endif #if HAS_CUTTER static void M3_M4(const bool is_M4); @@ -519,14 +551,22 @@ private: #endif #if ENABLED(COOLANT_CONTROL) - TERN_(COOLANT_MIST, static void M7()); - TERN_(COOLANT_FLOOD, static void M8()); + #if ENABLED(COOLANT_MIST) + static void M7(); + #endif + #if ENABLED(COOLANT_FLOOD) + static void M8(); + #endif static void M9(); #endif - TERN_(EXTERNAL_CLOSED_LOOP_CONTROLLER, static void M12()); + #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) + static void M12(); + #endif - TERN_(EXPECTED_PRINTER_CHECK, static void M16()); + #if ENABLED(EXPECTED_PRINTER_CHECK) + static void M16(); + #endif static void M17(); @@ -549,27 +589,43 @@ private: static void M31(); #if ENABLED(SDSUPPORT) - TERN_(HAS_MEDIA_SUBCALLS, static void M32()); - TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33()); + #if ENABLED(HAS_MEDIA_SUBCALLS) + static void M32(); + #endif + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + static void M33(); + #endif #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE) static void M34(); #endif #endif - TERN_(DIRECT_PIN_CONTROL, static void M42()); - TERN_(PINS_DEBUGGING, static void M43()); + #if ENABLED(DIRECT_PIN_CONTROL) + static void M42(); + #endif + #if ENABLED(PINS_DEBUGGING) + static void M43(); + #endif - TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48()); + #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) + static void M48(); + #endif - TERN_(LCD_SET_PROGRESS_MANUALLY, static void M73()); + #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + static void M73(); + #endif static void M75(); static void M76(); static void M77(); - TERN_(PRINTCOUNTER, static void M78()); + #if ENABLED(PRINTCOUNTER) + static void M78(); + #endif - TERN_(PSU_CONTROL, static void M80()); + #if ENABLED(PSU_CONTROL) + static void M80(); + #endif static void M81(); static void M82(); @@ -577,7 +633,9 @@ private: static void M85(); static void M92(); - TERN_(M100_FREE_MEMORY_WATCHER, static void M100()); + #if ENABLED(M100_FREE_MEMORY_WATCHER) + static void M100(); + #endif #if EXTRUDERS static void M104(); @@ -595,13 +653,17 @@ private: static void M108(); static void M112(); static void M410(); - TERN_(HOST_PROMPT_SUPPORT, static void M876()); + #if ENABLED(HOST_PROMPT_SUPPORT) + static void M876(); + #endif #endif static void M110(); static void M111(); - TERN_(HOST_KEEPALIVE_FEATURE, static void M113()); + #if ENABLED(HOST_KEEPALIVE_FEATURE) + static void M113(); + #endif static void M114(); static void M115(); @@ -611,7 +673,9 @@ private: static void M120(); static void M121(); - TERN_(PARK_HEAD_ON_PAUSE, static void M125()); + #if ENABLED(PARK_HEAD_ON_PAUSE) + static void M125(); + #endif #if ENABLED(BARICUDA) #if HAS_HEATER_1 @@ -643,9 +707,13 @@ private: static void M145(); #endif - TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149()); + #if ENABLED(TEMPERATURE_UNITS_SUPPORT) + static void M149(); + #endif - TERN_(HAS_COLOR_LEDS, static void M150()); + #if ENABLED(HAS_COLOR_LEDS) + static void M150(); + #endif #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) static void M155(); @@ -654,8 +722,12 @@ private: #if ENABLED(MIXING_EXTRUDER) static void M163(); static void M164(); - TERN_(DIRECT_MIXING_IN_G1, static void M165()); - TERN_(GRADIENT_MIX, static void M166()); + #if ENABLED(DIRECT_MIXING_IN_G1) + static void M165(); + #endif + #if ENABLED(GRADIENT_MIX) + static void M166(); + #endif #endif static void M200(); @@ -669,19 +741,27 @@ private: static void M204(); static void M205(); - TERN_(HAS_M206_COMMAND, static void M206()); + #if ENABLED(HAS_M206_COMMAND) + static void M206(); + #endif #if ENABLED(FWRETRACT) static void M207(); static void M208(); - TERN_(FWRETRACT_AUTORETRACT, static void M209()); + #if ENABLED(FWRETRACT_AUTORETRACT) + static void M209(); + #endif #endif static void M211(); - TERN_(HAS_MULTI_EXTRUDER, static void M217()); + #if ENABLED(HAS_MULTI_EXTRUDER) + static void M217(); + #endif - TERN_(HAS_HOTEND_OFFSET, static void M218()); + #if ENABLED(HAS_HOTEND_OFFSET) + static void M218(); + #endif static void M220(); @@ -689,11 +769,17 @@ private: static void M221(); #endif - TERN_(DIRECT_PIN_CONTROL, static void M226()); + #if ENABLED(DIRECT_PIN_CONTROL) + static void M226(); + #endif - TERN_(PHOTO_GCODE, static void M240()); + #if ENABLED(PHOTO_GCODE) + static void M240(); + #endif - TERN_(HAS_LCD_CONTRAST, static void M250()); + #if ENABLED(HAS_LCD_CONTRAST) + static void M250(); + #endif #if ENABLED(EXPERIMENTAL_I2CBUS) static void M260(); @@ -702,33 +788,55 @@ private: #if HAS_SERVOS static void M280(); - TERN_(EDITABLE_SERVO_ANGLES, static void M281()); + #if ENABLED(EDITABLE_SERVO_ANGLES) + static void M281(); + #endif #endif - TERN_(BABYSTEPPING, static void M290()); + #if ENABLED(BABYSTEPPING) + static void M290(); + #endif - TERN_(HAS_BUZZER, static void M300()); + #if ENABLED(HAS_BUZZER) + static void M300(); + #endif - TERN_(PIDTEMP, static void M301()); + #if ENABLED(PIDTEMP) + static void M301(); + #endif - TERN_(PREVENT_COLD_EXTRUSION, static void M302()); + #if ENABLED(PREVENT_COLD_EXTRUSION) + static void M302(); + #endif - TERN_(HAS_PID_HEATING, static void M303()); + #if ENABLED(HAS_PID_HEATING) + static void M303(); + #endif - TERN_(PIDTEMPBED, static void M304()); + #if ENABLED(PIDTEMPBED) + static void M304(); + #endif - TERN_(HAS_USER_THERMISTORS, static void M305()); + #if ENABLED(HAS_USER_THERMISTORS) + static void M305(); + #endif - TERN_(PIDTEMPCHAMBER, static void M309()); + #if ENABLED(PIDTEMPCHAMBER) + static void M309(); + #endif #if HAS_MICROSTEPS static void M350(); static void M351(); #endif - TERN_(CASE_LIGHT_ENABLE, static void M355()); + #if ENABLED(CASE_LIGHT_ENABLE) + static void M355(); + #endif - TERN_(REPETIER_GCODE_M360, static void M360()); + #if ENABLED(REPETIER_GCODE_M360) + static void M360(); + #endif #if ENABLED(MORGAN_SCARA) static bool M360(); @@ -750,7 +858,9 @@ private: static void M402(); #endif - TERN_(HAS_PRUSA_MMU2, static void M403()); + #if ENABLED(HAS_PRUSA_MMU2) + static void M403(); + #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) static void M404(); @@ -759,22 +869,34 @@ private: static void M407(); #endif - TERN_(HAS_FILAMENT_SENSOR, static void M412()); + #if ENABLED(HAS_FILAMENT_SENSOR) + static void M412(); + #endif - TERN_(HAS_MULTI_LANGUAGE, static void M414()); + #if ENABLED(HAS_MULTI_LANGUAGE) + static void M414(); + #endif #if HAS_LEVELING static void M420(); static void M421(); #endif - TERN_(BACKLASH_GCODE, static void M425()); + #if ENABLED(BACKLASH_GCODE) + static void M425(); + #endif - TERN_(HAS_M206_COMMAND, static void M428()); + #if ENABLED(HAS_M206_COMMAND) + static void M428(); + #endif - TERN_(HAS_POWER_MONITOR, static void M430()); + #if ENABLED(HAS_POWER_MONITOR) + static void M430(); + #endif - TERN_(CANCEL_OBJECTS, static void M486()); + #if ENABLED(CANCEL_OBJECTS) + static void M486(); + #endif static void M500(); static void M501(); @@ -782,17 +904,27 @@ private: #if DISABLED(DISABLE_M503) static void M503(); #endif - TERN_(EEPROM_SETTINGS, static void M504()); + #if ENABLED(EEPROM_SETTINGS) + static void M504(); + #endif #if ENABLED(PASSWORD_FEATURE) static void M510(); - TERN_(PASSWORD_UNLOCK_GCODE, static void M511()); - TERN_(PASSWORD_CHANGE_GCODE, static void M512()); + #if ENABLED(PASSWORD_UNLOCK_GCODE) + static void M511(); + #endif + #if ENABLED(PASSWORD_CHANGE_GCODE) + static void M512(); + #endif #endif - TERN_(SDSUPPORT, static void M524()); + #if ENABLED(SDSUPPORT) + static void M524(); + #endif - TERN_(SD_ABORT_ON_ENDSTOP_HIT, static void M540()); + #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) + static void M540(); + #endif #if HAS_ETHERNET static void M552(); @@ -800,16 +932,22 @@ private: static void M554(); #endif - TERN_(BAUD_RATE_GCODE, static void M575()); + #if ENABLED(BAUD_RATE_GCODE) + static void M575(); + #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); #endif - TERN_(HAS_DUPLICATION_MODE, static void M605()); + #if ENABLED(HAS_DUPLICATION_MODE) + static void M605(); + #endif - TERN_(IS_KINEMATIC, static void M665()); + #if ENABLED(IS_KINEMATIC) + static void M665(); + #endif #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS static void M666(); @@ -824,13 +962,21 @@ private: static void M702(); #endif - TERN_(GCODE_REPEAT_MARKERS, static void M808()); + #if ENABLED(GCODE_REPEAT_MARKERS) + static void M808(); + #endif - TERN_(GCODE_MACROS, static void M810_819()); + #if ENABLED(GCODE_MACROS) + static void M810_819(); + #endif - TERN_(HAS_BED_PROBE, static void M851()); + #if ENABLED(HAS_BED_PROBE) + static void M851(); + #endif - TERN_(SKEW_CORRECTION_GCODE, static void M852()); + #if ENABLED(SKEW_CORRECTION_GCODE) + static void M852(); + #endif #if ENABLED(I2C_POSITION_ENCODERS) FORCE_INLINE static void M860() { I2CPEM.M860(); } @@ -850,18 +996,26 @@ private: static void M871(); #endif - TERN_(LIN_ADVANCE, static void M900()); + #if ENABLED(LIN_ADVANCE) + static void M900(); + #endif #if HAS_TRINAMIC_CONFIG static void M122(); static void M906(); - TERN_(HAS_STEALTHCHOP, static void M569()); + #if ENABLED(HAS_STEALTHCHOP) + static void M569(); + #endif #if ENABLED(MONITOR_DRIVER_STATUS) static void M911(); static void M912(); #endif - TERN_(HYBRID_THRESHOLD, static void M913()); - TERN_(USE_SENSORLESS, static void M914()); + #if ENABLED(HYBRID_THRESHOLD) + static void M913(); + #endif + #if ENABLED(USE_SENSORLESS) + static void M914(); + #endif #endif #if HAS_L64XX @@ -883,18 +1037,26 @@ private: #endif #endif - TERN_(SDSUPPORT, static void M928()); + #if ENABLED(SDSUPPORT) + static void M928(); + #endif - TERN_(MAGNETIC_PARKING_EXTRUDER, static void M951()); + #if ENABLED(MAGNETIC_PARKING_EXTRUDER) + static void M951(); + #endif - TERN_(TOUCH_SCREEN_CALIBRATION, static void M995()); + #if ENABLED(TOUCH_SCREEN_CALIBRATION) + static void M995(); + #endif #if BOTH(HAS_SPI_FLASH, SDSUPPORT) static void M993(); static void M994(); #endif - TERN_(PLATFORM_M997_SUPPORT, static void M997()); + #if ENABLED(PLATFORM_M997_SUPPORT) + static void M997(); + #endif static void M999(); @@ -903,11 +1065,17 @@ private: static void M1000(); #endif - TERN_(SDSUPPORT, static void M1001()); + #if ENABLED(SDSUPPORT) + static void M1001(); + #endif - TERN_(MAX7219_GCODE, static void M7219()); + #if ENABLED(MAX7219_GCODE) + static void M7219(); + #endif - TERN_(CONTROLLER_FAN_EDITABLE, static void M710()); + #if ENABLED(CONTROLLER_FAN_EDITABLE) + static void M710(); + #endif static void T(const int8_t tool_index); diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 8e87d114eb..4d3ccb364e 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -40,9 +40,9 @@ public: * M110 N sets the current line number. */ long last_N; - int count; //!< Number of characters read in the current line of serial input - char line_buffer[MAX_CMD_SIZE]; //!< The current line accumulator - uint8_t input_state; //!< The input state + int count; //!< Number of characters read in the current line of serial input + char line_buffer[MAX_CMD_SIZE]; //!< The current line accumulator + uint8_t input_state; //!< The input state }; static SerialState serial_state[NUM_SERIAL]; //!< Serial states for each serial port @@ -57,9 +57,11 @@ public: * command and hands off execution to individual handler functions. */ struct CommandLine { - char buffer[MAX_CMD_SIZE]; //!< The command buffer - bool skip_ok; //!< Skip sending ok when command is processed? - TERN_(HAS_MULTI_SERIAL, serial_index_t port); //!< Serial port the command was received on + char buffer[MAX_CMD_SIZE]; //!< The command buffer + bool skip_ok; //!< Skip sending ok when command is processed? + #if ENABLED(HAS_MULTI_SERIAL) + serial_index_t port; //!< Serial port the command was received on + #endif }; /** diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index dcb65f676d..a2dfb74a57 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -536,7 +536,9 @@ void ST7920_Lite_Status_Screen::draw_heat_icon(const bool whichIcon, const bool static struct { bool E1_show_target : 1; bool E2_show_target : 1; - TERN_(HAS_HEATED_BED, bool bed_show_target : 1); + #if ENABLED(HAS_HEATED_BED) + bool bed_show_target : 1; + #endif } display_state = { true, true, TERN_(HAS_HEATED_BED, true) }; diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 0e9b93525d..d543ff0508 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -180,8 +180,12 @@ static uint8_t _card_percent = 0; static uint16_t _remain_time = 0; #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, uint16_t resume_hotend_temp = 0); - TERN_(HAS_HEATED_BED, uint16_t resume_bed_temp = 0); + #if ENABLED(HAS_HOTEND) + uint16_t resume_hotend_temp = 0; + #endif + #if ENABLED(HAS_HEATED_BED) + uint16_t resume_bed_temp = 0; + #endif #endif #if HAS_ZOFFSET_ITEM diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index 9e0cda86c2..dd2d1cbc01 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -234,9 +234,15 @@ extern char print_filename[16]; extern millis_t dwin_heat_time; typedef struct { - TERN_(HAS_HOTEND, celsius_t E_Temp = 0); - TERN_(HAS_HEATED_BED, celsius_t Bed_Temp = 0); - TERN_(HAS_FAN, int16_t Fan_speed = 0); + #if ENABLED(HAS_HOTEND) + celsius_t E_Temp = 0; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t Bed_Temp = 0; + #endif + #if ENABLED(HAS_FAN) + int16_t Fan_speed = 0; + #endif int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; @@ -312,9 +318,15 @@ void HMI_Move_E(); void HMI_Zoffset(); -TERN_(HAS_HOTEND, void HMI_ETemp()); -TERN_(HAS_HEATED_BED, void HMI_BedTemp()); -TERN_(HAS_FAN, void HMI_FanSpeed()); +#if ENABLED(HAS_HOTEND) + void HMI_ETemp(); +#endif +#if ENABLED(HAS_HEATED_BED) + void HMI_BedTemp(); +#endif +#if ENABLED(HAS_FAN) + void HMI_FanSpeed(); +#endif void HMI_PrintSpeed(); diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp index 473fcb954c..a585ef670a 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSScreenHandler.cpp @@ -624,7 +624,9 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr DEBUG_ECHOLNPGM("HandlePreheat"); uint8_t e_temp = 0; - TERN_(HAS_HEATED_BED, uint8_t bed_temp = 0); + #if ENABLED(HAS_HEATED_BED) + uint8_t bed_temp = 0; + #endif const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); switch (preheat_option) { default: diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 2cc6d19cc5..e9e501ae5f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -49,7 +49,9 @@ static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; -TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2); +#if ENABLED(HAS_MULTI_EXTRUDER) + static lv_obj_t *labelExt2; +#endif #if HAS_HEATED_BED static lv_obj_t* labelBed; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 9e5e0b6a62..cfd48e5dd9 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -103,8 +103,12 @@ namespace ExtUI { static struct { uint8_t printer_killed : 1; - TERN_(JOYSTICK, uint8_t jogging : 1); - TERN_(SDSUPPORT, uint8_t was_sd_printing : 1); + #if ENABLED(JOYSTICK) + uint8_t jogging : 1; + #endif + #if ENABLED(SDSUPPORT) + uint8_t was_sd_printing : 1; + #endif } flags; #ifdef __SAM3X8E__ @@ -175,8 +179,12 @@ namespace ExtUI { #if HAS_HEATED_BED case BED: thermalManager.reset_bed_idle_timer(); return; #endif - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer - TERN_(HAS_COOLER, case COOLER: return); // Cooler has no idle timer + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return; // Chamber has no idle timer + #endif + #if ENABLED(HAS_COOLER) + case COOLER: return; // Cooler has no idle timer + #endif default: TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0)); break; @@ -234,8 +242,12 @@ namespace ExtUI { bool isHeaterIdle(const heater_t heater) { #if HEATER_IDLE_HANDLER switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return false); // Chamber has no idle timer + #if ENABLED(HAS_HEATED_BED) + case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out; + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return false; // Chamber has no idle timer + #endif default: return TERN0(HAS_HOTEND, thermalManager.heater_idle[heater - H0].timed_out); } @@ -253,8 +265,12 @@ namespace ExtUI { float getActualTemp_celsius(const heater_t heater) { switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed())); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber())); + #if ENABLED(HAS_HEATED_BED) + case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed()); + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber()); + #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(heater - H0)); } } @@ -265,8 +281,12 @@ namespace ExtUI { float getTargetTemp_celsius(const heater_t heater) { switch (heater) { - TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed())); - TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber())); + #if ENABLED(HAS_HEATED_BED) + case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed()); + #endif + #if ENABLED(HAS_HEATED_CHAMBER) + case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber()); + #endif default: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(heater - H0)); } } @@ -294,13 +314,13 @@ namespace ExtUI { } float getAxisPosition_mm(const axis_t axis) { - return TERN_(JOYSTICK, flags.jogging ? destination[axis] :) current_position[axis]; + return TERN0(JOYSTICK, flags.jogging) ? destination[axis] : current_position[axis]; } float getAxisPosition_mm(const extruder_t extruder) { const extruder_t old_tool = getActiveTool(); setActiveTool(extruder, true); - const float epos = TERN_(JOYSTICK, flags.jogging ? destination.e :) current_position.e; + const float epos = TERN0(JOYSTICK, flags.jogging) ? destination.e : current_position.e; setActiveTool(old_tool, true); return epos; } @@ -491,14 +511,30 @@ namespace ExtUI { int getTMCBumpSensitivity(const axis_t axis) { switch (axis) { - TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold()); - TERN_(X2_SENSORLESS, case X2: return stepperX2.homing_threshold()); - TERN_(Y_SENSORLESS, case Y: return stepperY.homing_threshold()); - TERN_(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold()); - TERN_(Z_SENSORLESS, case Z: return stepperZ.homing_threshold()); - TERN_(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold()); - TERN_(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold()); - TERN_(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold()); + #if ENABLED(X_SENSORLESS) + case X: return stepperX.homing_threshold(); + #endif + #if ENABLED(X2_SENSORLESS) + case X2: return stepperX2.homing_threshold(); + #endif + #if ENABLED(Y_SENSORLESS) + case Y: return stepperY.homing_threshold(); + #endif + #if ENABLED(Y2_SENSORLESS) + case Y2: return stepperY2.homing_threshold(); + #endif + #if ENABLED(Z_SENSORLESS) + case Z: return stepperZ.homing_threshold(); + #endif + #if ENABLED(Z2_SENSORLESS) + case Z2: return stepperZ2.homing_threshold(); + #endif + #if ENABLED(Z3_SENSORLESS) + case Z3: return stepperZ3.homing_threshold(); + #endif + #if ENABLED(Z4_SENSORLESS) + case Z4: return stepperZ4.homing_threshold(); + #endif default: return 0; } } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 88566713a4..0be30efad8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -688,7 +688,9 @@ void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { xyze_pos_t ManualMove::all_axes_destination = { 0 }; bool ManualMove::processing = false; #endif - TERN_(MULTI_MANUAL, int8_t ManualMove::e_index = 0); + #if ENABLED(MULTI_MANUAL) + int8_t ManualMove::e_index = 0; + #endif AxisEnum ManualMove::axis = NO_AXIS; /** diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index a18a3384af..490d78401e 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -105,9 +105,15 @@ #if PREHEAT_COUNT typedef struct { - TERN_(HAS_HOTEND, celsius_t hotend_temp); - TERN_(HAS_HEATED_BED, celsius_t bed_temp ); - TERN_(HAS_FAN, uint16_t fan_speed ); + #if ENABLED(HAS_HOTEND) + celsius_t hotend_temp; + #endif + #if ENABLED(HAS_HEATED_BED) + celsius_t bed_temp; + #endif + #if ENABLED(HAS_FAN) + uint16_t fan_speed; + #endif } preheat_t; #endif @@ -123,10 +129,14 @@ static int8_t constexpr e_index = 0; #endif static millis_t start_time; - TERN_(IS_KINEMATIC, static xyze_pos_t all_axes_destination); + #if ENABLED(IS_KINEMATIC) + static xyze_pos_t all_axes_destination; + #endif public: static float menu_scale; - TERN_(IS_KINEMATIC, static float offset); + #if ENABLED(IS_KINEMATIC) + static float offset; + #endif template void set_destination(const T& dest) { #if IS_KINEMATIC diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index cba79e4f28..999aa78100 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -53,10 +53,18 @@ // Pool game data to save SRAM union MarlinGameData { - TERN_(MARLIN_BRICKOUT, brickout_data_t brickout); - TERN_(MARLIN_INVADERS, invaders_data_t invaders); - TERN_(MARLIN_SNAKE, snake_data_t snake); - TERN_(MARLIN_MAZE, maze_data_t maze); + #if ENABLED(MARLIN_BRICKOUT) + brickout_data_t brickout; + #endif + #if ENABLED(MARLIN_INVADERS) + invaders_data_t invaders; + #endif + #if ENABLED(MARLIN_SNAKE) + snake_data_t snake; + #endif + #if ENABLED(MARLIN_MAZE) + maze_data_t maze; + #endif }; extern MarlinGameData marlin_game_data; diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index a86ae74fce..ef9f2246c2 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -119,7 +119,9 @@ void lcd_delta_settings() { } void menu_delta_calibrate() { - TERN_(DELTA_CALIBRATION_MENU, const bool all_homed = all_axes_homed()); // Acquire ahead of loop + #if ENABLED(DELTA_CALIBRATION_MENU) + const bool all_homed = all_axes_homed(); // Acquire ahead of loop + #endif START_MENU(); BACK_ITEM(MSG_MAIN); diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index 3b3fa0fd2a..1d62ada327 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -42,7 +42,9 @@ // Global storage float z_offset_backup, calculated_z_offset, z_offset_ref; -TERN_(HAS_LEVELING, bool leveling_was_active); +#if ENABLED(HAS_LEVELING) + bool leveling_was_active; +#endif inline void z_clearance_move() { do_z_clearance( diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 4277e8d8d0..c56f45c70b 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -46,7 +46,9 @@ Nozzle nozzle; * @param strokes number of strokes to execute */ void Nozzle::stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) { - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t oldpos = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t oldpos = current_position; + #endif // Move to the starting point #if ENABLED(NOZZLE_CLEAN_NO_Z) @@ -86,7 +88,9 @@ Nozzle nozzle; const xy_pos_t diff = end - start; if (!diff.x || !diff.y) return; - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t back = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t back = current_position; + #endif #if ENABLED(NOZZLE_CLEAN_NO_Z) do_blocking_move_to_xy(start); @@ -129,7 +133,9 @@ Nozzle nozzle; void Nozzle::circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const float &radius) { if (strokes == 0) return; - TERN_(NOZZLE_CLEAN_GOBACK, const xyz_pos_t back = current_position); + #if ENABLED(NOZZLE_CLEAN_GOBACK) + const xyz_pos_t back = current_position; + #endif TERN(NOZZLE_CLEAN_NO_Z, do_blocking_move_to_xy, do_blocking_move_to)(start); LOOP_L_N(s, strokes) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index c0cc9cdb8e..13e814aa1f 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -46,9 +46,15 @@ class Endstops { public: #if HAS_EXTRA_ENDSTOPS typedef uint16_t esbits_t; - TERN_(X_DUAL_ENDSTOPS, static float x2_endstop_adj); - TERN_(Y_DUAL_ENDSTOPS, static float y2_endstop_adj); - TERN_(Z_MULTI_ENDSTOPS, static float z2_endstop_adj); + #if ENABLED(X_DUAL_ENDSTOPS) + static float x2_endstop_adj; + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + static float y2_endstop_adj; + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + static float z2_endstop_adj; + #endif #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 static float z3_endstop_adj; #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8c320925be..84c93e5296 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2019,9 +2019,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Bail if this is a zero-length block if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return false; - #if ENABLED(MIXING_EXTRUDER) - MIXER_POPULATE_BLOCK(); - #endif + TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)) TERN_(HAS_CUTTER, block->cutter_power = cutter.power); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 769967d4a6..24c814e851 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -170,7 +170,9 @@ typedef struct block_t { static constexpr uint8_t extruder = 0; #endif - TERN_(MIXING_EXTRUDER, MIXER_BLOCK_FIELD); // Normalized color for the mixing steppers + #if ENABLED(MIXING_EXTRUDER) + mixer_comp_t b_color[MIXING_STEPPERS]; // Normalized color for the mixing steppers + #endif // Settings for the trapezoid generator uint32_t accelerate_until, // The index of the step event on which to stop acceleration diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 27e5a2af2e..9b71dd390f 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -32,7 +32,9 @@ HAL_SERVO_LIB servo[NUM_SERVOS]; -TERN_(EDITABLE_SERVO_ANGLES, uint16_t servo_angles[NUM_SERVOS][2]); +#if ENABLED(EDITABLE_SERVO_ANGLES) + uint16_t servo_angles[NUM_SERVOS][2]; +#endif void servo_init() { #if NUM_SERVOS >= 1 && HAS_SERVO_0 diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 466f4f333a..77fa6539bc 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2130,9 +2130,7 @@ uint32_t Stepper::block_phase_isr() { accelerate_until = current_block->accelerate_until << oversampling; decelerate_after = current_block->decelerate_after << oversampling; - #if ENABLED(MIXING_EXTRUDER) - MIXER_STEPPER_SETUP(); - #endif + TERN_(MIXING_EXTRUDER, mixer.stepper_setup(current_block->b_color)) TERN_(HAS_MULTI_EXTRUDER, stepper_extruder = current_block->extruder); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c9e3575257..8092f1f7e2 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -326,14 +326,28 @@ class Temperature { static const celsius_t hotend_maxtemp[HOTENDS]; FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif - TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); - TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); - TERN_(HAS_TEMP_CHAMBER, static chamber_info_t temp_chamber); - TERN_(HAS_TEMP_COOLER, static cooler_info_t temp_cooler); + #if ENABLED(HAS_HEATED_BED) + static bed_info_t temp_bed; + #endif + #if ENABLED(HAS_TEMP_PROBE) + static probe_info_t temp_probe; + #endif + #if ENABLED(HAS_TEMP_CHAMBER) + static chamber_info_t temp_chamber; + #endif + #if ENABLED(HAS_TEMP_COOLER) + static cooler_info_t temp_cooler; + #endif - TERN_(AUTO_POWER_E_FANS, static uint8_t autofan_speed[HOTENDS]); - TERN_(AUTO_POWER_CHAMBER_FAN, static uint8_t chamberfan_speed); - TERN_(AUTO_POWER_COOLER_FAN, static uint8_t coolerfan_speed); + #if ENABLED(AUTO_POWER_E_FANS) + static uint8_t autofan_speed[HOTENDS]; + #endif + #if ENABLED(AUTO_POWER_CHAMBER_FAN) + static uint8_t chamberfan_speed; + #endif + #if ENABLED(AUTO_POWER_COOLER_FAN) + static uint8_t coolerfan_speed; + #endif #if ENABLED(FAN_SOFT_PWM) static uint8_t soft_pwm_amount_fan[FAN_COUNT], @@ -403,11 +417,15 @@ class Temperature { private: - TERN_(EARLY_WATCHDOG, static bool inited); // If temperature controller is running + #if ENABLED(EARLY_WATCHDOG) + static bool inited; // If temperature controller is running + #endif static volatile bool raw_temps_ready; - TERN_(WATCH_HOTENDS, static hotend_watch_t watch_hotend[HOTENDS]); + #if ENABLED(WATCH_HOTENDS) + static hotend_watch_t watch_hotend[HOTENDS]; + #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) static uint16_t redundant_temperature_raw; @@ -419,22 +437,30 @@ class Temperature { static lpq_ptr_t lpq_ptr; #endif - TERN_(HAS_HOTEND, static temp_range_t temp_range[HOTENDS]); + #if ENABLED(HAS_HOTEND) + static temp_range_t temp_range[HOTENDS]; + #endif #if HAS_HEATED_BED - TERN_(WATCH_BED, static bed_watch_t watch_bed); + #if ENABLED(WATCH_BED) + static bed_watch_t watch_bed; + #endif IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); static int16_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER - TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber); + #if ENABLED(WATCH_CHAMBER) + static chamber_watch_t watch_chamber; + #endif TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER - TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler); + #if ENABLED(WATCH_COOLER) + static cooler_watch_t watch_cooler; + #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif @@ -447,9 +473,13 @@ class Temperature { static millis_t preheat_end_time[HOTENDS]; #endif - TERN_(HAS_AUTO_FAN, static millis_t next_auto_fan_check_ms); + #if ENABLED(HAS_AUTO_FAN) + static millis_t next_auto_fan_check_ms; + #endif - TERN_(PROBING_HEATERS_OFF, static bool paused); + #if ENABLED(PROBING_HEATERS_OFF) + static bool paused; + #endif public: #if HAS_ADC_BUTTONS @@ -457,7 +487,9 @@ class Temperature { static uint16_t ADCKey_count; #endif - TERN_(PID_EXTRUSION_SCALING, static int16_t lpq_len); + #if ENABLED(PID_EXTRUSION_SCALING) + static int16_t lpq_len; + #endif /** * Instance Methods @@ -534,7 +566,9 @@ class Temperature { static constexpr inline uint8_t fanPercent(const uint8_t speed) { return ui8_to_percent(speed); } - TERN_(ADAPTIVE_FAN_SLOWING, static uint8_t fan_speed_scaler[FAN_COUNT]); + #if ENABLED(ADAPTIVE_FAN_SLOWING) + static uint8_t fan_speed_scaler[FAN_COUNT]; + #endif static inline uint8_t scaledFanSpeed(const uint8_t target, const uint8_t fs) { UNUSED(target); // Potentially unused! @@ -843,7 +877,9 @@ class Temperature { #endif #endif - TERN_(HAS_DISPLAY, static void set_heating_message(const uint8_t e)); + #if ENABLED(HAS_DISPLAY) + static void set_heating_message(const uint8_t e); + #endif #if HAS_LCD_MENU && HAS_TEMPERATURE static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); @@ -866,9 +902,15 @@ class Temperature { static void checkExtruderAutoFans(); - TERN_(HAS_HOTEND, static float get_pid_output_hotend(const uint8_t e)); - TERN_(PIDTEMPBED, static float get_pid_output_bed()); - TERN_(PIDTEMPCHAMBER, static float get_pid_output_chamber()); + #if ENABLED(HAS_HOTEND) + static float get_pid_output_hotend(const uint8_t e); + #endif + #if ENABLED(PIDTEMPBED) + static float get_pid_output_bed(); + #endif + #if ENABLED(PIDTEMPCHAMBER) + static float get_pid_output_chamber(); + #endif static void _temp_error(const heater_id_t e, PGM_P const serial_msg, PGM_P const lcd_msg); static void min_temp_error(const heater_id_t e); diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 5361451c82..a97b09fd89 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -109,9 +109,11 @@ #endif -TERN_(ELECTROMAGNETIC_SWITCHING_TOOLHEAD, void est_init()); - -TERN_(SWITCHING_TOOLHEAD, void swt_init()); +#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + void est_init(); +#elif ENABLED(SWITCHING_TOOLHEAD) + void swt_init(); +#endif /** * Perform a tool-change, which may result in moving the diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index a3e0577031..53053e88dc 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1084,7 +1084,9 @@ void CardReader::cdroot() { #if DISABLED(SDSORT_USES_RAM) selectFileByIndex(o1); // Pre-fetch the first entry and save it strcpy(name1, longest_filename()); // so the loop only needs one fetch - TERN_(HAS_FOLDER_SORTING, bool dir1 = flag.filenameIsDir); + #if ENABLED(HAS_FOLDER_SORTING) + bool dir1 = flag.filenameIsDir; + #endif #endif for (uint16_t j = 0; j < i; ++j) {