50 lines
768 B
C++
50 lines
768 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));
|
|
}
|
|
|
|
void 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();
|
|
|
|
bool initialized = false;
|
|
PersistHeights heights;
|
|
};
|
|
|
|
#endif |