diff --git a/src/WatchFacePages/Weather.cpp b/src/WatchFacePages/Weather.cpp index bb96bc3..5ea15ab 100644 --- a/src/WatchFacePages/Weather.cpp +++ b/src/WatchFacePages/Weather.cpp @@ -1,11 +1,10 @@ #include "Weather.h" #include "../SevenSegment.h" #include "../Icons.h" -#include -#include -#include +#include RTC_DATA_ATTR uint64_t WatchFacePages::Weather::m_lastSyncTime = 0; +RTC_DATA_ATTR int WatchFacePages::Weather::m_lastCalculatedDay = 0XFFFFFFFF; WatchFacePages::Weather::Weather(WatchyDisplay & display, WatchFeatures::WatchFeatures & features) : m_display(display), m_features(features) @@ -24,18 +23,34 @@ void WatchFacePages::Weather::DrawPage(bool partialRefresh) { m_display.setFullWindow(); m_display.fillScreen(GxEPD_WHITE); - m_display.display(partialRefresh); + m_display.setTextColor(GxEPD_BLACK); + + if (m_lastSyncTime == 0) { + m_display.setFont(&FreeSans12pt7b); + int16_t x, y; + uint16_t w, h; + m_display.getTextBounds("Have not synced", 0, 0, &x, &y, &w, &h); + m_display.setCursor(DISPLAY_WIDTH / 2 - w / 2, 110); + m_display.print("Have not synced"); + m_display.display(partialRefresh); + return; + } else if (m_features.rtc.GetTimestamp() - m_lastSyncTime > 86400) { + m_display.setFont(&FreeSans12pt7b); + m_display.setCursor(20, 110); + m_display.print("Last sync > 1 day"); + m_display.display(partialRefresh); + return; + } } void WatchFacePages::Weather::Resync() { + uint64_t currentTime = m_features.rtc.GetTimestamp(); + + if(m_lastSyncTime == 0 || currentTime - m_lastSyncTime > WEATHER_UPDATE_INTERVAL) { + } + // if(!m_features.wifi.Connect()) { // return; // } - - // uint64_t currentTime = m_features.rtc.GetTimestamp(); - - // if(m_lastSyncTime == 0 || m_lastSyncTime + 60 * 60 * 1000 < millis()) { - // m_lastSyncTime = millis(); - // } } \ No newline at end of file diff --git a/src/WatchFacePages/Weather.h b/src/WatchFacePages/Weather.h index 051525d..f84db95 100644 --- a/src/WatchFacePages/Weather.h +++ b/src/WatchFacePages/Weather.h @@ -25,4 +25,5 @@ private: WatchyDisplay & m_display; WatchFeatures::WatchFeatures & m_features; static RTC_DATA_ATTR uint64_t m_lastSyncTime; + static RTC_DATA_ATTR int m_lastCalculatedDay; }; \ No newline at end of file