Oval button
Same behavior as the round button, drawn as a wide pill. Caption, face text, values, and colors are separate properties.
Set it up on the server
- Sign in to the Box IO dashboard and open the project that uses this device key.
- Turn on Edit.
- In Edit, add Oval button.
- Set Virtual pin to
7. - Set Label, On text, Off text, the two values, and the four colors the same way as the round button.
- Save the layout, then open Live and click the button.
- Flash the sketch below with the same device key, host, and port
5923. KeepBoxIO.run()inloop().
Properties
Sketch values are always strings, including numbers: BoxIO.setProperty(V2, "max", "200").
| Property | Where to set it | Format | Example | Effect |
|---|---|---|---|---|
label | Dashboard or sketch | Plain text | Round | Caption above the button. This is not the word drawn on the face. |
textOn | Dashboard or sketch | Plain text | Go | Word on the face while the pin equals the on value. |
textOff | Dashboard or sketch | Plain text | Idle | Word on the face while the pin equals the off value. |
onValue | Dashboard or sketch | Exact text the pin must match | go | Clicking the button while it is off sends this string to the device. |
offValue | Dashboard or sketch | Exact text the pin must match | 0 | Clicking the button while it is on sends this string. Default is 0. |
sendValue | Dashboard or sketch | Same text as onValue | go | Older name for the on value. If onValue is empty, sendValue is used. |
colorOn | Dashboard or sketch | #RRGGBB | #2ee0c5 | Face background when on. |
colorOff | Dashboard or sketch | #RRGGBB | #314057 | Face background when off. |
textColorOn | Dashboard or sketch | #RRGGBB | #071018 | Face text color when on. |
textColorOff | Dashboard or sketch | #RRGGBB | #e8eef8 | Face text color when off. |
hideLabel | Dashboard | On or off | checked | Hides the caption. Button face text, meter numbers, and label text stay visible. |
fontSize | Dashboard | Whole number 8 to 160, or blank for automatic size | 28 | Text size in pixels inside the widget. |
opacity | Dashboard | 10% to 100% | 70% | Lets an overlapping widget show through. 100% is solid. |
Formatting
- On and off matching works the same as the round button: exact onValue, then exact offValue, then the usual on/off words.
- The sample face is Stop when the pin is
stop, and Run when the pin is0.
Sketch
Paste the device key over bx_paste_your_device_key_here. Wi-Fi boards include BoxIOEsp32.h. Ethernet boards use the same calls with an EthernetClient.
#define BOXIO_AUTH "bx_paste_your_device_key_here"
#define WIFI_SSID "your-ssid"
#define WIFI_PASS "your-password"
#define BOXIO_HOST "localhost"
#define BOXIO_PORT 5923
#include <BoxIOEsp32.h>
void setup() {
BoxIO.begin(BOXIO_AUTH, WIFI_SSID, WIFI_PASS, BOXIO_HOST, BOXIO_PORT);
BoxIO.setProperty(V7, "label", "Oval");
BoxIO.setProperty(V7, "textOn", "Stop");
BoxIO.setProperty(V7, "textOff", "Run");
BoxIO.setProperty(V7, "onValue", "stop");
BoxIO.setProperty(V7, "offValue", "0");
BoxIO.setProperty(V7, "sendValue", "stop");
BoxIO.setProperty(V7, "colorOn", "#ff5d73");
BoxIO.setProperty(V7, "colorOff", "#314057");
BoxIO.setProperty(V7, "textColorOn", "#071018");
BoxIO.setProperty(V7, "textColorOff", "#e8eef8");
}
void loop() {
BoxIO.run();
}
BOX_WRITE(V7) {
Serial.println(param.asStr());
}
What you should see
The caption is Oval. The face is Stop or Run. Serial prints stop or 0 when the button is clicked.