From 7274a6cc7055f9fed72a83c065781af4293e8462 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 3 May 2023 14:05:49 +0200 Subject: [PATCH] Persist display intensity to EEPROM --- Display.h | 2 ++ RNode_Firmware.ino | 5 +++++ ROM.h | 2 ++ Utilities.h | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/Display.h b/Display.h index f0ba7de..5b3e356 100644 --- a/Display.h +++ b/Display.h @@ -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 diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index b48e4c3..e12121e 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -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 diff --git a/ROM.h b/ROM.h index 6ea5686..611c88b 100644 --- a/ROM.h +++ b/ROM.h @@ -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 diff --git a/Utilities.h b/Utilities.h index 56b870d..fcef508 100644 --- a/Utilities.h +++ b/Utilities.h @@ -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;