Merge pull request #9 from n0xa/eepromfix

Eepromfix
This commit is contained in:
Noah Axon 2023-09-28 21:26:53 -05:00 committed by GitHub
commit 96be87edc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -224,7 +224,7 @@ void dmenu_loop() {
} }
brightness = 10 * cursor; brightness = 10 * cursor;
M5.Axp.ScreenBreath(brightness); M5.Axp.ScreenBreath(brightness);
EEPROM.write(3, brightness); EEPROM.write(2, brightness);
EEPROM.commit(); EEPROM.commit();
rstOverride = false; rstOverride = false;
isSwitching = true; isSwitching = true;
@ -839,16 +839,21 @@ void setup() {
//EEPROM.write(0, 255); //EEPROM.write(0, 255);
//EEPROM.write(1, 255); //EEPROM.write(1, 255);
//EEPROM.write(2, 255); //EEPROM.write(2, 255);
EEPROM.commit(); //EEPROM.commit();
if(EEPROM.read(0) <= 3){ Serial.printf("EEPROM 0: %d\n", EEPROM.read(0));
rotation = EEPROM.read(0); Serial.printf("EEPROM 1: %d\n", EEPROM.read(1));
} else { Serial.printf("EEPROM 2: %d\n", EEPROM.read(2));
rotation = 3; if(EEPROM.read(0) > 3){
EEPROM.write(0, rotation); // 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(); EEPROM.commit();
} }
screen_dim_time = EEPROM.read(1) % 30; rotation = EEPROM.read(0);
brightness = EEPROM.read(2) % 100; screen_dim_time = EEPROM.read(1);
brightness = EEPROM.read(2);
M5.Axp.ScreenBreath(brightness); M5.Axp.ScreenBreath(brightness);
M5.Lcd.setRotation(rotation); M5.Lcd.setRotation(rotation);
M5.Lcd.setTextColor(GREEN, BLACK); M5.Lcd.setTextColor(GREEN, BLACK);