Skip to content

Commit

Permalink
Adjust leveling conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed May 1, 2017
1 parent a64e565 commit ed81e9b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
7 changes: 3 additions & 4 deletions Marlin/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,14 @@
#endif

/**
* Set ABL options based on the specific type of leveling
* Set granular options based on the specific type of leveling
*/
#define ABL_PLANAR (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_3POINT))
#define ABL_GRID (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
#define HAS_ABL (ABL_PLANAR || ABL_GRID || ENABLED(AUTO_BED_LEVELING_UBL))

#define PLANNER_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING))
#define HAS_LEVELING (HAS_ABL || ENABLED(MESH_BED_LEVELING))
#define PLANNER_LEVELING (ABL_PLANAR || ABL_GRID || ENABLED(MESH_BED_LEVELING))
#define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))

#if HAS_PROBING_PROCEDURE
#define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))
#define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION))
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ float code_value_temp_diff();
linear_fit* lsf_linear_fit(double x[], double y[], double z[], const int);
#endif

#if PLANNER_LEVELING
#if HAS_LEVELING
void reset_bed_level();
#endif

Expand Down
24 changes: 12 additions & 12 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ static void clean_up_after_endstop_or_probe_move() {

#endif // HAS_BED_PROBE

#if PLANNER_LEVELING
#if HAS_LEVELING
/**
* Turn bed leveling on or off, fixing the current
* position as-needed.
Expand Down Expand Up @@ -2511,7 +2511,7 @@ static void clean_up_after_endstop_or_probe_move() {
#endif
}

#endif // PLANNER_LEVELING
#endif // HAS_LEVELING

#if ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)

Expand Down Expand Up @@ -3747,7 +3747,7 @@ inline void gcode_G28() {
#endif

// Disable the leveling matrix before homing
#if PLANNER_LEVELING
#if HAS_LEVELING
#if ENABLED(AUTO_BED_LEVELING_UBL)
const bool bed_leveling_state_at_entry = ubl.state.active;
#endif
Expand Down Expand Up @@ -4368,7 +4368,7 @@ void home_all_axes() { gcode_G28(); }

#endif

#if PLANNER_LEVELING
#if HAS_LEVELING

// Jettison bed leveling data
if (code_seen('J')) {
Expand Down Expand Up @@ -5034,7 +5034,7 @@ void home_all_axes() { gcode_G28(); }
if (!position_is_reachable(pos, true)) return;

// Disable leveling so the planner won't mess with us
#if PLANNER_LEVELING
#if HAS_LEVELING
set_bed_leveling_enabled(false);
#endif

Expand Down Expand Up @@ -5091,7 +5091,7 @@ void home_all_axes() { gcode_G28(); }

stepper.synchronize();

#if PLANNER_LEVELING
#if HAS_LEVELING
set_bed_leveling_enabled(false);
#endif

Expand Down Expand Up @@ -7294,7 +7294,7 @@ inline void gcode_M115() {
#endif

// MESH_REPORT (M420 V)
#if PLANNER_LEVELING
#if HAS_LEVELING
SERIAL_PROTOCOLLNPGM("Cap:LEVELING_DATA:1");
#else
SERIAL_PROTOCOLLNPGM("Cap:LEVELING_DATA:0");
Expand Down Expand Up @@ -8336,7 +8336,7 @@ void quickstop_stepper() {
SYNC_PLAN_POSITION_KINEMATIC();
}

#if PLANNER_LEVELING
#if HAS_LEVELING
/**
* M420: Enable/Disable Bed Leveling and/or set the Z fade height.
*
Expand Down Expand Up @@ -9857,12 +9857,12 @@ void process_next_command() {
gcode_G28();
break;

#if PLANNER_LEVELING || ENABLED(AUTO_BED_LEVELING_UBL)
#if HAS_LEVELING
case 29: // G29 Detailed Z probe, probes the bed at 3 or more points,
// or provides access to the UBL System if enabled.
gcode_G29();
break;
#endif // PLANNER_LEVELING
#endif // HAS_LEVELING

#if HAS_BED_PROBE

Expand Down Expand Up @@ -10363,7 +10363,7 @@ void process_next_command() {
break;
#endif // FILAMENT_WIDTH_SENSOR

#if PLANNER_LEVELING
#if HAS_LEVELING
case 420: // M420: Enable/Disable Bed Leveling
gcode_M420();
break;
Expand Down Expand Up @@ -10917,7 +10917,7 @@ void get_cartesian_from_steppers() {
*/
void set_current_from_steppers_for_axis(const AxisEnum axis) {
get_cartesian_from_steppers();
#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL)
#if PLANNER_LEVELING
planner.unapply_leveling(cartes);
#endif
if (axis == ALL_AXES)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ void MarlinSettings::reset() {
#endif

// Applies to all MBL and ABL
#if PLANNER_LEVELING
#if HAS_LEVELING
reset_bed_level();
#endif

Expand Down
6 changes: 3 additions & 3 deletions Marlin/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void Planner::check_axes_activity() {
#endif
}

#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL)
#if PLANNER_LEVELING
/**
* lx, ly, lz - logical (cartesian, not delta) positions in mm
*/
Expand Down Expand Up @@ -634,7 +634,7 @@ void Planner::check_axes_activity() {
#endif
}

#endif // PLANNER_LEVELING && !AUTO_BED_LEVELING_UBL
#endif // PLANNER_LEVELING

/**
* Planner::_buffer_line
Expand Down Expand Up @@ -1434,7 +1434,7 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
}

void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {
#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL)
#if PLANNER_LEVELING
float lpos[XYZ] = { position[X_AXIS], position[Y_AXIS], position[Z_AXIS] };
apply_leveling(lpos);
#else
Expand Down
8 changes: 4 additions & 4 deletions Marlin/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class Planner {

static bool is_full() { return (block_buffer_tail == BLOCK_MOD(block_buffer_head + 1)); }

#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL)
#if PLANNER_LEVELING

#define ARG_X float lx
#define ARG_Y float ly
Expand Down Expand Up @@ -296,7 +296,7 @@ class Planner {
* extruder - target extruder
*/
static FORCE_INLINE void buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, const float &fr_mm_s, const uint8_t extruder) {
#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) && IS_CARTESIAN
#if PLANNER_LEVELING && IS_CARTESIAN
apply_leveling(lx, ly, lz);
#endif
_buffer_line(lx, ly, lz, e, fr_mm_s, extruder);
Expand All @@ -312,7 +312,7 @@ class Planner {
* extruder - target extruder
*/
static FORCE_INLINE void buffer_line_kinematic(const float ltarget[XYZE], const float &fr_mm_s, const uint8_t extruder) {
#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL)
#if PLANNER_LEVELING
float lpos[XYZ] = { ltarget[X_AXIS], ltarget[Y_AXIS], ltarget[Z_AXIS] };
apply_leveling(lpos);
#else
Expand All @@ -336,7 +336,7 @@ class Planner {
* Clears previous speed values.
*/
static FORCE_INLINE void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
#if PLANNER_LEVELING && DISABLED(AUTO_BED_LEVELING_UBL) && IS_CARTESIAN
#if PLANNER_LEVELING && IS_CARTESIAN
apply_leveling(lx, ly, lz);
#endif
_set_position_mm(lx, ly, lz, e);
Expand Down

0 comments on commit ed81e9b

Please sign in to comment.