From 7a0ff89c2898d3a34fb5c7a27f0872e109bd83e2 Mon Sep 17 00:00:00 2001 From: Noah Axon Date: Thu, 28 Sep 2023 01:33:45 -0500 Subject: [PATCH 1/2] Fix bug with eeprom code - wrong address for brightness --- m5stick-nemo.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/m5stick-nemo.ino b/m5stick-nemo.ino index 04527d3..4774fb7 100644 --- a/m5stick-nemo.ino +++ b/m5stick-nemo.ino @@ -224,7 +224,7 @@ void dmenu_loop() { } brightness = 10 * cursor; M5.Axp.ScreenBreath(brightness); - EEPROM.write(3, brightness); + EEPROM.write(2, brightness); EEPROM.commit(); rstOverride = false; isSwitching = true; @@ -839,7 +839,10 @@ void setup() { //EEPROM.write(0, 255); //EEPROM.write(1, 255); //EEPROM.write(2, 255); - EEPROM.commit(); + //EEPROM.commit(); + Serial.printf("EEPROM 0: %d\n", EEPROM.read(0)); + Serial.printf("EEPROM 1: %d\n", EEPROM.read(1)); + Serial.printf("EEPROM 2: %d\n", EEPROM.read(2)); if(EEPROM.read(0) <= 3){ rotation = EEPROM.read(0); } else { From 67c768810b8f4ca4fe2e93ae46678706735b9957 Mon Sep 17 00:00:00 2001 From: Noah Axon Date: Thu, 28 Sep 2023 16:10:39 -0500 Subject: [PATCH 2/2] More EEPROM cleanup --- m5stick-nemo.ino | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/m5stick-nemo.ino b/m5stick-nemo.ino index 4774fb7..95cb0ce 100644 --- a/m5stick-nemo.ino +++ b/m5stick-nemo.ino @@ -843,15 +843,17 @@ void setup() { Serial.printf("EEPROM 0: %d\n", EEPROM.read(0)); Serial.printf("EEPROM 1: %d\n", EEPROM.read(1)); Serial.printf("EEPROM 2: %d\n", EEPROM.read(2)); - if(EEPROM.read(0) <= 3){ - rotation = EEPROM.read(0); - } else { - rotation = 3; - EEPROM.write(0, rotation); + if(EEPROM.read(0) > 3){ + // Let's just assume rotation > 3 is a fresh/corrupt EEPROM and write defaults for everything + Serial.println("EEPROM likely not properly configured. Writing defaults."); + EEPROM.write(0, 3); // Left rotation + EEPROM.write(1, 15); // 15 second auto dim time + EEPROM.write(2, 100); // 100% brightness EEPROM.commit(); } - screen_dim_time = EEPROM.read(1) % 30; - brightness = EEPROM.read(2) % 100; + rotation = EEPROM.read(0); + screen_dim_time = EEPROM.read(1); + brightness = EEPROM.read(2); M5.Axp.ScreenBreath(brightness); M5.Lcd.setRotation(rotation); M5.Lcd.setTextColor(GREEN, BLACK);