Air Card

This feature is only available in ESP-DASH Pro

The Air Card displays atmospheric pressure values.
Initializer
To create an air card in ESP-DASH v5, use the dash::AirCard<T, Precision>
class. The template parameters allow you to control the value type and decimal precision:
T
: Value type (e.g., float, int)Precision
: Number of decimal places for floating point values (default: 2)
Example 1: Float value, default precision (2 decimals)
dash::AirCard<float> air(dashboard, "Pressure");
Example 2: Float value, custom precision (3 decimals)
dash::AirCard<float, 3> air3(dashboard, "Pressure", "kPa");
Example 3: Integer value
dash::AirCard<int> airInt(dashboard, "Pressure", "Pa");
Methods
setValue(T value)
Set the air quality value. The type of value
must match the template type you chose for T
(e.g., int, float).
air.setValue(value); // value is of type T
- Signature:
void setValue(T value)
- Parameters:
T value
— The value to display (type matches template parameterT
).
- Returns:
void
value()
Get the current air quality value. The return type matches your template type for T
(e.g., int, float).
T v = air.value();
- Signature:
T value()
- Parameters: None
- Returns:
T
— The current value displayed by the card (type matches template parameterT
).
Note:
T
can be one of:int
orfloat
depending on how you instantiate the card.
setUnit(const char* unit)
Set the unit or symbol for the air card (e.g., “hPa”, “kPa”).
air.setUnit("kPa");
- Signature:
void setUnit(const char* unit)
- Parameters:
const char* unit
— The unit or symbol to display.
- Returns:
void
unit()
Get the current unit or symbol for the air card.
const char* unit = air.unit();
- Signature:
const char* unit()
- Parameters: None
- Returns:
const char*
— The current unit or symbol for the card.
Reference
Below is a reference code showing how to integrate this widget in a real project, including initialization and value updates usage.
// ...
// Create an air card (float, 2 decimals by default)
dash::AirCard<float> airCard(dashboard, "Pressure", "hPa");
void setup() {
// ...
airCard.setValue(1013.25f);
airCard.setUnit("hPa");
}
void loop() {
// ...
}
Last updated on