Skip to content

Commit

Permalink
馃帹 Apply TERN0/1 for some contexts (#27036)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellensp committed May 15, 2024
1 parent 5f96dff commit 3dc437a
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ struct XYZval {
// 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); }
// 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
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
FI constexpr XYZval<T> copy() const { XYZval<T> o = *this; return o; }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/temp/M306.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/

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)) {
SERIAL_ECHOLNPGM("?(E)xtruder index out of range (0-", (EXTRUDERS) - 1, ").");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
}

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());
switch (tag) {
case 2: ZOffsetWizard::runWizard(); break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool ZOffsetScreen::wizardRunning() {
}

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());
switch (tag) {
case 2: runWizard(); break;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_bed_tramming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static void _lcd_goto_next_corner() {
}

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;
endstops.enable_z_probe(true);
good_points = 0;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void ubl_map_screen() {
do {
// 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) > 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
x = ui.encoderPosition % (GRID_MAX_POINTS_X);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ void prepare_line_to_destination() {

// Move away from the endstop by the axis HOMING_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)

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ void Planner::check_axes_activity() {
*/
void Planner::autotemp_update() {
_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;
}

Expand All @@ -1445,7 +1445,7 @@ void Planner::check_axes_activity() {

// When AUTOTEMP_PROPORTIONAL is enabled, F0 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;
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ hal_timer_t Stepper::block_phase_isr() {
#if ENABLED(ADAPTIVE_STEP_SMOOTHING)
// Nonlinear Extrusion needs at least 2x oversampling to permit increase of E step rate
// 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
if (stepper.adaptive_step_smoothing_enabled) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

//#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)

#if HAS_FAN
Expand Down

0 comments on commit 3dc437a

Please sign in to comment.