🎨 Apply TERN0/1 for some contexts (#27036)

This commit is contained in:
ellensp
2024-05-16 08:42:19 +12:00
committed by GitHub
parent 5f96dffb9b
commit 3dc437add4
10 changed files with 12 additions and 12 deletions

View File

@@ -610,9 +610,9 @@ struct XYZval {
// If any element is true then it's true // If any element is true then it's true
FI constexpr operator bool() const { return 0 NUM_AXIS_GANG(|| x, || y, || z, || i, || j, || k, || u, || v, || w); } FI constexpr operator bool() const { return 0 NUM_AXIS_GANG(|| x, || y, || z, || i, || j, || k, || u, || v, || w); }
// Smallest element // Smallest element
FI constexpr T small() const { return TERN(HAS_X_AXIS, _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)), 0); } FI constexpr T small() const { return TERN0(HAS_X_AXIS, _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w))); }
// Largest element // Largest element
FI constexpr T large() const { return TERN(HAS_X_AXIS, _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)), 0); } FI constexpr T large() const { return TERN0(HAS_X_AXIS, _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w))); }
// Explicit copy and copies with conversion // Explicit copy and copies with conversion
FI constexpr XYZval<T> copy() const { XYZval<T> o = *this; return o; } FI constexpr XYZval<T> copy() const { XYZval<T> o = *this; return o; }

View File

