Skip to content

Commit

Permalink
Fix weekDay API spec
Browse files Browse the repository at this point in the history
- OUT param for weekDay char type
  • Loading branch information
RuffaloLavoisier committed Sep 28, 2024
1 parent ebfa6f9 commit e6c6ba4
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion include/apps/watchfaces/OswAppWatchfaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions include/osw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/apps/tools/OswAppStepStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/apps/watchfaces/OswAppWatchfaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);

Expand All @@ -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]);
Expand Down
5 changes: 3 additions & 2 deletions src/apps/watchfaces/OswAppWatchfaceFitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/apps/watchfaces/OswAppWatchfaceMix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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(", ");

Expand Down
5 changes: 3 additions & 2 deletions src/apps/watchfaces/OswAppWatchfaceNumerals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/hal/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

0 comments on commit e6c6ba4

Please sign in to comment.