Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring code chunk #400

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Rename index, stepsCountOnDay
  • Loading branch information
RuffaloLavoisier committed Sep 15, 2024
commit d965f56859c3d5aea9b7b9350e8e81edd761e6a7
15 changes: 8 additions & 7 deletions src/apps/watchfaces/OswAppWatchface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w
OswUI::getInstance()->resetTextColors();
uint32_t weekDay = 0;
uint32_t dayOfMonth = 0;
uint8_t index = 0;
RuffaloLavoisier marked this conversation as resolved.
Show resolved Hide resolved
hal->getLocalDate(&dayOfMonth, &weekDay);
for (uint8_t i = 0; i < 7; i++) {
uint32_t s = hal->environment()->getStepsOnDay(i);
uint16_t boxHeight = ((float)(s > max ? max : s) / max) * h;
for (index = 0; index < 7; index++) {
uint32_t stepsCountOnDay = hal->environment()->getStepsOnDay(index);
uint16_t boxHeight = ((float)(stepsCountOnDay > max ? max : stepsCountOnDay) / max) * h;
boxHeight = boxHeight < 2 ? 0 : boxHeight;

// step bars
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);
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);
// bar frames
uint16_t f = weekDay == i ? ui->getForegroundColor() : ui->getForegroundDimmedColor();
hal->gfx()->drawRFrame(x + i * w, y, w, h, 2, f);
uint16_t f = weekDay == index ? ui->getForegroundColor() : ui->getForegroundDimmedColor();
hal->gfx()->drawRFrame(x + index * w, y, w, h, 2, f);

// labels
hal->gfx()->setTextCenterAligned(); // horiz.
Expand Down