Docs
Table
The Table widget shows rows of name and value. Your board adds, updates and removes them.
Use it for: several sensors in one list, an event log, a list of devices, the last readings with their timestamps.
| Setting | What it does |
|---|---|
| Pin | the virtual pin your code writes to |
| Reorder | let the user drag rows |
| Selection | let the user tick rows, which calls back to your sketch |
Open these from the canvas: tap Edit, then long press the widget and choose Configure.
Example
Three sensors in one table, refreshed every ten seconds.
#include <PlynxSimpleEsp32.h>
WidgetTable table(V23);
PlynxTimer timer;
void updateTable()
{
table.clear();
table.addRow(0, "Living room", analogRead(34) * (3.3 / 4095.0) * 100.0);
table.addRow(1, "Bedroom", analogRead(35) * (3.3 / 4095.0) * 100.0);
table.addRow(2, "Outside", analogRead(36) * (3.3 / 4095.0) * 100.0);
}
void setup()
{
Serial.begin(115200);
// Auto setup: WiFi and the Plynx token are configured from the app.
//
// To provide them directly in the sketch instead, use:
// Plynx.begin(auth, ssid, pass);
Plynx.begin();
timer.setInterval(10000L, updateTable);
}
void loop()
{
Plynx.run();
timer.run();
} table.addRow(index, name, value) adds a row. table.updateRow() changes one
already there, which sends less traffic than clearing and rebuilding.
Rebuilding the whole table every time is simple and fine for a few rows. Above ten, update the rows that changed.
Reacting to taps
With selection on, ticking a row calls back into your sketch:
void onSelect(int index, bool selected)
{
Serial.print("Row ");
Serial.print(index);
Serial.println(selected ? " selected" : " deselected");
}
void setup()
{
// ...
table.onSelectChange(onSelect);
} Troubleshooting
| Problem | Check |
|---|---|
| Table stays empty | the widget pin and the WidgetTable pin do not match |
| Rows duplicate | clear() is missing before rebuilding |
| Rows flicker | rebuilding too often; use updateRow() on a timer |
| Callbacks never fire | selection or reorder is off in the widget settings |