mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
settings: Add global widget selection
Instead of each watch face implementing their own settings for which widgets to display, we can have a global selection of widgets. All watch faces can then determine whether it is enabled and so display it in whichever way makes sense for that face. Current widgets supported are heart rate, step counter, and weather.
This commit is contained in:
parent
3a0d673df4
commit
d8decb71c8
|
@ -410,6 +410,7 @@ list(APPEND SOURCE_FILES
|
|||
displayapp/screens/settings/SettingTimeFormat.cpp
|
||||
displayapp/screens/settings/SettingWeatherFormat.cpp
|
||||
displayapp/screens/settings/SettingWakeUp.cpp
|
||||
displayapp/screens/settings/SettingWidgets.cpp
|
||||
displayapp/screens/settings/SettingDisplay.cpp
|
||||
displayapp/screens/settings/SettingSteps.cpp
|
||||
displayapp/screens/settings/SettingSetDateTime.cpp
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Pinetime {
|
|||
enum class Notification : uint8_t { On, Off, Sleep };
|
||||
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 Widget : uint8_t { HeartRate = 0, Steps = 1, Weather = 2 };
|
||||
enum class Colors : uint8_t {
|
||||
White,
|
||||
Silver,
|
||||
|
@ -35,14 +36,12 @@ namespace Pinetime {
|
|||
Pink
|
||||
};
|
||||
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
|
||||
enum class PTSWeather : uint8_t { On, Off };
|
||||
|
||||
struct PineTimeStyle {
|
||||
Colors ColorTime = Colors::Teal;
|
||||
Colors ColorBar = Colors::Teal;
|
||||
Colors ColorBG = Colors::Black;
|
||||
PTSGaugeStyle gaugeStyle = PTSGaugeStyle::Full;
|
||||
PTSWeather weatherEnable = PTSWeather::Off;
|
||||
};
|
||||
|
||||
struct WatchFaceInfineat {
|
||||
|
@ -144,16 +143,6 @@ namespace Pinetime {
|
|||
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) {
|
||||
appMenu = menu;
|
||||
};
|
||||
|
@ -192,6 +181,21 @@ namespace Pinetime {
|
|||
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) {
|
||||
if (status != settings.notificationStatus) {
|
||||
settingsChanged = true;
|
||||
|
@ -321,6 +325,7 @@ namespace Pinetime {
|
|||
|
||||
WatchFaceInfineat watchFaceInfineat;
|
||||
|
||||
std::bitset<3> widgets {0b111}; // Set all 3 widgets to enabled by default
|
||||
std::bitset<5> wakeUpMode {0};
|
||||
uint16_t shakeWakeThreshold = 150;
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "displayapp/screens/settings/SettingTimeFormat.h"
|
||||
#include "displayapp/screens/settings/SettingWeatherFormat.h"
|
||||
#include "displayapp/screens/settings/SettingWakeUp.h"
|
||||
#include "displayapp/screens/settings/SettingWidgets.h"
|
||||
#include "displayapp/screens/settings/SettingDisplay.h"
|
||||
#include "displayapp/screens/settings/SettingSteps.h"
|
||||
#include "displayapp/screens/settings/SettingSetDateTime.h"
|
||||
|
@ -574,6 +575,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
case Apps::SettingWakeUp:
|
||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(settingsController);
|
||||
break;
|
||||
case Apps::SettingWidgets:
|
||||
currentScreen = std::make_unique<Screens::SettingWidgets>(settingsController);
|
||||
break;
|
||||
case Apps::SettingDisplay:
|
||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
||||
break;
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace Pinetime {
|
|||
SettingWeatherFormat,
|
||||
SettingDisplay,
|
||||
SettingWakeUp,
|
||||
SettingWidgets,
|
||||
SettingSteps,
|
||||
SettingSetDateTime,
|
||||
SettingChimes,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
{
|
||||
"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,
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Pinetime {
|
|||
static constexpr const char* eye = "\xEF\x81\xAE";
|
||||
static constexpr const char* home = "\xEF\x80\x95";
|
||||
static constexpr const char* sleep = "\xEE\xBD\x84";
|
||||
static constexpr const char* wrench = "\xEF\x82\xAD";
|
||||
|
||||
// fontawesome_weathericons.c
|
||||
// static constexpr const char* sun = "\xEF\x86\x85";
|
||||
|
|
|
@ -148,25 +148,29 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
|
|||
lv_obj_set_pos(backgroundLabel, 0, 0);
|
||||
lv_label_set_text_static(backgroundLabel, "");
|
||||
|
||||
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, color_text);
|
||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
|
||||
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, color_text);
|
||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
|
||||
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(heartbeatValue, "");
|
||||
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(heartbeatValue, "");
|
||||
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||
}
|
||||
|
||||
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_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
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, color_text);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
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_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
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_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);
|
||||
Refresh();
|
||||
|
@ -289,26 +293,30 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
|||
}
|
||||
}
|
||||
|
||||
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, color_text);
|
||||
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, "");
|
||||
}
|
||||
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, color_text);
|
||||
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);
|
||||
lv_obj_realign(heartbeatIcon);
|
||||
lv_obj_realign(heartbeatValue);
|
||||
}
|
||||
}
|
||||
|
||||
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::Steps)) {
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||
lv_obj_realign(stepValue);
|
||||
lv_obj_realign(stepIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,17 +39,19 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
|||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
|
||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
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_font(weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
|
||||
lv_label_set_text(weatherIcon, "");
|
||||
lv_obj_align(weatherIcon, nullptr, LV_ALIGN_IN_TOP_MID, -20, 50);
|
||||
lv_obj_set_auto_realign(weatherIcon, true);
|
||||
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, lv_color_hex(0x999999));
|
||||
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_IN_TOP_MID, -20, 50);
|
||||
lv_obj_set_auto_realign(weatherIcon, true);
|
||||
|
||||
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_hex(0x999999));
|
||||
lv_label_set_text(temperature, "");
|
||||
lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50);
|
||||
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_hex(0x999999));
|
||||
lv_label_set_text(temperature, "");
|
||||
lv_obj_align(temperature, nullptr, LV_ALIGN_IN_TOP_MID, 20, 50);
|
||||
}
|
||||
|
||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
|
||||
|
@ -64,25 +66,29 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
|
|||
lv_label_set_text_static(label_time_ampm, "");
|
||||
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
Refresh();
|
||||
|
@ -148,46 +154,52 @@ void WatchFaceDigital::Refresh() {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
|
||||
lv_obj_realign(stepValue);
|
||||
lv_obj_realign(stepIcon);
|
||||
}
|
||||
|
||||
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';
|
||||
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, "");
|
||||
}
|
||||
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(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);
|
||||
}
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,16 +230,18 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
|
|||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||
|
||||
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_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 10, 0);
|
||||
lv_label_set_text_static(stepValue, "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, grayColor);
|
||||
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 10, 0);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
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_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
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_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
}
|
||||
|
||||
// Setting buttons
|
||||
btnClose = lv_btn_create(lv_scr_act(), nullptr);
|
||||
|
@ -452,11 +454,13 @@ void WatchFaceInfineat::Refresh() {
|
|||
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
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(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
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_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 10, 0);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!lv_obj_get_hidden(btnSettings)) {
|
||||
|
|
|
@ -116,10 +116,10 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
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_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_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);
|
||||
} else {
|
||||
lv_obj_set_hidden(weatherIcon, true);
|
||||
|
@ -127,9 +127,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
|
||||
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_label_set_text(temperature, "--");
|
||||
lv_label_set_text(temperature, "");
|
||||
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);
|
||||
} else {
|
||||
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_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
|
||||
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);
|
||||
} else {
|
||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
||||
|
@ -193,60 +193,62 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
lv_obj_align(dateMonth, calendarOuter, LV_ALIGN_CENTER, 0, 32);
|
||||
|
||||
// Step count gauge
|
||||
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
|
||||
needle_colors[0] = LV_COLOR_BLACK;
|
||||
} else {
|
||||
needle_colors[0] = LV_COLOR_WHITE;
|
||||
}
|
||||
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
||||
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
||||
lv_gauge_set_range(stepGauge, 0, 100);
|
||||
lv_gauge_set_value(stepGauge, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Full) {
|
||||
lv_obj_set_size(stepGauge, 40, 40);
|
||||
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_gauge_set_scale(stepGauge, 360, 11, 0);
|
||||
lv_gauge_set_angle_offset(stepGauge, 180);
|
||||
lv_gauge_set_critical_value(stepGauge, 100);
|
||||
} else if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Half) {
|
||||
lv_obj_set_size(stepGauge, 37, 37);
|
||||
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
|
||||
lv_gauge_set_scale(stepGauge, 180, 5, 0);
|
||||
lv_gauge_set_angle_offset(stepGauge, 0);
|
||||
lv_gauge_set_critical_value(stepGauge, 120);
|
||||
} else if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepGauge, true);
|
||||
}
|
||||
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
|
||||
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
|
||||
needle_colors[0] = LV_COLOR_BLACK;
|
||||
} else {
|
||||
needle_colors[0] = LV_COLOR_WHITE;
|
||||
}
|
||||
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
|
||||
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
|
||||
lv_gauge_set_range(stepGauge, 0, 100);
|
||||
lv_gauge_set_value(stepGauge, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Full) {
|
||||
lv_obj_set_size(stepGauge, 40, 40);
|
||||
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_gauge_set_scale(stepGauge, 360, 11, 0);
|
||||
lv_gauge_set_angle_offset(stepGauge, 180);
|
||||
lv_gauge_set_critical_value(stepGauge, 100);
|
||||
} else if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Half) {
|
||||
lv_obj_set_size(stepGauge, 37, 37);
|
||||
lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
|
||||
lv_gauge_set_scale(stepGauge, 180, 5, 0);
|
||||
lv_gauge_set_angle_offset(stepGauge, 0);
|
||||
lv_gauge_set_critical_value(stepGauge, 120);
|
||||
} else if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepGauge, true);
|
||||
}
|
||||
|
||||
lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
|
||||
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
|
||||
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
|
||||
|
||||
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_BLACK);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepValue, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(stepValue, true);
|
||||
}
|
||||
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_BLACK);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepValue, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(stepValue, true);
|
||||
}
|
||||
|
||||
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_BLACK);
|
||||
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepIcon, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(stepIcon, true);
|
||||
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_BLACK);
|
||||
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||
if (settingsController.GetPTSGaugeStyle() == Pinetime::Controllers::Settings::PTSGaugeStyle::Numeric) {
|
||||
lv_obj_set_hidden(stepIcon, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(stepIcon, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Display seconds
|
||||
|
@ -350,25 +352,17 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
lv_obj_set_event_cb(btnClose, event_handler);
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
|
||||
btnSteps = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSteps->user_data = this;
|
||||
lv_obj_set_size(btnSteps, 160, 60);
|
||||
lv_obj_align(btnSteps, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
|
||||
lv_obj_set_style_local_bg_opa(btnSteps, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||
lv_obj_t* lblSteps = lv_label_create(btnSteps, nullptr);
|
||||
lv_label_set_text_static(lblSteps, "Steps style");
|
||||
lv_obj_set_event_cb(btnSteps, event_handler);
|
||||
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);
|
||||
if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) {
|
||||
btnSteps = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSteps->user_data = this;
|
||||
lv_obj_set_size(btnSteps, 160, 60);
|
||||
lv_obj_align(btnSteps, lv_scr_act(), LV_ALIGN_CENTER, 0, -10);
|
||||
lv_obj_set_style_local_bg_opa(btnSteps, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||
lv_obj_t* lblSteps = lv_label_create(btnSteps, nullptr);
|
||||
lv_label_set_text_static(lblSteps, "Steps style");
|
||||
lv_obj_set_event_cb(btnSteps, event_handler);
|
||||
lv_obj_set_hidden(btnSteps, true);
|
||||
}
|
||||
|
||||
btnSetColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSetColor->user_data = this;
|
||||
|
@ -428,7 +422,6 @@ void WatchFacePineTimeStyle::CloseMenu() {
|
|||
lv_obj_set_hidden(btnRandom, true);
|
||||
lv_obj_set_hidden(btnClose, true);
|
||||
lv_obj_set_hidden(btnSteps, true);
|
||||
lv_obj_set_hidden(btnWeather, true);
|
||||
}
|
||||
|
||||
bool WatchFacePineTimeStyle::OnButtonPushed() {
|
||||
|
@ -527,35 +520,39 @@ void WatchFacePineTimeStyle::Refresh() {
|
|||
}
|
||||
}
|
||||
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)) % 100);
|
||||
lv_obj_realign(stepGauge);
|
||||
lv_label_set_text_fmt(stepValue, "%luK", (stepCount.Get() / 1000));
|
||||
lv_obj_realign(stepValue);
|
||||
if (stepCount.Get() > settingsController.GetStepsGoal()) {
|
||||
lv_obj_set_style_local_line_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::Steps)) {
|
||||
stepCount = motionController.NbSteps();
|
||||
if (stepCount.IsUpdated()) {
|
||||
lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100)) % 100);
|
||||
lv_obj_realign(stepGauge);
|
||||
lv_label_set_text_fmt(stepValue, "%luK", (stepCount.Get() / 1000));
|
||||
lv_obj_realign(stepValue);
|
||||
if (stepCount.Get() > settingsController.GetStepsGoal()) {
|
||||
lv_obj_set_style_local_line_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentWeather = weatherService.Current();
|
||||
if (currentWeather.IsUpdated()) {
|
||||
auto optCurrentWeather = currentWeather.Get();
|
||||
if (optCurrentWeather) {
|
||||
int16_t temp = optCurrentWeather->temperature;
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
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;
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°", temp);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
lv_label_set_text(temperature, "--");
|
||||
lv_label_set_text(weatherIcon, Symbols::ban);
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°", temp);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
lv_label_set_text(temperature, "--");
|
||||
lv_label_set_text(weatherIcon, Symbols::ban);
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
|
||||
if (!lv_obj_get_hidden(btnSetColor)) {
|
||||
|
@ -703,37 +700,6 @@ void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event)
|
|||
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) {
|
||||
lv_obj_set_hidden(btnSetColor, 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(btnSetOpts, true);
|
||||
lv_obj_set_hidden(btnSteps, false);
|
||||
lv_obj_set_hidden(btnWeather, false);
|
||||
lv_obj_set_hidden(btnClose, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ namespace Pinetime {
|
|||
lv_obj_t* btnRandom;
|
||||
lv_obj_t* btnClose;
|
||||
lv_obj_t* btnSteps;
|
||||
lv_obj_t* btnWeather;
|
||||
lv_obj_t* timebar;
|
||||
lv_obj_t* sidebar;
|
||||
lv_obj_t* timeDD1;
|
||||
|
|
77
src/displayapp/screens/settings/SettingWidgets.cpp
Normal file
77
src/displayapp/screens/settings/SettingWidgets.cpp
Normal 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]);
|
||||
}
|
||||
}
|
38
src/displayapp/screens/settings/SettingWidgets.h
Normal file
38
src/displayapp/screens/settings/SettingWidgets.h
Normal 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()];
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,13 +40,14 @@ namespace Pinetime {
|
|||
{Symbols::shoe, "Steps", Apps::SettingSteps},
|
||||
{Symbols::clock, "Date&Time", Apps::SettingSetDateTime},
|
||||
{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::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
|
||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||
{Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth},
|
||||
|
||||
{Symbols::check, "Firmware", Apps::FirmwareValidation},
|
||||
{Symbols::list, "About", Apps::SysInfo},
|
||||
|
||||
// {Symbols::none, "None", Apps::None},
|
||||
|
|
Loading…
Reference in a new issue