WidgetRange

Functions

template<typename T>
inline BaseWidgetValue<T> *WIDGET_RANGE(T value, T step, T min, T max, const char *format, uint8_t cursorOffset = 0, bool cycle = false, void (*callback)(const T&) = nullptr)

Function to create a new WidgetRange<T> instance.

Template Parameters:

T – The type of the value.

Parameters:
  • value – The initial value of the widget.

  • step – The step value for incrementing/decrementing.

  • min – The minimum value of the range.

  • max – The maximum value of the range.

  • format – The format string for displaying the value.

  • cursorOffset – The offset for the cursor (default is 0).

  • cycle – Whether the value should cycle when out of range (default is false).

  • callback – The callback function to call when the value changes (default is nullptr).

template<typename T>
class WidgetRange : public BaseWidgetValue<T>
#include <WidgetRange.h>

Widget that allows user to select a value from a range. Manages a value within a specified range, allowing incrementing and decrementing.

Public Functions

inline WidgetRange(const T &value, const T step, const T min, const T max, const char *format, const uint8_t cursorOffset = 0, const bool cycle = false, void (*callback)(const T&) = nullptr)
inline virtual void setValue(const T &newValue) override

Sets the value.

Note

You need to call LcdMenu::refresh after this method to see the changes.

Parameters:

newValue – The value to set.

Protected Functions

inline virtual bool process(LcdMenu *menu, const unsigned char command) override

Process command.

Handle commands:

  • UP - increment value and trigger callback;

  • DOWN - decrement value and trigger callback;

inline bool increment()

Increments the value. If the value exceeds maxValue and cycling is enabled, the value resets to minValue.

Returns:

true if incremented or reset (in case of cycle)

inline bool decrement()

Decrements the value. If the value falls below minValue and cycling is enabled, the value resets to maxValue.

Returns:

true if decremented or reset (in case of cycle)

Protected Attributes

const T step
const T minValue
const T maxValue
const bool cycle