#include "OmEspHelpers.h"
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>
void buttonProc(const char *page, const char *item, int value, int ref1, void *ref2)
{
digitalWrite(LED_BUILTIN, ref1);
}
void buttonMomentaryProc(const char *page, const char *item, int value, int ref1, void *ref2)
{
digitalWrite(LED_BUILTIN, !value);
}
OmWebPages p;
OmWebServer s;
void setup()
{
Serial.begin(115200);
Serial.print("\n\nHello OmEspHelpers\n");
p.beginPage("Home");
p.addButton("ledOn", buttonProc, 0); // ref=0
p.addButton("ledOff", buttonProc, 1); // ref=1
p.addButton("ledMomentary", buttonMomentaryProc);
s.addWifi("omino warp", ""); // my home network, no password
s.setHandler(p);
s.setStatusLedPin(-1); // tell the server not to blink the led; this app uses it.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, 1); // off
}
void loop()
{
s.tick(); // in turn calls OmWebPages
delay(20);
}
And here's the web page it presents:
The general idea is to generate the button and other page elements dynamically, and ensure the main loop is non-blocking, including the Wifi join up. It's built on top of ESP8266WebServer and -WiFi.
Enjoy. Feedback welcome. WIP.