From 67c768810b8f4ca4fe2e93ae46678706735b9957 Mon Sep 17 00:00:00 2001 From: Noah Axon Date: Thu, 28 Sep 2023 16:10:39 -0500 Subject: [PATCH] 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);