Make leveling_is_active a macro

This commit is contained in:
Scott Lahteine
2017-10-13 10:25:05 -05:00
parent 58abc66c1d
commit 9a930ebec2
15 changed files with 47 additions and 54 deletions

View File

@ -55,18 +55,6 @@ bool leveling_is_valid() {
;
}
bool leveling_is_active() {
return
#if ENABLED(MESH_BED_LEVELING)
mbl.active()
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.state.active
#else // OLDSCHOOL_ABL
planner.abl_enabled
#endif
;
}
/**
* Turn bed leveling on or off, fixing the current
* position as-needed.
@ -82,7 +70,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
constexpr bool can_change = true;
#endif
if (can_change && enable != leveling_is_active()) {
if (can_change && enable != LEVELING_IS_ACTIVE()) {
#if ENABLED(MESH_BED_LEVELING)
@ -143,7 +131,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
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)

View File

@ -40,10 +40,19 @@
#endif
bool leveling_is_valid();
bool leveling_is_active();
void set_bed_leveling_enabled(const bool enable=true);
void reset_bed_level();
#if ENABLED(MESH_BED_LEVELING)
#define LEVELING_IS_ACTIVE() (mbl.active())
#elif ENABLED(AUTO_BED_LEVELING_UBL)
#define LEVELING_IS_ACTIVE() (ubl.state.active)
#elif HAS_ABL
#define LEVELING_IS_ACTIVE() (planner.abl_enabled)
#else
#define LEVELING_IS_ACTIVE() (false)
#endif
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
void set_z_fade_height(const float zfh);
#endif