Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
More EEPROM cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
n0xa committed Sep 28, 2023
1 parent 7a0ff89 commit 67c7688
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions m5stick-nemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 67c7688

Please sign in to comment.