use task for interruptions: button and led
This commit is contained in:
parent
584fa688c3
commit
22544c225a
@ -10,7 +10,6 @@ void onButtonCallback();
|
|||||||
Scheduler ts;
|
Scheduler ts;
|
||||||
Task tCheckWifi(5 * TASK_MINUTE, TASK_ONCE, checkWifiCallback, &ts);
|
Task tCheckWifi(5 * TASK_MINUTE, TASK_ONCE, checkWifiCallback, &ts);
|
||||||
Task tWifiConnected(TASK_IMMEDIATE, TASK_ONCE, onWifiConnected, &ts);
|
Task tWifiConnected(TASK_IMMEDIATE, TASK_ONCE, onWifiConnected, &ts);
|
||||||
Task tButton(TASK_IMMEDIATE, TASK_ONCE, onButtonCallback, &ts);
|
|
||||||
|
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
@ -22,6 +21,12 @@ Task tButton(TASK_IMMEDIATE, TASK_ONCE, onButtonCallback, &ts);
|
|||||||
|
|
||||||
#define BUTTON D3
|
#define BUTTON D3
|
||||||
|
|
||||||
|
Task tButton(TASK_IMMEDIATE, TASK_ONCE, []() {
|
||||||
|
Display::displayTemp(Bmp::data.readTemp());
|
||||||
|
}, &ts);
|
||||||
|
Task tLed(TASK_IMMEDIATE, TASK_ONCE, []() {
|
||||||
|
Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON");
|
||||||
|
}, &ts);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
@ -73,9 +78,5 @@ ICACHE_RAM_ATTR void onButtonPressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ICACHE_RAM_ATTR void onLed() {
|
ICACHE_RAM_ATTR void onLed() {
|
||||||
Mqtt::publish(Mqtt::ledMqtt->stateTopic, digitalRead(LED_BUILTIN) ? "OFF" : "ON");
|
tLed.restart();
|
||||||
}
|
|
||||||
|
|
||||||
void onButtonCallback() {
|
|
||||||
Display::displayTemp(Bmp::data.readTemp());
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user