Update the smart switch example
@@ -40,8 +40,10 @@ using namespace sensesp;
// SensESP builds upon the ReactESP framework. Every ReactESP application
-// defines an "app" object (vs. defining a "main()" method).
-ReactESP app([]() {
+// defines an "app" object.
+ReactESP app;
+
+void setup() {
// Some initialization boilerplate when in debug mode...
#ifndef SERIAL_DEBUG_DISABLED
@@ -97,7 +99,7 @@ ReactESP app([]() {
// Connect a physical button that will feed manual click types into the controller...
- DigitalInputState* btn = new DigitalInputState(PIN_BUTTON, INPUT, CHANGE, 100);
+ DigitalInputState* btn = new DigitalInputState(PIN_BUTTON, INPUT, 100);
PressRepeater* pr = new PressRepeater();
btn->connect_to(pr);
pr->connect_to(new ClickType(config_path_button_c))
@@ -129,4 +131,10 @@ ReactESP app([]() {
// Start the SensESP application running
sensesp_app->start();
-});
+}
+
+// The loop function is called in an endless loop during program execution.
+// It simply calls `app.tick()` which will then execute all reactions as needed.
+void loop() {
+ app.tick();
+}
