Skip to content

Commit

Permalink
Bed subdivision can be managed internally by bbl
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrazier committed Mar 7, 2022
1 parent 8660571 commit 7216e63
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Marlin/src/feature/bedlevel/abl/bbl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void bilinear_bed_leveling::print_leveling_grid() {
print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3,
[](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
);

TERN_(ABL_BILINEAR_SUBDIVISION, print_leveling_grid_virt());
}

#if ENABLED(ABL_BILINEAR_SUBDIVISION)
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/feature/bedlevel/abl/bbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class bilinear_bed_leveling {
static xy_pos_t grid_spacing_virt;
static xy_float_t grid_factor_virt;

static void print_leveling_grid_virt();

static float bed_level_virt_coord(const uint8_t x, const uint8_t y);
static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t);
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty);
#endif
static void bed_level_virt_interpolate();
#endif

public:
static void reset();
Expand All @@ -50,10 +53,6 @@ class bilinear_bed_leveling {
static void print_leveling_grid();
static void refresh_bed_level();
static bool has_mesh() {return !!grid_spacing.x;}
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
static void print_leveling_grid_virt();
static void bed_level_virt_interpolate();
#endif
static bed_mesh_t& get_z_values() {return z_values;}
static const xy_pos_t& get_grid_spacing() {return grid_spacing;}
static const xy_pos_t& get_grid_start() {return grid_start;}
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/gcode/bedlevel/M420.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void GcodeSuite::M420() {
Z_VALUES(x, y) -= zmean;
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
}
TERN_(ABL_BILINEAR_SUBDIVISION, bbl.bed_level_virt_interpolate());
TERN_(ABL_BILINEAR_SUBDIVISION, bbl.refresh_bed_level());
}

#endif
Expand All @@ -202,7 +202,6 @@ void GcodeSuite::M420() {
if (leveling_is_valid()) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
bbl.print_leveling_grid();
TERN_(ABL_BILINEAR_SUBDIVISION, bbl.print_leveling_grid_virt());
#elif ENABLED(MESH_BED_LEVELING)
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
mbl.report_mesh();
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ G29_TYPE GcodeSuite::G29() {
if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) {
set_bed_leveling_enabled(false);
Z_VALUES_ARR[i][j] = rz;
TERN_(ABL_BILINEAR_SUBDIVISION, bbl.bed_level_virt_interpolate());
bbl.refresh_bed_level();
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz));
set_bed_leveling_enabled(abl.reenable);
if (abl.reenable) report_current_position();
Expand Down Expand Up @@ -752,11 +752,10 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)

if (!abl.dryrun) bbl.extrapolate_unprobed_bed_level();
bbl.print_leveling_grid();

bbl.refresh_bed_level();

TERN_(ABL_BILINEAR_SUBDIVISION, bbl.print_leveling_grid_virt());
bbl.print_leveling_grid();

#elif ENABLED(AUTO_BED_LEVELING_LINEAR)

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/abl/M421.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void GcodeSuite::M421() {
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES_ARR[x][y]));
}
}
TERN_(ABL_BILINEAR_SUBDIVISION, bbl.bed_level_virt_interpolate());
bbl.refresh_bed_level();
}
else
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
Expand Down

0 comments on commit 7216e63

Please sign in to comment.