tcMenu
Public Types | Public Member Functions | List of all members
ScrollChoiceMenuItem Class Reference

#include <ScrollChoiceMenuItem.h>

Inheritance diagram for ScrollChoiceMenuItem:
RuntimeMenuItem MenuItem

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)
 
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)
 
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
 
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)
 
bool isChanged () const
 
bool isSendRemoteNeeded (uint8_t remoteNo) const
 
void setSendRemoteNeededAll ()
 
void clearSendRemoteNeededAll ()
 
void setSendRemoteNeeded (uint8_t remoteNo, bool needed)
 
void setActive (bool active)
 
bool isActive () const
 
void setEditing (bool active)
 
bool isEditing () const
 
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
 
MenuItemgetNext () const
 
void setNext (MenuItem *next)
 
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
 
MenuItemnext
 
union {
const AnyMenuInfoinfo
 
RuntimeRenderingFn renderFn
 
}; 
 
MenuType menuType
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ ScrollChoiceMenuItem() [1/3]

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.

Parameters
idthe ID of the item
renderFnthe function that will do the rendering, enumItemRenderFn is the default
currentSelthe currently selected item
enumItemsInRamthe array of items, where each item is of itemSize length
itemSizethe size of each item
numberOfItemsthe number of items
nextoptional pointer to next item

◆ ScrollChoiceMenuItem() [2/3]

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.

Parameters
idthe ID of the item
renderFnthe function that will do the rendering, enumItemRenderFn is the default
currentSel
eepromStartthe start location in eeprom of the array
itemSizethe size of each item
numberOfItemsthe number of items to start with
nextoptional pointer to next item

◆ ScrollChoiceMenuItem() [3/3]

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.

Parameters
idthe ID of the item
renderFnthe function that will do the rendering, enumItemRenderFn is the default
currentSelthe currently selected choice
numberOfItemsthe number of choices
nextoptional pointer to next item

Member Function Documentation

◆ cacheEepromValues()

void ScrollChoiceMenuItem::cacheEepromValues ( )

For EEPROM based items you can choose to cache the values in RAM, the total size should not exceed 256 bytes.

◆ valueAtPosition()

void ScrollChoiceMenuItem::valueAtPosition ( char *  buffer,
size_t  bufferSize,
int  idx 
)

Get the string value at a given index

Parameters
bufferthe buffer area
bufferSizesize of the buffer
idxthe index to copy

◆ setCurrentValue()

void ScrollChoiceMenuItem::setCurrentValue ( int  val,
bool  silent = false 
)

Set the current choice to the new value

Parameters
valthe new value
silentif you do not want the callbacks to trigger.

◆ getCurrentValue()

int ScrollChoiceMenuItem::getCurrentValue ( )
inline
Returns
integer of the current choice

The documentation for this class was generated from the following files: