Move leveling_is_active to a macro
This commit is contained in:
parent
fcd3b326e9
commit
da93a272a0
@ -323,7 +323,6 @@ extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
|
|||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
bool leveling_is_valid();
|
bool leveling_is_valid();
|
||||||
bool leveling_is_active();
|
|
||||||
void set_bed_leveling_enabled(const bool enable=true);
|
void set_bed_leveling_enabled(const bool enable=true);
|
||||||
void reset_bed_level();
|
void reset_bed_level();
|
||||||
#endif
|
#endif
|
||||||
|
@ -2471,18 +2471,6 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool leveling_is_active() {
|
|
||||||
return
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
|
||||||
mbl.active()
|
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
|
||||||
ubl.state.active
|
|
||||||
#else
|
|
||||||
planner.abl_enabled
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn bed leveling on or off, fixing the current
|
* Turn bed leveling on or off, fixing the current
|
||||||
* position as-needed.
|
* position as-needed.
|
||||||
@ -2498,7 +2486,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
constexpr bool can_change = true;
|
constexpr bool can_change = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (can_change && enable != leveling_is_active()) {
|
if (can_change && enable != LEVELING_IS_ACTIVE()) {
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
|
||||||
@ -2559,7 +2547,7 @@ static void clean_up_after_endstop_or_probe_move() {
|
|||||||
|
|
||||||
void set_z_fade_height(const float zfh) {
|
void set_z_fade_height(const float zfh) {
|
||||||
|
|
||||||
const bool level_active = leveling_is_active();
|
const bool level_active = LEVELING_IS_ACTIVE();
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
|
|
||||||
@ -3771,7 +3759,7 @@ inline void gcode_G4() {
|
|||||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
SERIAL_ECHOPGM("UBL");
|
SERIAL_ECHOPGM("UBL");
|
||||||
#endif
|
#endif
|
||||||
if (leveling_is_active()) {
|
if (LEVELING_IS_ACTIVE()) {
|
||||||
SERIAL_ECHOLNPGM(" (enabled)");
|
SERIAL_ECHOLNPGM(" (enabled)");
|
||||||
#if ABL_PLANAR
|
#if ABL_PLANAR
|
||||||
const float diff[XYZ] = {
|
const float diff[XYZ] = {
|
||||||
@ -3802,7 +3790,7 @@ inline void gcode_G4() {
|
|||||||
#elif ENABLED(MESH_BED_LEVELING)
|
#elif ENABLED(MESH_BED_LEVELING)
|
||||||
|
|
||||||
SERIAL_ECHOPGM("Mesh Bed Leveling");
|
SERIAL_ECHOPGM("Mesh Bed Leveling");
|
||||||
if (leveling_is_active()) {
|
if (LEVELING_IS_ACTIVE()) {
|
||||||
float lz = current_position[Z_AXIS];
|
float lz = current_position[Z_AXIS];
|
||||||
planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
|
planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
|
||||||
SERIAL_ECHOLNPGM(" (enabled)");
|
SERIAL_ECHOLNPGM(" (enabled)");
|
||||||
@ -3971,7 +3959,7 @@ inline void gcode_G28(const bool always_home_all) {
|
|||||||
// Disable the leveling matrix before homing
|
// Disable the leveling matrix before homing
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
const bool ubl_state_at_entry = leveling_is_active();
|
const bool ubl_state_at_entry = LEVELING_IS_ACTIVE();
|
||||||
#endif
|
#endif
|
||||||
set_bed_leveling_enabled(false);
|
set_bed_leveling_enabled(false);
|
||||||
#endif
|
#endif
|
||||||
@ -4261,7 +4249,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case MeshReport:
|
case MeshReport:
|
||||||
if (leveling_is_valid()) {
|
if (leveling_is_valid()) {
|
||||||
SERIAL_PROTOCOLLNPAIR("State: ", leveling_is_active() ? MSG_ON : MSG_OFF);
|
SERIAL_PROTOCOLLNPAIR("State: ", LEVELING_IS_ACTIVE() ? MSG_ON : MSG_OFF);
|
||||||
mbl_mesh_report();
|
mbl_mesh_report();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4580,7 +4568,7 @@ void home_all_axes() { gcode_G28(true); }
|
|||||||
abl_probe_index = -1;
|
abl_probe_index = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
abl_should_enable = leveling_is_active();
|
abl_should_enable = LEVELING_IS_ACTIVE();
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
|
||||||
@ -7077,7 +7065,7 @@ inline void gcode_M42() {
|
|||||||
// Disable bed level correction in M48 because we want the raw data when we probe
|
// Disable bed level correction in M48 because we want the raw data when we probe
|
||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
const bool was_enabled = leveling_is_active();
|
const bool was_enabled = LEVELING_IS_ACTIVE();
|
||||||
set_bed_leveling_enabled(false);
|
set_bed_leveling_enabled(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -9413,7 +9401,7 @@ void quickstop_stepper() {
|
|||||||
if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
|
if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const bool new_status = leveling_is_active();
|
const bool new_status = LEVELING_IS_ACTIVE();
|
||||||
|
|
||||||
if (to_enable && !new_status) {
|
if (to_enable && !new_status) {
|
||||||
SERIAL_ERROR_START();
|
SERIAL_ERROR_START();
|
||||||
@ -9644,7 +9632,7 @@ inline void gcode_M502() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||||
if (!no_babystep && leveling_is_active())
|
if (!no_babystep && LEVELING_IS_ACTIVE())
|
||||||
thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
|
thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
|
||||||
#else
|
#else
|
||||||
UNUSED(no_babystep);
|
UNUSED(no_babystep);
|
||||||
@ -10691,7 +10679,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
|||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
|
||||||
if (leveling_is_active()) {
|
if (LEVELING_IS_ACTIVE()) {
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1594,7 +1594,7 @@ void MarlinSettings::reset() {
|
|||||||
SERIAL_ECHOLNPGM(":");
|
SERIAL_ECHOLNPGM(":");
|
||||||
}
|
}
|
||||||
CONFIG_ECHO_START;
|
CONFIG_ECHO_START;
|
||||||
SERIAL_ECHOPAIR(" M420 S", leveling_is_active() ? 1 : 0);
|
SERIAL_ECHOPAIR(" M420 S", LEVELING_IS_ACTIVE() ? 1 : 0);
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
|
SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
|
||||||
#endif
|
#endif
|
||||||
@ -1615,7 +1615,7 @@ void MarlinSettings::reset() {
|
|||||||
SERIAL_ECHOLNPGM("Auto Bed Leveling:");
|
SERIAL_ECHOLNPGM("Auto Bed Leveling:");
|
||||||
}
|
}
|
||||||
CONFIG_ECHO_START;
|
CONFIG_ECHO_START;
|
||||||
SERIAL_ECHOPAIR(" M420 S", leveling_is_active() ? 1 : 0);
|
SERIAL_ECHOPAIR(" M420 S", LEVELING_IS_ACTIVE() ? 1 : 0);
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
|
SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
|
||||||
#endif
|
#endif
|
||||||
|
@ -468,6 +468,16 @@ class Planner {
|
|||||||
|
|
||||||
#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
|
#define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
|
||||||
|
|
||||||
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
#define LEVELING_IS_ACTIVE() (mesh_bed_leveling::active())
|
||||||
|
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
|
#define LEVELING_IS_ACTIVE() (unified_bed_leveling::state.active)
|
||||||
|
#elif HAS_ABL
|
||||||
|
#define LEVELING_IS_ACTIVE() (Planner::abl_enabled)
|
||||||
|
#else
|
||||||
|
#define LEVELING_IS_ACTIVE() (false)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern Planner planner;
|
extern Planner planner;
|
||||||
|
|
||||||
#endif // PLANNER_H
|
#endif // PLANNER_H
|
||||||
|
@ -50,6 +50,11 @@
|
|||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
#include "ubl.h"
|
#include "ubl.h"
|
||||||
bool ubl_lcd_map_control = false;
|
bool ubl_lcd_map_control = false;
|
||||||
|
#elif HAS_ABL
|
||||||
|
#include "planner.h"
|
||||||
|
#elif ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
|
||||||
|
#include "mesh_bed_leveling.h"
|
||||||
|
extern void mesh_probing_done();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialized by settings.load()
|
// Initialized by settings.load()
|
||||||
@ -194,11 +199,6 @@ uint16_t max_display_update_time = 0;
|
|||||||
void lcd_delta_calibrate_menu();
|
void lcd_delta_calibrate_menu();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
|
|
||||||
#include "mesh_bed_leveling.h"
|
|
||||||
extern void mesh_probing_done();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
//////////// Menu System Actions ///////////
|
//////////// Menu System Actions ///////////
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
@ -1937,7 +1937,7 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
|
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
|
||||||
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
|
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
|
||||||
else if (leveling_is_valid()) {
|
else if (leveling_is_valid()) {
|
||||||
_level_state = leveling_is_active();
|
_level_state = LEVELING_IS_ACTIVE();
|
||||||
MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &_level_state, _lcd_toggle_bed_leveling);
|
MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &_level_state, _lcd_toggle_bed_leveling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,7 +792,7 @@ static void lcd_implementation_status_screen() {
|
|||||||
lcd.print(ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
|
lcd.print(ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
|
||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
lcd.write(leveling_is_active() || blink ? '_' : ' ');
|
lcd.write(LEVELING_IS_ACTIVE() || blink ? '_' : ' ');
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // LCD_HEIGHT > 2
|
#endif // LCD_HEIGHT > 2
|
||||||
|
Loading…
Reference in New Issue
Block a user