Introduction:
Widgets are controls to communicate to one ore more devices. There are currently three types of Widgets:
Status: The Status widget is a read-only display of a specific value like a Temperature display.
Slider: The slider is used to set a value in a specific range like setting a Voltage output.
Switch: This switch can be used for a simple on/off or other 2-state controls e.g. switching a Light on/off.
WinoBOARD code Example:
(please make sure your WinoBOARD is connected to WIFI to use this example)
#include "widgets.h"
#include "wino.h"
void setup() {
wifi.on(115200);
wifi.wait(20000);
SerialUSB.println("Connected to IP:" + wifi.getip());
widget.start();
widget.addStatus(0, "Temperature", "C");
widget.addSlider(1, "LED-Brightness", "%", 0, 100);
widget.addSwitch(2, "LED", "on", "off");
}
void loop() {
widget.write(0, float(getTemp())/10); //reads MCU temperature
analogWrite(2, widget.read(1)/100*127*widget.read(2)); //this controls the voltage of the LED on Pin 2
widget.refresh();
}