add button to display temperature
This commit is contained in:
parent
a1b0481416
commit
b437c5746e
@ -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;
|
||||
|
||||
|
||||
@ -2,12 +2,15 @@
|
||||
|
||||
void checkWifiCallback();
|
||||
void onWifiConnected();
|
||||
void onButtonPressed();
|
||||
void onButtonCallback();
|
||||
|
||||
// #define _TASK_STATUS_REQUEST
|
||||
#include <TaskScheduler.h>
|
||||
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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user