Anniversary Sale · up to 80% off all librariesEnds Nov 9Shop now
SOFTTDocs
Cards

Feedback Card

Display a status message with an info, success, warning or danger indicator using dash::FeedbackCard.

The feedback card displays a text message together with a status indicator. Use it to report system state, the result of an operation, warnings or errors.

Feedback card with no status
Feedback card with info status
Feedback card with warning status
Feedback card with success status
Feedback card with danger status

Constructor

dash::FeedbackCard<T> card(dashboard, name, initialStatus, initialMessage);

Prop

Type

Template parameters:

Prop

Type

dash::FeedbackCard<const char*> feedback(dashboard, "Status");
dash::FeedbackCard<dash::string> network(dashboard, "Network", dash::Status::INFO, "Connecting");

An overload without the dashboard argument creates the card without attaching it to a dashboard; attach it later with dashboard.add(card).

Status values

ValueMeaning
dash::Status::NONENo status indicator (default).
dash::Status::INFOInformational message.
dash::Status::SUCCESSOperation completed successfully.
dash::Status::WARNINGWarning condition.
dash::Status::DANGERError or critical failure.

Methods

setFeedback()

bool setFeedback(const char* message, dash::Status status);
bool setFeedback(const dash::string& message, dash::Status status); // T = dash::string only

Sets the message and the status in one call. Returns true if either changed.

feedback.setFeedback("Light is on", dash::Status::SUCCESS);

setMessage()

bool setMessage(const char* message);
bool setMessage(const dash::string& message); // T = dash::string only

Sets the message and keeps the current status. Returns true if the message changed.

setStatus()

bool setStatus(dash::Status status);

Sets the status and keeps the current message. Returns true if the status changed.

status()

dash::Status status() const;

Returns the current status.

value()

const T& value() const;

Returns the current message. Call it only when hasValue() returns true; the constructor always sets a message, so this holds unless you call removeValue().

Example

main.cpp
#include <Arduino.h>
#include <WiFi.h>              // ESP32; use the networking headers for your board
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ESPDash.h>

AsyncWebServer server(80);
ESPDash dashboard(server);

dash::FeedbackCard<const char*> feedback(dashboard, "Status");

void setup() {
  // ... connect to Wi-Fi
  server.begin();

  feedback.setFeedback("System ready", dash::Status::SUCCESS);
  dashboard.sendUpdates();
}

void loop() {
  if (WiFi.RSSI() < -80) {
    feedback.setFeedback("Weak Wi-Fi signal", dash::Status::WARNING);
  } else {
    feedback.setFeedback("System ready", dash::Status::SUCCESS);
  }
  dashboard.sendUpdates();
  delay(3000);
}

Notes

  • With T = const char*, the card stores the pointer and does not copy the string. Pass string literals or buffers that outlive the card. Use dash::string for messages built at runtime.

On this page