Skip to content

Commit

Permalink
Resize data size
Browse files Browse the repository at this point in the history
  • Loading branch information
RuffaloLavoisier committed Sep 28, 2024
1 parent ebfa6f9 commit d4c1db6
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 121 deletions.
12 changes: 6 additions & 6 deletions emulator/include/RtcDS3231.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class RtcDateTime {

void InitWithUnix32Time(time_t time);

uint32_t Hour();
uint32_t Minute();
uint32_t Second();
uint8_t Hour();
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
12 changes: 6 additions & 6 deletions emulator/src/RtcDS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ void RtcDateTime::InitWithUnix32Time(time_t time) {
this->time = time;
}

uint32_t RtcDateTime::Hour() {
uint8_t RtcDateTime::Hour() {
struct tm* parts = std::localtime(&this->time);
return parts->tm_hour;
}
uint32_t RtcDateTime::Minute() {
uint8_t RtcDateTime::Minute() {
struct tm* parts = std::localtime(&this->time);
return parts->tm_min;
}
uint32_t RtcDateTime::Second() {
uint8_t RtcDateTime::Second() {
struct tm* parts = std::localtime(&this->time);
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
10 changes: 5 additions & 5 deletions include/apps/watchfaces/OswAppWatchfaceFitnessAnalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ 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 timeDisplay(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second);
void timeDisplay(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon);
void dateDisplay(OswHal* hal, uint8_t hour, uint8_t minute, uint8_t second, bool afterNoon);

void test();

Expand All @@ -38,8 +38,8 @@ class OswAppWatchfaceFitnessAnalog : public OswAppV2 {
unsigned screen = 0;

void showFitnessTracking(OswHal* hal);
void drawWatchFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon);
void drawDateFace(OswHal* hal, uint32_t hour, uint32_t minute, uint32_t second, bool afterNoon);
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);

#ifdef GIF_BG
OswAppGifPlayer* bgGif = nullptr;
Expand Down
26 changes: 13 additions & 13 deletions include/osw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,50 +181,50 @@ class OswHal {
// UTC Time
void setUTCTime(const time_t& epoch);
time_t getUTCTime();
void getUTCTime(uint32_t* hour, uint32_t* minute, uint32_t* second);
void getUTCTime(uint8_t* hour, uint8_t* minute, uint8_t* second);

// Offset getters for primary / secondary time (cached!)
time_t getTimezoneOffsetPrimary();
time_t getTimezoneOffsetSecondary();

// New time functions with offset
time_t getTime(time_t& offset);
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 getTime(time_t& offset, uint8_t* hour, uint8_t* minute, uint8_t* second, bool* afterNoon = nullptr);
void getDate(time_t& offset, uint8_t* day, uint8_t* weekDay);
void getDate(time_t& offset, uint8_t* day, uint8_t* month, uint32_t* year);
const char* getWeekday(time_t& offset, uint8_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) {
inline void getLocalTime(uint8_t* hour, uint8_t* minute, uint8_t* second, bool* afterNoon = nullptr) {
this->getTime(this->timezoneOffsetPrimary, hour, minute, second, afterNoon);
}
inline uint32_t getLocalTime() {
return this->getTime(this->timezoneOffsetPrimary);
}
inline void getLocalDate(uint32_t* day, uint32_t* weekDay) {
inline void getLocalDate(uint8_t* day, uint8_t* weekDay) {
this->getDate(this->timezoneOffsetPrimary, day, weekDay);
};
inline void getLocalDate(uint32_t* day, uint32_t* month, uint32_t* year) {
inline void getLocalDate(uint8_t* day, uint8_t* month, uint32_t* year) {
this->getDate(this->timezoneOffsetPrimary, day, month, year);
};
inline const char* getLocalWeekday(uint32_t* sWDay = nullptr) {
inline const char* getLocalWeekday(uint8_t* sWDay = nullptr) {
return this->getWeekday(this->timezoneOffsetPrimary, sWDay);
};

// For backward compatibility: Dual time functions (= secondary timezone)
inline void getDualTime(uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon = nullptr) {
inline void getDualTime(uint8_t* hour, uint8_t* minute, uint8_t* second, bool* afterNoon = nullptr) {
this->getTime(this->timezoneOffsetSecondary, hour, minute, second, afterNoon);
}
inline uint32_t getDualTime() {
return this->getTime(this->timezoneOffsetSecondary);
}
inline void getDualDate(uint32_t* day, uint32_t* weekDay) {
inline void getDualDate(uint8_t* day, uint8_t* weekDay) {
this->getDate(this->timezoneOffsetSecondary, day, weekDay);
};
inline void getDualDate(uint32_t* day, uint32_t* month, uint32_t* year) {
inline void getDualDate(uint8_t* day, uint8_t* month, uint32_t* year) {
this->getDate(this->timezoneOffsetSecondary, day, month, year);
};
inline const char* getDualWeekday(uint32_t* sWDay = nullptr) {
inline const char* getDualWeekday(uint8_t* sWDay = nullptr) {
return this->getWeekday(this->timezoneOffsetSecondary, sWDay);
};

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
12 changes: 6 additions & 6 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 All @@ -48,7 +48,7 @@ void dateDisplay() {
OswAppWatchfaceDigital::dateOutput(yearInt, monthInt, dayInt);
}

void timeDisplay(uint32_t hour, uint32_t minute, uint32_t second) {
void timeDisplay(uint8_t hour, uint8_t minute, uint8_t second) {
OswHal* hal = OswHal::getInstance();
hal->gfx()->printDecimal(hour, 2);
hal->gfx()->print(":");
Expand All @@ -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
Loading

0 comments on commit d4c1db6

Please sign in to comment.