Ver código fonte

Add alternative TERN macros

Scott Lahteine 4 anos atrás
pai
commit
06bf3ccfb7

+ 1
- 1
Marlin/src/MarlinCore.cpp Ver arquivo

248
   bool wait_for_user; // = false;
248
   bool wait_for_user; // = false;
249
 
249
 
250
   void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
250
   void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
251
-    TERN(ADVANCED_PAUSE_FEATURE,,UNUSED(no_sleep));
251
+    UNUSED(no_sleep);
252
     KEEPALIVE_STATE(PAUSED_FOR_USER);
252
     KEEPALIVE_STATE(PAUSED_FOR_USER);
253
     wait_for_user = true;
253
     wait_for_user = true;
254
     if (ms) ms += millis(); // expire time
254
     if (ms) ms += millis(); // expire time

+ 3
- 0
Marlin/src/core/macros.h Ver arquivo

196
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
196
 #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
197
 #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
197
 #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
198
 
198
 
199
+#define IF_ENABLED          TERN_
200
+#define IF_DISABLED(O,A)    TERN(O,,A)
201
+
199
 #define ANY(V...)          !DISABLED(V)
202
 #define ANY(V...)          !DISABLED(V)
200
 #define NONE(V...)          DISABLED(V)
203
 #define NONE(V...)          DISABLED(V)
201
 #define ALL(V...)           ENABLED(V)
204
 #define ALL(V...)           ENABLED(V)

+ 2
- 2
Marlin/src/feature/backlash.h Ver arquivo

54
   #endif
54
   #endif
55
 
55
 
56
   static inline float get_measurement(const AxisEnum a) {
56
   static inline float get_measurement(const AxisEnum a) {
57
+    UNUSED(a);
57
     // Return the measurement averaged over all readings
58
     // Return the measurement averaged over all readings
58
     return TERN(MEASURE_BACKLASH_WHEN_PROBING
59
     return TERN(MEASURE_BACKLASH_WHEN_PROBING
59
       , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
60
       , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
60
       , 0
61
       , 0
61
     );
62
     );
62
-    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
63
   }
63
   }
64
 
64
 
65
   static inline bool has_measurement(const AxisEnum a) {
65
   static inline bool has_measurement(const AxisEnum a) {
66
+    UNUSED(a);
66
     return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
67
     return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
67
-    TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
68
   }
68
   }
69
 
69
 
70
   static inline bool has_any_measurement() {
70
   static inline bool has_any_measurement() {

+ 1
- 1
Marlin/src/feature/leds/neopixel.h Ver arquivo

110
       #if CONJOINED_NEOPIXEL
110
       #if CONJOINED_NEOPIXEL
111
         adaneo2.show();
111
         adaneo2.show();
112
       #else
112
       #else
113
-        TERN(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN));
113
+        IF_DISABLED(NEOPIXEL2_SEPARATE, adaneo1.setPin(NEOPIXEL2_PIN));
114
         adaneo1.show();
114
         adaneo1.show();
115
         adaneo1.setPin(NEOPIXEL_PIN);
115
         adaneo1.setPin(NEOPIXEL_PIN);
116
       #endif
116
       #endif

+ 1
- 1
Marlin/src/lcd/dogm/marlinui_DOGM.cpp Ver arquivo

123
           custom_start_bmp
123
           custom_start_bmp
124
         #endif
124
         #endif
125
       ;
125
       ;
126
-      TERN(CUSTOM_BOOTSCREEN_ANIMATED,,UNUSED(frame));
126
+      UNUSED(frame);
127
 
127
 
128
       u8g.drawBitmapP(left, top, CUSTOM_BOOTSCREEN_BMP_BYTEWIDTH, CUSTOM_BOOTSCREEN_BMPHEIGHT, bmp);
128
       u8g.drawBitmapP(left, top, CUSTOM_BOOTSCREEN_BMP_BYTEWIDTH, CUSTOM_BOOTSCREEN_BMPHEIGHT, bmp);
129
 
129
 

+ 3
- 0
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h Ver arquivo

253
   #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
253
   #define __TERN(T,V...)      ___TERN(_CAT(_NO,T),V)  // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
254
   #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
254
   #define ___TERN(P,V...)     THIRD(P,V)              // If first argument has a comma, A. Else B.
255
 
255
 
256
+  #define IF_ENABLED          TERN_
257
+  #define IF_DISABLED(O,A)    _TERN(_ENA_1(O),,A)
258
+
256
   #define ANY(V...)          !DISABLED(V)
259
   #define ANY(V...)          !DISABLED(V)
257
   #define NONE(V...)          DISABLED(V)
260
   #define NONE(V...)          DISABLED(V)
258
   #define ALL(V...)           ENABLED(V)
261
   #define ALL(V...)           ENABLED(V)

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp Ver arquivo

81
 }
