This commit is contained in:
parent
36510ace7a
commit
4e3800e332
2 changed files with 26 additions and 10 deletions
|
@ -1,11 +1,10 @@
|
||||||
#include "Weather.h"
|
#include "Weather.h"
|
||||||
#include "../SevenSegment.h"
|
#include "../SevenSegment.h"
|
||||||
#include "../Icons.h"
|
#include "../Icons.h"
|
||||||
#include <Fonts/FreeSans9pt7b.h>
|
#include <Fonts/FreeSans12pt7b.h>
|
||||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
|
||||||
#include <Fonts/FreeMonoBold12pt7b.h>
|
|
||||||
|
|
||||||
RTC_DATA_ATTR uint64_t WatchFacePages::Weather::m_lastSyncTime = 0;
|
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)
|
WatchFacePages::Weather::Weather(WatchyDisplay & display, WatchFeatures::WatchFeatures & features)
|
||||||
: m_display(display), m_features(features)
|
: m_display(display), m_features(features)
|
||||||
|
@ -24,18 +23,34 @@ void WatchFacePages::Weather::DrawPage(bool partialRefresh)
|
||||||
{
|
{
|
||||||
m_display.setFullWindow();
|
m_display.setFullWindow();
|
||||||
m_display.fillScreen(GxEPD_WHITE);
|
m_display.fillScreen(GxEPD_WHITE);
|
||||||
|
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);
|
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()
|
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()) {
|
// if(!m_features.wifi.Connect()) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// uint64_t currentTime = m_features.rtc.GetTimestamp();
|
|
||||||
|
|
||||||
// if(m_lastSyncTime == 0 || m_lastSyncTime + 60 * 60 * 1000 < millis()) {
|
|
||||||
// m_lastSyncTime = millis();
|
|
||||||
// }
|
|
||||||
}
|
}
|
|
@ -25,4 +25,5 @@ private:
|
||||||
WatchyDisplay & m_display;
|
WatchyDisplay & m_display;
|
||||||
WatchFeatures::WatchFeatures & m_features;
|
WatchFeatures::WatchFeatures & m_features;
|
||||||
static RTC_DATA_ATTR uint64_t m_lastSyncTime;
|
static RTC_DATA_ATTR uint64_t m_lastSyncTime;
|
||||||
|
static RTC_DATA_ATTR int m_lastCalculatedDay;
|
||||||
};
|
};
|
Loading…
Reference in a new issue