0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-18 15:21:25 +00:00

🚸 Support Bed Leveling Mesh > 16x16

Co-Authored-By: raTmole <ratmole@users.noreply.github.com>
This commit is contained in:
Scott Lahteine 2023-05-16 02:52:52 -05:00
parent df078cac92
commit 060ddf5e95
13 changed files with 30 additions and 25 deletions

View file

@ -276,6 +276,9 @@ typedef float celsius_float_t;
typedef const_float_t const_feedRate_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
#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)

View file

@ -48,8 +48,8 @@ struct mesh_index_pair;
typedef struct {
bool C_seen;
int8_t KLS_storage_slot;
uint8_t R_repetition,
V_verbosity,
grid_count_t R_repetition;
uint8_t V_verbosity,
P_phase,
T_map_type;
float B_shim_thickness,

View file

@ -351,7 +351,7 @@ void unified_bed_leveling::G29() {
// Invalidate one or more nearby mesh points, possibly all.
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;
if (!invalidate_all) {
while (count--) {
@ -760,14 +760,14 @@ void unified_bed_leveling::shift_mesh_height() {
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());
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;
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_START));
do {
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, ".");
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;
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);
if (param.R_repetition < 1) {
SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");

View file

@ -628,7 +628,7 @@ void GcodeSuite::G26() {
}
// Get repeat from 'R', otherwise do one full circuit
int16_t g26_repeats;
grid_count_t g26_repeats;
#if HAS_MARLINUI_MENU
g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1);
#else

View file

@ -102,11 +102,11 @@ public:
#endif
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
int abl_points;
grid_count_t abl_points;
#elif ENABLED(AUTO_BED_LEVELING_3POINT)
static constexpr int abl_points = 3;
static constexpr grid_count_t abl_points = 3;
#elif ABL_USES_GRID
static constexpr int abl_points = GRID_MAX_POINTS;
static constexpr grid_count_t abl_points = GRID_MAX_POINTS;
#endif
#if ABL_USES_GRID
@ -132,8 +132,8 @@ public:
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
int indexIntoAB[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
float eqnAMatrix[(GRID_MAX_POINTS) * 3], // "A" matrix of the linear system of equations
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
float eqnAMatrix[GRID_MAX_POINTS * 3], // "A" matrix of the linear system of equations
eqnBVector[GRID_MAX_POINTS], // "B" vector of Z points
mean;
#endif
#endif
@ -141,7 +141,7 @@ public:
#if ABL_USES_GRID && EITHER(AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR)
constexpr xy_uint8_t G29_State::grid_points;
constexpr int G29_State::abl_points;
constexpr grid_count_t G29_State::abl_points;
#endif
/**
@ -677,7 +677,7 @@ G29_TYPE GcodeSuite::G29() {
zig ^= true; // zag
// 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 X with PROBE_Y_FIRST disabled

View file

@ -173,7 +173,7 @@ void GcodeSuite::G29() {
SET_SOFT_ENDSTOP_LOOSE(false);
}
// 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
// If G29 is left hanging without completion they won't be re-enabled!
SET_SOFT_ENDSTOP_LOOSE(true);

View file

@ -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."
#elif DISABLED(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)
#error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15."
#elif !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
#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)
#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
#elif ENABLED(MESH_BED_LEVELING)

View file

@ -202,7 +202,7 @@ bool livemove = false;
bool liveadjust = false;
uint8_t preheatmode = 0;
float zoffsetvalue = 0;
uint8_t gridpoint;
grid_count_t gridpoint;
float corner_avg;
float corner_pos;

View file

@ -549,7 +549,7 @@ namespace Anycubic {
bool msg_matched = false;
#if HAS_LEVELING
static uint8_t probe_cnt = 0;
static grid_count_t probe_cnt = 0;
#endif
// 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
// Ignore the custom machine name
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;
injectCommands(F("M500")); // G27 park nozzle
//ChangePageOfTFT(PAGE_PreLEVEL);

View file

@ -415,7 +415,7 @@ void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr)
}
#if ENABLED(MESH_BED_LEVELING)
uint8_t mesh_point_count = GRID_MAX_POINTS;
grid_count_t mesh_point_count = GRID_MAX_POINTS;
#endif
void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) {

View file

@ -26,7 +26,7 @@
struct BedMeshViewScreenData {
FSTR_P message;
uint8_t count;
grid_count_t count;
xy_uint8_t highlight;
};

View file

@ -53,7 +53,7 @@
//
// 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.

View file

@ -901,7 +901,7 @@ void MarlinSettings::postprocess() {
{
#if ENABLED(MESH_BED_LEVELING)
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."
);
#else
@ -955,7 +955,7 @@ void MarlinSettings::postprocess() {
{
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
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."
);
#endif