@@ -49,7 +49,7 @@
*/ */
void GcodeSuite::M306() { void GcodeSuite::M306() {
const uint8_t e = TERN(HAS_MULTI_EXTRUDER, parser.intval('E', active_extruder), 0); const uint8_t e = TERN0(HAS_MULTI_EXTRUDER, parser.intval('E', active_extruder));
if (e >= (EXTRUDERS)) { if (e >= (EXTRUDERS)) {
SERIAL_ECHOLNPGM("?(E)xtruder index out of range (0-", (EXTRUDERS) - 1, ")."); SERIAL_ECHOLNPGM("?(E)xtruder index out of range (0-", (EXTRUDERS) - 1, ").");
return; return;

View File

@@ -43,7 +43,7 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
} }
bool ZOffsetScreen::onTouchHeld(uint8_t tag) { bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
const int16_t steps = TERN(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z), 0); const int16_t steps = TERN0(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z));
const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement()); const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement());
switch (tag) { switch (tag) {
case 2: ZOffsetWizard::runWizard(); break; case 2: ZOffsetWizard::runWizard(); break;

View File

@@ -95,7 +95,7 @@ bool ZOffsetScreen::wizardRunning() {
} }
bool ZOffsetScreen::onTouchHeld(uint8_t tag) { bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
const int16_t steps = TERN(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z), 0); const int16_t steps = TERN0(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z));
const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement()); const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement());
switch (tag) { switch (tag) {
case 2: runWizard(); break; case 2: runWizard(); break;

View File

@@ -274,7 +274,7 @@ static void _lcd_goto_next_corner() {
} }
void _lcd_test_corners() { void _lcd_test_corners() {
bed_corner = TERN(BED_TRAMMING_INCLUDE_CENTER, center_index, 0); bed_corner = TERN0(BED_TRAMMING_INCLUDE_CENTER, center_index);
last_z = BED_TRAMMING_HEIGHT; last_z = BED_TRAMMING_HEIGHT;
endstops.enable_z_probe(true); endstops.enable_z_probe(true);
good_points = 0; good_points = 0;

View File

@@ -446,7 +446,7 @@ void ubl_map_screen() {
do { do {
// Now, keep the encoder position within range // Now, keep the encoder position within range
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = GRID_MAX_POINTS + TERN(TOUCH_SCREEN, ui.encoderPosition, -1); if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = GRID_MAX_POINTS + TERN(TOUCH_SCREEN, ui.encoderPosition, -1);
if (int32_t(ui.encoderPosition) > GRID_MAX_POINTS - 1) ui.encoderPosition = TERN(TOUCH_SCREEN, ui.encoderPosition - GRID_MAX_POINTS, 0); if (int32_t(ui.encoderPosition) > GRID_MAX_POINTS - 1) ui.encoderPosition = TERN0(TOUCH_SCREEN, ui.encoderPosition - GRID_MAX_POINTS);
// Draw the grid point based on the encoder // Draw the grid point based on the encoder
x = ui.encoderPosition % (GRID_MAX_POINTS_X); x = ui.encoderPosition % (GRID_MAX_POINTS_X);

View File

@@ -2186,7 +2186,7 @@ void prepare_line_to_destination() {
// Move away from the endstop by the axis HOMING_BUMP_MM // Move away from the endstop by the axis HOMING_BUMP_MM
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away: ", -bump, "mm"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away: ", -bump, "mm");
do_homing_move(axis, -bump, TERN(HOMING_Z_WITH_PROBE, (axis == Z_AXIS ? z_probe_fast_mm_s : 0), 0), false); do_homing_move(axis, -bump, TERN0(HOMING_Z_WITH_PROBE, (axis == Z_AXIS ? z_probe_fast_mm_s : 0)), false);
#if ENABLED(DETECT_BROKEN_ENDSTOP) #if ENABLED(DETECT_BROKEN_ENDSTOP)

View File

@@ -1429,7 +1429,7 @@ void Planner::check_axes_activity() {
*/ */
void Planner::autotemp_update() { void Planner::autotemp_update() {
_autotemp_update_from_hotend(); _autotemp_update_from_hotend();
autotemp.factor = TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); autotemp.factor = TERN0(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P);
autotemp.enabled = autotemp.factor != 0; autotemp.enabled = autotemp.factor != 0;
} }
@@ -1445,7 +1445,7 @@ void Planner::check_axes_activity() {
// When AUTOTEMP_PROPORTIONAL is enabled, F0 disables autotemp. // When AUTOTEMP_PROPORTIONAL is enabled, F0 disables autotemp.
// Normally, leaving off F also disables autotemp. // Normally, leaving off F also disables autotemp.
autotemp.factor = parser.seen('F') ? parser.value_float() : TERN(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P, 0); autotemp.factor = parser.seen('F') ? parser.value_float() : TERN0(AUTOTEMP_PROPORTIONAL, AUTOTEMP_FACTOR_P);
autotemp.enabled = autotemp.factor != 0; autotemp.enabled = autotemp.factor != 0;
} }

View File

@@ -2681,7 +2681,7 @@ hal_timer_t Stepper::block_phase_isr() {
#if ENABLED(ADAPTIVE_STEP_SMOOTHING) #if ENABLED(ADAPTIVE_STEP_SMOOTHING)
// Nonlinear Extrusion needs at least 2x oversampling to permit increase of E step rate // Nonlinear Extrusion needs at least 2x oversampling to permit increase of E step rate
// Otherwise assume no axis smoothing (via oversampling) // Otherwise assume no axis smoothing (via oversampling)
oversampling_factor = TERN(NONLINEAR_EXTRUSION, 1, 0); oversampling_factor = TERN0(NONLINEAR_EXTRUSION, 1);
// Decide if axis smoothing is possible // Decide if axis smoothing is possible
if (stepper.adaptive_step_smoothing_enabled) { if (stepper.adaptive_step_smoothing_enabled) {

View File

@@ -43,7 +43,7 @@
//#define ERR_INCLUDE_TEMP //#define ERR_INCLUDE_TEMP
#define HOTEND_INDEX TERN(HAS_MULTI_HOTEND, e, 0) #define HOTEND_INDEX TERN0(HAS_MULTI_HOTEND, e)
#define E_NAME TERN_(HAS_MULTI_HOTEND, e) #define E_NAME TERN_(HAS_MULTI_HOTEND, e)
#if HAS_FAN #if HAS_FAN