Fix eeprom on esp32
This commit is contained in:
parent
57850dd0d9
commit
6c2f39a4ea
1 changed files with 5 additions and 3 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue