Viking Skull Lamp
V1.0.1
|
Configuration Manager Class. More...
#include <configuration.hpp>
Classes | |
struct | configurationData_t |
Type for configTree element. More... | |
Public Member Functions | |
configurationManager (configurationData_t *configTree_p, uint8_t configTreeSize_p) | |
Constructor. More... | |
void | saveConfig () |
Save configuration to EEPROM. More... | |
bool | loadConfig () |
Load configuration from EEPROM. More... | |
Private Member Functions | |
void | crcFeed (uint8_t data) |
Maxim like crc-8. More... | |
Private Attributes | |
configurationData_t * | configTree = NULL |
Pointer to configTree. More... | |
uint8_t | configTreeSize = 0 |
configTree size. More... | |
uint8_t | crc = 0xff |
Calculated CRC. More... | |
Configuration Manager Class.
This class handles the saving and loading any type of data. The data has to be specified in an array called configTree. You can use the createData macro to simplify the configTree creation.
Definition at line 45 of file configuration.hpp.
configurationManager::configurationManager | ( | configurationData_t * | configTree_p, |
uint8_t | configTreeSize_p | ||
) |
Constructor.
configTree_p | Pointer to the configTree. |
configTreeSize_p | Size of the configTree. |
Definition at line 32 of file configuration.cpp.
|
private |
Maxim like crc-8.
Definition at line 159 of file configuration.cpp.
bool configurationManager::loadConfig | ( | ) |
Load configuration from EEPROM.
Typically you should call this at startup. It loads the previously saved configuration from the EEPROM to the elements in the configTree. The function calculates a CRC from the stored data and compare it with a stored CRC. If they doesn't match, that means the saved data has corrupted( or the EEPROM was empty ). In this case it wont update the elements in the configTree with the wrong values.
Definition at line 90 of file configuration.cpp.
void configurationManager::saveConfig | ( | ) |
Save configuration to EEPROM.
You shall call this when you have changed some of the elements value in the configTree. The function generates a CRC and store it as well, to detect data corruption.
Definition at line 40 of file configuration.cpp.
|
private |
Pointer to configTree.
Definition at line 93 of file configuration.hpp.
|
private |
configTree size.
Definition at line 96 of file configuration.hpp.
|
private |
Calculated CRC.
Definition at line 99 of file configuration.hpp.