Skip to content

Commit

Permalink
🎨 Adjust some conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 15, 2021
1 parent 9679424 commit c9a3ba9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/bedlevel/bedlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "../../inc/MarlinConfigPre.h"

#if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
#define G28_L0_ENSURES_LEVELING_OFF 1
#define CAN_SET_LEVELING_AFTER_G28 1
#endif

#if ENABLED(PROBE_MANUALLY)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ typedef struct {
uint8_t fan_speed[FAN_COUNT];
#endif

#if ENABLED(HAS_LEVELING)
#if HAS_LEVELING
float fade;
#endif

Expand Down Expand Up @@ -120,7 +120,7 @@ typedef struct {
bool raised:1; // Raised before saved
bool dryrun:1; // M111 S8
bool allow_cold_extrusion:1; // M302 P1
#if ENABLED(HAS_LEVELING)
#if HAS_LEVELING
bool leveling:1; // M420 S
#endif
#if DISABLED(NO_VOLUMETRICS)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ G29_TYPE GcodeSuite::G29() {

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

// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void GcodeSuite::G29() {
mbl.reset();
mbl_probe_index = 0;
if (!ui.wait_for_move) {
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
return;
}
state = MeshNext;
Expand Down
23 changes: 13 additions & 10 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,16 @@ void GcodeSuite::G28() {
SET_SOFT_ENDSTOP_LOOSE(false); // Reset a leftover 'loose' motion state

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

// Cancel any prior G29 session
TERN_(PROBE_MANUALLY, g29_in_progress = false);

// Disable leveling before homing
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));

// Reset to the XY plane
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);

Expand Down Expand Up @@ -353,13 +357,14 @@ void GcodeSuite::G28() {

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

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

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

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

#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
// move to a height where we can use the full xy-area
do_blocking_move_to_z(delta_clip_start_height);
#endif
// Move to a height where we can use the full xy-area
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));

TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));
TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());

restore_feedrate_and_scaling();

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class GcodeSuite {
static void process_subcommands_now(char * gcode);

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

#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,10 @@
#endif
#endif

#if DISABLED(DELTA)
#undef DELTA_HOME_TO_SAFE_ZONE
#endif

// This flag indicates some kind of jerk storage is needed
#if EITHER(CLASSIC_JERK, IS_KINEMATIC)
#define HAS_CLASSIC_JERK 1
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_probe_offset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// Global storage
float z_offset_backup, calculated_z_offset, z_offset_ref;

#if ENABLED(HAS_LEVELING)
#if HAS_LEVELING
bool leveling_was_active;
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_tramming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void goto_tramming_wizard() {

// Inject G28, wait for homing to complete,
set_all_unhomed();
queue.inject_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
queue.inject_P(TERN(CAN_SET_LEVELING_AFTER_G28, PSTR("G28L0"), G28_STR));

ui.goto_screen([]{
_lcd_draw_homing();
Expand Down

0 comments on commit c9a3ba9

Please sign in to comment.