diff --git a/lib/Rtc_Pcf8563/Rtc_Pcf8563.cpp b/lib/Rtc_Pcf8563/Rtc_Pcf8563.cpp index 9c508b5..5311e68 100644 --- a/lib/Rtc_Pcf8563/Rtc_Pcf8563.cpp +++ b/lib/Rtc_Pcf8563/Rtc_Pcf8563.cpp @@ -522,7 +522,7 @@ const char *Rtc_Pcf8563::formatTime(byte style) } -const char *Rtc_Pcf8563::formatDate(byte style) +const char * Rtc_Pcf8563::formatDate(byte style) { getDate(); diff --git a/src/WatchFacePages/Clock.cpp b/src/WatchFacePages/Clock.cpp index 0788335..a2f106f 100644 --- a/src/WatchFacePages/Clock.cpp +++ b/src/WatchFacePages/Clock.cpp @@ -2,8 +2,8 @@ #include "../SevenSegment.h" #include "../Icons.h" #include -#include -#include +#include +#include WatchFacePages::Clock::Clock(WatchyDisplay & display, WatchFeatures::WatchFeatures & features) : m_display(display), m_features(features) @@ -28,6 +28,7 @@ void WatchFacePages::Clock::DrawPage(bool partialRefresh) // Get current time and offset by timezone tmElements_t currentTime; m_features.rtc.Get(currentTime); + std::string date = m_features.rtc.GetDateString(); int tzOffset = m_features.storage.GetTzOffset(); m_features.rtc.OffsetTime(currentTime, tzOffset); @@ -35,23 +36,48 @@ void WatchFacePages::Clock::DrawPage(bool partialRefresh) SevenSegment sevenSegment(30, 60, 6, 5, 5); if (currentTime.Hour < 10) { - sevenSegment.DrawDigit(m_display, 0, 15, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, 0, 15, 65, GxEPD_BLACK); } else { - sevenSegment.DrawDigit(m_display, currentTime.Hour / 10, 20, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, currentTime.Hour / 10, 20, 65, GxEPD_BLACK); } - sevenSegment.DrawDigit(m_display, currentTime.Hour % 10, 60, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, currentTime.Hour % 10, 60, 65, GxEPD_BLACK); if (currentTime.Minute < 10) { - sevenSegment.DrawDigit(m_display, 0, 110, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, 0, 110, 65, GxEPD_BLACK); } else { - sevenSegment.DrawDigit(m_display, currentTime.Minute / 10, 110, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, currentTime.Minute / 10, 110, 65, GxEPD_BLACK); } - sevenSegment.DrawDigit(m_display, currentTime.Minute % 10, 150, 75, GxEPD_BLACK); + sevenSegment.DrawDigit(m_display, currentTime.Minute % 10, 150, 65, GxEPD_BLACK); - m_display.fillRect(97, 90, 5, 5, GxEPD_BLACK); - m_display.fillRect(97, 110, 5, 5, GxEPD_BLACK); + m_display.fillRect(97, 80, 5, 5, GxEPD_BLACK); + m_display.fillRect(97, 100, 5, 5, GxEPD_BLACK); + + // Print day and date + const char * weekDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; + const char * dow = weekDays[currentTime.Wday - 1]; + + m_display.setFont(&FreeSans9pt7b); + m_display.setTextColor(GxEPD_BLACK); + m_display.setCursor(15, 150); + m_display.print(dow); + + int16_t x, y; + uint16_t w, h; + m_display.getTextBounds(date.c_str(), 0, 0, &x, &y, &w, &h); + m_display.setCursor(180 - w, 150); + m_display.print(m_features.rtc.GetDateString().c_str()); + + // Seperator + m_display.fillRect(15, 127, 170, 2, GxEPD_BLACK); + + // Steps + m_display.setFont(&FreeSans12pt7b); + m_display.setTextColor(GxEPD_BLACK); + m_display.drawBitmap(10, 177, Icons::steps, 19, 23, GxEPD_BLACK); + m_display.setCursor(40, 195); + m_display.print(m_features.stepCounter.GetSteps()); m_display.display(partialRefresh); } @@ -65,19 +91,22 @@ void WatchFacePages::Clock::DrawBatteryIcon() m_display.fillRect(200 - 44, 9, (int)std::round(35.0f * level), 15, GxEPD_BLACK); - int x = 200 - 85; + int16_t x = 200 - 85; if (intLevel == 100) { x -= 13; } - m_display.setFont(&FreeMonoBold9pt7b); - m_display.setCursor(x, 22); - m_display.setTextColor(GxEPD_BLACK); - m_display.print(intLevel); - m_display.print("%"); + std::ostringstream oss; + oss << intLevel << "%"; - m_display.setFont(&FreeMonoBold12pt7b); - m_display.drawBitmap(10, 177, Icons::steps, 19, 23, GxEPD_BLACK); - m_display.setCursor(40, 195); - m_display.print(m_features.stepCounter.GetSteps()); + m_display.setFont(&FreeSans9pt7b); + m_display.setTextColor(GxEPD_BLACK); + + + int16_t y; + uint16_t w, h; + m_display.getTextBounds(oss.str().c_str(), 0, 0, &x, &y, &w, &h); + + m_display.setCursor(142 - w, 22); + m_display.print(oss.str().c_str()); } \ No newline at end of file diff --git a/src/WatchFeatures/RTC.cpp b/src/WatchFeatures/RTC.cpp index 7fbe6b4..fb40f85 100644 --- a/src/WatchFeatures/RTC.cpp +++ b/src/WatchFeatures/RTC.cpp @@ -129,6 +129,11 @@ bool WatchFeatures::RTC::CheckWakeup() return true; } +std::string WatchFeatures::RTC::GetDateString() +{ + return std::string(m_rtcPcf.formatDate(RTCC_DATE_ISO8601)); +} + void WatchFeatures::RTC::Resync() { m_rtcPcf.getDateTime(); diff --git a/src/WatchFeatures/RTC.h b/src/WatchFeatures/RTC.h index 1c2bcd0..66110dd 100644 --- a/src/WatchFeatures/RTC.h +++ b/src/WatchFeatures/RTC.h @@ -16,6 +16,7 @@ public: void Get(tmElements_t & tm); void Set(tmElements_t tm); uint64_t GetTimestamp(); + std::string GetDateString(); void SetTimer(); bool CheckWakeup(); // Checks to really wake up or not, also resets the timer after the initial sleep void Resync(); // Resync the timer cycle, both initially and after RTC resync