small refactoring how the playlist works. allow faces to do working stuff in a loop thread

pull/1/head
Thomas Ballmann 4 years ago
parent c8523e02f2
commit aeae08e1c0

@ -4,6 +4,7 @@
void setupFaceCalendar();
void loopFaceCalendar();
void playlistFaceCalendar();
bool updateCalendarData();
#endif

@ -37,6 +37,7 @@ extern faceWeatherData weatherData;
void setupFaceWeather();
void loopFaceWeather();
void playlistFaceWeather();
bool updateWeatherData();

@ -31,6 +31,12 @@ void setupFaceCalendar()
}
void loopFaceCalendar()
{
//downloadRandomePicture();
//downloadFile("https://images.unsplash.com/photo-1582225764554-a82806fe9f30?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDM0OH0&w=390&h=384&fm=png&fit=crop&duotone=000000,FFFFFF", "/tom");
}
void playlistFaceCalendar()
{
// TODO update picture every x seconds
showFaceCalendar();

@ -5,6 +5,7 @@
#include "display.h"
#include "download.h"
#include "settings.h"
#include "datetime.h"
#include <Fonts/FreeSansBold24pt7b.h> // current day
#include <Fonts/FreeSansBold18pt7b.h> // current day
@ -13,6 +14,8 @@ const char faceWeatherCurrent[] = "/weatherCurrent.json";
const char faceWeatherForecast[] = "/weatherForecast.json";
faceWeatherData weatherData;
unsigned long lastWeatherDataUpdate = 0;
void render_current();
void render_forecast();
bool readWeatherData();
@ -20,9 +23,21 @@ bool readWeatherData();
void setupFaceWeather()
{
readWeatherData();
lastWeatherDataUpdate = millis();
}
void loopFaceWeather()
{
// update every 10 min
if ((millis() - lastWeatherDataUpdate) >= 600000)
{
Serial.println(&now, "update weather data @ %A, %B %d %Y %H:%M:%S");
lastWeatherDataUpdate = millis();
updateWeatherData();
}
}
void playlistFaceWeather()
{
display.setRotation(0);
display.setFullWindow();

@ -16,8 +16,8 @@ typedef FaceAndName FaceAndNameList[];
// List of faces to cycle through
FaceAndNameList faces = {
{loopFaceWeather, "Weather"},
{loopFaceCalendar, "Calendar"},
{playlistFaceWeather, "Weather"},
{playlistFaceCalendar, "Calendar"},
};
const uint8_t faceCount = ARRAY_SIZE(faces);
@ -51,6 +51,9 @@ void setupPlaylist()
void loopPlaylist()
{
loopFaceWeather();
loopFaceCalendar();
if (PlaylistGetRemainingTimeMs() <= 0) // && autoplayEnabled
{
PlaylistResetTimer();

Loading…
Cancel
Save