This commit is contained in:
Victor Kareh 2024-10-03 12:35:40 +00:00 committed by GitHub
commit 10392648a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 499 additions and 266 deletions

View file

@ -410,6 +410,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/settings/SettingTimeFormat.cpp displayapp/screens/settings/SettingTimeFormat.cpp
displayapp/screens/settings/SettingWeatherFormat.cpp displayapp/screens/settings/SettingWeatherFormat.cpp
displayapp/screens/settings/SettingWakeUp.cpp displayapp/screens/settings/SettingWakeUp.cpp
displayapp/screens/settings/SettingWidgets.cpp
displayapp/screens/settings/SettingDisplay.cpp displayapp/screens/settings/SettingDisplay.cpp
displayapp/screens/settings/SettingSteps.cpp displayapp/screens/settings/SettingSteps.cpp
displayapp/screens/settings/SettingSetDateTime.cpp displayapp/screens/settings/SettingSetDateTime.cpp

View file

@ -14,6 +14,7 @@ namespace Pinetime {
enum class Notification : uint8_t { On, Off, Sleep }; enum class Notification : uint8_t { On, Off, Sleep };
enum class ChimesOption : uint8_t { None, Hours, HalfHours }; enum class ChimesOption : uint8_t { None, Hours, HalfHours };
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 }; enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
enum class Widget : uint8_t { HeartRate = 0, Steps = 1, Weather = 2 };
enum class Colors : uint8_t { enum class Colors : uint8_t {
White, White,
Silver, Silver,
@ -35,14 +36,12 @@ namespace Pinetime {
Pink Pink
}; };
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
enum class PTSWeather : uint8_t { On, Off };
struct PineTimeStyle { struct PineTimeStyle {
Colors ColorTime = Colors::Teal; Colors ColorTime = Colors::Teal;
Colors ColorBar = Colors::Teal; Colors ColorBar = Colors::Teal;
Colors ColorBG = Colors::Black; Colors ColorBG = Colors::Black;
PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full; PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full;
PTSWeather weatherEnable = PTSWeather::Off;
}; };
struct WatchFaceInfineat { struct WatchFaceInfineat {
@ -144,16 +143,6 @@ namespace Pinetime {
return settings.PTS.gaugeStyle; return settings.PTS.gaugeStyle;
}; };
void SetPTSWeather(PTSWeather weatherEnable) {
if (weatherEnable != settings.PTS.weatherEnable)
settingsChanged = true;
settings.PTS.weatherEnable = weatherEnable;
};
PTSWeather GetPTSWeather() const {
return settings.PTS.weatherEnable;
};
void SetAppMenu(uint8_t menu) { void SetAppMenu(uint8_t menu) {
appMenu = menu; appMenu = menu;
}; };
@ -192,6 +181,21 @@ namespace Pinetime {
return settings.weatherFormat; return settings.weatherFormat;
}; };
void SetWidget(Widget widget, bool enabled) {
if (enabled != IsWidgetOn(widget)) {
settingsChanged = true;
}
settings.widgets.set(static_cast<size_t>(widget), enabled);
}
std::bitset<3> GetWidgets() const {
return settings.widgets;
}
bool IsWidgetOn(const Widget widget) const {
return GetWidgets()[static_cast<size_t>(widget)];
}
void SetNotificationStatus(Notification status) { void SetNotificationStatus(Notification status) {
if (status != settings.notificationStatus) { if (status != settings.notificationStatus) {
settingsChanged = true; settingsChanged = true;
@ -321,6 +325,7 @@ namespace Pinetime {
WatchFaceInfineat watchFaceInfineat; WatchFaceInfineat watchFaceInfineat;
std::bitset<3> widgets {0b111}; // Set all 3 widgets to enabled by default
std::bitset<5> wakeUpMode {0}; std::bitset<5> wakeUpMode {0};
uint16_t shakeWakeThreshold = 150; uint16_t shakeWakeThreshold = 150;

View file

@ -43,6 +43,7 @@
#include "displayapp/screens/settings/SettingTimeFormat.h" #include "displayapp/screens/settings/SettingTimeFormat.h"
#include "displayapp/screens/settings/SettingWeatherFormat.h" #include "displayapp/screens/settings/SettingWeatherFormat.h"
#include "displayapp/screens/settings/SettingWakeUp.h" #include "displayapp/screens/settings/SettingWakeUp.h"
#include "displayapp/screens/settings/SettingWidgets.h"
#include "displayapp/screens/settings/SettingDisplay.h" #include "displayapp/screens/settings/SettingDisplay.h"
#include "displayapp/screens/settings/SettingSteps.h" #include "displayapp/screens/settings/SettingSteps.h"
#include "displayapp/screens/settings/SettingSetDateTime.h" #include "displayapp/screens/settings/SettingSetDateTime.h"
@ -581,6 +582,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
case Apps::SettingWakeUp: case Apps::SettingWakeUp:
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController); currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
break; break;
case Apps::SettingWidgets:
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
break;
case Apps::SettingDisplay: case Apps::SettingDisplay:
currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController); currentScreen = std::make_unique<Screens::SettingDisplay>(settingsController);
break; break;

View file

@ -37,6 +37,7 @@ namespace Pinetime {
SettingWeatherFormat, SettingWeatherFormat,
SettingDisplay, SettingDisplay,
SettingWakeUp, SettingWakeUp,
SettingWidgets,
SettingSteps, SettingSteps,
SettingSetDateTime, SettingSetDateTime,
SettingChimes, SettingChimes,

View file

@ -7,7 +7,7 @@
}, },
{ {
"file": "FontAwesome5-Solid+Brands+Regular.woff", "file": "FontAwesome5-Solid+Brands+Regular.woff",
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743" "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743, 0xf0ad"
} }
], ],
"bpp": 1, "bpp": 1,

View file

@ -39,6 +39,7 @@ namespace Pinetime {
static constexpr const char* eye = "\xEF\x81\xAE"; static constexpr const char* eye = "\xEF\x81\xAE";
static constexpr const char* home = "\xEF\x80\x95"; static constexpr const char* home = "\xEF\x80\x95";
static constexpr const char* sleep = "\xEE\xBD\x84"; static constexpr const char* sleep = "\xEE\xBD\x84";
static constexpr const char* wrench = "\xEF\x82\xAD";
// fontawesome_weathericons.c // fontawesome_weathericons.c
// static constexpr const char* sun = "\xEF\x86\x85"; // static constexpr const char* sun = "\xEF\x86\x85";

View file

@ -5,6 +5,10 @@
#include "displayapp/screens/BleIcon.h" #include "displayapp/screens/BleIcon.h"
#include "displayapp/screens/Symbols.h" #include "displayapp/screens/Symbols.h"
#include "displayapp/screens/NotificationIcon.h" #include "displayapp/screens/NotificationIcon.h"
#include "displayapp/screens/WeatherSymbols.h"
#include "components/ble/SimpleWeatherService.h"
#include "components/heartrate/HeartRateController.h"
#include "components/motion/MotionController.h"
#include "components/settings/Settings.h" #include "components/settings/Settings.h"
#include "displayapp/InfiniTimeTheme.h" #include "displayapp/InfiniTimeTheme.h"
@ -45,14 +49,20 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController) Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::SimpleWeatherService& weatherService)
: currentDateTime {{}}, : currentDateTime {{}},
batteryIcon(true), batteryIcon(true),
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
batteryController {batteryController}, batteryController {batteryController},
bleController {bleController}, bleController {bleController},
notificationManager {notificationManager}, notificationManager {notificationManager},
settingsController {settingsController} { settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
weatherService {weatherService} {
sHour = 99; sHour = 99;
sMinute = 99; sMinute = 99;
@ -111,13 +121,25 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
// Date - Day / Week day // Date - Day / Week day
label_date_day = lv_label_create(lv_scr_act(), nullptr); label_date_day = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0); lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
weatherIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
lv_label_set_text(weatherIcon, "");
lv_obj_align(weatherIcon, nullptr, LV_ALIGN_CENTER, -50, -12);
temperature = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_label_set_text(temperature, "");
lv_obj_align(temperature, nullptr, LV_ALIGN_CENTER, -50, 12);
}
minute_body = lv_line_create(lv_scr_act(), nullptr); minute_body = lv_line_create(lv_scr_act(), nullptr);
minute_body_trace = lv_line_create(lv_scr_act(), nullptr); minute_body_trace = lv_line_create(lv_scr_act(), nullptr);
hour_body = lv_line_create(lv_scr_act(), nullptr); hour_body = lv_line_create(lv_scr_act(), nullptr);
@ -154,6 +176,30 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh(); Refresh();
@ -261,4 +307,53 @@ void WatchFaceAnalog::Refresh() {
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
} }
} }
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeat = heartRateController.HeartRate();
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
if (heartbeatRunning.Get()) {
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
} else {
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
lv_label_set_text_static(heartbeatValue, "");
}
lv_obj_realign(heartbeatIcon);
lv_obj_realign(heartbeatValue);
}
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue);
lv_obj_realign(stepIcon);
}
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
currentWeather = weatherService.Current();
if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get();
if (optCurrentWeather) {
int16_t temp = optCurrentWeather->temperature;
char tempUnit = 'C';
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
tempUnit = 'F';
}
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
} else {
lv_label_set_text_static(temperature, "");
lv_label_set_text(weatherIcon, "");
}
lv_obj_realign(temperature);
lv_obj_realign(weatherIcon);
}
}
} }

