EEPROMextent
Arduino EEPROM library
|
#include <EEPROM_ItemList.hpp>
Public Member Functions | |
EEPROM_ItemListClass () | |
void | begin (int inStartListPos, byte inItemSize, int inListSize) |
void | FreeItem (byte inSlotNumber) |
void | FreeOwnedItems (byte inOwnerSlotNumber) |
int | GetItemPos (byte inSlotNumber) |
int | GetItemPosRaw (byte inSlotNumber) |
byte | GetSlotFromPos (int inPosition) |
byte | GetItemType (byte inSlotNumber) |
byte | GetItemOwner (byte inSlotNumber) |
int | SaveItemPrefix (byte inSlotNumber, byte inType, byte inOwner) |
byte | GetFirstFreeSlot () |
byte | FindItem (byte inType, byte inStartSlotNumber = 0, byte inOwnerId = 255) |
byte | CountItems (byte inType) |
byte | CountOwnedItems (byte inOwnerId) |
void | clear () const |
This class can be used to save heterogeneous items form a hierarchical list..
The base of the data is a list of items of the same size in EEPROM. This size have to be the greatest size among all items to save. The list is initialized with the total size of memory dedicated to this list. The number of items which must be lower than 255, so the total size must be lower than (item size + 2) * 255 ! Each item is identified by a number, the slot number betw<een 0 and the maximum - 1 .
0 1 2 ... max +------+------+------+---------------+ |TPitem|TPitem|TPitem|........|TPitem| +------+------+------+--------+------+
Each item starts with a type on a byte (the 'T' in the schema). A type at 0 means empty slot. The following byte 'P' gives an optionnal parent slot number. A parent at 255 means no parent. And finaly, the item itself fill the rest of the 'slot' place. Parent and children can be separated and even saved in a random order...
|
inline |
Default constructor.
|
inline |
Initialize the instance.
inStartListPos | EEPROM address of the begginning of the memory used for the storage |
inItemSize | Size in bytes of one item to save. |
inListSize | Number of bytes of EEPROM used for the total list. |
void EEPROM_ItemListClass::clear | ( | ) | const |
Clears all the EEPROM memory area reserved for this list.
byte EEPROM_ItemListClass::CountItems | ( | byte | inType | ) |
Counts the used slot number.
inType | Counts all items of this type. 0 means all types. |
byte EEPROM_ItemListClass::CountOwnedItems | ( | byte | inOwnerId | ) |
Counts the children of the given item id.
inOwnerId | Parent id. |
byte EEPROM_ItemListClass::FindItem | ( | byte | inType, |
byte | inStartSlotNumber = 0 , |
||
byte | inOwnerId = 255 |
||
) |
Try to find an item according to its type.
inType | type of the item to find. |
inStartSlotNumber | Starting position for the research. Default 0. |
inOwnerId | Try to find a child of the given owner id. Default is 255, meaning no research by owner id. |
void EEPROM_ItemListClass::FreeItem | ( | byte | inSlotNumber | ) |
Reset the given slot and children to empty.
inSlotNumber | This slot will be declared as empty. If this item have children, there will be freed too. |
void EEPROM_ItemListClass::FreeOwnedItems | ( | byte | inOwnerSlotNumber | ) |
Reset all the children of the given slot to empty. The slot itself will not be freed.
inOwnerSlotNumber | Owner of the slots to free. |
byte EEPROM_ItemListClass::GetFirstFreeSlot | ( | ) |
Gets the first free slot number.
|
inline |
Gets the parent of the slot item.
inSlotNumber | slot to check. |
|
inline |
Gets the absolute EEPROM address for the given slot's item.
inSlotNumber | Slot number to check. |
|
inline |
Gets the absolute EEPROM address for the full given slot.
inSlotNumber | Slot number to check. |
|
inline |
Gets the type of the slot item.
inSlotNumber | slot to check. |
|
inline |
Gets the slot number from an absolute EEPROM address.
inPosition | EEPROM address. |
int EEPROM_ItemListClass::SaveItemPrefix | ( | byte | inSlotNumber, |
byte | inType, | ||
byte | inOwner | ||
) |
Save the prefix (bytes T and P) of this item.
inSlotNumber | slot to write. |
inType | type byte to write. |
inOwner | parent slot number to write, 255 if no parent. |