Fix EEPROM save load

This commit is contained in:
Dejvino 2026-03-01 14:18:33 +01:00
parent 14ac4401ce
commit 8cc8898c01

View File

@ -109,7 +109,7 @@ void setupUI() {
display.display(); display.display();
// Initialize EEPROM // Initialize EEPROM
EEPROM.begin(1024); EEPROM.begin(2048);
// Check for safety clear (Button held on startup) // Check for safety clear (Button held on startup)
if (digitalRead(PIN_ENC_SW) == LOW) { if (digitalRead(PIN_ENC_SW) == LOW) {
@ -320,13 +320,13 @@ void checkSerial() {
} }
} else if (state == 1) { // Count } else if (state == 1) { // Count
elementCount = b; elementCount = b;
if (1 + elementCount * 5 > sizeof(buffer)) { if (1 + elementCount * 5 + 1 > sizeof(buffer)) {
state = 0; state = 0;
bufferIdx = 0; bufferIdx = 0;
Serial.println(F("ERROR: Grid too large")); Serial.println(F("ERROR: Grid too large"));
} else { } else {
buffer[bufferIdx++] = b; buffer[bufferIdx++] = b;
state = 2; state = (elementCount == 0) ? 3 : 2;
} }
} else if (state == 2) { // Data } else if (state == 2) { // Data
buffer[bufferIdx++] = b; buffer[bufferIdx++] = b;