81
 }
82
 
82
 
83
 void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
83
 void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) {
84
-  TERN(TURBO_BACK_MENU_ITEM,,constexpr bool is_back = false);
84
+  IF_DISABLED(TURBO_BACK_MENU_ITEM, constexpr bool is_back = false);
85
   TERN_(HAS_TOUCH_XPT2046, on_edit_screen = false);
85
   TERN_(HAS_TOUCH_XPT2046, on_edit_screen = false);
86
   if (screen_history_depth > 0) {
86
   if (screen_history_depth > 0) {
87
     menuPosition &sh = screen_history[--screen_history_depth];
87
     menuPosition &sh = screen_history[--screen_history_depth];

+ 2
- 2
Marlin/src/lcd/menu/menu_advanced.cpp Ver arquivo

202
   // Helpers for editing PID Ki & Kd values
202
   // Helpers for editing PID Ki & Kd values
203
   // grab the PID value out of the temp variable; scale it; then update the PID driver
203
   // grab the PID value out of the temp variable; scale it; then update the PID driver
204
   void copy_and_scalePID_i(int16_t e) {
204
   void copy_and_scalePID_i(int16_t e) {
205
-    TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
205
+    UNUSED(e);
206
     PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
206
     PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
207
     thermalManager.updatePID();
207
     thermalManager.updatePID();
208
   }
208
   }
209
   void copy_and_scalePID_d(int16_t e) {
209
   void copy_and_scalePID_d(int16_t e) {
210
-    TERN(PID_PARAMS_PER_HOTEND,,UNUSED(e));
210
+    UNUSED(e);
211
     PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
211
     PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
212
     thermalManager.updatePID();
212
     thermalManager.updatePID();
213
   }
213
   }

+ 1
- 1
Marlin/src/lcd/menu/menu_filament.cpp Ver arquivo

219
 #define HOTEND_STATUS_ITEM() do { \
219
 #define HOTEND_STATUS_ITEM() do { \
220
   if (_menuLineNr == _thisItemNr) { \
220
   if (_menuLineNr == _thisItemNr) { \
221
     if (ui.should_draw()) { \
221
     if (ui.should_draw()) { \
222
-      TERN(HAS_GRAPHICAL_TFT,, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \
222
+      IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \
223
       ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
223
       ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
224
     } \
224
     } \
225
     if (_skipStatic && encoderLine <= _thisItemNr) { \
225
     if (_skipStatic && encoderLine <= _thisItemNr) { \

+ 1
- 1
Marlin/src/lcd/menu/menu_ubl.cpp Ver arquivo

64
       ubl.encoder_diff > 0 ? 0.005f : -0.005f
64
       ubl.encoder_diff > 0 ? 0.005f : -0.005f
65
     );
65
     );
66
     ubl.encoder_diff = 0;
66
     ubl.encoder_diff = 0;
67
-    TERN(IS_TFTGLCD_PANEL,,ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
67
+    IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
68
   }
68
   }
69
   TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
69
   TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
70
 
70
 

+ 3
- 3
Marlin/src/module/settings.cpp Ver arquivo

1497
       }
1497
       }
1498
       DEBUG_ECHO_START();
1498
       DEBUG_ECHO_START();
1499
       DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1499
       DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1500
-      TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_version());
1500
+      IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version());
1501
       eeprom_error = true;
1501
       eeprom_error = true;
1502
     }
1502
     }
