diff --git a/Firmware/lib/LightController/LightController.cpp b/Firmware/lib/LightController/LightController.cpp index f8fe3e5..ae96010 100644 --- a/Firmware/lib/LightController/LightController.cpp +++ b/Firmware/lib/LightController/LightController.cpp @@ -9,6 +9,7 @@ LightController::LightController(const int bjtPins[], __SIZE_TYPE__ bjtCount) this->bjtCount = bjtCount; this->bjtPins = bjtPins; this->bjtState = new int[bjtCount]; + EEPROM.begin(64); initializePins(); initializeState(); } @@ -31,7 +32,7 @@ void LightController::initializeStateDefaultValues() { for (__SIZE_TYPE__ i = 0; i < bjtCount; i++) { - bjtState[i] = 0; + bjtState[i] = 20; } } @@ -39,7 +40,7 @@ void LightController::restoreState() { for (__SIZE_TYPE__ i = 0; i < bjtCount; i++) { - bjtState[i] = EEPROM.read(i); + bjtState[i] = EEPROM.readInt(i * sizeof(bjtState[i])); commitPinState(i); } } @@ -113,7 +114,8 @@ int LightController::clampState(int stateValue) void LightController::commitState(int index) { commitPinState(index); - EEPROM.write(index, bjtState[index]); + EEPROM.writeInt(index * sizeof(bjtState[index]), bjtState[index]); + EEPROM.commit(); } void LightController::commitPinState(int index)