tcMenu
Loading...
Searching...
No Matches
AnalogMenuItem Class Reference

#include <MenuItems.h>

Inheritance diagram for AnalogMenuItem:
ValueMenuItem MenuItem

Public Member Functions

 AnalogMenuItem (const AnalogMenuInfo *info, uint16_t defaultVal, MenuItem *next=nullptr, bool infoInPgm=INFO_LOCATION_PGM)
int getOffset () const
int getStep () const
void setStep (int newStep)
uint16_t getDivisor () const
int unitNameLength () const
void copyUnitToBuffer (char *unitBuff, uint8_t size=5) const
void copyValue (char *buffer, uint8_t bufferSize) const
float getAsFloatingPointValue () const
void setFromFloatingPointValue (float value)
int getIntValueIncludingOffset ()
WholeAndFraction getWholeAndFraction () const
void setFromWholeAndFraction (WholeAndFraction wf)
uint8_t getDecimalPlacesForDivisor () const
uint16_t getActualDecimalDivisor () const
Public Member Functions inherited from ValueMenuItem
void setCurrentValue (uint16_t val, bool silent=false)
uint16_t getCurrentValue () const
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
MenuItemgetNext () const
void setNext (MenuItem *pNext)
void changeOccurred (bool silent)

Additional Inherited Members

Protected Member Functions inherited from ValueMenuItem
 ValueMenuItem (MenuType menuType, const AnyMenuInfo *info, uint16_t defaultVal, MenuItem *next, bool infoPgm)
Protected Member Functions inherited from MenuItem
 MenuItem (MenuType menuType, const AnyMenuInfo *menuInfo, MenuItem *next, bool infoProgMem)
Protected Attributes inherited from ValueMenuItem
uint16_t currentValue
Protected Attributes inherited from MenuItem
uint16_t flags
MenuItemnext
const AnyMenuInfoinfo = nullptr
RuntimeRenderingFn renderFn = nullptr
MenuType menuType

Detailed Description

An item that can represent a numeric value, integer, or decimal. On an 8bit Arduino this value is a 16 bit unsigned integer value. We can make it appear negative by giving a negative offset. We make it appear decimal by giving it a divisor. If the divisor were 2, we'd increment in halves. If the offset point were -100, unit dB and divisor 2, the first value would be -50.0dB and the next would be -49.5dB and so on. For convenience there are methods to convert between both floating point values and also fixed point (WholeAndFraction) values.

See also
AnalogMenuInfo

Constructor & Destructor Documentation

◆ AnalogMenuItem()

AnalogMenuItem::AnalogMenuItem ( const AnalogMenuInfo * info,
uint16_t defaultVal,
MenuItem * next = nullptr,
bool infoInPgm = INFO_LOCATION_PGM )
inline

Create an instance of the class

Parameters
infoan AnalogMenuInfo structure
defaultValthe default starting value
nextthe next menu in the chain if there is one, or NULL.

Member Function Documentation

◆ getOffset()

int AnalogMenuItem::getOffset ( ) const

Returns the offset from the MenuInfo structure

◆ getStep()

int AnalogMenuItem::getStep ( ) const
inline

Returns the step from the menu info structure

◆ setStep()

void AnalogMenuItem::setStep ( int newStep)
inline

Change the step for incremental updates, must be an exact multiple of max value

◆ getDivisor()

uint16_t AnalogMenuItem::getDivisor ( ) const

Returns the divisor from the menu info structure

◆ unitNameLength()

int AnalogMenuItem::unitNameLength ( ) const

Returns the length of the unit name

◆ copyUnitToBuffer()

void AnalogMenuItem::copyUnitToBuffer ( char * unitBuff,
uint8_t size = 5 ) const

copies the unit name into the provided buffer

◆ copyValue()

void AnalogMenuItem::copyValue ( char * buffer,
uint8_t bufferSize ) const

copies the whole value including unit into the buffer provided.

Parameters
bufferthe buffer to write the value into
bufferSizethe size of the buffer

◆ getAsFloatingPointValue()

float AnalogMenuItem::getAsFloatingPointValue ( ) const

returns the closest floating point representation of the value, note that floating point values are not always able to exactly represent a given value and may therefore be slightly out.

Returns
the nearest floating point value

◆ setFromFloatingPointValue()

void AnalogMenuItem::setFromFloatingPointValue ( float value)

Sets the menu item's current value to be the value provided in the float.

Parameters
valuethe new value.

◆ getWholeAndFraction()

WholeAndFraction AnalogMenuItem::getWholeAndFraction ( ) const

gets the whole and fraction part with the fractional part converted to decimal for ease of use. It based upon the divisor.

Returns
a structure containing the whole and fraction in decimal form

◆ setFromWholeAndFraction()

void AnalogMenuItem::setFromWholeAndFraction ( WholeAndFraction wf)

sets the menu based on the decimal whole and decimal fraction part. If decimal is true, the fraction is expected to be in decimal form (eg for halves it would be 0 or 5).

Parameters
wfthe whole fraction part.

◆ getDecimalPlacesForDivisor()

uint8_t AnalogMenuItem::getDecimalPlacesForDivisor ( ) const
Returns
the number of decimal places needed for the fraction part based on the divisor

◆ getActualDecimalDivisor()

uint16_t AnalogMenuItem::getActualDecimalDivisor ( ) const
Returns
the nearest decimal divisor based on the divisor.

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