Represents a toggle switch UI element in the Bind framework. More...
#include <BindSwitch.hpp>
Public Member Functions | |
BindSwitch (const char *cstr) | |
Constructor to create a BindSwitch with a custom label. | |
BindSwitch () | |
Default constructor to create a BindSwitch with a default label ("Switch"). | |
void | setlabel (const char *cstr) |
Sets the label text for the toggle switch. | |
uint16_t | getBytes (uint8_t *out) override |
Generates and returns the byte data representing the toggle switch configuration. | |
Public Attributes | |
int16_t | x |
X-coordinate position of the toggle switch. | |
int16_t | y |
Y-coordinate position of the toggle switch. | |
uint8_t | cmdId = 0 |
Command identifier. See the notes for possible cmdId values. | |
bool | switchValue |
The current state (ON/OFF) of the toggle switch. | |
int16_t | fontSize |
Font size for the switch label. | |
int32_t | textColor |
Text color for the switch label. | |
![]() | |
int16_t | tag |
Represents a toggle switch UI element in the Bind framework.
The BindSwitch
class allows you to create toggle switch UI elements within your Arduino projects to be shown in BindCanvas. You can customize the appearance and behavior of the switch, such as its position, label text, size, and colors. Users can interact with the switch to toggle its state, and you can capture and respond to these state changes.
Example usage:
bind.sync(&mySwitchObj)
to enable user interactions.Note: To receive touch events and user interactions, you must regularly call bind.sync()
in your main loop.
|
inline |
Constructor to create a BindSwitch
with a custom label.
cstr | The label text for the toggle switch. |
|
inlineoverridevirtual |
Generates and returns the byte data representing the toggle switch configuration.
This function is meant for internal use by the Bind framework and should not be called directly by users. It serializes the toggle switch's properties into a byte array for communication with the Bind framework.
out | Pointer to the output byte array. |
Reimplemented from BindView.
|
inline |
Sets the label text for the toggle switch.
cstr | The label text for the toggle switch. |