DeskControl/src/lib/persist.cpp

40 lines
602 B
C++

#include "./persist.h"
#include <EEPROM.h>
void Persist::init()
{
PersistHeader header;
EEPROM.get(0, header);
if (header.identifier == PersistIdentifier)
{
if (header.version >= 1)
this->readHeights();
this->initialized = true;
}
}
void Persist::readHeights()
{
EEPROM.get(PersistHeightsAddress, this->heights);
}
void Persist::writeHeights()
{
EEPROM.put(PersistHeightsAddress, this->heights);
}
void Persist::setHeightOffset(uint8_t newValue)
{
if (newValue == this->heights.offset)
return;
this->heights.offset = newValue;
this->writeHeights();
}