diff --git a/include/apps/watchfaces/OswAppWatchfaceDigital.h b/include/apps/watchfaces/OswAppWatchfaceDigital.h index 259ddb645..df5cea00c 100644 --- a/include/apps/watchfaces/OswAppWatchfaceDigital.h +++ b/include/apps/watchfaces/OswAppWatchfaceDigital.h @@ -23,7 +23,7 @@ class OswAppWatchfaceDigital: public OswAppV2 { static void digitalWatch(short timeZone, uint8_t fontSize, uint8_t dateCoordY, uint8_t timeCoordY); static void timeOutput(uint32_t hour, uint32_t minute, uint32_t second, bool showSecond = true); static void dateOutput(uint32_t yearInt, uint32_t monthInt, uint32_t dayInt); - static void displayWeekDay3(const char* weekday); + static void displayWeekDay3(char* weekday); private: static uint8_t dateFormatCache; diff --git a/include/osw_hal.h b/include/osw_hal.h index b92bccd37..ac4cc2a83 100644 --- a/include/osw_hal.h +++ b/include/osw_hal.h @@ -192,7 +192,7 @@ class OswHal { void getTime(time_t& offset, uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr); void getDate(time_t& offset, uint32_t* day, uint32_t* weekDay); void getDate(time_t& offset, uint32_t* day, uint32_t* month, uint32_t* year); - const char* getWeekday(time_t& offset, uint32_t* setWDay = nullptr); + void getWeekday(time_t& offset, char** weekDayName, uint32_t* setWDay = nullptr); // For backward compatibility: Local time functions (= primary timezone) inline void getLocalTime(uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr) { @@ -207,8 +207,8 @@ class OswHal { inline void getLocalDate(uint32_t* day, uint32_t* month, uint32_t* year) { this->getDate(this->timezoneOffsetPrimary, day, month, year); }; - inline const char* getLocalWeekday(uint32_t* sWDay = nullptr) { - return this->getWeekday(this->timezoneOffsetPrimary, sWDay); + inline void getLocalWeekday(char** weekDayName, uint32_t* sWDay = nullptr) { + this->getWeekday(this->timezoneOffsetPrimary, weekDayName, sWDay); }; // For backward compatibility: Dual time functions (= secondary timezone) @@ -224,8 +224,8 @@ class OswHal { inline void getDualDate(uint32_t* day, uint32_t* month, uint32_t* year) { this->getDate(this->timezoneOffsetSecondary, day, month, year); }; - inline const char* getDualWeekday(uint32_t* sWDay = nullptr) { - return this->getWeekday(this->timezoneOffsetSecondary, sWDay); + inline void getDualWeekday(char** weekDayName, uint32_t* sWDay = nullptr) { + this->getWeekday(this->timezoneOffsetSecondary, weekDayName, sWDay); }; bool _requestDisableBuffer = false; diff --git a/src/apps/tools/OswAppStepStats.cpp b/src/apps/tools/OswAppStepStats.cpp index eee20f443..fad9cf413 100644 --- a/src/apps/tools/OswAppStepStats.cpp +++ b/src/apps/tools/OswAppStepStats.cpp @@ -43,7 +43,9 @@ void OswAppStepStats::drawInfoPanel(OswUI* ui, uint32_t pos, uint32_t lastWeekDa hal->gfx()->setTextCenterAligned(); hal->gfx()->setTextBottomAligned(); hal->gfx()->setTextCursor(DISP_W / 2, 170); - hal->gfx()->print(hal->getLocalWeekday(&pos)); + char* weekDay = nullptr; + hal->getLocalWeekday(&weekDay, &pos); + hal->gfx()->print(weekDay); hal->gfx()->setTextCursor(DISP_W / 2, 190); hal->gfx()->print(String(lastWeekData)); // lastweek(before 7 day) hal->gfx()->setTextCursor(DISP_W / 2, 215); diff --git a/src/apps/watchfaces/OswAppWatchfaceDigital.cpp b/src/apps/watchfaces/OswAppWatchfaceDigital.cpp index ca74c6d41..194a86465 100644 --- a/src/apps/watchfaces/OswAppWatchfaceDigital.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceDigital.cpp @@ -22,7 +22,7 @@ void OswAppWatchfaceDigital::refreshDateFormatCache() { } // display Weekday to 3 character -void OswAppWatchfaceDigital::displayWeekDay3(const char* weekday) { +void OswAppWatchfaceDigital::displayWeekDay3(char* weekday) { OswHal* hal = OswHal::getInstance(); char weekday3[4]; @@ -65,7 +65,8 @@ static void drawDate(time_t timeZone, uint8_t fontSize, uint8_t CoordY) { uint32_t monthInt = 0; uint32_t yearInt = 0; OswHal* hal = OswHal::getInstance(); - const char* weekday = hal->getWeekday(timeZone); + char* weekdayTo3char = nullptr; + hal->getWeekday(timeZone, &weekdayTo3char); hal->getDate(timeZone,&dayInt, &monthInt, &yearInt); @@ -76,7 +77,7 @@ static void drawDate(time_t timeZone, uint8_t fontSize, uint8_t CoordY) { hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(120 - hal->gfx()->getTextOfsetColumns(6.9f), CoordY); - OswAppWatchfaceDigital::displayWeekDay3(weekday); + OswAppWatchfaceDigital::displayWeekDay3(weekdayTo3char); // The GFX library has an alignment bug, causing single letters to "float", therefore the workaround above is used to still utilize the correct string printing. //hal->gfx()->print(weekday[0]); diff --git a/src/apps/watchfaces/OswAppWatchfaceFitness.cpp b/src/apps/watchfaces/OswAppWatchfaceFitness.cpp index d7fe46baf..f3dc59208 100644 --- a/src/apps/watchfaces/OswAppWatchfaceFitness.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceFitness.cpp @@ -29,7 +29,8 @@ void dateDisplay() { uint32_t monthInt = 0; uint32_t yearInt = 0; OswHal* hal = OswHal::getInstance(); - const char* weekday = hal->getLocalWeekday(); + char* weekdayTo3char = nullptr; + hal->getLocalWeekday(&weekdayTo3char); hal->getLocalDate(&dayInt, &monthInt, &yearInt); @@ -38,7 +39,7 @@ void dateDisplay() { hal->gfx()->setTextRightAligned(); hal->gfx()->setTextCursor(205, 90); - OswAppWatchfaceDigital::displayWeekDay3(weekday); + OswAppWatchfaceDigital::displayWeekDay3(weekdayTo3char); // Date hal->gfx()->setTextSize(2); diff --git a/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp b/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp index 63562eff0..954b463c9 100644 --- a/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp @@ -111,12 +111,13 @@ void OswAppWatchfaceFitnessAnalog::drawWatchFace(OswHal* hal, uint32_t hour, uin } void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon) { - const char* weekday = hal->getLocalWeekday(); + char* weekdayTo3char = nullptr; + hal->getLocalWeekday(&weekdayTo3char); hal->gfx()->setTextSize(2); hal->gfx()->setTextRightAligned(); hal->gfx()->setTextCursor(205, 75); - OswAppWatchfaceDigital::displayWeekDay3(weekday); + OswAppWatchfaceDigital::displayWeekDay3(weekdayTo3char); // Date uint32_t dayInt = 0; diff --git a/src/apps/watchfaces/OswAppWatchfaceMix.cpp b/src/apps/watchfaces/OswAppWatchfaceMix.cpp index 51633f877..e42209c4e 100644 --- a/src/apps/watchfaces/OswAppWatchfaceMix.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceMix.cpp @@ -53,7 +53,8 @@ void OswAppWatchfaceMix::dateDisplay() { uint32_t monthInt = 0; uint32_t yearInt = 0; OswHal* hal = OswHal::getInstance(); - const char* weekday = hal->getLocalWeekday(); + char* weekdayTo3char = nullptr; + hal->getLocalWeekday(&weekdayTo3char); hal->getLocalDate(&dayInt, &monthInt, &yearInt); @@ -62,7 +63,7 @@ void OswAppWatchfaceMix::dateDisplay() { hal->gfx()->setTextLeftAligned(); hal->gfx()->setTextCursor(DISP_W / 2 - OFF_SET_DATE_DIGITAL_WATCH_X_COORD, 75); - OswAppWatchfaceDigital::displayWeekDay3(weekday); + OswAppWatchfaceDigital::displayWeekDay3(weekdayTo3char); hal->gfx()->print(", "); diff --git a/src/apps/watchfaces/OswAppWatchfaceNumerals.cpp b/src/apps/watchfaces/OswAppWatchfaceNumerals.cpp index ab5d49a92..ec38cc578 100644 --- a/src/apps/watchfaces/OswAppWatchfaceNumerals.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceNumerals.cpp @@ -43,9 +43,10 @@ void OswAppWatchfaceNumerals::drawWatch() { hal->gfx()->setTextCursor(120, 85); hal->gfx()->print(dayInt); - const char* weekday = hal->getLocalWeekday(); + char* weekdayTo3char = nullptr; + hal->getLocalWeekday(&weekdayTo3char); hal->gfx()->setTextCursor(120, 70); - OswAppWatchfaceDigital::displayWeekDay3(weekday); + OswAppWatchfaceDigital::displayWeekDay3(weekdayTo3char); #if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1 uint32_t steps = hal->environment()->getStepsToday(); diff --git a/src/hal/time.cpp b/src/hal/time.cpp index d0ce9cb71..82b9beeff 100644 --- a/src/hal/time.cpp +++ b/src/hal/time.cpp @@ -137,12 +137,12 @@ void OswHal::getDate(time_t& offset, uint32_t* day, uint32_t* month, uint32_t* y *year = d.Year(); } -const char* OswHal::getWeekday(time_t& offset, uint32_t* setWDay) { +void OswHal::getWeekday(time_t& offset, char** weekDayName, uint32_t* setWDay) { uint32_t day = 0; uint32_t wDay = 0; this->getDate(offset, &day, &wDay); - const char* dayMap[7] = {LANG_SUNDAY, LANG_MONDAY, LANG_TUESDAY, LANG_WEDNESDAY, LANG_THURSDAY, LANG_FRIDAY, LANG_SATURDAY}; + char* dayMap[7] = {LANG_SUNDAY, LANG_MONDAY, LANG_TUESDAY, LANG_WEDNESDAY, LANG_THURSDAY, LANG_FRIDAY, LANG_SATURDAY}; if (setWDay != nullptr) wDay = *setWDay; - return dayMap[wDay]; + *weekDayName = dayMap[wDay]; }