Viking Skull Lamp  V1.0.1
Loading...
Searching...
No Matches
configurationManager Class Reference

Configuration Manager Class. More...

#include <configuration.hpp>

Collaboration diagram for configurationManager:
[legend]

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_tconfigTree = NULL
 Pointer to configTree. More...
 
uint8_t configTreeSize = 0
 configTree size. More...
 
uint8_t crc = 0xff
 Calculated CRC. More...
 

Detailed Description

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.

See also
createData

Definition at line 45 of file configuration.hpp.

Constructor & Destructor Documentation

◆ configurationManager()

configurationManager::configurationManager ( configurationData_t configTree_p,
uint8_t  configTreeSize_p 
)

Constructor.

Parameters
configTree_pPointer to the configTree.
configTreeSize_pSize of the configTree.

Definition at line 32 of file configuration.cpp.

Member Function Documentation

◆ crcFeed()

void configurationManager::crcFeed ( uint8_t  data)
private

Maxim like crc-8.

Definition at line 159 of file configuration.cpp.

Here is the caller graph for this function:

◆ loadConfig()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveConfig()

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.

Note
You can call this every time when some key parameter changes. It will only write the EEPROM if something actually changed.

Definition at line 40 of file configuration.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ configTree

configurationData_t* configurationManager::configTree = NULL
private

Pointer to configTree.

Definition at line 93 of file configuration.hpp.

◆ configTreeSize

uint8_t configurationManager::configTreeSize = 0
private

configTree size.

Definition at line 96 of file configuration.hpp.

◆ crc

uint8_t configurationManager::crc = 0xff
private

Calculated CRC.

Definition at line 99 of file configuration.hpp.