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.

SettingWhat it does
Pinthe virtual pin your code writes to
Reorderlet the user drag rows
Selectionlet 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.

table.ino
#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:

Handle a row being selected
void onSelect(int index, bool selected)
{
  Serial.print("Row ");
  Serial.print(index);
  Serial.println(selected ? " selected" : " deselected");
}

void setup()
{
  // ...
  table.onSelectChange(onSelect);
}

Troubleshooting

ProblemCheck
Table stays emptythe widget pin and the WidgetTable pin do not match
Rows duplicateclear() is missing before rebuilding
Rows flickerrebuilding too often; use updateRow() on a timer
Callbacks never fireselection or reorder is off in the widget settings

Next