Docs

Styled Button

The Styled Button sends 1 or 0 like the plain Button, and lets you set text and colour for each state.

Use it when the control should say what it does: PUMP ON in green, PUMP OFF in grey.

SettingWhat it does
Pinthe virtual pin your code reads
ModeSwitch toggles, Push sends while held
On label, Off labelthe text for each state
On colour, Off colourthe colour for each state
Valuesthe numbers sent for on and off, 1 and 0 by default

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Example

Same handler as a plain Button. The styling lives in the app.

styled-button.ino
#include <PlynxSimpleEsp32.h>

#define PUMP_PIN 26

PLYNX_WRITE(V11)
{
  digitalWrite(PUMP_PIN, param.asInt() ? HIGH : LOW);
}

void setup()
{
  Serial.begin(115200);
  pinMode(PUMP_PIN, OUTPUT);

  // 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();
}

void loop()
{
  Plynx.run();
}

If you change the on and off values in the widget settings, read them the same way. param.asInt() returns whatever number you configured, so compare against that number instead of 1.

Troubleshooting

ProblemCheck
Nothing happensthe widget pin and PLYNX_WRITE() do not match
Output invertedthe on and off values are swapped in the widget settings
Labels never changePush mode returns to off as soon as you lift your finger

Next