From 2ffc80fb70d3c70777729e1ce03105cdc3e7ebc4 Mon Sep 17 00:00:00 2001 From: Ruffalo-sunghwan Date: Sun, 17 Apr 2022 18:03:32 +0900 Subject: [PATCH] Apps : display goal steps on Watchfaces -Update watchface -Add settingDisplayStepsGoal OSW keys -See https://github.com/Open-Smartwatch/open-smartwatch-os/issues/207 --- include/osw_config_keys.h | 1 + src/apps/watchfaces/watchface.cpp | 9 ++++++++- src/osw_config_keys.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/osw_config_keys.h b/include/osw_config_keys.h index acb107c81..f37f0d338 100644 --- a/include/osw_config_keys.h +++ b/include/osw_config_keys.h @@ -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 diff --git a/src/apps/watchfaces/watchface.cpp b/src/apps/watchfaces/watchface.cpp index abbd87cb4..739cfaf80 100644 --- a/src/apps/watchfaces/watchface.cpp +++ b/src/apps/watchfaces/watchface.cpp @@ -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 diff --git a/src/osw_config_keys.cpp b/src/osw_config_keys.cpp index 7256ec12a..9e5ff2d47 100644 --- a/src/osw_config_keys.cpp +++ b/src/osw_config_keys.cpp @@ -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", @@ -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,