Skip to content

Commit

Permalink
Apps : display goal steps on Watchfaces
Browse files Browse the repository at this point in the history
-Update watchface
-Add settingDisplayStepsGoal OSW keys
-See Open-Smartwatch#207
  • Loading branch information
RuffaloLavoisier committed Apr 17, 2022
1 parent d1aca96 commit 69235d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/osw_config_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern OswConfigKeyShort resetDay;
#if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1
extern OswConfigKeyInt stepsPerDay;
extern OswConfigKeyBool stepsHistoryClear;
extern OswConfigKeyBool settingDisplayStepsGoal;
#endif
extern OswConfigKeyDropDown settingDisplayDefaultWatchface;
} // namespace OswConfigAllKeys
Expand Down
9 changes: 8 additions & 1 deletion src/apps/watchfaces/watchface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ void OswAppWatchface::drawStepHistory(OswUI* ui, uint8_t x, uint8_t y, uint8_t w
hal->gfx()->setTextBottomAligned();
hal->gfx()->setTextSize(1);
hal->gfx()->setTextCursor(DISP_W / 2, y - 1);
hal->gfx()->print(hal->environment->getStepsToday());

if (OswConfigAllKeys::settingDisplayStepsGoal.get()) {
char stepsTodayNGoal[20];
sprintf(stepsTodayNGoal, "%d/%d", hal->environment->getStepsToday(), max);
hal->gfx()->print(stepsTodayNGoal);
} else {
hal->gfx()->print(hal->environment->getStepsToday());
}
hal->gfx()->setTextCursor(DISP_W / 2, y + 1 + 8 + w * 4);
hal->gfx()->setTextColor(ui->getForegroundColor()); // Let's make the background transparent.
// See : https://github.com/Open-Smartwatch/open-smartwatch-os/issues/194
Expand Down
7 changes: 6 additions & 1 deletion src/osw_config_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ OswConfigKeyBool settingDisplayOverlays("s3", "Display", "Display Overlays", "Sh
OswConfigKeyBool settingDisplayOverlaysOnWatchScreen("s4", "Display", "Display Watchface Overlays", nullptr, DISPLAY_OVERLAYS_ON_WF);
OswConfigKeyDropDown settingDisplayDefaultWatchface("n", "Display",
"Default Watchface ID (analog, digital, mix, binary)", "0,1,2,3", String(CONFIG_DEFAULT_WATCHFACE_INDEX));

#if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1
OswConfigKeyBool settingDisplayStepsGoal("g1", "Display", "Display Steps Goal", "Show goal steps", 1);
#endif
OswConfigKeyBool raiseToWakeEnabled("s5", "Power", "Raise/Tilt to Wake", "Enables Raise to Wake",
WAKE_FROM_RAISE);
OswConfigKeyShort raiseToWakeSensitivity("s6", "Power", "Raise to Wake Sensitivity",
Expand Down Expand Up @@ -82,6 +84,9 @@ OswConfigKey *oswConfigKeys[] = {
&OswConfigAllKeys::settingDisplayTimeout, &OswConfigAllKeys::settingDisplayBrightness,
&OswConfigAllKeys::settingDisplayOverlays, &OswConfigAllKeys::settingDisplayOverlaysOnWatchScreen,
&OswConfigAllKeys::settingDisplayDefaultWatchface,
#if OSW_PLATFORM_ENVIRONMENT_ACCELEROMETER == 1
&OswConfigAllKeys::settingDisplayStepsGoal,
#endif
// energy
&OswConfigAllKeys::buttonToWakeEnabled, &OswConfigAllKeys::raiseToWakeEnabled,
&OswConfigAllKeys::raiseToWakeSensitivity, &OswConfigAllKeys::tapToWakeEnabled,
Expand Down

0 comments on commit 69235d8

Please sign in to comment.