From 0af7d280749101b4f32a5d7b109e6913738f4315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 22 Oct 2022 16:49:58 +0000 Subject: [PATCH] PFW-1397 Allocate EEPROM memory for toolchange counter --- Firmware/Marlin_main.cpp | 1 + Firmware/eeprom.cpp | 1 + Firmware/eeprom.h | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 04df9804c..3b35e8529 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -711,6 +711,7 @@ static void factory_reset_stats(){ eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0); eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); + eeprom_update_dword((uint32_t *)EEPROM_TOTAL_TOOLCHANGE_COUNT, 0); } // Factory reset function diff --git a/Firmware/eeprom.cpp b/Firmware/eeprom.cpp index 0e00cafc1..cc14471e4 100644 --- a/Firmware/eeprom.cpp +++ b/Firmware/eeprom.cpp @@ -62,6 +62,7 @@ void eeprom_init() if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0); if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0); + if (eeprom_read_dword((uint32_t*)EEPROM_TOTAL_TOOLCHANGE_COUNT) == 0xffffffff) eeprom_update_dword((uint32_t *)EEPROM_TOTAL_TOOLCHANGE_COUNT, 0); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == EEPROM_EMPTY_VALUE) { eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 5c2272a26..a949cbd4d 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -343,6 +343,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0CAE 3246 | float | EEPROM_TEMP_MODEL_E | ??? | ff ff ff ffh | Temp model error threshold (K/s) | Temp model | D3 Ax0cae C4 | 0x0CAD 3245 | uint8 | EEPROM_FSENSOR_JAM_DETECTION | 01h 1 | ff/01 | fsensor pat9125 jam detection feature | LCD menu | D3 Ax0cad C1 | 0x0CAC 3244 | uint8 | EEPROM_MMU_ENABLED | 01h 1 | ff/01 | MMU enabled | LCD menu | D3 Ax0cac C1 +| 0x0CA8 3240 | uint32 | EEPROM_TOTAL_TOOLCHANGE_COUNT | ??? | ff ff ff ffh | MMU toolchange counter over printers lifetime | LCD statistic| D3 Ax0ca8 C4 |Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: @@ -568,8 +569,9 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_FSENSOR_JAM_DETECTION (EEPROM_TEMP_MODEL_E-1) // uint8_t #define EEPROM_MMU_ENABLED (EEPROM_FSENSOR_JAM_DETECTION-1) // uint8_t +#define EEPROM_TOTAL_TOOLCHANGE_COUNT (EEPROM_MMU_ENABLED-4) //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_MMU_ENABLED +#define EEPROM_LAST_ITEM EEPROM_TOTAL_TOOLCHANGE_COUNT // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!!