🚸 Support Bed Leveling Mesh > 16x16
Co-Authored-By: raTmole <ratmole@users.noreply.github.com>
This commit is contained in:
@@ -276,6 +276,9 @@ typedef float celsius_float_t;
|
|||||||
typedef const_float_t const_feedRate_t;
|
typedef const_float_t const_feedRate_t;
|
||||||
typedef const_float_t const_celsius_float_t;
|
typedef const_float_t const_celsius_float_t;
|
||||||
|
|
||||||
|
// Type large enough to count leveling grid points
|
||||||
|
typedef IF<TERN0(ABL_USES_GRID, (GRID_MAX_POINTS > 255)), uint16_t, uint8_t>::type grid_count_t;
|
||||||
|
|
||||||
// Conversion macros
|
// Conversion macros
|
||||||
#define MMM_TO_MMS(MM_M) feedRate_t(static_cast<float>(MM_M) / 60.0f)
|
#define MMM_TO_MMS(MM_M) feedRate_t(static_cast<float>(MM_M) / 60.0f)
|
||||||
#define MMS_TO_MMM(MM_S) (static_cast<float>(MM_S) * 60.0f)
|
#define MMS_TO_MMM(MM_S) (static_cast<float>(MM_S) * 60.0f)
|
||||||
|
@@ -48,8 +48,8 @@ struct mesh_index_pair;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool C_seen;
|
bool C_seen;
|
||||||
int8_t KLS_storage_slot;
|
int8_t KLS_storage_slot;
|
||||||
uint8_t R_repetition,
|
grid_count_t R_repetition;
|
||||||
V_verbosity,
|
uint8_t V_verbosity,
|
||||||
P_phase,
|
P_phase,
|
||||||
T_map_type;
|
T_map_type;
|
||||||
float B_shim_thickness,
|
float B_shim_thickness,
|
||||||
|
@@ -351,7 +351,7 @@ void unified_bed_leveling::G29() {
|
|||||||
|
|
||||||
// Invalidate one or more nearby mesh points, possibly all.
|
// Invalidate one or more nearby mesh points, possibly all.
|
||||||
if (parser.seen('I')) {
|
if (parser.seen('I')) {
|
||||||
uint8_t count = parser.has_value() ? parser.value_byte() : 1;
|
grid_count_t count = parser.has_value() ? parser.value_ushort() : 1;
|
||||||
bool invalidate_all = count >= GRID_MAX_POINTS;
|
bool invalidate_all = count >= GRID_MAX_POINTS;
|
||||||
if (!invalidate_all) {
|
if (!invalidate_all) {
|
||||||
while (count--) {
|
while (count--) {
|
||||||
@@ -760,14 +760,14 @@ void unified_bed_leveling::shift_mesh_height() {
|
|||||||
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
|
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
|
||||||
|
|
||||||
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
|
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
|
||||||
uint8_t count = GRID_MAX_POINTS;
|
grid_count_t count = GRID_MAX_POINTS;
|
||||||
|
|
||||||
mesh_index_pair best;
|
mesh_index_pair best;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_START));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_START));
|
||||||
do {
|
do {
|
||||||
if (do_ubl_mesh_map) display_map(param.T_map_type);
|
if (do_ubl_mesh_map) display_map(param.T_map_type);
|
||||||
|
|
||||||
const uint8_t point_num = (GRID_MAX_POINTS - count) + 1;
|
const grid_count_t point_num = (GRID_MAX_POINTS - count) + 1;
|
||||||
SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
|
SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
|
||||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS)));
|
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS)));
|
||||||
|
|
||||||
@@ -1135,7 +1135,7 @@ bool unified_bed_leveling::G29_parse_parameters() {
|
|||||||
param.R_repetition = 0;
|
param.R_repetition = 0;
|
||||||
|
|
||||||
if (parser.seen('R')) {
|
if (parser.seen('R')) {
|
||||||
param.R_repetition = parser.has_value() ? parser.value_byte() : GRID_MAX_POINTS;
|
param.R_repetition = parser.has_value() ? parser.value_ushort() : GRID_MAX_POINTS;
|
||||||
NOMORE(param.R_repetition, GRID_MAX_POINTS);
|
NOMORE(param.R_repetition, GRID_MAX_POINTS);
|
||||||
if (param.R_repetition < 1) {
|
if (param.R_repetition < 1) {
|
||||||
SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
|
SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
|
||||||
|
@@ -628,7 +628,7 @@ void GcodeSuite::G26() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get repeat from 'R', otherwise do one full circuit
|
// Get repeat from 'R', otherwise do one full circuit
|
||||||
int16_t g26_repeats;
|
grid_count_t g26_repeats;
|
||||||
#if HAS_MARLINUI_MENU
|
#if HAS_MARLINUI_MENU
|
||||||
g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
|
g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
|
||||||
#else
|
#else
|
||||||
|
@@ -102,11 +102,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||||
int abl_points;
|
grid_count_t abl_points;
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||||
static constexpr int abl_points = 3;
|
static constexpr grid_count_t abl_points = 3;
|
||||||
#elif ABL_USES_GRID
|
#elif ABL_USES_GRID
|
||||||
static constexpr int abl_points = GRID_MAX_POINTS;
|
static constexpr grid_count_t abl_points = GRID_MAX_POINTS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ABL_USES_GRID
|
#if ABL_USES_GRID
|
||||||
@@ -132,8 +132,8 @@ public:
|
|||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||||
int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||||
float eqnAMatrix[(GRID_MAX_POINTS) * 3], // "A" matrix of the linear system of equations
|
float eqnAMatrix[GRID_MAX_POINTS * 3], // "A" matrix of the linear system of equations
|
||||||
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
|
||||||
mean;
|
mean;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -141,7 +141,7 @@ public:
|
|||||||
|
|
||||||
#if ABL_USES_GRID && EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR)
|
#if ABL_USES_GRID && EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR)
|
||||||
constexpr xy_uint8_t G29_State::grid_points;
|
constexpr xy_uint8_t G29_State::grid_points;
|
||||||
constexpr int G29_State::abl_points;
|
constexpr grid_count_t G29_State::abl_points;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -677,7 +677,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
zig ^= true; // zag
|
zig ^= true; // zag
|
||||||
|
|
||||||
// An index to print current state
|
// An index to print current state
|
||||||
uint8_t pt_index = (PR_OUTER_VAR) * (PR_INNER_SIZE) + 1;
|
grid_count_t pt_index = (PR_OUTER_VAR) * (PR_INNER_SIZE) + 1;
|
||||||
|
|
||||||
// Inner loop is Y with PROBE_Y_FIRST enabled
|
// Inner loop is Y with PROBE_Y_FIRST enabled
|
||||||
// Inner loop is X with PROBE_Y_FIRST disabled
|
// Inner loop is X with PROBE_Y_FIRST disabled
|
||||||
|
@@ -173,7 +173,7 @@ void GcodeSuite::G29() {
|
|||||||
SET_SOFT_ENDSTOP_LOOSE(false);
|
SET_SOFT_ENDSTOP_LOOSE(false);
|
||||||
}
|
}
|
||||||
// If there's another point to sample, move there with optional lift.
|
// If there's another point to sample, move there with optional lift.
|
||||||
if (mbl_probe_index < (GRID_MAX_POINTS)) {
|
if (mbl_probe_index < GRID_MAX_POINTS) {
|
||||||
// Disable software endstops to allow manual adjustment
|
// Disable software endstops to allow manual adjustment
|
||||||
// If G29 is left hanging without completion they won't be re-enabled!
|
// If G29 is left hanging without completion they won't be re-enabled!
|
||||||
SET_SOFT_ENDSTOP_LOOSE(true);
|
SET_SOFT_ENDSTOP_LOOSE(true);
|
||||||
|
@@ -1498,8 +1498,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
|
|||||||
#error "AUTO_BED_LEVELING_UBL does not yet support POLAR printers."
|
#error "AUTO_BED_LEVELING_UBL does not yet support POLAR printers."
|
||||||
#elif DISABLED(EEPROM_SETTINGS)
|
#elif DISABLED(EEPROM_SETTINGS)
|
||||||
#error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS."
|
#error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS."
|
||||||
#elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15)
|
#elif !WITHIN(GRID_MAX_POINTS_X, 3, 255) || !WITHIN(GRID_MAX_POINTS_Y, 3, 255)
|
||||||
#error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
|
#error "GRID_MAX_POINTS_[XY] must be between 3 and 255."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif HAS_ABL_NOT_UBL
|
#elif HAS_ABL_NOT_UBL
|
||||||
@@ -1513,6 +1513,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
|
|||||||
*/
|
*/
|
||||||
#if IS_SCARA && DISABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if IS_SCARA && DISABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
#error "SCARA machines can only use the AUTO_BED_LEVELING_BILINEAR leveling option."
|
#error "SCARA machines can only use the AUTO_BED_LEVELING_BILINEAR leveling option."
|
||||||
|
#elif ABL_USES_GRID && !(WITHIN(GRID_MAX_POINTS_X, 3, 255) && WITHIN(GRID_MAX_POINTS_Y, 3, 255))
|
||||||
|
#error "GRID_MAX_POINTS_[XY] must be between 3 and 255."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif ENABLED(MESH_BED_LEVELING)
|
#elif ENABLED(MESH_BED_LEVELING)
|
||||||
|
@@ -202,7 +202,7 @@ bool livemove = false;
|
|||||||
bool liveadjust = false;
|
bool liveadjust = false;
|
||||||
uint8_t preheatmode = 0;
|
uint8_t preheatmode = 0;
|
||||||
float zoffsetvalue = 0;
|
float zoffsetvalue = 0;
|
||||||
uint8_t gridpoint;
|
grid_count_t gridpoint;
|
||||||
float corner_avg;
|
float corner_avg;
|
||||||
float corner_pos;
|
float corner_pos;
|
||||||
|
|
||||||
|
@@ -549,7 +549,7 @@ namespace Anycubic {
|
|||||||
bool msg_matched = false;
|
bool msg_matched = false;
|
||||||
|
|
||||||
#if HAS_LEVELING
|
#if HAS_LEVELING
|
||||||
static uint8_t probe_cnt = 0;
|
static grid_count_t probe_cnt = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The only way to get printer status is to parse messages
|
// The only way to get printer status is to parse messages
|
||||||
@@ -564,7 +564,7 @@ namespace Anycubic {
|
|||||||
// If probing completes ok save the mesh and park
|
// If probing completes ok save the mesh and park
|
||||||
// Ignore the custom machine name
|
// Ignore the custom machine name
|
||||||
if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) {
|
if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) {
|
||||||
if (probe_cnt == GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y) {
|
if (probe_cnt == GRID_MAX_POINTS) {
|
||||||
probe_cnt = 0;
|
probe_cnt = 0;
|
||||||
injectCommands(F("M500")); // G27 park nozzle
|
injectCommands(F("M500")); // G27 park nozzle
|
||||||
//ChangePageOfTFT(PAGE_PreLEVEL);
|
//ChangePageOfTFT(PAGE_PreLEVEL);
|
||||||
|
@@ -415,7 +415,7 @@ void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
uint8_t mesh_point_count = GRID_MAX_POINTS;
|
grid_count_t mesh_point_count = GRID_MAX_POINTS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) {
|
void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) {
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
struct BedMeshViewScreenData {
|
struct BedMeshViewScreenData {
|
||||||
FSTR_P message;
|
FSTR_P message;
|
||||||
uint8_t count;
|
grid_count_t count;
|
||||||
xy_uint8_t highlight;
|
xy_uint8_t highlight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
// LCD probed points are from defaults
|
// LCD probed points are from defaults
|
||||||
constexpr uint8_t total_probe_points = TERN(AUTO_BED_LEVELING_3POINT, 3, GRID_MAX_POINTS);
|
constexpr grid_count_t total_probe_points = TERN(AUTO_BED_LEVELING_3POINT, 3, GRID_MAX_POINTS);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bed leveling is done. Wait for G29 to complete.
|
// Bed leveling is done. Wait for G29 to complete.
|
||||||
|
@@ -901,7 +901,7 @@ void MarlinSettings::postprocess() {
|
|||||||
{
|
{
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
static_assert(
|
static_assert(
|
||||||
sizeof(bedlevel.z_values) == (GRID_MAX_POINTS) * sizeof(bedlevel.z_values[0][0]),
|
sizeof(bedlevel.z_values) == GRID_MAX_POINTS * sizeof(bedlevel.z_values[0][0]),
|
||||||
"MBL Z array is the wrong size."
|
"MBL Z array is the wrong size."
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
@@ -955,7 +955,7 @@ void MarlinSettings::postprocess() {
|
|||||||
{
|
{
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
static_assert(
|
static_assert(
|
||||||
sizeof(bedlevel.z_values) == (GRID_MAX_POINTS) * sizeof(bedlevel.z_values[0][0]),
|
sizeof(bedlevel.z_values) == GRID_MAX_POINTS * sizeof(bedlevel.z_values[0][0]),
|
||||||
"Bilinear Z array is the wrong size."
|
"Bilinear Z array is the wrong size."
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user