DeskControl/src/lib/persist.h

49 lines
738 B
C++

#ifndef __persist
#define __persist
#include <stdint.h>
#include <string.h>
#define PersistIdentifier 0x42
#define PersistVersion1 1
struct PersistHeader
{
uint8_t identifier;
uint8_t version;
};
#define PersistHeightsAddress sizeof(PersistHeader)
struct PersistHeights
{
uint8_t offset;
uint16_t setting[2];
};
class Persist
{
public:
Persist()
{
memset(&this->heights, 0, sizeof(PersistHeights));
}
bool init();
// How many centimeters up the reflective surface is from the ground
uint8_t getHeightOffset() { return this->heights.offset; }
void setHeightOffset(uint8_t newValue);
private:
void readHeights();
void writeHeights();
PersistHeights heights;
};
#endif