From 4b499583b555991f7b01e24d28bbd0ca7e173e99 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 15 Feb 2023 11:40:53 +0100 Subject: [PATCH] TM: future-proofing for incompatible model upgrades Introduce a model version. This is initialized at "1" and doesn't require any upgrade/downgrade checks since it's currently retro-compatible. --- Firmware/eeprom.h | 3 ++- Firmware/temperature.cpp | 6 +++--- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 6380225b..3e5c6be1 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -594,9 +594,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_TEMP_MODEL_V (EEPROM_TEMP_MODEL_U-4) //float #define EEPROM_TEMP_MODEL_D (EEPROM_TEMP_MODEL_V-4) //float #define EEPROM_TEMP_MODEL_L (EEPROM_TEMP_MODEL_D-2) //uint16_t +#define EEPROM_TEMP_MODEL_VER (EEPROM_TEMP_MODEL_L-1) //uint8_t //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_TEMP_MODEL_L +#define EEPROM_LAST_ITEM EEPROM_TEMP_MODEL_VER // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index fafbffa3..ced7ea50 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2633,13 +2633,13 @@ void temp_model_load_settings() static_assert(TEMP_MODEL_R_SIZE == 16); // ensure we don't desync with the eeprom table TempMgrGuard temp_mgr_guard; - // handle upgrade from a model without UVDL (FW<3.13) - // WARNING: this only works as long as UVDL are the same constants/model type as FW 3.12, - // it needs to consider the upgrading FW version otherwise! + // handle upgrade from a model without UVDL (FW<3.13, TM VER<1): model is retro-compatible, + // reset UV to an identity without doing any special handling eeprom_init_default_float((float*)EEPROM_TEMP_MODEL_U, TEMP_MODEL_U); eeprom_init_default_float((float*)EEPROM_TEMP_MODEL_V, TEMP_MODEL_V); eeprom_init_default_float((float*)EEPROM_TEMP_MODEL_D, TEMP_MODEL_fS); eeprom_init_default_word((uint16_t*)EEPROM_TEMP_MODEL_L, TEMP_MODEL_LAG); + eeprom_init_default_byte((uint8_t*)EEPROM_TEMP_MODEL_VER, TEMP_MODEL_VER); temp_model::enabled = eeprom_read_byte((uint8_t*)EEPROM_TEMP_MODEL_ENABLE); temp_model::data.P = eeprom_read_float((float*)EEPROM_TEMP_MODEL_P); diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 3fc80249..e1ca66ac 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -412,6 +412,7 @@ // model-based temperature check #define TEMP_MODEL 1 // enable model-based temperature checks +#define TEMP_MODEL_VER 1 // model parameters version #define TEMP_MODEL_DEBUG 1 // extended runtime logging #define TEMP_MODEL_P 38. // heater power (W) diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 015124fa..ad599335 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -416,6 +416,7 @@ // model-based temperature check #define TEMP_MODEL 1 // enable model-based temperature checks +#define TEMP_MODEL_VER 1 // model parameters version #define TEMP_MODEL_DEBUG 1 // extended runtime logging #define TEMP_MODEL_P 38. // heater power (W)