#include <ScrollChoiceMenuItem.h>
Public Types | |
enum | EnumMemMode : uint8_t { MEMORY_ONLY , EEPROM_BASED , CUSTOM } |
Public Member Functions | |
ScrollChoiceMenuItem (int id, RuntimeRenderingFn renderFn, uint8_t currentSel, const char *enumItemsInRam, int itemSize, int numberOfItems, MenuItem *next=nullptr) | |
ScrollChoiceMenuItem (uint16_t id, RuntimeRenderingFn renderFn, uint8_t currentSel, EepromPosition eepromStart, int itemSize, int numberOfItems, MenuItem *next=nullptr) | |
ScrollChoiceMenuItem (uint16_t id, RuntimeRenderingFn renderFn, uint8_t currentSel, int numberOfItems, MenuItem *next=nullptr) | |
ScrollChoiceMenuItem (const AnyMenuInfo *info, uint8_t currentSel, const char *enumItemsInRam, int itemSize, int numberOfItems, MenuItem *next=nullptr, bool isPgm=INFO_LOCATION_PGM) | |
ScrollChoiceMenuItem (const AnyMenuInfo *info, uint8_t currentSel, EepromPosition eepromStart, int itemSize, int numberOfItems, MenuItem *next=nullptr, bool isPgm=INFO_LOCATION_PGM) | |
ScrollChoiceMenuItem (const AnyMenuInfo *info, RuntimeRenderingFn renderFn, uint8_t currentSel, int numberOfItems, MenuItem *next=nullptr, bool isPgm=INFO_LOCATION_PGM) | |
void | cacheEepromValues () |
void | valueAtPosition (char *buffer, size_t bufferSize, int idx) |
void | setCurrentValue (int val, bool silent=false) |
int | getEepromStart () const |
int | getItemWidth () const |
EnumMemMode | getMemMode () const |
int | getCurrentValue () |
void | copyTransportText (char *string, size_t i) |
void | setFromRemote (const char *buffer) |
Public Member Functions inherited from RuntimeMenuItem | |
RuntimeMenuItem (MenuType menuType, menuid_t id, RuntimeRenderingFn renderFn, uint8_t itemPosition, uint8_t numberOfRows, MenuItem *next=nullptr) | |
RuntimeMenuItem (const AnyMenuInfo *rtInfo, bool isPgm, MenuType menuType, RuntimeRenderingFn renderFn, uint8_t itemPosition, uint8_t numberOfRows, MenuItem *next=nullptr) | |
void | copyValue (char *buffer, int bufferSize) const |
void | runCallback () const |
int | getRuntimeId () const |
int | getRuntimeEeprom () const |
uint8_t | getNumberOfParts () const |
void | copyRuntimeName (char *buffer, int bufferSize) const |
uint8_t | getNumberOfRows () const |
uint8_t | getItemPosition () const |
void | setNumberOfRows (uint8_t rows) |
Public Member Functions inherited from MenuItem | |
uint8_t | copyNameToBuffer (char *sz, int size) const |
uint8_t | copyNameToBuffer (char *sz, int offset, int size) const |
menuid_t | getId () const |
uint16_t | getMaximumValue () const |
uint16_t | getEepromPosition () const |
MenuType | getMenuType () const |
void | triggerCallback () const |
bool | isInfoProgMem () const |
void | setChanged (bool changed) |
void | setChanged (int num, bool changed) |
bool | isChanged (int num=0) const |
bool | isSendRemoteNeeded (uint8_t remoteNo) const |
void | setSendRemoteNeededAll () |
void | clearSendRemoteNeededAll () |
void | setSendRemoteNeeded (uint8_t remoteNo, bool needed) |
void | setReadOnly (bool active) |
bool | isReadOnly () const |
void | setLocalOnly (bool localOnly) |
bool | isLocalOnly () const |
void | setSecured (bool secured) |
bool | isSecured () const |
void | setVisible (bool visible) |
bool | isVisible () const |
MenuItem * | getNext () const |
void | setNext (MenuItem *pNext) |
void | changeOccurred (bool silent) |
Additional Inherited Members | |
Protected Member Functions inherited from MenuItem | |
MenuItem (MenuType menuType, const AnyMenuInfo *menuInfo, MenuItem *next, bool infoProgMem) | |
Protected Attributes inherited from RuntimeMenuItem | |
menuid_t | id |
uint8_t | itemPosition |
uint8_t | noOfParts |
Protected Attributes inherited from MenuItem | |
uint16_t | flags |
MenuItem * | next |
const AnyMenuInfo * | info = nullptr |
RuntimeRenderingFn | renderFn = nullptr |
MenuType | menuType |
An item that can represent a series of values that is too large, changes at runtime, or otherwise cannot be described by an EnumMenuItem. Imagine for example a DAB radio preset selector or the tracks on a CD, or a range of values that are taken from EEPROM.
There are three default ways in which you can use it, and these are described breifly below. In any of the cases, this menu item is completely dynamic, and the number of items and values can change at runtime. The modes of operation are as follows:
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | int | id, |
RuntimeRenderingFn | renderFn, | ||
uint8_t | currentSel, | ||
const char * | enumItemsInRam, | ||
int | itemSize, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr |
||
) |
Create an enum menu item that has values directly in RAM. The items are stored in ram in an equally spaced array. In this case you are responsible for the memory that makes up the array.
id | the ID of the item |
renderFn | the function that will do the rendering, enumItemRenderFn is the default |
currentSel | the currently selected item |
enumItemsInRam | the array of items, where each item is of itemSize length |
itemSize | the size of each item |
numberOfItems | the number of items |
next | optional pointer to next item |
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | uint16_t | id, |
RuntimeRenderingFn | renderFn, | ||
uint8_t | currentSel, | ||
EepromPosition | eepromStart, | ||
int | itemSize, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr |
||
) |
Create a choice menu item that scrolls through available values. Use this constructor to store the values in EEPROM stoage. This uses a flat array where each item is itemSize. So item 0 would be at eemproStart and item 1 would be at eepromStart + itemSize.. Further, it can be cached into memory using cacheEepromValues(), calling this again, will refresh the cache. Before using this you must call menuMgr.setEepromRef(..) to initialise the EEPROM object that should be used.
id | the ID of the item |
renderFn | the function that will do the rendering, enumItemRenderFn is the default |
currentSel | |
eepromStart | the start location in eeprom of the array |
itemSize | the size of each item |
numberOfItems | the number of items to start with |
next | optional pointer to next item |
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | uint16_t | id, |
RuntimeRenderingFn | renderFn, | ||
uint8_t | currentSel, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr |
||
) |
Create a choice menu item that scrolls through available values. Use this constructor to provide the values manually using a runtime menu callback, this is the most flexible method but requires extra coding.
id | the ID of the item |
renderFn | the function that will do the rendering, enumItemRenderFn is the default |
currentSel | the currently selected choice |
numberOfItems | the number of choices |
next | optional pointer to next item |
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | const AnyMenuInfo * | info, |
uint8_t | currentSel, | ||
const char * | enumItemsInRam, | ||
int | itemSize, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr , |
||
bool | isPgm = INFO_LOCATION_PGM |
||
) |
Create an enum menu item that has values directly in RAM. The items are stored in ram in an equally spaced array. In this case you are responsible for the memory that makes up the array.
info | the block of static data |
currentSel | the currently selected item |
enumItemsInRam | the array of items, where each item is of itemSize length |
itemSize | the size of each item |
numberOfItems | the number of items |
next | optional pointer to next item |
isPgm | optional the memory location of the info block (default prog-mem) |
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | const AnyMenuInfo * | info, |
uint8_t | currentSel, | ||
EepromPosition | eepromStart, | ||
int | itemSize, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr , |
||
bool | isPgm = INFO_LOCATION_PGM |
||
) |
Create a choice menu item that scrolls through available values. Use this constructor to store the values in EEPROM stoage. This uses a flat array where each item is itemSize. So item 0 would be at eemproStart and item 1 would be at eepromStart + itemSize.. Further, it can be cached into memory using cacheEepromValues(), calling this again, will refresh the cache. Before using this you must call menuMgr.setEepromRef(..) to initialise the EEPROM object that should be used.
info | the block of static data |
currentSel | the currently selected item |
eepromStart | the start location in eeprom of the array |
itemSize | the size of each item |
numberOfItems | the number of items to start with |
next | optional pointer to next item |
isPgm | optional the memory location of the info block (default prog-mem) |
ScrollChoiceMenuItem::ScrollChoiceMenuItem | ( | const AnyMenuInfo * | info, |
RuntimeRenderingFn | renderFn, | ||
uint8_t | currentSel, | ||
int | numberOfItems, | ||
MenuItem * | next = nullptr , |
||
bool | isPgm = INFO_LOCATION_PGM |
||
) |
Create a choice menu item that scrolls through available values. Use this constructor to provide the values manually using a runtime menu callback, this is the most flexible method but requires extra coding.
info | the block of static data |
renderFn | the function that will do the rendering, enumItemRenderFn is the default |
currentSel | the currently selected choice |
numberOfItems | the number of choices |
next | optional pointer to next item |
isPgm | optional the memory location of the info block (default prog-mem) |
void ScrollChoiceMenuItem::cacheEepromValues | ( | ) |
For EEPROM based items you can choose to cache the values in RAM, the total size should not exceed 256 bytes.
void ScrollChoiceMenuItem::valueAtPosition | ( | char * | buffer, |
size_t | bufferSize, | ||
int | idx | ||
) |
Get the string value at a given index
buffer | the buffer area |
bufferSize | size of the buffer |
idx | the index to copy |
void ScrollChoiceMenuItem::setCurrentValue | ( | int | val, |
bool | silent = false |
||
) |
Set the current choice to the new value
val | the new value |
silent | if you do not want the callbacks to trigger. |
|
inline |