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