From 28c91deb5c3813acb8f92f36afe3c3b975f01146 Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Wed, 18 Mar 2015 21:00:31 +0100 Subject: [PATCH] EEPROM saving of z_values. Tried to make it a little intelligent. --- Marlin/ConfigurationStore.cpp | 41 +++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/Marlin/ConfigurationStore.cpp b/Marlin/ConfigurationStore.cpp index 6e0eeb04cf..1d582d9ac2 100644 --- a/Marlin/ConfigurationStore.cpp +++ b/Marlin/ConfigurationStore.cpp @@ -113,7 +113,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { // wrong data being written to the variables. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order. -#define EEPROM_VERSION "V16" +#define EEPROM_VERSION "V17" #ifdef EEPROM_SETTINGS @@ -136,9 +136,26 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, max_e_jerk); EEPROM_WRITE_VAR(i, add_homing); + uint8_t mesh_num_x = 3; + uint8_t mesh_num_y = 3; #if defined(MESH_BED_LEVELING) + // Compile time test that sizeof(mbl.z_values) is as expected + typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS*sizeof(dummy)) ? 1 : -1]; + mesh_num_x = MESH_NUM_X_POINTS; + mesh_num_y = MESH_NUM_Y_POINTS; EEPROM_WRITE_VAR(i, mbl.active); + EEPROM_WRITE_VAR(i, mesh_num_x); + EEPROM_WRITE_VAR(i, mesh_num_y); EEPROM_WRITE_VAR(i, mbl.z_values); + #else + uint8_t dummy_uint8 = 0; + EEPROM_WRITE_VAR(i, dummy_uint8); + EEPROM_WRITE_VAR(i, mesh_num_x); + EEPROM_WRITE_VAR(i, mesh_num_y); + dummy = 0.0f; + for (int q=0; q