diff --git a/include/apps/watchfaces/OswAppWatchface.h b/include/apps/watchfaces/OswAppWatchface.h index 2724bccda..ed33c0052 100644 --- a/include/apps/watchfaces/OswAppWatchface.h +++ b/include/apps/watchfaces/OswAppWatchface.h @@ -22,7 +22,7 @@ class OswAppWatchface : public OswAppV2 { void onButton(Button id, bool up, ButtonStateNames state) override; #ifdef OSW_FEATURE_STATS_STEPS - static void drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint32_t max); + static void drawStepHistory(OswUI* ui, uint8_t posX, uint8_t posY, uint8_t width, uint8_t height, uint32_t max); #endif static void addButtonDefaults(std::array& knownButtonStates); static bool onButtonDefaults(OswAppV2& app, Button id, bool up, ButtonStateNames state); diff --git a/src/apps/watchfaces/OswAppWatchface.cpp b/src/apps/watchfaces/OswAppWatchface.cpp index 477d3a078..b0268e54d 100644 --- a/src/apps/watchfaces/OswAppWatchface.cpp +++ b/src/apps/watchfaces/OswAppWatchface.cpp @@ -27,7 +27,7 @@ const char* OswAppWatchface::getAppName() { } #ifdef OSW_FEATURE_STATS_STEPS -void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint32_t max) { +void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t posX, uint8_t posY, uint8_t width, uint8_t height, uint32_t max) { OswHal* hal = OswHal::getInstance(); OswUI::getInstance()->resetTextColors(); uint32_t weekDay = 0; @@ -36,25 +36,25 @@ void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w hal->getLocalDate(&dayOfMonth, &weekDay); for (index = 0; index < WEEK; index++) { uint32_t stepsCountOnDay = hal->environment()->getStepsOnDay(index); - uint16_t boxHeight = ((float)(stepsCountOnDay > max ? max : stepsCountOnDay) / max) * h; - boxHeight = boxHeight < 2 ? 0 : boxHeight; + uint16_t boxHeight = ((float)(stepsCountOnDay > max ? max : stepsCountOnDay) / max) * height; + boxHeight = boxHeight < 2 ? 0 : boxHeight; // minumum value is 2 // step bars - uint16_t c = (unsigned int) OswConfigAllKeys::stepsPerDay.get() <= stepsCountOnDay ? ui->getSuccessColor() : ui->getPrimaryColor(); - hal->gfx()->fillFrame(x + index * w, y + (h - boxHeight), w, boxHeight, c); + uint16_t stepsCountBoxColor = (unsigned int) OswConfigAllKeys::stepsPerDay.get() <= stepsCountOnDay ? ui->getSuccessColor() : ui->getPrimaryColor(); + hal->gfx()->fillFrame(posX + index * width, posY + (height - boxHeight), width, boxHeight, stepsCountBoxColor); // bar frames - uint16_t f = weekDay == index ? ui->getForegroundColor() : ui->getForegroundDimmedColor(); - hal->gfx()->drawRFrame(x + index * w, y, w, h, 2, f); + uint16_t frameLineColor = weekDay == index ? ui->getForegroundColor() : ui->getForegroundDimmedColor(); + hal->gfx()->drawRFrame(posX + index * width, posY, width, height, 2, frameLineColor); // 2 is cornerRoundness // labels hal->gfx()->setTextCenterAligned(); // horiz. hal->gfx()->setTextBottomAligned(); hal->gfx()->setTextSize(1); - hal->gfx()->setTextCursor(CENTER_X, y - 1); + hal->gfx()->setTextCursor(CENTER_X, posY - 1); hal->gfx()->print(hal->environment()->getStepsToday() + (OswConfigAllKeys::settingDisplayStepsGoal.get() ? String("/") + max:"")); - hal->gfx()->setTextCursor(CENTER_X, y + 1 + 8 + w * 4); + hal->gfx()->setTextCursor(CENTER_X, 221); hal->gfx()->setTextColor(ui->getForegroundColor()); // Let's make the background transparent. // See : https://github.com/Open-Smartwatch/open-smartwatch-os/issues/194 // font : WHITE / bg : None @@ -73,7 +73,7 @@ void OswAppWatchface::drawWatch() { #if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1 uint32_t steps = hal->environment()->getStepsToday(); uint32_t stepsTarget = OswConfigAllKeys::stepsPerDay.get(); - hal->gfx()->drawArc(CENTER_X, CENTER_Y, 0, 360.0f * (float)(steps % stepsTarget) / (float)stepsTarget, 90, 93, 6, + hal->gfx()->drawArc(CENTER_X, CENTER_Y, 0, (float) (360.0f / stepsTarget * (steps % stepsTarget)), 90, 93, 6, steps > stepsTarget ? ui->getSuccessColor() : ui->getInfoColor(), true); #endif diff --git a/src/apps/watchfaces/OswAppWatchfaceDual.cpp b/src/apps/watchfaces/OswAppWatchfaceDual.cpp index 2e49d2107..eec2652ff 100644 --- a/src/apps/watchfaces/OswAppWatchfaceDual.cpp +++ b/src/apps/watchfaces/OswAppWatchfaceDual.cpp @@ -32,10 +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; - hal->getLocalTime(&Hs,&Ms,&Ss); - uint32_t onlySecond = Ss; - uint16_t barValue = ((float)onlySecond / 60) * barWidth; + uint32_t seconds = 0; + hal->getLocalTime(nullptr, nullptr, &seconds); + uint16_t barValue = ((float)seconds / 60) * barWidth; barValue = barValue < 2 ? 0 : barValue; uint8_t coordX = (DISP_W - barWidth) / 2; uint8_t levelY = DISP_H / 2; diff --git a/src/hal/time.cpp b/src/hal/time.cpp index 7d9251e66..f6a5c6462 100644 --- a/src/hal/time.cpp +++ b/src/hal/time.cpp @@ -29,9 +29,15 @@ void OswHal::updateTimeProvider() { void OswHal::getUTCTime(uint32_t* hour, uint32_t* minute, uint32_t* second) { RtcDateTime d = RtcDateTime(); d.InitWithUnix32Time(this->getUTCTime()); - *hour = d.Hour(); - *minute = d.Minute(); - *second = d.Second(); + if (hour != nullptr){ + *hour = d.Hour(); + } + if (minute != nullptr){ + *minute = d.Minute(); + } + if (second != nullptr){ + *second = d.Second(); + } } void OswHal::getTime(time_t& offset, uint32_t* hour, uint32_t* minute, uint32_t* second, bool* afterNoon) { @@ -39,24 +45,38 @@ void OswHal::getTime(time_t& offset, uint32_t* hour, uint32_t* minute, uint32_t* d.InitWithUnix32Time(this->getTime(offset)); if (!OswConfigAllKeys::timeFormat.get()) { if (d.Hour() > 12) { - *hour = d.Hour() - 12; + if(hour != nullptr){ + *hour = d.Hour() - 12; + } if (afterNoon != nullptr) *afterNoon = true; } else if (d.Hour() == 0) { - *hour = 12; + if(hour != nullptr){ + *hour = 12; + } if (afterNoon != nullptr) *afterNoon = false; } else if (d.Hour() == 12) { - *hour = d.Hour(); + if(hour != nullptr){ + *hour = d.Hour(); + } if (afterNoon != nullptr) *afterNoon = true; } else { - *hour = d.Hour(); + if(hour != nullptr){ + *hour = d.Hour(); + } if (afterNoon != nullptr) *afterNoon = false; } } else { - *hour = d.Hour(); + if(hour != nullptr){ + *hour = d.Hour(); + } if (afterNoon != nullptr) *afterNoon = false; } - *minute = d.Minute(); - *second = d.Second(); + if (minute != nullptr){ + *minute = d.Minute(); + } + if (second != nullptr){ + *second = d.Second(); + } } /**