Skip to content

Commit

Permalink
Resize data type on getDate, getTime
Browse files Browse the repository at this point in the history
  • Loading branch information
RuffaloLavoisier committed Sep 25, 2024
1 parent a67bb1f commit 1c3574b
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 88 deletions.
6 changes: 3 additions & 3 deletions emulator/include/RtcDS3231.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class RtcDateTime {
uint8_t Minute();
uint8_t Second();

uint32_t DayOfWeek();
uint32_t Day();
uint32_t Month();
uint8_t DayOfWeek();
uint8_t Day();
uint8_t Month();
uint32_t Year();
private:
time_t time = 0;
Expand Down
6 changes: 3 additions & 3 deletions emulator/src/RtcDS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ uint8_t RtcDateTime::Second() {
return parts->tm_sec;
}

uint32_t RtcDateTime::DayOfWeek() {
uint8_t RtcDateTime::DayOfWeek() {
struct tm* parts = std::localtime(&this->time);
return parts->tm_wday;
}
uint32_t RtcDateTime::Day() {
uint8_t RtcDateTime::Day() {
struct tm* parts = std::localtime(&this->time);
return parts->tm_mday;
}
uint32_t RtcDateTime::Month() {
uint8_t RtcDateTime::Month() {
struct tm* parts = std::localtime(&this->time);
return parts->tm_mon + 1;
}
Expand Down
2 changes: 1 addition & 1 deletion include/apps/tools/OswAppStepStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OswAppStepStats : public OswApp {
#endif
virtual void stop() override;
~OswAppStepStats() {};
static void drawInfoPanel(OswUI* ui, uint32_t pos, uint32_t lastWeekData, uint32_t todayData, uint32_t average, uint32_t total, const String& unit = String(""));
static void drawInfoPanel(OswUI* ui, uint8_t pos, uint32_t lastWeekData, uint32_t todayData, uint32_t average, uint32_t total, const String& unit = String(""));

private:
void showStickChart();
Expand Down
4 changes: 2 additions & 2 deletions include/apps/watchfaces/OswAppWatchfaceDigital.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(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 timeOutput(uint8_t hour, uint8_t minute, uint8_t second, bool showSecond = true);
static void dateOutput(uint32_t yearInt, uint8_t monthInt, uint8_t dayInt);
static void displayWeekDay3(const char* weekday);

private:
Expand Down
8 changes: 4 additions & 4 deletions src/apps/tools/OswAppDistStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void OswAppDistStats::drawChart() {
uint8_t interval = 20;
uint16_t goalValue = OswConfigAllKeys::distPerDay.get();

uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t weekDay = 0;
uint8_t dayOfMonth = 0;
hal->getLocalDate(&dayOfMonth, &weekDay);

for (uint8_t index = 0; index < 7; index++) {
Expand Down Expand Up @@ -51,8 +51,8 @@ void OswAppDistStats::showStickChart() {

void OswAppDistStats::setup() {
OswHal* hal = OswHal::getInstance();
uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t weekDay = 0;
uint8_t dayOfMonth = 0;
hal->getLocalDate(&dayOfMonth, &weekDay);
cursorPos = weekDay;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/tools/OswAppKcalStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

uint32_t findCursorWeekDay(uint8_t Index) { // Show the day of the week that cursor (Dynamic weekDay--info)
OswHal* hal = OswHal::getInstance();
uint32_t d, wD = 0;
uint8_t d, wD = 0;
hal->getLocalDate(&d, &wD);
int cursorWeekDay = wD - (6 - Index);
int findWeekDay = (cursorWeekDay >= 0) ? cursorWeekDay : (cursorWeekDay + 7);
Expand Down
10 changes: 5 additions & 5 deletions src/apps/tools/OswAppStepStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ void OswAppStepStats::drawChart() {
uint8_t interval = 20;
uint16_t goalValue = OswConfigAllKeys::stepsPerDay.get();

uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t weekDay = 0;
uint8_t dayOfMonth = 0;
hal->getLocalDate(&dayOfMonth, &weekDay);

for (uint8_t index = 0; index < 7; index++) {
Expand All @@ -33,7 +33,7 @@ void OswAppStepStats::drawChart() {
}
}

void OswAppStepStats::drawInfoPanel(OswUI* ui, uint32_t pos, uint32_t lastWeekData, uint32_t todayData, uint32_t average, uint32_t total,const String& unit) {
void OswAppStepStats::drawInfoPanel(OswUI* ui, uint8_t pos, uint32_t lastWeekData, uint32_t todayData, uint32_t average, uint32_t total,const String& unit) {
OswHal* hal = OswHal::getInstance();

uint8_t coord_X = 30;
Expand Down Expand Up @@ -69,8 +69,8 @@ void OswAppStepStats::showStickChart() {

void OswAppStepStats::setup() {
OswHal* hal = OswHal::getInstance();
uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t weekDay = 0;
uint8_t dayOfMonth = 0;
hal->getLocalDate(&dayOfMonth, &weekDay);
cursorPos = weekDay;
}
Expand Down
16 changes: 8 additions & 8 deletions src/apps/tools/OswAppTimeConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
void OswAppTimeConfig::setup() {}

void OswAppTimeConfig::enterManualMode() {
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint32_t day = 0;
uint32_t month = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
uint8_t day = 0;
uint8_t month = 0;
uint32_t year = 0;
OswHal::getInstance()->getLocalTime(&hour, &minute, &second);
OswHal::getInstance()->getLocalDate(&day, &month, &year);
Expand Down Expand Up @@ -197,9 +197,9 @@ void OswAppTimeConfig::loop() {
hal->gfx()->setTextLeftAligned();
hal->gfx()->setTextCursor(120 - hal->gfx()->getTextOfsetColumns(4), 120);

uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
hal->getLocalTime(&hour, &minute, &second);
hal->gfx()->printDecimal(hour, 2);
hal->gfx()->print(":");
Expand Down
16 changes: 8 additions & 8 deletions src/apps/watchfaces/OswAppWatchface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const char* OswAppWatchface::getAppName() {
void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint32_t max) {
OswHal* hal = OswHal::getInstance();
OswUI::getInstance()->resetTextColors();
uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t weekDay = 0;
uint8_t dayOfMonth = 0;
hal->getLocalDate(&dayOfMonth, &weekDay);
for (uint8_t i = 0; i < 7; i++) {
uint32_t s = hal->environment()->getStepsOnDay(i);
Expand Down Expand Up @@ -91,15 +91,15 @@ void OswAppWatchface::drawWatch() {
// hal->gfx()->drawArc(120, 120, 0, bat, 180, 57, 7, dimColor(COLOR_BLUE, 25));
// hal->gfx()->drawArc(120, 120, 0, bat, 180, 57, 6, COLOR_BLUE);

uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
hal->getLocalTime(&hour, &minute, &second);

if(OswConfigAllKeys::settingDisplayDualHourTick.get()) {
uint32_t dualSecond = 0;
uint32_t dualMinute = 0;
uint32_t dualHour = 0;
uint8_t dualSecond = 0;
uint8_t dualMinute = 0;
uint8_t dualHour = 0;
hal->getDualTime(&dualHour, &dualMinute, &dualSecond);

// dual-hours
Expand Down
6 changes: 3 additions & 3 deletions src/apps/watchfaces/OswAppWatchfaceBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#define COLOR_WHxITE rgb565(255, 255, 255)

void OswAppWatchfaceBinary::drawWatch() {
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
bool afterNoon = false;
OswHal* hal = OswHal::getInstance();
hal->getLocalTime(&hour, &minute, &second, &afterNoon);
Expand Down
14 changes: 7 additions & 7 deletions src/apps/watchfaces/OswAppWatchfaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void OswAppWatchfaceDigital::displayWeekDay3(const char* weekday) {
hal->gfx()->print(weekday3);
}

void OswAppWatchfaceDigital::dateOutput(uint32_t yearInt, uint32_t monthInt, uint32_t dayInt) {
void OswAppWatchfaceDigital::dateOutput(uint32_t yearInt, uint8_t monthInt, uint8_t dayInt) {
OswHal* hal = OswHal::getInstance();
switch (OswAppWatchfaceDigital::getDateFormat()) {
case 1: // 0 : mm/dd/yyyy
Expand Down Expand Up @@ -61,8 +61,8 @@ void OswAppWatchfaceDigital::dateOutput(uint32_t yearInt, uint32_t monthInt, uin
}

static void drawDate(time_t timeZone, uint8_t fontSize, uint8_t CoordY) {
uint32_t dayInt = 0;
uint32_t monthInt = 0;
uint8_t dayInt = 0;
uint8_t monthInt = 0;
uint32_t yearInt = 0;
OswHal* hal = OswHal::getInstance();
const char* weekday = hal->getWeekday(timeZone);
Expand All @@ -89,7 +89,7 @@ static void drawDate(time_t timeZone, uint8_t fontSize, uint8_t CoordY) {
OswAppWatchfaceDigital::dateOutput(yearInt, monthInt, dayInt);
}

void OswAppWatchfaceDigital::timeOutput(uint32_t hour, uint32_t minute, uint32_t second,bool showSecond) {
void OswAppWatchfaceDigital::timeOutput(uint8_t hour, uint8_t minute, uint8_t second,bool showSecond) {
OswHal* hal = OswHal::getInstance();
hal->gfx()->printDecimal(hour, 2);
hal->gfx()->print(":");
Expand All @@ -101,9 +101,9 @@ void OswAppWatchfaceDigital::timeOutput(uint32_t hour, uint32_t minute, uint32_t
}

static void drawTime(time_t timeZone,uint8_t CoordY) {
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
bool afterNoon = false;
char am[] = "AM";
char pm[] = "PM";
Expand Down
4 changes: 2 additions & 2 deletions src/apps/watchfaces/OswAppWatchfaceDual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ void OswAppWatchfaceDual::drawProgressBar(OswUI* ui,uint8_t cx, uint8_t cy, uint
void OswAppWatchfaceDual::drawAnimSec() {
OswHal* hal = OswHal::getInstance();
uint8_t barWidth = 140;
uint32_t Hs, Ms, Ss = 0;
uint8_t Hs, Ms, Ss = 0;
hal->getLocalTime(&Hs,&Ms,&Ss);
uint32_t onlySecond = Ss;
uint8_t onlySecond = Ss;
uint16_t barValue = ((float)onlySecond / 60) * barWidth;
barValue = barValue < 2 ? 0 : barValue;
uint8_t coordX = (DISP_W - barWidth) / 2;
Expand Down
10 changes: 5 additions & 5 deletions src/apps/watchfaces/OswAppWatchfaceFitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ uint32_t OswAppWatchfaceFitness::calculateKcalorie(uint32_t steps) {
}

void dateDisplay() {
uint32_t dayInt = 0;
uint32_t monthInt = 0;
uint8_t dayInt = 0;
uint8_t monthInt = 0;
uint32_t yearInt = 0;
OswHal* hal = OswHal::getInstance();
const char* weekday = hal->getLocalWeekday();
Expand Down Expand Up @@ -62,9 +62,9 @@ void timeDisplay(uint32_t hour, uint32_t minute, uint32_t second) {
}

void digitalWatchDisplay() {
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
bool afterNoon = false;
char am[] = "AM";
char pm[] = "PM";
Expand Down
12 changes: 6 additions & 6 deletions src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void OswAppWatchfaceFitnessAnalog::drawWatchFace(OswHal* hal, uint32_t hour, uin
#endif
}

void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon) {
void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon) {
const char* weekday = hal->getLocalWeekday();

hal->gfx()->setTextSize(2);
Expand All @@ -119,8 +119,8 @@ void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint32_t hour, uint
OswAppWatchfaceDigital::displayWeekDay3(weekday);

// Date
uint32_t dayInt = 0;
uint32_t monthInt = 0;
uint8_t dayInt = 0;
uint8_t monthInt = 0;
uint32_t yearInt = 0;
hal->getLocalDate(&dayInt, &monthInt, &yearInt);
hal->gfx()->setTextSize(3);
Expand Down Expand Up @@ -207,9 +207,9 @@ void OswAppWatchfaceFitnessAnalog::onDraw() {

OswHal* hal = OswHal::getInstance();

uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
bool afterNoon;
hal->getLocalTime(&hour, &minute, &second, &afterNoon);

Expand Down
16 changes: 8 additions & 8 deletions src/apps/watchfaces/OswAppWatchfaceMix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const char* OswAppWatchfaceMix::getAppName() {

void OswAppWatchfaceMix::analogWatchDisplay() {
OswHal* hal = OswHal::getInstance();
uint32_t second = 0;
uint32_t minute = 0; // Unused, but required by function signature
uint32_t hour = 0; // Unused, but required by function signature
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;

hal->getLocalTime(&hour, &minute, &second);
hal->gfx()->drawCircle((int)(DISP_W*0.5)-OFF_SET_ANALOG_WATCH_X_COORD, 100, 50, ui->getForegroundColor());
Expand All @@ -49,8 +49,8 @@ void OswAppWatchfaceMix::analogWatchDisplay() {
}

void OswAppWatchfaceMix::dateDisplay() {
uint32_t dayInt = 0;
uint32_t monthInt = 0;
uint8_t dayInt = 0;
uint8_t monthInt = 0;
uint32_t yearInt = 0;
OswHal* hal = OswHal::getInstance();
const char* weekday = hal->getLocalWeekday();
Expand All @@ -76,9 +76,9 @@ void OswAppWatchfaceMix::dateDisplay() {
}

void OswAppWatchfaceMix::digitalWatchDisplay() {
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
bool afterNoon = false;
char am[] = "AM";
char pm[] = "PM";
Expand Down
12 changes: 6 additions & 6 deletions src/apps/watchfaces/OswAppWatchfaceMonotimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ void OswAppWatchfaceMonotimer::drawWatch() {
#endif

// ticks
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
hal->getLocalTime(&hour, &minute, &second);

if (OswConfigAllKeys::settingDisplayDualHourTick.get()) {
uint32_t dualSecond = 0;
uint32_t dualMinute = 0;
uint32_t dualHour = 0;
uint8_t dualSecond = 0;
uint8_t dualMinute = 0;
uint8_t dualHour = 0;
hal->getDualTime(&dualHour, &dualMinute, &dualSecond);

hal->gfx()->drawThickTick(120, 120, 0, 105, (360.0f * (60 * dualHour + dualMinute)) / 720.0f, 1, ui->getBackgroundDimmedColor());
Expand Down
16 changes: 8 additions & 8 deletions src/apps/watchfaces/OswAppWatchfaceNumerals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void OswAppWatchfaceNumerals::drawWatch() {

OswAppWatchfaceMonotimer::drawHour();

uint32_t dayInt = 0;
uint32_t monthInt = 0;
uint8_t dayInt = 0;
uint8_t monthInt = 0;
uint32_t yearInt = 0;
hal->getLocalDate(&dayInt, &monthInt, &yearInt);
hal->gfx()->setTextCenterAligned();
Expand All @@ -61,14 +61,14 @@ void OswAppWatchfaceNumerals::drawWatch() {
#endif

// ticks
uint32_t second = 0;
uint32_t minute = 0;
uint32_t hour = 0;
uint8_t second = 0;
uint8_t minute = 0;
uint8_t hour = 0;
hal->getLocalTime(&hour, &minute, &second);
if(OswConfigAllKeys::settingDisplayDualHourTick.get()) {
uint32_t dualSecond = 0;
uint32_t dualMinute = 0;
uint32_t dualHour = 0;
uint8_t dualSecond = 0;
uint8_t dualMinute = 0;
uint8_t dualHour = 0;
hal->getDualTime(&dualHour, &dualMinute, &dualSecond);

// dual-hours
Expand Down
Loading

0 comments on commit 1c3574b

Please sign in to comment.