power panic: support any valid DOS 8.3 extension
When a SD file is selected to print save the DOS 8.3 extension into EEPROM. After a power outage, the correct file extension is then selected instead of always assuming it's ".gco" This allows users to recover ".g" files. Change in memory: Flash: +104 bytes SRAM: 0 bytes
This commit is contained in:
parent
4c52d92d16
commit
dc280b0d9e
|
|
@ -368,6 +368,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
|
|||
| 0x0C97 3223 | uint8 | EEPROM_THERMAL_MODEL_VER | 0-255 | ffh | Thermal Model Version | Thermal Model| D3 Ax0c97 C1
|
||||
| 0x0C95 3221 | PGM_P | EEPROM_KILL_MESSAGE | 0-65535 | ff ffh | Kill message PGM pointer | kill() | D3 Ax0c95 C2
|
||||
| 0x0C94 3220 | uint8 | EEPROM_KILL_PENDING_FLAG | 42h, ffh | ffh | Kill pending flag (0x42 magic value) | kill() | D3 Ax0c94 C1
|
||||
| 0x0C91 3217 | char[3] | EEPROM_FILENAME_EXTENSION | ??? | ffffffffh | DOS 8.3 filename extension | ??? | D3 Ax0c91 C1
|
||||
|
||||
|Address begin|Bit/Type | Name | Valid values | Default/FactoryReset | Description |Gcode/Function| Debug code
|
||||
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--:
|
||||
|
|
@ -606,8 +607,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
|
|||
#define EEPROM_KILL_MESSAGE (EEPROM_THERMAL_MODEL_VER-2) //PGM_P
|
||||
#define EEPROM_KILL_PENDING_FLAG (EEPROM_KILL_MESSAGE-1) //uint8
|
||||
|
||||
#define EEPROM_FILENAME_EXTENSION (EEPROM_KILL_PENDING_FLAG - 3) // 3 x char
|
||||
|
||||
//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_PENDING_FLAG
|
||||
#define EEPROM_LAST_ITEM EEPROM_FILENAME_EXTENSION
|
||||
// !!!!!
|
||||
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
|
||||
// !!!!!
|
||||
|
|
|
|||
|
|
@ -428,6 +428,7 @@ void restore_file_from_sd()
|
|||
{
|
||||
char filename[FILENAME_LENGTH];
|
||||
char dir_name[9];
|
||||
char extension_ptr[5];
|
||||
uint8_t depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH);
|
||||
|
||||
for (uint8_t i = 0; i < depth; i++) {
|
||||
|
|
@ -443,8 +444,11 @@ void restore_file_from_sd()
|
|||
// Add null delimiter in case all 8 characters were not NULL
|
||||
filename[8] = '\0';
|
||||
|
||||
// Add extension to complete the DOS 8.3 filename
|
||||
strcat_P(filename, PSTR(".gco"));
|
||||
// Add extension to complete the DOS 8.3 filename e.g. ".gco" or ".g"
|
||||
extension_ptr[0] = '.';
|
||||
eeprom_read_block(&extension_ptr[1], (const char *)EEPROM_FILENAME_EXTENSION, 3);
|
||||
extension_ptr[4] = '\0';
|
||||
strcat(filename, extension_ptr);
|
||||
|
||||
enquecommandf_P(MSG_M23, filename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7003,6 +7003,22 @@ static void menu_action_sdfile(const char* filename)
|
|||
}
|
||||
}
|
||||
|
||||
// Write the DOS 8.3 file extension into EEPROM
|
||||
char * extension_ptr = strchr(selected_filename, '.');
|
||||
|
||||
if (extension_ptr) {
|
||||
extension_ptr++; // skip the '.'
|
||||
}
|
||||
|
||||
for (uint_least8_t i = 0; i < 3; i++)
|
||||
{
|
||||
if (extension_ptr == NULL || extension_ptr[i] == '\0') {
|
||||
eeprom_update_byte((uint8_t*)EEPROM_FILENAME_EXTENSION + i, '\0');
|
||||
} else {
|
||||
eeprom_update_byte((uint8_t*)EEPROM_FILENAME_EXTENSION + i, extension_ptr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t depth = card.getWorkDirDepth();
|
||||
eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue