diff --git a/include/apps/watchfaces/OswAppWatchfaceDigital.h b/include/apps/watchfaces/OswAppWatchfaceDigital.h index a077f49f..835585b1 100644 --- a/include/apps/watchfaces/OswAppWatchfaceDigital.h +++ b/include/apps/watchfaces/OswAppWatchfaceDigital.h @@ -21,8 +21,8 @@ class OswAppWatchfaceDigital: public OswAppV2 { static void refreshDateFormatCache(); static void drawSteps(); static void digitalWatch(short timeZone, uint8_t fontSize, uint8_t dateCoordY, uint8_t timeCoordY); - static void timeOutput(uint8_t hour, uint8_t minute, uint8_t second, bool showSecond = true); - static void dateOutput(uint16_t year, uint8_t month, uint8_t day); + static void timeOutput(const OswTime& oswTime, bool showSecond = true); + static void dateOutput(const OswDate& oswDate); static void displayWeekDay3(const char* weekday); private: diff --git a/include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h b/include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h index e1703da4..c2a2d6e8 100644 --- a/include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h +++ b/include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h @@ -25,12 +25,6 @@ class OswAppWatchfaceFitnessAnalog : public OswAppV2 { static uint32_t calculateDistance(uint32_t steps); - void timeDisplay(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second); - void timeDisplay(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon); - void dateDisplay(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon); - - void test(); - ~OswAppWatchfaceFitnessAnalog() {} private: @@ -38,8 +32,8 @@ class OswAppWatchfaceFitnessAnalog : public OswAppV2 { unsigned screen = 0; void showFitnessTracking(OswHal* hal); - void drawWatchFace(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon); - void drawDateFace(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon); + void drawWatchFace(OswHal* hal, const OswTime& oswTime); + void drawDateFace(OswHal* hal, const OswDate& oswDate, const OswTime& oswTime); #ifdef GIF_BG OswAppGifPlayer* bgGif = nullptr; diff --git a/src/apps/watchfaces/OswAppWatchfaceDigital.cpp b/src/apps/watchfaces/OswAppWatchfaceDigital.cpp index 888b0abf..141dcd3f 100644 --- a/src/apps/watchfaces/OswAppWatchfaceDigital.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceDigital.cpp @@ -47,36 +47,36 @@ void OswAppWatchfaceDigital::displayWeekDay3(const char* weekday) { hal->gfx()->print(weekday3); } -void OswAppWatchfaceDigital::dateOutput(uint16_t year, uint8_t month, uint8_t day) { +void OswAppWatchfaceDigital::dateOutput(const OswDate& oswDate) { OswHal* hal = OswHal::getInstance(); switch (OswAppWatchfaceDigital::getDateFormat()) { case 0: - hal->gfx()->printDecimal(month, 2); + hal->gfx()->printDecimal(oswDate.month, 2); hal->gfx()->print("/"); - hal->gfx()->printDecimal(day, 2); + hal->gfx()->printDecimal(oswDate.day, 2); hal->gfx()->print("/"); - hal->gfx()->print(year); + hal->gfx()->print(oswDate.year); break; case 1: - hal->gfx()->printDecimal(day, 2); + hal->gfx()->printDecimal(oswDate.day, 2); hal->gfx()->print("."); - hal->gfx()->printDecimal(month, 2); + hal->gfx()->printDecimal(oswDate.month, 2); hal->gfx()->print("."); - hal->gfx()->print(year); + hal->gfx()->print(oswDate.year); break; case 2: - hal->gfx()->print(year); + hal->gfx()->print(oswDate.year); hal->gfx()->print("."); - hal->gfx()->printDecimal(month, 2); + hal->gfx()->printDecimal(oswDate.month, 2); hal->gfx()->print("/"); - hal->gfx()->printDecimal(day, 2); + hal->gfx()->printDecimal(oswDate.day, 2); break; case 3: - hal->gfx()->printDecimal(day, 2); + hal->gfx()->printDecimal(oswDate.day, 2); hal->gfx()->print("/"); - hal->gfx()->printDecimal(month, 2); + hal->gfx()->printDecimal(oswDate.month, 2); hal->gfx()->print("/"); - hal->gfx()->print(year); + hal->gfx()->print(oswDate.year); break; } } @@ -109,17 +109,17 @@ static void drawDate(time_t timeZone, uint8_t fontSize, uint8_t CoordY) { // i really would want the date to be dynamic based on what's in the config, but the most efficient thing to do right // now is simply three if statements covering the 3 common conditions. - OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day); + OswAppWatchfaceDigital::dateOutput(oswDate); } -void OswAppWatchfaceDigital::timeOutput(uint8_t hour, uint8_t minute, uint8_t second,bool showSecond) { +void OswAppWatchfaceDigital::timeOutput(const OswTime& oswTime, bool showSecond) { OswHal* hal = OswHal::getInstance(); - hal->gfx()->printDecimal(hour, 2); + hal->gfx()->printDecimal(oswTime.hour, 2); hal->gfx()->print(":"); - hal->gfx()->printDecimal(minute, 2); + hal->gfx()->printDecimal(oswTime.minute, 2); if (showSecond) { hal->gfx()->print(":"); - hal->gfx()->printDecimal(second, 2); + hal->gfx()->printDecimal(oswTime.second, 2); } } @@ -135,7 +135,7 @@ static void drawTime(time_t timeZone,uint8_t CoordY) { hal->gfx()->setTextCursor(120 - hal->gfx()->getTextOfsetColumns(OswConfigAllKeys::timeFormat.get() ? 4 : 5.5),CoordY ); hal->getTime(timeZone, oswTime); - OswAppWatchfaceDigital::timeOutput(oswTime.hour, oswTime.minute, oswTime.second); + OswAppWatchfaceDigital::timeOutput(oswTime); if (!OswConfigAllKeys::timeFormat.get()) { hal->gfx()->print(" "); if (oswTime.afterNoon) { diff --git a/src/apps/watchfaces/OswAppWatchfaceFitness.cpp b/src/apps/watchfaces/OswAppWatchfaceFitness.cpp index 91d6ef75..4671e27b 100644 --- a/src/apps/watchfaces/OswAppWatchfaceFitness.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceFitness.cpp @@ -24,12 +24,8 @@ uint32_t OswAppWatchfaceFitness::calculateKcalorie(uint32_t steps) { // effects by marking fewer calories than they actually consumed. } -void dateDisplay() { +static void dateDisplay(const OswDate& oswDate) { OswHal* hal = OswHal::getInstance(); - - OswDate oswDate = { }; - hal->getLocalDate(oswDate); - hal->gfx()->setTextSize(2); hal->gfx()->setTextMiddleAligned(); hal->gfx()->setTextRightAligned(); @@ -49,20 +45,20 @@ void dateDisplay() { OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day); } -void timeDisplay(uint32_t hour, uint32_t minute, uint32_t second) { +static void timeDisplay(const OswTime& oswTime) { OswHal* hal = OswHal::getInstance(); - hal->gfx()->printDecimal(hour, 2); + hal->gfx()->printDecimal(oswTime.hour, 2); hal->gfx()->print(":"); - hal->gfx()->printDecimal(minute, 2); + hal->gfx()->printDecimal(oswTime.minute, 2); hal->gfx()->setTextSize(1); hal->gfx()->setTextMiddleAligned(); hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(215, DISP_H / 2); - hal->gfx()->printDecimal(second,2); + hal->gfx()->printDecimal(oswTime.second,2); } -void digitalWatchDisplay() { +static void digitalWatchDisplay(const OswTime& oswTime) { char am[] = "AM"; char pm[] = "PM"; OswHal* hal = OswHal::getInstance(); @@ -71,10 +67,8 @@ void digitalWatchDisplay() { hal->gfx()->setTextMiddleAligned(); hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(DISP_W / 2 - 30, DISP_W / 2); - OswTime oswTime = { }; - hal->getLocalTime(oswTime); - timeDisplay(oswTime.hour, oswTime.minute, oswTime.second); + timeDisplay(oswTime); if (!OswConfigAllKeys::timeFormat.get()) { hal->gfx()->setTextCursor(215, 130); if (oswTime.afterNoon) { @@ -84,6 +78,7 @@ void digitalWatchDisplay() { } } } + void OswAppWatchfaceFitness::showFitnessTracking() { OswHal* hal = OswHal::getInstance(); @@ -158,8 +153,13 @@ void OswAppWatchfaceFitness::onLoop() { void OswAppWatchfaceFitness::onDraw() { OswAppV2::onDraw(); - dateDisplay(); - digitalWatchDisplay(); + OswDate oswDate = { }; + OswTime oswTime = { }; + hal->getLocalDate(oswDate); + hal->getLocalTime(oswTime); + + dateDisplay(oswDate); + digitalWatchDisplay(oswTime); #if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1 showFitnessTracking(); diff --git a/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp b/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp index 075c890d..89d2068a 100644 --- a/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp @@ -90,30 +90,27 @@ void OswAppWatchfaceFitnessAnalog::showFitnessTracking(OswHal* hal) { hal->gfx()->print(LANG_WATCHFACE_FITNESS_DISTANCE); } -void OswAppWatchfaceFitnessAnalog::drawWatchFace(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon) { +void OswAppWatchfaceFitnessAnalog::drawWatchFace(OswHal* hal, const OswTime& oswTime) { // Indices hal->gfx()->drawMinuteTicks(CENTER_X, CENTER_Y, 116, 112, ui->getForegroundDimmedColor(), true); hal->gfx()->drawHourTicks(CENTER_X, CENTER_Y, 117, 107, ui->getForegroundColor(), true); // Hours - hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 12.0f * (hour + minute / 60.0f)), 3, ui->getForegroundColor(), true, STRAIGHT_END); - hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 60, (int)(360.0f / 12.0f * (hour + minute / 60.0f)), 7, ui->getForegroundColor(), true); + hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 12.0f * (oswTime.hour + oswTime.minute / 60.0f)), 3, ui->getForegroundColor(), true, STRAIGHT_END); + hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 60, (int)(360.0f / 12.0f * (oswTime.hour + oswTime.minute / 60.0f)), 7, ui->getForegroundColor(), true); // Minutes - hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 60.0f * (minute + second / 60.0f)), 3, ui->getForegroundColor(), true, STRAIGHT_END); - hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 105, (int)(360.0f / 60.0f * (minute + second / 60.0f)), 7, ui->getForegroundColor(), true); + hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 60.0f * (oswTime.minute + oswTime.second / 60.0f)), 3, ui->getForegroundColor(), true, STRAIGHT_END); + hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 105, (int)(360.0f / 60.0f * (oswTime.minute + oswTime.second / 60.0f)), 7, ui->getForegroundColor(), true); #ifndef GIF_BG // Seconds hal->gfx()->fillCircleAA(CENTER_X, CENTER_Y, 6, ui->getDangerColor()); - hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, -16, 110, 360 / 60 * second, 3, ui->getDangerColor(), true); + hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, -16, 110, 360 / 60 * oswTime.second, 3, ui->getDangerColor(), true); #endif } -void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon) { - OswDate oswDate = { }; - hal->getLocalDate(oswDate); - +void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, const OswDate& oswDate, const OswTime& oswTime) { hal->gfx()->setTextSize(2); hal->gfx()->setTextRightAligned(); hal->gfx()->setTextCursor(205, 75); @@ -133,20 +130,20 @@ void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint8_t hour, uint8 hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(CENTER_X - 35, CENTER_Y); - hal->gfx()->printDecimal(hour, 2); + hal->gfx()->printDecimal(oswTime.hour, 2); hal->gfx()->print(":"); - hal->gfx()->printDecimal(minute, 2); + hal->gfx()->printDecimal(oswTime.minute, 2); hal->gfx()->setTextSize(2); hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(215, CENTER_Y); - hal->gfx()->printDecimal(second,2); + hal->gfx()->printDecimal(oswTime.second,2); if (!OswConfigAllKeys::timeFormat.get()) { const char am[] = "AM"; const char pm[] = "PM"; hal->gfx()->setTextCursor(215, 130); - if (afterNoon) { + if (oswTime.afterNoon) { hal->gfx()->print(pm); } else { hal->gfx()->print(am); @@ -203,7 +200,9 @@ void OswAppWatchfaceFitnessAnalog::onDraw() { OswHal* hal = OswHal::getInstance(); + OswDate oswDate = { }; OswTime oswTime = { }; + hal->getLocalDate(oswDate); hal->getLocalTime(oswTime); if (this->screen == 0) { @@ -211,9 +210,9 @@ void OswAppWatchfaceFitnessAnalog::onDraw() { showFitnessTracking(hal); #endif - drawWatchFace(hal, oswTime.hour, oswTime.minute, oswTime.second, oswTime.afterNoon); + drawWatchFace(hal, oswTime); } else if (this->screen == 1) { - drawDateFace(hal, oswTime.hour, oswTime.minute, oswTime.second, oswTime.afterNoon); + drawDateFace(hal, oswDate, oswTime); static int wait_time = 1; if (wait_time >= 0)