Base class to wrap an EEPROM variable. More...
#include <EEPROM-Base.h>
Public Member Functions | |
EEPROMBase (const uint address) | |
Initialize an instance of EEPROMBase<T> with the specified address. | |
EEPROMBase (const uint address, T defaultValue) | |
Initialize an instance of EEPROMBase with the specified address and default value. | |
operator T () | |
Implicitly converts the class instance to the value of type T. This allows the variable to be used on the right side of the equal sign. | |
byte | operator[] (const uint index) |
Treating the variable as a byte array, get the byte at position index where index is between 0 and length. | |
T | operator++ (int) |
Postfix increment operator. | |
T | operator++ () |
Prefix increment operator. | |
T | operator-- (int) |
Postfix decrement operator. | |
T | operator-- () |
Postfix decrement operator. | |
T | operator+= (T const &value) |
Addition assignment operator. | |
T | operator-= (T const &value) |
Subtraction assignment operator. | |
T | operator*= (T const &value) |
Multiplication assignment operator. | |
T | operator/= (T const &value) |
Division assignment operator. | |
T | operator^= (T const &value) |
Bitwise XOR assignment operator. | |
T | operator%= (T const &value) |
Modulus assignment operator. | |
T | operator&= (T const &value) |
Bitwise AND assignment operator. | |
T | operator|= (T const &value) |
Bitwise OR assignment operator. | |
T | operator<<= (T const &value) |
Bitwise left shift assignment operator. | |
T | operator>>= (T const &value) |
Bitwise right shift assignment operator. | |
virtual T | get () const |
Get the variable value. | |
virtual T | set (T const &value) |
Set the variable value. | |
T | read () const |
Read the variable value from the EEPROM using the address in this variable. | |
void | write (T const &value) const |
Write the value to the EEPROM using the address in this instance. | |
bool | isInitialized () const |
Checks whether the EEPROM variable has been initialized. | |
uint | length () const |
Returns the number of EEPROM bytes used. | |
uint | size () const |
Returns the number of EEPROM bytes used by T. | |
void | unset (byte unsetValue=UNSET_VALUE) |
Unset the variable. | |
uint | checksumAddress () const |
Gets the address of the checksum byte in EEPROM for this variable. | |
byte | checksumByte () const |
Gets the stored checksum byte. | |
byte | checksum () const |
Calculate the checksum of the data in the EEPROM for this instance. | |
void | copyTo (byte *data, uint length) const |
Copy the EEPROM bytes of this instance to a byte array. | |
uint | getAddress () const |
Get the EEPROM address of the variable. | |
uint | nextAddress () const |
Gets the next EEPROM address after this variable. | |
T | getDefaultValue () const |
Gets the default value for this instance. | |
Protected Member Functions | |
byte | computeChecksum (T value) |
Computes the checksum of the given value. | |
uint | normalizeAddress (uint address) const |
Normalize the given EEPROM address to ensure it is within valid range. | |
Protected Attributes | |
uint | _address = 0 |
The address of this variable in the EEPROM. | |
T | _defaultValue |
The default value. | |
Base class to wrap an EEPROM variable.
This class contains the methods and properties to allow reading and writing EEPROM, storing the location of the variable (address), calculating, storing and comparing the variable checksum, computing the next address for subsequent EEPROM variables, standard operator functionality, and implicit conversion to the value type from the class instance.
T | The type of the variable stored. |
Definition at line 53 of file EEPROM-Base.h.
|
inline |
Initialize an instance of EEPROMBase<T> with the specified address.
address | The address (or index) of the variable within EEPROM. |
Definition at line 60 of file EEPROM-Base.h.
|
inline |
Initialize an instance of EEPROMBase with the specified address and default value.
address | The address (or index) of the variable within EEPROM. |
defaultValue | The default value returned when the variable has not been initialized. |
Definition at line 70 of file EEPROM-Base.h.
|
inline |
Calculate the checksum of the data in the EEPROM for this instance.
Definition at line 386 of file EEPROM-Base.h.
|
inline |
Gets the address of the checksum byte in EEPROM for this variable.
Definition at line 368 of file EEPROM-Base.h.
|
inline |
Gets the stored checksum byte.
Definition at line 377 of file EEPROM-Base.h.
|
protected |
Computes the checksum of the given value.
value | The value to compute the checksum for. |
|
inline |
Copy the EEPROM bytes of this instance to a byte array.
Definition at line 394 of file EEPROM-Base.h.
|
inlinevirtual |
Get the variable value.
Reimplemented in EEPROMCache< T >, and EEPROMStorage< T >.
Definition at line 242 of file EEPROM-Base.h.
|
inline |
Get the EEPROM address of the variable.
Definition at line 407 of file EEPROM-Base.h.
|
inline |
Gets the default value for this instance.
Definition at line 426 of file EEPROM-Base.h.
|
inline |
Checks whether the EEPROM variable has been initialized.
Determines if the variable has been initialized by comparing the stored checksum to the actual checksum of the bytes stored.
Definition at line 318 of file EEPROM-Base.h.
|
inline |
Returns the number of EEPROM bytes used.
Returns the number of EEPROM bytes used by this instance including the checksum byte.
Definition at line 328 of file EEPROM-Base.h.
|
inline |
Gets the next EEPROM address after this variable.
This can be used to set the address of another EEPROM variable.
Definition at line 417 of file EEPROM-Base.h.
|
inlineprotected |
Normalize the given EEPROM address to ensure it is within valid range.
address | The address to normalize. |
Definition at line 458 of file EEPROM-Base.h.
|
inline |
Implicitly converts the class instance to the value of type T. This allows the variable to be used on the right side of the equal sign.
Definition at line 80 of file EEPROM-Base.h.
|
inline |
Modulus assignment operator.
value | The value to mod with. |
Definition at line 193 of file EEPROM-Base.h.
|
inline |
Bitwise AND assignment operator.
value | The value to AND with. |
Definition at line 203 of file EEPROM-Base.h.
|
inline |
Multiplication assignment operator.
value | The value to multiply by. |
Definition at line 163 of file EEPROM-Base.h.
|
inline |
Prefix increment operator.
Definition at line 113 of file EEPROM-Base.h.
|
inline |
Postfix increment operator.
Definition at line 102 of file EEPROM-Base.h.
|
inline |
Addition assignment operator.
value | The value to add. |
Definition at line 143 of file EEPROM-Base.h.
|
inline |
Postfix decrement operator.
Definition at line 133 of file EEPROM-Base.h.
|
inline |
Postfix decrement operator.
Definition at line 122 of file EEPROM-Base.h.
|
inline |
Subtraction assignment operator.
value | The value to subtract. |
Definition at line 153 of file EEPROM-Base.h.
|
inline |
Division assignment operator.
value | The value to divide by. |
Definition at line 173 of file EEPROM-Base.h.
|
inline |
Bitwise left shift assignment operator.
value | The value to shift by. |
Definition at line 223 of file EEPROM-Base.h.
|
inline |
Bitwise right shift assignment operator.
value | The value to shift by. |
Definition at line 233 of file EEPROM-Base.h.
|
inline |
Treating the variable as a byte array, get the byte at position index where index is between 0 and length.
index | The index position. |
Definition at line 92 of file EEPROM-Base.h.
|
inline |
Bitwise XOR assignment operator.
value | The value to XOR with. |
Definition at line 183 of file EEPROM-Base.h.
|
inline |
Bitwise OR assignment operator.
value | The value to OR with. |
Definition at line 213 of file EEPROM-Base.h.
|
inline |
Read the variable value from the EEPROM using the address in this variable.
Definition at line 264 of file EEPROM-Base.h.
|
inlinevirtual |
Set the variable value.
value | The new value to store in EEPROM. |
Reimplemented in EEPROMCache< T >, and EEPROMStorage< T >.
Definition at line 255 of file EEPROM-Base.h.
|
inline |
Returns the number of EEPROM bytes used by T.
Returns the number of EEPROM bytes used by this instance NOT including the checksum byte.
Definition at line 342 of file EEPROM-Base.h.
|
inline |
Unset the variable.
Change the EEPROM values back to UNSET_VALUE as if the variable has never been written to the EEPROM. The isInitialized() method will return false.
Definition at line 355 of file EEPROM-Base.h.
|
inline |
Write the value to the EEPROM using the address in this instance.
value | The new value to store in EEPROM. |
Definition at line 296 of file EEPROM-Base.h.
|
protected |
The address of this variable in the EEPROM.
This variable cannot/will not be modified after instantiation.
Definition at line 436 of file EEPROM-Base.h.
|
protected |
The default value.
The default value to return when the EEPROM has not been initialized. The address of this variable in the EEPROM. This variable cannot/will not be modified after instantiation.
Definition at line 444 of file EEPROM-Base.h.