Skip to content

Commit

Permalink
Apps: remove unnecessary data type
Browse files Browse the repository at this point in the history
  • Loading branch information
RuffaloLavoisier committed Oct 7, 2024
1 parent 3f5698a commit d8fb1aa
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 149 deletions.
5 changes: 0 additions & 5 deletions src/apps/tools/OswAppDistStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ void OswAppDistStats::drawChart() {
uint8_t interval = 20;
uint16_t goalValue = OswConfigAllKeys::distPerDay.get();

OswDate oswDate = { };
hal->getLocalDate(oswDate);
uint32_t weekDay = oswDate.day;
uint32_t dayOfMonth = oswDate.weekDay;

for (uint8_t index = 0; index < 7; index++) {
uint32_t weekDayDist = OswAppWatchfaceFitness::calculateDistance(hal->environment()->getStepsOnDay(index));
uint16_t chartStickValue = ((float)(weekDayDist > goalValue ? goalValue : weekDayDist) / goalValue) * chartStickHeight;
Expand Down
5 changes: 0 additions & 5 deletions src/apps/tools/OswAppStepStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ void OswAppStepStats::drawChart() {
uint8_t interval = 20;
uint16_t goalValue = OswConfigAllKeys::stepsPerDay.get();

OswDate oswDate = { };
hal->getLocalDate(oswDate);
uint32_t weekDay = oswDate.weekDay;
uint32_t dayOfMonth = oswDate.day;

for (uint8_t index = 0; index < 7; index++) {
unsigned int weekDayStep = hal->environment()->getStepsOnDay(index);
unsigned short chartStickValue = ((float)(weekDayStep > goalValue ? goalValue : weekDayStep) / goalValue) * chartStickHeight;
Expand Down
28 changes: 11 additions & 17 deletions src/apps/tools/OswAppTimeConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,17 @@ void OswAppTimeConfig::enterManualMode() {
OswDate oswDate = { };
OswHal::getInstance()->getLocalTime(oswTime);
OswHal::getInstance()->getLocalDate(oswDate);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;
uint32_t day = oswDate.day;
uint32_t month = oswDate.month;
uint32_t year = oswDate.year;
manualSettingTimestamp[0] = year % 10;
manualSettingTimestamp[1] = month / 10;
manualSettingTimestamp[2] = month % 10;
manualSettingTimestamp[3] = day / 10;
manualSettingTimestamp[4] = day % 10;
manualSettingTimestamp[5] = hour / 10;
manualSettingTimestamp[6] = hour % 10;
manualSettingTimestamp[7] = minute / 10;
manualSettingTimestamp[8] = minute % 10;
manualSettingTimestamp[9] = second / 10;
manualSettingTimestamp[10] = second % 10;
manualSettingTimestamp[0] = oswDate.year % 10;
manualSettingTimestamp[1] = oswDate.month / 10;
manualSettingTimestamp[2] = oswDate.month % 10;
manualSettingTimestamp[3] = oswDate.day / 10;
manualSettingTimestamp[4] = oswDate.day % 10;
manualSettingTimestamp[5] = oswTime.hour / 10;
manualSettingTimestamp[6] = oswTime.hour % 10;
manualSettingTimestamp[7] = oswTime.minute / 10;
manualSettingTimestamp[8] = oswTime.minute % 10;
manualSettingTimestamp[9] = oswTime.second / 10;
manualSettingTimestamp[10] = oswTime.second % 10;
manualSettingScreen = true;
}

Expand Down
27 changes: 10 additions & 17 deletions src/apps/watchfaces/OswAppWatchface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w

OswDate oswDate = { };
hal->getLocalDate(oswDate);
uint32_t weekDay = oswDate.weekDay;

for (uint8_t i = 0; i < 7; i++) {
uint32_t s = hal->environment()->getStepsOnDay(i);
Expand All @@ -42,7 +41,7 @@ void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w
uint16_t c = (unsigned int) OswConfigAllKeys::stepsPerDay.get() <= s ? ui->getSuccessColor() : ui->getPrimaryColor();
hal->gfx()->fillFrame(x + i * w, y + (h - boxHeight), w, boxHeight, c);
// bar frames
uint16_t f = weekDay == i ? ui->getForegroundColor() : ui->getForegroundDimmedColor();
uint16_t f = oswDate.weekDay == i ? ui->getForegroundColor() : ui->getForegroundDimmedColor();
hal->gfx()->drawRFrame(x + i * w, y, w, h, 2, f);

// labels
Expand Down Expand Up @@ -96,33 +95,27 @@ void OswAppWatchface::drawWatch() {

OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;

if(OswConfigAllKeys::settingDisplayDualHourTick.get()) {
OswTime oswTime = { };
hal->getDualTime(oswTime);
uint32_t dualSecond = oswTime.second;
uint32_t dualMinute = oswTime.minute;
uint32_t dualHour = oswTime.hour;
OswTime oswDualTime = { };
hal->getDualTime(oswDualTime);

// dual-hours
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 12.0f * (dualHour + dualMinute / 60.0f)), 2, ui->getBackgroundDimmedColor(), true, STRAIGHT_END);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 60, (int)(360.0f / 12.0f * (dualHour + dualMinute / 60.0f)), 5, ui->getBackgroundDimmedColor(), true);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 12.0f * (oswDualTime.hour + oswDualTime.minute / 60.0f)), 2, ui->getBackgroundDimmedColor(), true, STRAIGHT_END);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 60, (int)(360.0f / 12.0f * (oswDualTime.hour + oswDualTime.minute / 60.0f)), 5, ui->getBackgroundDimmedColor(), true);
}
// hours
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, (int)16, (int)(360.0f / 12.0f * (hour + minute / 60.0f)), 1, ui->getForegroundColor(), true, STRAIGHT_END);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 60, (int)(360.0f / 12.0f * (hour + minute / 60.0f)), 4, ui->getForegroundColor(), true);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, (int)16, (int)(360.0f / 12.0f * (oswTime.hour + oswTime.minute / 60.0f)), 1, 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)), 4, ui->getForegroundColor(), true);

