Push Button Card
This feature is only available in ESP-DASH Pro
The Push Button Card triggers a callback on every user click. Stateless, no value is sent back to the dashboard.
Initializer
To create a push button card in ESP-DASH v5, use the dash::PushButtonCard class.
dash::PushButtonCard pushbtn(dashboard, "Push Button");Callback
Register a callback function to be called when the button is pressed:
pushbtn.onPush([]() {
// Handle button press
Serial.println("Push Button Triggered");
});Methods
💡
Push button cards do not maintain state or value. They simply trigger a callback when pressed.
setValue(T value)
Set the push button value. The type of value must match the template type you chose for T (e.g., int, bool).
pushbtn.setValue(value); // value is of type T- Signature:
void setValue(T value) - Parameters:
T value— The value to set (type matches template parameterT).
- Returns:
void
Note:
Tcan be one of:intorbooldepending on how you instantiate the card.
Reference
// ...
dash::PushButtonCard pushbtn(dashboard, "Push Button");
void setup() {
// ...
// Register callback for button press
pushbtn.onPush([]() {
Serial.println("Push Button Triggered");
// Perform action here
});
}
void loop() {
// ...
}Last updated on