-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPersistentStorage.h
67 lines (56 loc) · 1.45 KB
/
PersistentStorage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @file PersistentStorage.h
* @author Ryan Johnson ([email protected])
* @brief An interface to write persistent data to the Adafruit FRAM I2C Module.
* @version 0.1
* @date 2020-05-26
*
* @copyright Copyright (c) 2020
*
*/
#ifndef PERSISTENT_STORAGE_H
#define PERSISTENT_STORAGE_H
#include "Adafruit_FRAM_I2C.h"
#include "InclinometerModel.h"
#include <Wire.h>
namespace PersistentStorage {
/**
* @brief PersistentStorage memory map
*/
typedef struct {
Inclinometer::ModelZeropoint zeroFrame1;
Inclinometer::ModelZeropoint zeroFrame2;
} Map;
/**
* @brief PersistentStorage memory manager
*/
class Manager {
public:
/**
* @brief Initializes the memory module
*
* @return true if the module successfully initialized
* @return false if the module did not successfully initialized
*/
bool begin() { return fram.begin(); };
/**
* @brief read the memory from persistent storage into the manager
*/
void readMap();
/**
* @brief write the memory from the manager into persistent storage
*/
void writeMap();
/**
* @brief Gets a pointer to the memory map that can be read or edited
* between readMap() and writeMap() operations.
*
* @return Map*
*/
Map *getMap() { return &storageMap; };
private:
Map storageMap;
Adafruit_FRAM_I2C fram;
};
}; // namespace PersistentStorage
#endif