From c9cb11063ae66f24118462c930b49a9e93b89ea7 Mon Sep 17 00:00:00 2001 From: ThomasToka Date: Sat, 2 Aug 2025 17:42:44 +0200 Subject: [PATCH] ABL/UBL/Settings pass checks bbl.h ubl.h ubl_G29.cpp settings.cpp --- Marlin/src/feature/bedlevel/abl/bbl.h | 2 -- Marlin/src/feature/bedlevel/ubl/ubl.h | 4 ---- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- Marlin/src/module/settings.cpp | 24 +++++++++++++++------ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Marlin/src/feature/bedlevel/abl/bbl.h b/Marlin/src/feature/bedlevel/abl/bbl.h index ddca13c9e191..07b6851afc53 100644 --- a/Marlin/src/feature/bedlevel/abl/bbl.h +++ b/Marlin/src/feature/bedlevel/abl/bbl.h @@ -61,8 +61,6 @@ class LevelingBilinear { static xy_float_t grid_factor_virt; #if ENABLED(VARIABLE_GRID_POINTS) static xy_uint_t nr_grid_points_virt; - #else - static constexpr xy_uint_t nr_grid_points_virt { ABL_MAX_POINTS_VIRT_X, ABL_MAX_POINTS_VIRT_Y }; #endif static float virt_coord(const uint8_t x, const uint8_t y); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index 0c500718a5e4..ea00d12e2318 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -62,10 +62,6 @@ typedef struct { #endif } G29_parameters_t; -#if ENABLED(VARIABLE_GRID_POINTS) - class unified_bed_leveling; -#endif - class unified_bed_leveling { private: diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 4ec2d45317ed..47c51a981e81 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1731,7 +1731,7 @@ typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info; SERIAL_ECHOPGM("Extrapolating mesh..."); - const float weight_scaled = weight_factor * _MAX(mesh_dist.x, mesh_dist.y); + const float weight_scaled = weight_factor * _MAX(TERN(VARIABLE_GRID_POINTS, mesh_dist.x, MESH_X_DIST), TERN(VARIABLE_GRID_POINTS, mesh_dist.y, MESH_Y_DIST)); GRID_LOOP_COND(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6ce586f8e3c1..dedb08374508 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -303,7 +303,7 @@ typedef struct SettingsDataStruct { xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F #if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(VARIABLE_GRID_POINTS) - xy_uint8_t bilinear_grid_points; + xy_uint8_t nr_grid_points; #endif bed_mesh_t z_values; // G29 #else @@ -3180,8 +3180,12 @@ void MarlinSettings::postprocess() { // Write crc to MAT along with other data, or just tack on to the beginning or end persistentStore.access_start(); - const bool err = persistentStore.write_data(pos, (uint8_t *)&bedlevel.nr_grid_points, sizeof(bedlevel.nr_grid_points), &crc) - || persistentStore.write_data(pos, src, MESH_DATA_SIZE, &crc); + #if ENABLED(VARIABLE_GRID_POINTS) + const bool err = persistentStore.write_data(pos, (uint8_t *)&bedlevel.nr_grid_points, sizeof(bedlevel.nr_grid_points), &crc) + || persistentStore.write_data(pos, src, MESH_DATA_SIZE, &crc); + #else + const bool err = persistentStore.write_data(pos, src, MESH_DATA_SIZE, &crc); + #endif persistentStore.access_finish(); if (err) SERIAL_ECHOLNPGM("?Unable to save mesh data."); @@ -3215,9 +3219,13 @@ void MarlinSettings::postprocess() { #endif persistentStore.access_start(); - xy_uint8_t nr_grid_points; - bool err = persistentStore.read_data(pos, (uint8_t *)&nr_grid_points, sizeof(nr_grid_points), &crc) - || persistentStore.read_data(pos, dest, MESH_DATA_SIZE, &crc); + #if ENABLED(VARIABLE_GRID_POINTS) + xy_uint8_t nr_grid_points; + bool err = persistentStore.read_data(pos, (uint8_t *)&nr_grid_points, sizeof(nr_grid_points), &crc) + || persistentStore.read_data(pos, dest, MESH_DATA_SIZE, &crc); + #else + uint16_t err = persistentStore.read_data(pos, dest, MESH_DATA_SIZE, &crc); + #endif persistentStore.access_finish(); #if ENABLED(OPTIMIZED_MESH_STORAGE) @@ -3243,7 +3251,9 @@ void MarlinSettings::postprocess() { if (err) SERIAL_ECHOLNPGM("?Unable to load mesh data."); else { - bedlevel.set_nr_grid_points(nr_grid_points); + #if ENABLED(VARIABLE_GRID_POINTS) + bedlevel.set_nr_grid_points(nr_grid_points); + #endif DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); }