Use a different location as a kill message pending flag
The old implementation would fail if the message was in progmem at address 0xffff or 0x0000 (both unlikely). It would also fail if the eeprom was initialized to some other random value, which could have been dangerous when displayed as a full screen message.
This commit is contained in:
parent
4b65d49512
commit
f333d36e47
|
|
@ -1037,11 +1037,13 @@ static void fw_crash_init()
|
|||
eeprom_update_byte((uint8_t*)EEPROM_FW_CRASH_FLAG, 0xFF);
|
||||
}
|
||||
|
||||
#define KILL_PENDING_FLAG 0x42
|
||||
|
||||
static void fw_kill_init() {
|
||||
PGM_P kill_msg = (PGM_P)eeprom_init_default_word((uint16_t*)EEPROM_KILL_MESSAGE, 0);
|
||||
if (kill_msg) {
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG) == KILL_PENDING_FLAG) {
|
||||
PGM_P kill_msg = (PGM_P)eeprom_read_word((uint16_t*)EEPROM_KILL_MESSAGE);
|
||||
// clear pending message event
|
||||
eeprom_write_word((uint16_t*)EEPROM_KILL_MESSAGE, 0);
|
||||
eeprom_write_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG, EEPROM_EMPTY_VALUE);
|
||||
|
||||
// display the kill message
|
||||
lcd_show_fullscreen_message_and_wait_P(kill_msg);
|
||||
|
|
@ -9501,6 +9503,7 @@ void kill(const char *full_screen_message) {
|
|||
|
||||
// update eeprom with the correct kill message to be shown on startup
|
||||
eeprom_write_word((uint16_t*)EEPROM_KILL_MESSAGE, (uint16_t)full_screen_message);
|
||||
eeprom_write_byte((uint8_t*)EEPROM_KILL_PENDING_FLAG, KILL_PENDING_FLAG);
|
||||
|
||||
softReset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
|
|||
| 0x0C99 3225 | uint16 | EEPROM_TEMP_MODEL_L | 0-2160 | ff ffh | Temp model sim. response lag (ms) | Temp model | D3 Ax0c99 C2
|
||||
| 0x0C98 3224 | uint8 | EEPROM_TEMP_MODEL_VER | 0-255 | ffh | Temp model Version | Temp model | D3 Ax0c98 C1
|
||||
| 0x0C96 3222 | PGM_P | EEPROM_KILL_MESSAGE | 0-65535 | ff ffh | Kill message PGM pointer | kill() | D3 Ax0c96 C2
|
||||
| 0x0C95 3221 | uint8 | EEPROM_KILL_PENDING_FLAG | 42h, ffh | ffh | Kill pending flag (0x42 magic value) | kill() | D3 Ax0c95 C1
|
||||
|
||||
|Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code
|
||||
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--:
|
||||
|
|
@ -599,9 +600,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
|
|||
#define EEPROM_TEMP_MODEL_VER (EEPROM_TEMP_MODEL_L-1) //uint8_t
|
||||
|
||||
#define EEPROM_KILL_MESSAGE (EEPROM_TEMP_MODEL_VER-2) //PGM_P
|
||||
#define EEPROM_KILL_PENDING_FLAG (EEPROM_KILL_MESSAGE-1) //uint8
|
||||
|
||||
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
|
||||
#define EEPROM_LAST_ITEM EEPROM_KILL_MESSAGE
|
||||
#define EEPROM_LAST_ITEM EEPROM_KILL_PENDING_FLAG
|
||||
// !!!!!
|
||||
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
|
||||
// !!!!!
|
||||
|
|
|
|||
Loading…
Reference in New Issue