diff --git a/include/mqtt.h b/include/mqtt.h index c344be2..147248e 100644 --- a/include/mqtt.h +++ b/include/mqtt.h @@ -9,7 +9,7 @@ namespace Mqtt { void publishCommand(); void publishBmp280(); Task tPublish(TASK_SECOND, TASK_FOREVER, publishCommand, &ts); - Task tPublishBmp(TASK_MINUTE, TASK_FOREVER, publishBmp280, &ts); + Task tPublishBmp(5 * TASK_MINUTE, TASK_FOREVER, publishBmp280, &ts); AsyncMqttClient client; diff --git a/src/esp_clock.cpp b/src/esp_clock.cpp index a4cd6a1..f3ad33a 100644 --- a/src/esp_clock.cpp +++ b/src/esp_clock.cpp @@ -2,12 +2,15 @@ void checkWifiCallback(); void onWifiConnected(); +void onButtonPressed(); +void onButtonCallback(); // #define _TASK_STATUS_REQUEST #include Scheduler ts; -Task tCheckWifi(5*TASK_SECOND, TASK_FOREVER, checkWifiCallback, &ts); +Task tCheckWifi(5 * TASK_SECOND, TASK_FOREVER, checkWifiCallback, &ts); Task tWifiConnected(TASK_IMMEDIATE, TASK_ONCE, onWifiConnected, &ts); +Task tButton(TASK_IMMEDIATE, TASK_ONCE, onButtonCallback, &ts); #include "wifi.h" #include "display.h" @@ -18,6 +21,7 @@ Task tWifiConnected(TASK_IMMEDIATE, TASK_ONCE, onWifiConnected, &ts); #include "ir.h" #define STAY_CONNECTED_AFTER_BOOT 5*60 +#define BUTTON D3 void setup() { @@ -31,6 +35,9 @@ void setup() { Bmp::setup(); Wifi::setup(); + + pinMode(BUTTON, INPUT_PULLUP); + attachInterrupt(digitalPinToInterrupt(BUTTON), onButtonPressed, FALLING); } void loop() { @@ -58,3 +65,11 @@ void checkWifiCallback() { Wifi::disconnect(); } } + +ICACHE_RAM_ATTR void onButtonPressed() { + tButton.restart(); +} + +void onButtonCallback() { + Display::displayTemp(Bmp::data.readTemp()); +}