WidgetBool

Functions

inline BaseWidgetValue<bool> *WIDGET_BOOL(const bool value = false, const char *textOn = "ON", const char *textOff = "OFF", const char *format = "%s", const uint8_t cursorOffset = 0, void (*callback)(const bool&) = nullptr)

Function to create a new Widget<bool> object.

Parameters:
  • value – The initial enabled value (default is false)

  • textOn – The display text when value is true (default is “ON”)

  • textOff – The display text when value is false (default is “OFF”)

  • format – The format to display the value (default is “%s”)

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

  • callback – The callback function to execute when value changes (default is nullptr)

class WidgetBool : public BaseWidgetValue<bool>
#include <WidgetBool.h>

Widget that allows user to toggle between ON/OFF states. Manages a boolean value, allowing toggling between ‘ON’ and ‘OFF’ states.

Public Functions

inline WidgetBool(const bool value, const char *textOn, const char *textOff, const char *format, const uint8_t cursorOffset, void (*callback)(const bool&))
inline const char *getTextOn() const
inline const char *getTextOff() const

Protected Functions

inline virtual uint8_t draw(char *buffer, const uint8_t start) override

Draw the widget into specified buffer.

Parameters:
  • buffer – the buffer where widget will be drawn

  • start – the index where to start drawing in the buffer

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

Process command.

Handle commands:

  • ENTER - toggle value and trigger callback;

Returns:

true if command was handled, false otherwise

Protected Attributes

const char *textOn
const char *textOff