// minutes
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 60.0f * (minute + second / 60.0f)), 1, ui->getForegroundColor(), true, STRAIGHT_END);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 16, 105, (int)(360.0f / 60.0f * (minute + second / 60.0f)), 4, ui->getForegroundColor(), true);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, 0, 16, (int)(360.0f / 60.0f * (oswTime.minute + oswTime.second / 60.0f)), 1, 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)), 4, ui->getForegroundColor(), true);

#ifndef GIF_BG
// seconds
hal->gfx()->fillCircleAA(CENTER_X, CENTER_Y, 3, ui->getDangerColor());
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, -16, 110, 180 + 360 / 60 * second, 1, ui->getDangerColor(), true);
hal->gfx()->drawThickTick(CENTER_X, CENTER_Y, -16, 110, 180 + 360 / 60 * oswTime.second, 1, ui->getDangerColor(), true);
#endif
}

Expand Down
10 changes: 3 additions & 7 deletions src/apps/watchfaces/OswAppWatchfaceBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ void OswAppWatchfaceBinary::drawWatch() {

OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;
bool afterNoon = oswTime.afterNoon;

uint16_t width = hal->gfx()->getWidth();
uint16_t height = hal->gfx()->getHeight();

//hours
for(uint8_t i = 0; i < 5 ; i++ ) {
uint32_t b = pow(2, i);
if((hour & b) == 0) {
if((oswTime.hour & b) == 0) {
hal->gfx()->drawFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2 - 16, 8, 8, ui->getWarningColor());
} else {
hal->gfx()->fillFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2 - 16, 8, 8, ui->getWarningColor());
Expand All @@ -38,7 +34,7 @@ void OswAppWatchfaceBinary::drawWatch() {
//minutes
for(uint8_t i = 0; i < 6 ; i++ ) {
uint32_t b = pow(2, i);
if((minute & b) == 0) {
if((oswTime.minute & b) == 0) {
hal->gfx()->drawFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2, 8, 8, ui->getDangerColor());
} else {
hal->gfx()->fillFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2, 8, 8, ui->getDangerColor());
Expand All @@ -47,7 +43,7 @@ void OswAppWatchfaceBinary::drawWatch() {
//seconds
for(uint8_t i = 0; i < 6 ; i++ ) {
uint32_t b = pow(2, i);
if((second & b) == 0) {
if((oswTime.second & b) == 0) {
hal->gfx()->drawFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2 + 16, 8, 8, ui->getInfoColor());
} else {
hal->gfx()->fillFrame(width - (((width - 32) / 8) * i + 64) - 32, height / 2 + 16, 8, 8, ui->getInfoColor());
Expand Down
8 changes: 1 addition & 7 deletions src/apps/watchfaces/OswAppWatchfaceDigital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@ 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;
uint32_t yearInt = 0;
const char* weekday = nullptr;
OswDate oswDate = { };
OswHal* hal = OswHal::getInstance();

hal->getDate(timeZone, oswDate);

dayInt = oswDate.day;
monthInt = oswDate.month;
yearInt = oswDate.year;
weekday = oswDate.weekDayName;
// we want to output a value like "Wed, 05/02/2021"

Expand All @@ -91,7 +85,7 @@ 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(yearInt, monthInt, dayInt);
OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day);
}

void OswAppWatchfaceDigital::timeOutput(uint32_t hour, uint32_t minute, uint32_t second,bool showSecond) {
Expand Down
13 changes: 3 additions & 10 deletions src/apps/watchfaces/OswAppWatchfaceFitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ void dateDisplay() {

OswDate oswDate = { };
hal->getLocalDate(oswDate);
uint32_t dayInt = oswDate.day;
uint32_t monthInt = oswDate.month;
uint32_t yearInt = oswDate.year;
const char* weekday = oswDate.weekDayName;

hal->gfx()->setTextSize(2);
Expand All @@ -46,7 +43,7 @@ void dateDisplay() {
hal->gfx()->setTextMiddleAligned();
hal->gfx()->setTextLeftAligned();
hal->gfx()->setTextCursor(DISP_W / 2 - 30 + hal->gfx()->getTextOfsetColumns(1), 150);
OswAppWatchfaceDigital::dateOutput(yearInt, monthInt, dayInt);
OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day);
}

void timeDisplay(uint32_t hour, uint32_t minute, uint32_t second) {
Expand All @@ -73,15 +70,11 @@ void digitalWatchDisplay() {
hal->gfx()->setTextCursor(DISP_W / 2 - 30, DISP_W / 2);
OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;
bool afterNoon = oswTime.afterNoon;

timeDisplay(hour, minute, second);
timeDisplay(oswTime.hour, oswTime.minute, oswTime.second);
if (!OswConfigAllKeys::timeFormat.get()) {
hal->gfx()->setTextCursor(215, 130);
if (afterNoon) {
if (oswTime.afterNoon) {
hal->gfx()->print(pm);
} else {
hal->gfx()->print(am);
Expand Down
15 changes: 3 additions & 12 deletions src/apps/watchfaces/OswAppWatchfaceFitnessAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,11 @@ void OswAppWatchfaceFitnessAnalog::drawDateFace(OswHal* hal, uint32_t hour, uint
hal->gfx()->setTextRightAligned();
hal->gfx()->setTextCursor(205, 75);
OswAppWatchfaceDigital::displayWeekDay3(weekday);

// Date
uint32_t dayInt = oswDate.day;
uint32_t monthInt = oswDate.month;
uint32_t yearInt = oswDate.year;

hal->gfx()->setTextSize(3);
hal->gfx()->setTextLeftAligned();
hal->gfx()->setTextCursor(CENTER_X - 70, 170);
OswAppWatchfaceDigital::dateOutput(yearInt, monthInt, dayInt);
OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day);

hal->gfx()->setTextSize(4);
hal->gfx()->setTextLeftAligned();
Expand Down Expand Up @@ -210,19 +205,15 @@ void OswAppWatchfaceFitnessAnalog::onDraw() {
OswHal* hal = OswHal::getInstance();

OswTime oswTime = { };
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;
bool afterNoon = oswTime.afterNoon;

if (this->screen == 0) {
#if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1
showFitnessTracking(hal);
#endif

drawWatchFace(hal, hour, minute, second, afterNoon);
drawWatchFace(hal, oswTime.hour, oswTime.minute, oswTime.second, oswTime.afterNoon);
} else if (this->screen == 1) {
drawDateFace(hal, hour, minute, second, afterNoon);
drawDateFace(hal, oswTime.hour, oswTime.minute, oswTime.second, oswTime.afterNoon);

static int wait_time = 1;
if (wait_time >= 0)
Expand Down
32 changes: 11 additions & 21 deletions src/apps/watchfaces/OswAppWatchfaceMix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,32 @@ void OswAppWatchfaceMix::analogWatchDisplay() {
OswHal* hal = OswHal::getInstance();
OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;

hal->gfx()->drawCircle((int)(DISP_W*0.5)-OFF_SET_ANALOG_WATCH_X_COORD, 100, 50, ui->getForegroundColor());
hal->gfx()->drawHourTicks((int)(DISP_W*0.5)-OFF_SET_ANALOG_WATCH_X_COORD, 100, 45, 40, ui->getForegroundDimmedColor());

// hour
hal->gfx()->drawLine(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 100,
rpx(DISP_W/3-OFF_SET_ANALOG_WATCH_X_COORD, 33 / 2, (int32_t) (hour * 30 + minute/10 * 6)),
rpy(100, 33 / 2, (int32_t)(hour * 30 + minute/10 * 6)), ui->getForegroundColor());
rpx(DISP_W/3-OFF_SET_ANALOG_WATCH_X_COORD, 33 / 2, (int32_t) (oswTime.hour * 30 + oswTime.minute/10 * 6)),
rpy(100, 33 / 2, (int32_t)(oswTime.hour * 30 + oswTime.minute/10 * 6)), ui->getForegroundColor());
// minute
hal->gfx()->drawLine(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 100,
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 66 / 2, (int32_t) minute * 6),
rpy(100, 66 / 2, (int32_t)(minute * 6)), ui->getSuccessColor());
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 66 / 2, (int32_t) oswTime.minute * 6),
rpy(100, 66 / 2, (int32_t)(oswTime.minute * 6)), ui->getSuccessColor());
// second
hal->gfx()->drawLine(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 100,
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 15 / 2, s2d(second) + 180),
rpy(100, (int)(15 * 0.5f), s2d(second) + 180), ui->getDangerColor()); // short backwards
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 15 / 2, s2d(oswTime.second) + 180),
rpy(100, (int)(15 * 0.5f), s2d(oswTime.second) + 180), ui->getDangerColor()); // short backwards
hal->gfx()->drawLine(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 100,
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 90 / 2, s2d(second)),
rpy(100, (int)(90 * 0.5f), s2d(second)), ui->getDangerColor()); // long front
rpx(DISP_W/2-OFF_SET_ANALOG_WATCH_X_COORD, 90 / 2, s2d(oswTime.second)),
rpy(100, (int)(90 * 0.5f), s2d(oswTime.second)), ui->getDangerColor()); // long front
}

void OswAppWatchfaceMix::dateDisplay() {
OswHal* hal = OswHal::getInstance();

OswDate oswDate = { };
hal->getLocalDate(oswDate);
uint32_t dayInt = oswDate.day;
uint32_t monthInt = oswDate.month;
uint32_t yearInt = oswDate.year;
const char* weekday = oswDate.weekDayName;

hal->gfx()->setTextSize(1);
Expand All @@ -74,7 +68,7 @@ void OswAppWatchfaceMix::dateDisplay() {
hal->gfx()->setTextLeftAligned();
hal->gfx()->setTextCursor(DISP_W / 2 - OFF_SET_DATE_DIGITAL_WATCH_X_COORD, 90);

OswAppWatchfaceDigital::dateOutput(yearInt, monthInt, dayInt);
OswAppWatchfaceDigital::dateOutput(oswDate.year, oswDate.month, oswDate.day);
}

void OswAppWatchfaceMix::digitalWatchDisplay() {
Expand All @@ -89,11 +83,7 @@ void OswAppWatchfaceMix::digitalWatchDisplay() {

OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;
bool afterNoon = oswTime.afterNoon;
OswAppWatchfaceDigital::timeOutput(hour, minute, second,false);
OswAppWatchfaceDigital::timeOutput(oswTime.hour, oswTime.minute, oswTime.second, false);
if (!OswConfigAllKeys::timeFormat.get()) {
hal->gfx()->setTextSize(1);
hal->gfx()->setTextMiddleAligned();
Expand All @@ -103,7 +93,7 @@ void OswAppWatchfaceMix::digitalWatchDisplay() {
hal->gfx()->setTextCursor(DISP_W / 2 - OFF_SET_DATE_DIGITAL_WATCH_X_COORD + hal->gfx()->getTextOfsetColumns(5.25f), 130);
hal->gfx()->setTextSize(1);
hal->gfx()->print(" ");
if (afterNoon) {
if (oswTime.afterNoon) {
hal->gfx()->print(pm);
} else {
hal->gfx()->print(am);
Expand Down
14 changes: 4 additions & 10 deletions src/apps/watchfaces/OswAppWatchfaceMonotimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,15 @@ void OswAppWatchfaceMonotimer::drawWatch() {
// ticks
OswTime oswTime = { };
hal->getLocalTime(oswTime);
uint32_t second = oswTime.second;
uint32_t minute = oswTime.minute;
uint32_t hour = oswTime.hour;

if (OswConfigAllKeys::settingDisplayDualHourTick.get()) {
OswTime oswTime = { };
hal->getDualTime(oswTime);
uint32_t dualSecond = oswTime.second;
uint32_t dualMinute = oswTime.minute;
uint32_t dualHour = oswTime.hour;
OswTime oswDualTime = { };
hal->getDualTime(oswDualTime);

hal->gfx()->drawThickTick(120, 120, 0, 105, (360.0f * (60 * dualHour + dualMinute)) / 720.0f, 1, ui->getBackgroundDimmedColor());
hal->gfx()->drawThickTick(120, 120, 0, 105, (360.0f * (60 * oswDualTime.hour + oswDualTime.minute)) / 720.0f, 1, ui->getBackgroundDimmedColor());
}

hal->gfx()->drawThickTick(120, 120, 0, 105, (360.0f * (60 * hour + minute)) / 720.0f, 1, ui->getForegroundColor());
hal->gfx()->drawThickTick(120, 120, 0, 105, (360.0f * (60 * oswTime.hour + oswTime.minute)) / 720.0f, 1, ui->getForegroundColor());

hal->gfx()->fillEllipse(120, 120, 4, 4, ui->getForegroundColor());
}
Expand Down
Loading

0 comments on commit d8fb1aa

Please sign in to comment.