View file

@ -9,6 +9,7 @@
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/ble/SimpleWeatherService.h"
#include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/BatteryIcon.h"
#include "utility/DirtyValue.h" #include "utility/DirtyValue.h"
@ -18,6 +19,8 @@ namespace Pinetime {
class Battery; class Battery;
class Ble; class Ble;
class NotificationManager; class NotificationManager;
class HeartRateController;
class MotionController;
} }
namespace Applications { namespace Applications {
@ -29,8 +32,10 @@ namespace Pinetime {
const Controllers::Battery& batteryController, const Controllers::Battery& batteryController,
const Controllers::Ble& bleController, const Controllers::Ble& bleController,
Controllers::NotificationManager& notificationManager, Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController); Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
Controllers::MotionController& motionController,
Controllers::SimpleWeatherService& weather);
~WatchFaceAnalog() override; ~WatchFaceAnalog() override;
void Refresh() override; void Refresh() override;
@ -42,8 +47,12 @@ namespace Pinetime {
Utility::DirtyValue<bool> isCharging {}; Utility::DirtyValue<bool> isCharging {};
Utility::DirtyValue<bool> bleState {}; Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime; Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
Utility::DirtyValue<uint32_t> stepCount {};
Utility::DirtyValue<uint8_t> heartbeat {};
Utility::DirtyValue<bool> heartbeatRunning {};
Utility::DirtyValue<bool> notificationState {false}; Utility::DirtyValue<bool> notificationState {false};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate; Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
Utility::DirtyValue<std::optional<Pinetime::Controllers::SimpleWeatherService::CurrentWeather>> currentWeather {};
lv_obj_t* minor_scales; lv_obj_t* minor_scales;
lv_obj_t* major_scales; lv_obj_t* major_scales;
@ -73,6 +82,13 @@ namespace Pinetime {
lv_obj_t* notificationIcon; lv_obj_t* notificationIcon;
lv_obj_t* bleIcon; lv_obj_t* bleIcon;
lv_obj_t* heartbeatIcon;
lv_obj_t* heartbeatValue;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
lv_obj_t* weatherIcon;
lv_obj_t* temperature;
BatteryIcon batteryIcon; BatteryIcon batteryIcon;
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;
@ -80,6 +96,9 @@ namespace Pinetime {
const Controllers::Ble& bleController; const Controllers::Ble& bleController;
Controllers::NotificationManager& notificationManager; Controllers::NotificationManager& notificationManager;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
Controllers::SimpleWeatherService& weatherService;
void UpdateClock(); void UpdateClock();
void SetBatteryIcon(); void SetBatteryIcon();
@ -98,7 +117,10 @@ namespace Pinetime {
controllers.batteryController, controllers.batteryController,
controllers.bleController, controllers.bleController,
controllers.notificationManager, controllers.notificationManager,
controllers.settingsController); controllers.settingsController,
controllers.heartRateController,
controllers.motionController,
*controllers.weatherController);
}; };
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {

View file

@ -148,6 +148,7 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
lv_obj_set_pos(backgroundLabel, 0, 0); lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, ""); lv_label_set_text_static(backgroundLabel, "");
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
@ -157,7 +158,9 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
lv_label_set_text_static(heartbeatValue, ""); lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepValue = lv_label_create(lv_scr_act(), nullptr); stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
lv_label_set_text_static(stepValue, "0"); lv_label_set_text_static(stepValue, "0");
@ -167,6 +170,7 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text); lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
lv_label_set_text_static(stepIcon, Symbols::shoe); lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh(); Refresh();
@ -289,6 +293,7 @@ void WatchFaceCasioStyleG7710::Refresh() {
} }
} }
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeat = heartRateController.HeartRate(); heartbeat = heartRateController.HeartRate();
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
@ -303,13 +308,16 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_obj_realign(heartbeatIcon); lv_obj_realign(heartbeatIcon);
lv_obj_realign(heartbeatValue); lv_obj_realign(heartbeatValue);
} }
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepCount = motionController.NbSteps(); stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) { if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue); lv_obj_realign(stepValue);
lv_obj_realign(stepIcon); lv_obj_realign(stepIcon);
} }
}
} }
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) { bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {

View file

@ -39,6 +39,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
weatherIcon = lv_label_create(lv_scr_act(), nullptr); weatherIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons); lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
@ -50,6 +51,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999));
lv_label_set_text(temperature, ""); lv_label_set_text(temperature, "");
lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50); lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50);
}
label_date = lv_label_create(lv_scr_act(), nullptr); label_date = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
@ -64,6 +66,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(label_time_ampm, ""); lv_label_set_text_static(label_time_ampm, "");
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55); lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
@ -73,7 +76,9 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_label_set_text_static(heartbeatValue, ""); lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepValue = lv_label_create(lv_scr_act(), nullptr); stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepValue, "0"); lv_label_set_text_static(stepValue, "0");
@ -83,6 +88,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
lv_label_set_text_static(stepIcon, Symbols::shoe); lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh(); Refresh();
@ -148,6 +154,7 @@ void WatchFaceDigital::Refresh() {
} }
} }
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) {
heartbeat = heartRateController.HeartRate(); heartbeat = heartRateController.HeartRate();
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
@ -162,14 +169,18 @@ void WatchFaceDigital::Refresh() {
lv_obj_realign(heartbeatIcon); lv_obj_realign(heartbeatIcon);
lv_obj_realign(heartbeatValue); lv_obj_realign(heartbeatValue);
} }
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepCount = motionController.NbSteps(); stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) { if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_realign(stepValue); lv_obj_realign(stepValue);
lv_obj_realign(stepIcon); lv_obj_realign(stepIcon);
} }
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
currentWeather = weatherService.Current(); currentWeather = weatherService.Current();
if (currentWeather.IsUpdated()) { if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get(); auto optCurrentWeather = currentWeather.Get();
@ -190,4 +201,5 @@ void WatchFaceDigital::Refresh() {
lv_obj_realign(temperature); lv_obj_realign(temperature);
lv_obj_realign(weatherIcon); lv_obj_realign(weatherIcon);
} }
}
} }

