diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 4839e3ed3d..e064ebaf7d 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -341,10 +341,6 @@ void MarlinSettings::postprocess() { bool MarlinSettings::eeprom_error, MarlinSettings::validating; - #if ENABLED(AUTO_BED_LEVELING_UBL) - int16_t MarlinSettings::meshes_begin; - #endif - void MarlinSettings::write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) { if (eeprom_error) { pos += size; return; } while (size--) { @@ -1364,9 +1360,6 @@ void MarlinSettings::postprocess() { } #if ENABLED(AUTO_BED_LEVELING_UBL) - meshes_begin = (eeprom_index + 32) & 0xFFF8; // Pad the end of configuration data so it - // can float up or down a little bit without - // disrupting the mesh data ubl.report_state(); if (!validating) { @@ -1434,12 +1427,13 @@ void MarlinSettings::postprocess() { } #endif + int16_t MarlinSettings::meshes_start_index() { + return (datasize() + EEPROM_OFFSET + 32) & 0xFFF8; // Pad the end of configuration data so it can float up + // or down a little bit without disrupting the mesh data + } + uint16_t MarlinSettings::calc_num_meshes() { - //obviously this will get more sophisticated once we've added an actual MAT - - if (meshes_begin <= 0) return 0; - - return (meshes_end - meshes_begin) / sizeof(ubl.z_values); + return (meshes_end - meshes_start_index()) / sizeof(ubl.z_values); } void MarlinSettings::store_mesh(const int8_t slot) { diff --git a/Marlin/configuration_store.h b/Marlin/configuration_store.h index 55cfb1fb19..54102807b7 100644 --- a/Marlin/configuration_store.h +++ b/Marlin/configuration_store.h @@ -38,13 +38,10 @@ class MarlinSettings { bool success = true; reset(); #if ENABLED(EEPROM_SETTINGS) - if ((success = save())) { - #if ENABLED(AUTO_BED_LEVELING_UBL) - success = load(); // UBL uses load() to know the end of EEPROM - #elif ENABLED(EEPROM_CHITCHAT) - report(); - #endif - } + success = save(); + #if ENABLED(EEPROM_CHITCHAT) + if (success) report(); + #endif #endif return success; } @@ -55,8 +52,8 @@ class MarlinSettings { #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system // That can store is enabled - FORCE_INLINE static int16_t get_start_of_meshes() { return meshes_begin; } - FORCE_INLINE static int16_t get_end_of_meshes() { return meshes_end; } + static int16_t meshes_start_index(); + FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; } static uint16_t calc_num_meshes(); static void store_mesh(const int8_t slot); static void load_mesh(const int8_t slot, void * const into=NULL); diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index e741e391d6..e1b00b4751 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -308,12 +308,6 @@ void unified_bed_leveling::G29() { - if (!settings.calc_num_meshes()) { - SERIAL_PROTOCOLLNPGM("?Enable EEPROM and init with"); - SERIAL_PROTOCOLLNPGM("M502, M500, M501 in that order.\n"); - return; - } - if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem, // Check for commands that require the printer to be homed @@ -1273,8 +1267,8 @@ SERIAL_EOL(); safe_delay(50); - SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes())); - SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes())); + SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index())); + SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.meshes_end_index())); safe_delay(50); SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl)); @@ -1283,7 +1277,7 @@ SERIAL_EOL(); safe_delay(25); - SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes()))); + SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index()))); safe_delay(50); SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes()); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 1abf8ec259..a66003d311 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2303,7 +2303,6 @@ void kill_screen(const char* lcd_msg) { MENU_BACK(MSG_UBL_LEVEL_BED); if (!WITHIN(ubl_storage_slot, 0, a - 1)) { STATIC_ITEM(MSG_NO_STORAGE); - STATIC_ITEM(MSG_INIT_EEPROM); } else { MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);