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

Commit

Permalink
Merge pull request #9 from n0xa/eepromfix
Browse files Browse the repository at this point in the history
Eepromfix
  • Loading branch information
n0xa committed Sep 29, 2023
2 parents 8153b0e + 67c7688 commit 96be87e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions m5stick-nemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -839,16 +839,21 @@ void setup() {
//EEPROM.write(0, 255);
//EEPROM.write(1, 255);
//EEPROM.write(2, 255);
EEPROM.commit();
if(EEPROM.read(0) <= 3){
rotation = EEPROM.read(0);
} else {
rotation = 3;
EEPROM.write(0, rotation);
//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){
// 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 96be87e

Please sign in to comment.