Skip to content

Commit

Permalink
Rework part 1: task-based clock feed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstoer committed Dec 20, 2023
1 parent 22f189d commit 525798c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ lib_deps =
https://github.com/Bodmer/OpenFontRender#f163cc6 ; no tags or releases to reference :( -> pin to Git revision
squix78/JsonStreamingParser@~1.0.5
thingpulse/ESP8266 Weather Station@~2.2.0
arkhipenko/TaskScheduler@~3.7.0
14 changes: 11 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <OpenWeatherMapCurrent.h>
#include <OpenWeatherMapForecast.h>
#include <SunMoonCalc.h>
#include <TaskScheduler.h>

#include "connectivity.h"
#include "display.h"
Expand Down Expand Up @@ -41,6 +42,8 @@ const int16_t centerWidth = tft.width() / 2;
OpenWeatherMapCurrentData currentWeather;
OpenWeatherMapForecastData forecasts[NUMBER_OF_FORECASTS];

Scheduler scheduler;



// ----------------------------------------------------------------------------
Expand All @@ -60,6 +63,9 @@ void repaint();
void updateData(boolean updateProgressBar);


Task clockTask(1000, TASK_FOREVER, &drawTimeAndDate);



// ----------------------------------------------------------------------------
// setup() & loop()
Expand All @@ -79,6 +85,10 @@ void setup(void) {

initFileSystem();
initOpenFontRender();

scheduler.init();
scheduler.addTask(clockTask);
clockTask.enable();
}

void loop(void) {
Expand All @@ -89,10 +99,7 @@ void loop(void) {
lastUpdateMillis == 0 ||
(millis() - lastUpdateMillis) > updateIntervalMillis) {
repaint();
} else {
drawTimeAndDate();
}
delay(1000);

// if (ts.touched()) {
// TS_Point p = ts.getPoint();
Expand All @@ -104,6 +111,7 @@ void loop(void) {
// // Debouncing; avoid returning the same touch multiple times.
// delay(50);
// }
scheduler.execute();
}


Expand Down

0 comments on commit 525798c

Please sign in to comment.