Persist display intensity to EEPROM

This commit is contained in:
Mark Qvist 2023-05-03 14:05:49 +02:00
parent 7e86873ead
commit 7274a6cc70
4 changed files with 13 additions and 0 deletions

View File

@ -134,6 +134,8 @@ bool display_init() {
disp_area.cp437(true);
display.cp437(true);
display_intensity = EEPROM.read(eeprom_addr(ADDR_CONF_DINT));
return true;
}
#else

View File

@ -117,6 +117,10 @@ void setup() {
#endif
#if HAS_DISPLAY
if (EEPROM.read(eeprom_addr(ADDR_CONF_DSET)) != CONF_OK_BYTE) {
eeprom_update(eeprom_addr(ADDR_CONF_DSET), CONF_OK_BYTE);
eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF);
}
disp_ready = display_init();
update_display();
#endif
@ -798,6 +802,7 @@ void serialCallback(uint8_t sbyte) {
ESCAPE = false;
}
display_intensity = sbyte;
di_conf_save(display_intensity);
}
#endif

2
ROM.h
View File

@ -58,6 +58,8 @@
#define ADDR_CONF_OK 0xA7
#define ADDR_CONF_BT 0xB0
#define ADDR_CONF_DSET 0xB1
#define ADDR_CONF_DINT 0xB2
#define INFO_LOCK_BYTE 0x73
#define CONF_OK_BYTE 0x73

View File

@ -1096,6 +1096,10 @@ void bt_conf_save(bool is_enabled) {
}
}
void di_conf_save(uint8_t dint) {
eeprom_update(eeprom_addr(ADDR_CONF_DINT), dint);
}
bool eeprom_have_conf() {
if (EEPROM.read(eeprom_addr(ADDR_CONF_OK)) == CONF_OK_BYTE) {
return true;