|
| 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.
|
|
void | setlabel (const char *cstr) |
|
void | setCallback (void(*callback)(bool)) |
| Set the Callback function for the toggle switch.
|
|
void | invokeCallback (bool val) |
|
uint16_t | getBytes (uint8_t *out) override |
| Generates and returns the byte data representing the toggle switch configuration.
|
|
Represents a toggle switch UI element in the Bind framework.
BindSwitch
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.
- Note
- Possible cmdId values for a BindView and corresponding effects:
- BIND_ADD_OR_REFRESH_CMD: Adds the object to the canvas (screen) or refreshes the existing one.
- BIND_DATA_ONLY_CMD: Refreshes the existing object without moving or resizing; updates data, such as text.
- BIND_REMOVE_CMD: Removes the object from the canvas (screen).
- BIND_DISABLE_CMD: Disables the object.
- BIND_ENABLE_CMD: Enables the object.
- BIND_HIDE_CMD: Hides the object.
- BIND_VISIBLE_CMD: Restores the object's visibility.
Example usage:
- Create a toggle switch with specific settings.
- Set its position, label, and appearance properties.
- Register a callback function to handle state changes when users interact with the switch:
mySwitchObj.setCallback(mySwitchCallback)
.
- Synchronize the switch with the Bind framework using
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.
- See also
- Bind for more information on using Bind UI elements.