1503
     else {
1503
     else {
2325
       if (eeprom_error) {
2325
       if (eeprom_error) {
2326
         DEBUG_ECHO_START();
2326
         DEBUG_ECHO_START();
2327
         DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
2327
         DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
2328
-        TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_index());
2328
+        IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index());
2329
       }
2329
       }
2330
       else if (working_crc != stored_crc) {
2330
       else if (working_crc != stored_crc) {
2331
         eeprom_error = true;
2331
         eeprom_error = true;
2332
         DEBUG_ERROR_START();
2332
         DEBUG_ERROR_START();
2333
         DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
2333
         DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
2334
-        TERN(EEPROM_AUTO_INIT,,ui.eeprom_alert_crc());
2334
+        IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc());
2335
       }
2335
       }
2336
       else if (!validating) {
2336
       else if (!validating) {
2337
         DEBUG_ECHO_START();
2337
         DEBUG_ECHO_START();

+ 1
- 1
Marlin/src/module/stepper.cpp Ver arquivo

180
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
180
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
181
 uint8_t Stepper::steps_per_isr;
181
 uint8_t Stepper::steps_per_isr;
182
 
182
 
183
-TERN(ADAPTIVE_STEP_SMOOTHING,,constexpr) uint8_t Stepper::oversampling_factor;
183
+IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor;
184
 
184
 
185
 xyze_long_t Stepper::delta_error{0};
185
 xyze_long_t Stepper::delta_error{0};
186
 
186
 

+ 1
- 1
Marlin/src/module/temperature.cpp Ver arquivo

268
     int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
268
     int16_t Temperature::maxtemp_raw_BED = HEATER_BED_RAW_HI_TEMP;
269
   #endif
269
   #endif
270
   TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
270
   TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
271
-  TERN(PIDTEMPBED,, millis_t Temperature::next_bed_check_ms);
271
+  IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
272
 #endif // HAS_HEATED_BED
272
 #endif // HAS_HEATED_BED
273
 
273
 
274
 #if HAS_TEMP_CHAMBER
274
 #if HAS_TEMP_CHAMBER

+ 1
- 1
Marlin/src/module/temperature.h Ver arquivo

392
 
392
 
393
     #if HAS_HEATED_BED
393
     #if HAS_HEATED_BED
394
       TERN_(WATCH_BED, static bed_watch_t watch_bed);
394
       TERN_(WATCH_BED, static bed_watch_t watch_bed);
395
-      TERN(PIDTEMPBED,,static millis_t next_bed_check_ms);
395
+      IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms);
396
       #ifdef BED_MINTEMP
396
       #ifdef BED_MINTEMP
397
         static int16_t mintemp_raw_BED;
397
         static int16_t mintemp_raw_BED;
398
       #endif
398
       #endif

+ 4
- 4
Marlin/src/module/tool_change.cpp Ver arquivo

799
     // Park
799
     // Park
800
     #if ENABLED(TOOLCHANGE_PARK)
800
     #if ENABLED(TOOLCHANGE_PARK)
801
       if (ok) {
801
       if (ok) {
802
-        TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x);
803
-        TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y);
802
+        IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x);
803
+        IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y);
804
         planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), active_extruder);
804
         planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), active_extruder);
805
         planner.synchronize();
805
         planner.synchronize();
806
       }
806
       }
998
       // Toolchange park
998
       // Toolchange park
999
       #if ENABLED(TOOLCHANGE_PARK) && DISABLED(SWITCHING_NOZZLE)
999
       #if ENABLED(TOOLCHANGE_PARK) && DISABLED(SWITCHING_NOZZLE)
1000
         if (can_move_away && toolchange_settings.enable_park) {
1000
         if (can_move_away && toolchange_settings.enable_park) {
1001
-          TERN(TOOLCHANGE_PARK_Y_ONLY,,current_position.x = toolchange_settings.change_point.x);
1002
-          TERN(TOOLCHANGE_PARK_X_ONLY,,current_position.y = toolchange_settings.change_point.y);
1001
+          IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x);
1002
+          IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y);
1003
           planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), old_tool);
1003
           planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), old_tool);
1004
           planner.synchronize();
1004
           planner.synchronize();
1005
         }
1005
         }

Carregando…
Cancelar
Salvar