Skip to content

Commit c9a3ba9

Browse files
committed
🎨 Adjust some conditionals
1 parent 9679424 commit c9a3ba9

File tree

9 files changed

+25
-18
lines changed

9 files changed

+25
-18
lines changed

Marlin/src/feature/bedlevel/bedlevel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "../../inc/MarlinConfigPre.h"
2525

2626
#if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
27-
#define G28_L0_ENSURES_LEVELING_OFF 1
27+
#define CAN_SET_LEVELING_AFTER_G28 1
2828
#endif
2929

3030
#if ENABLED(PROBE_MANUALLY)

Marlin/src/feature/powerloss.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ typedef struct {
8888
uint8_t fan_speed[FAN_COUNT];
8989
#endif
9090

91-
#if ENABLED(HAS_LEVELING)
91+
#if HAS_LEVELING
9292
float fade;
9393
#endif
9494

@@ -120,7 +120,7 @@ typedef struct {
120120
bool raised:1; // Raised before saved
121121
bool dryrun:1; // M111 S8
122122
bool allow_cold_extrusion:1; // M302 P1
123-
#if ENABLED(HAS_LEVELING)
123+
#if HAS_LEVELING
124124
bool leveling:1; // M420 S
125125
#endif
126126
#if DISABLED(NO_VOLUMETRICS)

Marlin/src/gcode/bedlevel/abl/G29.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ G29_TYPE GcodeSuite::G29() {
246246

247247
// Send 'N' to force homing before G29 (internal only)
248248
if (parser.seen_test('N'))
249-
process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
249+
process_subcommands_now_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
250250

251251
// Don't allow auto-leveling without homing first
252252
if (homing_needed_error()) G29_RETURN(false);

Marlin/src/gcode/bedlevel/mbl/G29.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void GcodeSuite::G29() {
8787
mbl.reset();
8888
mbl_probe_index = 0;
8989
if (!ui.wait_for_move) {
90-
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
90+
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
9191
return;
9292
}
9393
state = MeshNext;

Marlin/src/gcode/calibrate/G28.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,16 @@ void GcodeSuite::G28() {
242242
SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state
243243

244244
// Disable the leveling matrix before homing
245-
#if HAS_LEVELING
246-
const bool leveling_restore_state = parser.boolval('L', TERN(RESTORE_LEVELING_AFTER_G28, planner.leveling_active, ENABLED(ENABLE_LEVELING_AFTER_G28)));
247-
IF_ENABLED(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session
248-
set_bed_leveling_enabled(false);
245+
#if CAN_SET_LEVELING_AFTER_G28
246+
const bool leveling_restore_state = parser.boolval('L', TERN1(RESTORE_LEVELING_AFTER_G28, planner.leveling_active));
249247
#endif
250248

249+
// Cancel any prior G29 session
250+
TERN_(PROBE_MANUALLY, g29_in_progress = false);
251+
252+
// Disable leveling before homing
253+
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
254+
251255
// Reset to the XY plane
252256
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
253257

@@ -353,13 +357,14 @@ void GcodeSuite::G28() {
353357

354358
const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT;
355359

356-
if (z_homing_height && (0 LINEAR_AXIS_GANG(|| doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
360+
if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) {
357361
// Raise Z before homing any other axes and z is not already high enough (never lower z)
358362
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
359363
do_z_clearance(z_homing_height);
360364
TERN_(BLTOUCH, bltouch.init());
361365
}
362366

367+
// Diagonal move first if both are homing
363368
TERN_(QUICK_HOME, if (doX && doY) quick_home_xy());
364369

365370
// Home Y (before X)
@@ -464,12 +469,10 @@ void GcodeSuite::G28() {
464469
// Clear endstop state for polled stallGuard endstops
465470
TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
466471

467-
#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
468-
// move to a height where we can use the full xy-area
469-
do_blocking_move_to_z(delta_clip_start_height);
470-
#endif
472+
// Move to a height where we can use the full xy-area
473+
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
471474

472-
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));
475+
TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());
473476

474477
restore_feedrate_and_scaling();
475478

Marlin/src/gcode/gcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class GcodeSuite {
392392
static void process_subcommands_now(char * gcode);
393393

394394
static inline void home_all_axes(const bool keep_leveling=false) {
395-
process_subcommands_now_P(keep_leveling ? G28_STR : TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
395+
process_subcommands_now_P(keep_leveling ? G28_STR : TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
396396
}
397397

398398
#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)

Marlin/src/inc/Conditionals_LCD.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,10 @@
10271027
#endif
10281028
#endif
10291029

1030+
#if DISABLED(DELTA)
1031+
#undef DELTA_HOME_TO_SAFE_ZONE
1032+
#endif
1033+
10301034
// This flag indicates some kind of jerk storage is needed
10311035
#if EITHER(CLASSIC_JERK, IS_KINEMATIC)
10321036
#define HAS_CLASSIC_JERK 1

Marlin/src/lcd/menu/menu_probe_offset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// Global storage
4343
float z_offset_backup, calculated_z_offset, z_offset_ref;
4444

45-
#if ENABLED(HAS_LEVELING)
45+
#if HAS_LEVELING
4646
bool leveling_was_active;
4747
#endif
4848

Marlin/src/lcd/menu/menu_tramming.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void goto_tramming_wizard() {
9292

9393
// Inject G28, wait for homing to complete,
9494
set_all_unhomed();
95-
queue.inject_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
95+
queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));
9696

9797
ui.goto_screen([]{
9898
_lcd_draw_homing();

0 commit comments

Comments
 (0)