Add custom types for position (#15204)

This commit is contained in:
Scott Lahteine
2019-09-29 04:25:39 -05:00
committed by GitHub
parent 43d6e9fa43
commit 50e4545255
227 changed files with 3147 additions and 3264 deletions
+16 -16
View File
@@ -51,7 +51,7 @@ bool leveling_is_valid() {
#if ENABLED(MESH_BED_LEVELING)
mbl.has_mesh()
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
!!bilinear_grid_spacing[X_AXIS]
!!bilinear_grid_spacing.x
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.mesh_is_valid()
#else // 3POINT, LINEAR
@@ -81,13 +81,13 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// Force bilinear_z_offset to re-calculate next time
const float reset[XYZ] = { -9999.999, -9999.999, 0 };
const xyz_pos_t reset { -9999.999, -9999.999, 0 };
(void)bilinear_z_offset(reset);
#endif
if (planner.leveling_active) { // leveling from on to off
// change unleveled current_position to physical current_position without moving steppers.
planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
planner.apply_leveling(current_position);
planner.leveling_active = false; // disable only AFTER calling apply_leveling
}
else { // leveling from off to on
@@ -116,9 +116,9 @@ TemporaryBedLevelingState::TemporaryBedLevelingState(const bool enable) : saved(
planner.set_z_fade_height(zfh);
if (leveling_was_active) {
const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
const xyz_pos_t oldpos = current_position;
set_bed_leveling_enabled(true);
if (do_report && memcmp(oldpos, current_position, sizeof(oldpos)))
if (do_report && oldpos != current_position)
report_current_position();
}
}
@@ -137,8 +137,8 @@ void reset_bed_level() {
#if ENABLED(MESH_BED_LEVELING)
mbl.reset();
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
bilinear_start.reset();
bilinear_grid_spacing.reset();
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
z_values[x][y] = NAN;
@@ -223,25 +223,25 @@ void reset_bed_level() {
#if EITHER(MESH_BED_LEVELING, PROBE_MANUALLY)
void _manual_goto_xy(const float &rx, const float &ry) {
void _manual_goto_xy(const xy_pos_t &pos) {
#ifdef MANUAL_PROBE_START_Z
constexpr float startz = _MAX(0, MANUAL_PROBE_START_Z);
#if MANUAL_PROBE_HEIGHT > 0
do_blocking_move_to(rx, ry, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(_MAX(0,MANUAL_PROBE_START_Z));
do_blocking_move_to(pos, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(startz);
#else
do_blocking_move_to(rx, ry, _MAX(0,MANUAL_PROBE_START_Z));
do_blocking_move_to(pos, startz);
#endif
#elif MANUAL_PROBE_HEIGHT > 0
const float prev_z = current_position[Z_AXIS];
do_blocking_move_to(rx, ry, MANUAL_PROBE_HEIGHT);
const float prev_z = current_position.z;
do_blocking_move_to(pos, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(prev_z);
#else
do_blocking_move_to_xy(rx, ry);
do_blocking_move_to_xy(pos);
#endif
current_position[X_AXIS] = rx;
current_position[Y_AXIS] = ry;
current_position = pos;
#if ENABLED(LCD_BED_LEVELING)
ui.wait_for_bl_move = false;