CardsPush Button

Push Button Card

This feature is only available in ESP-DASH Pro
Push Button Card Preview

An interactive button component that triggers a callback function on user click. Provides a stateless push button interface for executing actions directly from the dashboard.

Initializer

/* 
  Push Button Card
  Valid Arguments: (ESPDash dashboard, Card Type, const char* name)
*/
Card card1(&dashboard, PUSH_BUTTON_CARD, "Push Button");

Callback

Push button card will trigger a callback on every click by user, there is no need to update or sendUpdates to dashboard because there is no state.

/*
  We provide our attachCallback with a lambda function to handle trigger
*/
card1.attachCallback([&](){
  Serial.println("[Card1] Push Button Triggered");
});

Updater

💡

Push button card doesn’t require any updater as value is not passed back to dashboard.


Reference

This is a reference sketch showing positions for intializer and callback.

 
...
 
/* Push button card initializer */
Card pushbtn(&dashboard, PUSH_BUTTON_CARD, "Push Button");
 
 
void setup() {
  ...
 
  /* Push button card callback */
  pushbtn.attachCallback([&](){
    Serial.println("Push Button Callback Triggered");
  });
}
 
void loop() {
  ...
}
 
Copyright © 2024 Softt. All rights reserved.