#include <Simpletimer.h>
#include <WiFiManager.h>
#include <EasyButton.h>
// the timer object
Simpletimer timer{};
WiFiManager wm;
EasyButton button(14,50,true,true);
const uint16_t PixelCount = 1; // make sure to set this to the number of pixels in your strip
const uint8_t PixelPin = 12; // make sure to set this to the correct pin, ignored for Esp8266
unsigned long callbacksleep = 20;
int16_t counter=0;
void change_animation(){
counter++;
if(counter%10==0)Serial.printf("counter: %i\n",counter);
}
Simpletimer::callback cb = change_animation;
void onPressed()
{
Serial.println((digitalRead(14)));
Serial.println("Button pressed");
if(!wm.getConfigPortalActive())wm.startConfigPortal("Iforce");
else Serial.println("Config already active");
}
void onPressedFor(){
Serial.println("reset settings");
}
void setup()
{
Serial.begin(115200);
while (!Serial); // wait for serial attach
button.begin();
// Add the callback function to be called when the button is pressed.
button.onPressed(onPressed);
button.onPressedFor(1000,onPressedFor);
timer.register_multiple_callbacks(&cb, &callbacksleep);
wm.setConfigPortalBlocking(false);
wm.setConfigPortalTimeout(60);
bool res;
// res = wm.autoConnect(); // auto generated AP name from chipid
// res = wm.autoConnect("AutoConnectAP"); // anonymous ap
res = wm.autoConnect("Iforce"); // password protected ap
if(!res) {
Serial.println("Failed to connect");
// ESP.restart();
}
else {
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
}
void loop()
{
timer.run();
wm.process();
button.read();
//sleep(10);
}