View file

@ -230,6 +230,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(bleIcon, Symbols::bluetooth); lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepValue = lv_label_create(lv_scr_act(), nullptr); stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor); lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko); lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
@ -240,6 +241,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor); lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
lv_label_set_text_static(stepIcon, Symbols::shoe); lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
}
// Setting buttons // Setting buttons
btnClose = lv_btn_create(lv_scr_act(), nullptr); btnClose = lv_btn_create(lv_scr_act(), nullptr);
@ -452,12 +454,14 @@ void WatchFaceInfineat::Refresh() {
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3); lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
} }
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepCount = motionController.NbSteps(); stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) { if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 10, 0); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 10, 0);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
} }
}
if (!lv_obj_get_hidden(btnSettings)) { if (!lv_obj_get_hidden(btnSettings)) {
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) { if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {

View file

@ -116,10 +116,10 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
weatherIcon = lv_label_create(lv_scr_act(), nullptr); weatherIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_text_color(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons); lv_obj_set_style_local_text_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
lv_label_set_text(weatherIcon, Symbols::ban); lv_label_set_text(weatherIcon, "");
lv_obj_align(weatherIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 35); lv_obj_align(weatherIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 35);
lv_obj_set_auto_realign(weatherIcon, true); lv_obj_set_auto_realign(weatherIcon, true);
if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
lv_obj_set_hidden(weatherIcon, false); lv_obj_set_hidden(weatherIcon, false);
} else { } else {
lv_obj_set_hidden(weatherIcon, true); lv_obj_set_hidden(weatherIcon, true);
@ -127,9 +127,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
temperature = lv_label_create(lv_scr_act(), nullptr); temperature = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_label_set_text(temperature, "--"); lv_label_set_text(temperature, "");
lv_obj_align(temperature, sidebar, LV_ALIGN_IN_TOP_MID, 0, 65); lv_obj_align(temperature, sidebar, LV_ALIGN_IN_TOP_MID, 0, 65);
if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
lv_obj_set_hidden(temperature, false); lv_obj_set_hidden(temperature, false);
} else { } else {
lv_obj_set_hidden(temperature, true); lv_obj_set_hidden(temperature, true);
@ -140,7 +140,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarOuter, 34, 34); lv_obj_set_size(calendarOuter, 34, 34);
if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) { if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20); lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20);
} else { } else {
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
@ -193,6 +193,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
lv_obj_align(dateMonth, calendarOuter, LV_ALIGN_CENTER, 0, 32); lv_obj_align(dateMonth, calendarOuter, LV_ALIGN_CENTER, 0, 32);
// Step count gauge // Step count gauge
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) { if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
needle_colors[0] = LV_COLOR_BLACK; needle_colors[0] = LV_COLOR_BLACK;
} else { } else {
@ -248,6 +249,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
} else { } else {
lv_obj_set_hidden(stepIcon, true); lv_obj_set_hidden(stepIcon, true);
} }
}
// Display seconds // Display seconds
timeDD3 = lv_label_create(lv_scr_act(), nullptr); timeDD3 = lv_label_create(lv_scr_act(), nullptr);
@ -350,6 +352,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
lv_obj_set_event_cb(btnClose, event_handler); lv_obj_set_event_cb(btnClose, event_handler);
lv_obj_set_hidden(btnClose, true); lv_obj_set_hidden(btnClose, true);
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
btnSteps = lv_btn_create(lv_scr_act(), nullptr); btnSteps = lv_btn_create(lv_scr_act(), nullptr);
btnSteps->user_data = this; btnSteps->user_data = this;
lv_obj_set_size(btnSteps, 160, 60); lv_obj_set_size(btnSteps, 160, 60);
@ -359,16 +362,7 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
lv_label_set_text_static(lblSteps, "Steps style"); lv_label_set_text_static(lblSteps, "Steps style");
lv_obj_set_event_cb(btnSteps, event_handler); lv_obj_set_event_cb(btnSteps, event_handler);
lv_obj_set_hidden(btnSteps, true); lv_obj_set_hidden(btnSteps, true);
}
btnWeather = lv_btn_create(lv_scr_act(), nullptr);
btnWeather->user_data = this;
lv_obj_set_size(btnWeather, 160, 60);
lv_obj_align(btnWeather, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
lv_obj_set_style_local_bg_opa(btnWeather, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
lv_obj_t* lblWeather = lv_label_create(btnWeather, nullptr);
lv_label_set_text_static(lblWeather, "Weather");
lv_obj_set_event_cb(btnWeather, event_handler);
lv_obj_set_hidden(btnWeather, true);
btnSetColor = lv_btn_create(lv_scr_act(), nullptr); btnSetColor = lv_btn_create(lv_scr_act(), nullptr);
btnSetColor->user_data = this; btnSetColor->user_data = this;
@ -428,7 +422,6 @@ void WatchFacePineTimeStyle::CloseMenu() {
lv_obj_set_hidden(btnRandom, true); lv_obj_set_hidden(btnRandom, true);
lv_obj_set_hidden(btnClose, true); lv_obj_set_hidden(btnClose, true);
lv_obj_set_hidden(btnSteps, true); lv_obj_set_hidden(btnSteps, true);
lv_obj_set_hidden(btnWeather, true);
} }
bool WatchFacePineTimeStyle::OnButtonPushed() { bool WatchFacePineTimeStyle::OnButtonPushed() {
@ -527,6 +520,7 @@ void WatchFacePineTimeStyle::Refresh() {
} }
} }
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
stepCount = motionController.NbSteps(); stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) { if (stepCount.IsUpdated()) {
lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)) % 100); lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)) % 100);
@ -538,7 +532,9 @@ void WatchFacePineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
} }
} }
}
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Weather)) {
currentWeather = weatherService.Current(); currentWeather = weatherService.Current();
if (currentWeather.IsUpdated()) { if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get(); auto optCurrentWeather = currentWeather.Get();
@ -557,6 +553,7 @@ void WatchFacePineTimeStyle::Refresh() {
lv_obj_realign(temperature); lv_obj_realign(temperature);
lv_obj_realign(weatherIcon); lv_obj_realign(weatherIcon);
} }
}
if (!lv_obj_get_hidden(btnSetColor)) { if (!lv_obj_get_hidden(btnSetColor)) {
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) { if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
@ -703,37 +700,6 @@ void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event)
settingsController.SetPTSGaugeStyle(Controllers::Settings::PTSGaugeStyle::Full); settingsController.SetPTSGaugeStyle(Controllers::Settings::PTSGaugeStyle::Full);
} }
} }
if (object == btnWeather) {
if (lv_obj_get_hidden(weatherIcon)) {
// show weather icon and temperature
lv_obj_set_hidden(weatherIcon, false);
lv_obj_set_hidden(temperature, false);
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20);
lv_obj_realign(calendarInner);
lv_obj_realign(calendarBar1);
lv_obj_realign(calendarBar2);
lv_obj_realign(calendarCrossBar1);
lv_obj_realign(calendarCrossBar2);
lv_obj_realign(dateDayOfWeek);
lv_obj_realign(dateDay);
lv_obj_realign(dateMonth);
settingsController.SetPTSWeather(Controllers::Settings::PTSWeather::On);
} else {
// hide weather
lv_obj_set_hidden(weatherIcon, true);
lv_obj_set_hidden(temperature, true);
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
lv_obj_realign(calendarInner);
lv_obj_realign(calendarBar1);
lv_obj_realign(calendarBar2);
lv_obj_realign(calendarCrossBar1);
lv_obj_realign(calendarCrossBar2);
lv_obj_realign(dateDayOfWeek);
lv_obj_realign(dateDay);
lv_obj_realign(dateMonth);
settingsController.SetPTSWeather(Controllers::Settings::PTSWeather::Off);
}
}
if (object == btnSetColor) { if (object == btnSetColor) {
lv_obj_set_hidden(btnSetColor, true); lv_obj_set_hidden(btnSetColor, true);
lv_obj_set_hidden(btnSetOpts, true); lv_obj_set_hidden(btnSetOpts, true);
@ -751,7 +717,6 @@ void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event)
lv_obj_set_hidden(btnSetColor, true); lv_obj_set_hidden(btnSetColor, true);
lv_obj_set_hidden(btnSetOpts, true); lv_obj_set_hidden(btnSetOpts, true);
lv_obj_set_hidden(btnSteps, false); lv_obj_set_hidden(btnSteps, false);
lv_obj_set_hidden(btnWeather, false);
lv_obj_set_hidden(btnClose, false); lv_obj_set_hidden(btnClose, false);
} }
} }

