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.
| Setting | What it does |
|---|---|
| Pin | the virtual pin your code reads |
| Mode | Switch toggles, Push sends while held |
| On label, Off label | the text for each state |
| On colour, Off colour | the colour for each state |
| Values | the 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.
#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
| Problem | Check |
|---|---|
| Nothing happens | the widget pin and PLYNX_WRITE() do not match |
| Output inverted | the on and off values are swapped in the widget settings |
| Labels never change | Push mode returns to off as soon as you lift your finger |