2020-02-24 00:53:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "part.h"
|
|
|
|
#include "stmlib/stmlib.h"
|
|
|
|
#include "stmlib/system/storage.h"
|
|
|
|
|
|
|
|
struct PersistentData {
|
|
|
|
uint8_t honor;
|
2020-02-24 23:25:00 +00:00
|
|
|
uint8_t padding[7];
|
2020-02-24 00:53:33 +00:00
|
|
|
enum { tag = 0x494C4143 }; // CALI
|
|
|
|
};
|
|
|
|
|
|
|
|
struct State {
|
2020-02-24 23:25:00 +00:00
|
|
|
PartData part_datas[PART_COUNT];
|
2020-02-24 00:53:33 +00:00
|
|
|
//uint8_t padding[4];
|
|
|
|
enum { tag = 0x54415453 }; // STAT
|
|
|
|
};
|
|
|
|
|
|
|
|
class Settings {
|
|
|
|
public:
|
|
|
|
Settings();
|
|
|
|
~Settings() {}
|
|
|
|
|
|
|
|
void SavePersistentData();
|
|
|
|
void SaveState();
|
|
|
|
|
|
|
|
/*inline const ChannelCalibrationData& calibration_data(int channel) const
|
|
|
|
{
|
|
|
|
return persistent_data_.channel_calibration_data[channel];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ChannelCalibrationData* mutable_calibration_data(int channel)
|
|
|
|
{
|
|
|
|
return &persistent_data_.channel_calibration_data[channel];
|
|
|
|
}*/
|
|
|
|
|
|
|
|
inline const State& state() const
|
|
|
|
{
|
|
|
|
return state_;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline State* mutable_state()
|
|
|
|
{
|
|
|
|
return &state_;
|
|
|
|
}
|
|
|
|
|
2020-02-24 23:25:00 +00:00
|
|
|
inline const PartData& part(int i) const
|
2020-02-24 00:53:33 +00:00
|
|
|
{
|
2020-02-24 23:25:00 +00:00
|
|
|
return state_.part_datas[i];
|
2020-02-24 00:53:33 +00:00
|
|
|
}
|
|
|
|
|
2020-02-24 23:25:00 +00:00
|
|
|
inline PartData* mutable_part(int i)
|
2020-02-24 00:53:33 +00:00
|
|
|
{
|
2020-02-24 23:25:00 +00:00
|
|
|
return &state_.part_datas[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_first_start() {
|
|
|
|
return this->first_start;
|
2020-02-24 00:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-02-24 23:25:00 +00:00
|
|
|
bool first_start;
|
2020-02-24 00:53:33 +00:00
|
|
|
PersistentData persistent_data_;
|
|
|
|
State state_;
|
|
|
|
|
|
|
|
stmlib::ChunkStorage<
|
2020-02-25 20:48:04 +00:00
|
|
|
0x08006000,
|
2020-02-24 00:53:33 +00:00
|
|
|
0x08008000,
|
|
|
|
PersistentData,
|
|
|
|
State>
|
|
|
|
chunk_storage_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Settings);
|
|
|
|
};
|