View file

@ -76,7 +76,6 @@ namespace Pinetime {
lv_obj_t* btnRandom; lv_obj_t* btnRandom;
lv_obj_t* btnClose; lv_obj_t* btnClose;
lv_obj_t* btnSteps; lv_obj_t* btnSteps;
lv_obj_t* btnWeather;
lv_obj_t* timebar; lv_obj_t* timebar;
lv_obj_t* sidebar; lv_obj_t* sidebar;
lv_obj_t* timeDD1; lv_obj_t* timeDD1;

View file

@ -0,0 +1,77 @@
#include "displayapp/screens/settings/SettingWidgets.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/Styles.h"
using namespace Pinetime::Applications::Screens;
constexpr std::array<SettingWidgets::Option, 3> SettingWidgets::options;
namespace {
void event_handler(lv_obj_t* obj, lv_event_t event) {
auto* screen = static_cast<SettingWidgets*>(obj->user_data);
if (event == LV_EVENT_VALUE_CHANGED) {
screen->UpdateSelected(obj);
}
}
}
SettingWidgets::SettingWidgets(Pinetime::Controllers::Settings& settingsController) : settingsController {settingsController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_pos(container1, 10, 35);
lv_obj_set_width(container1, LV_HOR_RES - 20);
lv_obj_set_height(container1, LV_VER_RES - 20);
lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Widgets");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
lv_label_set_text_static(icon, Symbols::wrench);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
for (unsigned int i = 0; i < options.size(); i++) {
cbOption[i] = lv_checkbox_create(container1, nullptr);
lv_checkbox_set_text(cbOption[i], options[i].name);
if (settingsController.IsWidgetOn(static_cast<Controllers::Settings::Widget>(i))) {
lv_checkbox_set_checked(cbOption[i], true);
}
cbOption[i]->user_data = this;
lv_obj_set_event_cb(cbOption[i], event_handler);
}
}
SettingWidgets::~SettingWidgets() {
lv_obj_clean(lv_scr_act());
settingsController.SaveSettings();
}
void SettingWidgets::UpdateSelected(lv_obj_t* object) {
// Find the index of the checkbox that triggered the event
for (size_t i = 0; i < options.size(); i++) {
if (cbOption[i] == object) {
bool currentState = settingsController.IsWidgetOn(options[i].widget);
settingsController.SetWidget(options[i].widget, !currentState);
break;
}
}
// Update checkbox according to current widgets.
auto modes = settingsController.GetWidgets();
for (size_t i = 0; i < options.size(); ++i) {
lv_checkbox_set_checked(cbOption[i], modes[i]);
}
}

View file

@ -0,0 +1,38 @@
#pragma once
#include <array>
#include <cstdint>
#include <lvgl/lvgl.h>
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
namespace Pinetime {
namespace Applications {
namespace Screens {
class SettingWidgets : public Screen {
public:
SettingWidgets(Pinetime::Controllers::Settings& settingsController);
~SettingWidgets() override;
void UpdateSelected(lv_obj_t* object);
private:
struct Option {
Controllers::Settings::Widget widget;
const char* name;
};
Controllers::Settings& settingsController;
static constexpr std::array<Option, 3> options = {{
{Controllers::Settings::Widget::HeartRate, "Heart Rate"},
{Controllers::Settings::Widget::Steps, "Steps"},
{Controllers::Settings::Widget::Weather, "Weather"},
}};
lv_obj_t* cbOption[options.size()];
};
}
}
}

View file

@ -40,13 +40,14 @@ namespace Pinetime {
{Symbols::shoe, "Steps", Apps::SettingSteps}, {Symbols::shoe, "Steps", Apps::SettingSteps},
{Symbols::clock, "Date&Time", Apps::SettingSetDateTime}, {Symbols::clock, "Date&Time", Apps::SettingSetDateTime},
{Symbols::cloudSunRain, "Weather", Apps::SettingWeatherFormat}, {Symbols::cloudSunRain, "Weather", Apps::SettingWeatherFormat},
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, {Symbols::wrench, "Widgets", Apps::SettingWidgets},
{Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
{Symbols::clock, "Chimes", Apps::SettingChimes}, {Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
{Symbols::list, "About", Apps::SysInfo}, {Symbols::list, "About", Apps::SysInfo},
// {Symbols::none, "None", Apps::None}, // {Symbols::none, "None", Apps::None},