PineTimeStyle weather display (#1459)
Weather display for PineTimeStyle Documentation : https://wiki.pine64.org/wiki/PineTimeStyle and https://wiki.pine64.org/wiki/Infinitime-Weather
This commit is contained in:
parent
394f58fbb2
commit
94f41258d5
|
@ -39,12 +39,14 @@ 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 {
|
||||
|
@ -146,6 +148,16 @@ 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;
|
||||
};
|
||||
|
@ -267,7 +279,7 @@ namespace Pinetime {
|
|||
private:
|
||||
Pinetime::Controllers::FS& fs;
|
||||
|
||||
static constexpr uint32_t settingsVersion = 0x0004;
|
||||
static constexpr uint32_t settingsVersion = 0x0005;
|
||||
|
||||
struct SettingsData {
|
||||
uint32_t version = settingsVersion;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "displayapp/screens/Steps.h"
|
||||
#include "displayapp/screens/PassKey.h"
|
||||
#include "displayapp/screens/Error.h"
|
||||
#include "displayapp/screens/Weather.h"
|
||||
|
||||
#include "drivers/Cst816s.h"
|
||||
#include "drivers/St7789.h"
|
||||
|
@ -417,6 +418,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
settingsController,
|
||||
heartRateController,
|
||||
motionController,
|
||||
systemTask->nimble().weather(),
|
||||
filesystem);
|
||||
break;
|
||||
|
||||
|
@ -538,6 +540,11 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||
case Apps::Metronome:
|
||||
currentScreen = std::make_unique<Screens::Metronome>(motorController, *systemTask);
|
||||
break;
|
||||
/* Weather debug app
|
||||
case Apps::Weather:
|
||||
currentScreen = std::make_unique<Screens::Weather>(this, systemTask->nimble().weather());
|
||||
break;
|
||||
*/
|
||||
case Apps::Steps:
|
||||
currentScreen = std::make_unique<Screens::Steps>(motionController, settingsController);
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
|
||||
jetbrains_mono_extrabold_compressed lv_font_navi_80 lv_font_sys_48
|
||||
open_sans_light)
|
||||
open_sans_light fontawesome_weathericons)
|
||||
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED
|
||||
HINTS "${CMAKE_SOURCE_DIR}/node_modules/.bin")
|
||||
message(STATUS "Using ${LV_FONT_CONV} to generate font files")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"sources": [
|
||||
{
|
||||
"file": "JetBrainsMono-Bold.ttf",
|
||||
"range": "0x20-0x7e, 0x410-0x44f"
|
||||
"range": "0x20-0x7e, 0x410-0x44f, 0xB0"
|
||||
},
|
||||
{
|
||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||
|
@ -74,5 +74,15 @@
|
|||
"bpp": 2,
|
||||
"size": 80,
|
||||
"compress": true
|
||||
},
|
||||
"fontawesome_weathericons": {
|
||||
"sources": [
|
||||
{
|
||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
||||
"range": "0xf185, 0xf6c4, 0xf743, 0xf740, 0xf75f, 0xf0c2, 0xf05e"
|
||||
}
|
||||
],
|
||||
"bpp": 1,
|
||||
"size": 25
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ Clock::Clock(Controllers::DateTime& dateTimeController,
|
|||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::WeatherService& weatherService,
|
||||
Controllers::FS& filesystem)
|
||||
: dateTimeController {dateTimeController},
|
||||
batteryController {batteryController},
|
||||
|
@ -32,6 +33,7 @@ Clock::Clock(Controllers::DateTime& dateTimeController,
|
|||
settingsController {settingsController},
|
||||
heartRateController {heartRateController},
|
||||
motionController {motionController},
|
||||
weatherService {weatherService},
|
||||
filesystem {filesystem},
|
||||
screen {[this, &settingsController]() {
|
||||
switch (settingsController.GetWatchFace()) {
|
||||
|
@ -95,7 +97,8 @@ std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
|
|||
bleController,
|
||||
notificationManager,
|
||||
settingsController,
|
||||
motionController);
|
||||
motionController,
|
||||
weatherService);
|
||||
}
|
||||
|
||||
std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <components/heartrate/HeartRateController.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/ble/weather/WeatherService.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
|
@ -28,6 +29,7 @@ namespace Pinetime {
|
|||
Controllers::Settings& settingsController,
|
||||
Controllers::HeartRateController& heartRateController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::WeatherService& weatherService,
|
||||
Controllers::FS& filesystem);
|
||||
~Clock() override;
|
||||
|
||||
|
@ -42,6 +44,7 @@ namespace Pinetime {
|
|||
Controllers::Settings& settingsController;
|
||||
Controllers::HeartRateController& heartRateController;
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::WeatherService& weatherService;
|
||||
Controllers::FS& filesystem;
|
||||
|
||||
std::unique_ptr<Screen> screen;
|
||||
|
|
|
@ -38,6 +38,15 @@ namespace Pinetime {
|
|||
static constexpr const char* home = "\xEF\x80\x95";
|
||||
static constexpr const char* sleep = "\xEE\xBD\x84";
|
||||
|
||||
// fontawesome_weathericons.c
|
||||
// static constexpr const char* sun = "\xEF\x86\x85";
|
||||
static constexpr const char* cloudSun = "\xEF\x9B\x84";
|
||||
static constexpr const char* cloudSunRain = "\xEF\x9D\x83";
|
||||
static constexpr const char* cloudShowersHeavy = "\xEF\x9D\x80";
|
||||
static constexpr const char* smog = "\xEF\x9D\x9F";
|
||||
static constexpr const char* cloud = "\xEF\x83\x82";
|
||||
static constexpr const char* ban = "\xEF\x81\x9E";
|
||||
|
||||
// lv_font_sys_48.c
|
||||
static constexpr const char* settings = "\xEE\xA2\xB8";
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "components/motion/MotionController.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "displayapp/DisplayApp.h"
|
||||
#include "components/ble/weather/WeatherService.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
|
@ -48,7 +49,8 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController)
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::WeatherService& weatherService)
|
||||
: currentDateTime {{}},
|
||||
batteryIcon(false),
|
||||
dateTimeController {dateTimeController},
|
||||
|
@ -56,7 +58,8 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
bleController {bleController},
|
||||
notificationManager {notificationManager},
|
||||
settingsController {settingsController},
|
||||
motionController {motionController} {
|
||||
motionController {motionController},
|
||||
weatherService {weatherService} {
|
||||
|
||||
// Create a 200px wide background rectangle
|
||||
timebar = lv_obj_create(lv_scr_act(), nullptr);
|
||||
|
@ -94,27 +97,52 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
// Display icons
|
||||
batteryIcon.Create(sidebar);
|
||||
batteryIcon.SetColor(LV_COLOR_BLACK);
|
||||
lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_MID, 0, 2);
|
||||
lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_MID, 10, 2);
|
||||
|
||||
plugIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(plugIcon, Symbols::plug);
|
||||
lv_obj_set_style_local_text_color(plugIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_align(plugIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
|
||||
lv_obj_align(plugIcon, sidebar, LV_ALIGN_IN_TOP_MID, 10, 2);
|
||||
|
||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_label_set_text_static(bleIcon, "");
|
||||
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, -10, 2);
|
||||
|
||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_label_set_text_static(notificationIcon, "");
|
||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
|
||||
lv_obj_align(notificationIcon, timebar, LV_ALIGN_IN_TOP_LEFT, 5, 5);
|
||||
|
||||
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::cloudSunRain);
|
||||
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) {
|
||||
lv_obj_set_hidden(weatherIcon, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(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_BLACK);
|
||||
lv_obj_align(temperature, sidebar, LV_ALIGN_IN_TOP_MID, 0, 65);
|
||||
if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) {
|
||||
lv_obj_set_hidden(temperature, false);
|
||||
} else {
|
||||
lv_obj_set_hidden(temperature, true);
|
||||
}
|
||||
|
||||
// Calendar icon
|
||||
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
|
||||
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);
|
||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
||||
if (settingsController.GetPTSWeather() == Pinetime::Controllers::Settings::PTSWeather::On) {
|
||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 20);
|
||||
} else {
|
||||
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
|
@ -150,17 +178,17 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_label_set_text_static(dateDayOfWeek, "THU");
|
||||
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
|
||||
lv_obj_align(dateDayOfWeek, calendarOuter, LV_ALIGN_CENTER, 0, -32);
|
||||
|
||||
dateDay = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_label_set_text_static(dateDay, "25");
|
||||
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
|
||||
lv_obj_align(dateDay, calendarOuter, LV_ALIGN_CENTER, 0, 3);
|
||||
|
||||
dateMonth = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_label_set_text_static(dateMonth, "MAR");
|
||||
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
|
||||
lv_obj_align(dateMonth, calendarOuter, LV_ALIGN_CENTER, 0, 32);
|
||||
|
||||
// Step count gauge
|
||||
if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
|
||||
|
@ -323,13 +351,23 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
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, 0);
|
||||
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);
|
||||
|
||||
btnSetColor = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnSetColor->user_data = this;
|
||||
lv_obj_set_size(btnSetColor, 150, 60);
|
||||
|
@ -337,9 +375,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
lv_obj_set_style_local_radius(btnSetColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_bg_opa(btnSetColor, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||
lv_obj_set_event_cb(btnSetColor, event_handler);
|
||||
lbl_btnSetColor = lv_label_create(btnSetColor, nullptr);
|
||||
lv_obj_set_style_local_text_font(lbl_btnSetColor, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(lbl_btnSetColor, Symbols::paintbrushLg);
|
||||
lv_obj_t* lblSetColor = lv_label_create(btnSetColor, nullptr);
|
||||
lv_obj_set_style_local_text_font(lblSetColor, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(lblSetColor, Symbols::paintbrushLg);
|
||||
lv_obj_set_hidden(btnSetColor, true);
|
||||
|
||||
btnSetOpts = lv_btn_create(lv_scr_act(), nullptr);
|
||||
|
@ -349,9 +387,9 @@ WatchFacePineTimeStyle::WatchFacePineTimeStyle(Controllers::DateTime& dateTimeCo
|
|||
lv_obj_set_style_local_radius(btnSetOpts, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_bg_opa(btnSetOpts, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
|
||||
lv_obj_set_event_cb(btnSetOpts, event_handler);
|
||||
lbl_btnSetOpts = lv_label_create(btnSetOpts, nullptr);
|
||||
lv_obj_set_style_local_text_font(lbl_btnSetOpts, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(lbl_btnSetOpts, Symbols::settings);
|
||||
lv_obj_t* lblSetOpts = lv_label_create(btnSetOpts, nullptr);
|
||||
lv_obj_set_style_local_text_font(lblSetOpts, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
|
||||
lv_label_set_text_static(lblSetOpts, Symbols::settings);
|
||||
lv_obj_set_hidden(btnSetOpts, true);
|
||||
|
||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||
|
@ -388,6 +426,7 @@ 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() {
|
||||
|
@ -403,17 +442,6 @@ void WatchFacePineTimeStyle::SetBatteryIcon() {
|
|||
batteryIcon.SetBatteryPercentage(batteryPercent);
|
||||
}
|
||||
|
||||
void WatchFacePineTimeStyle::AlignIcons() {
|
||||
if (notificationState.Get() && bleState.Get()) {
|
||||
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25);
|
||||
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25);
|
||||
} else if (notificationState.Get() && !bleState.Get()) {
|
||||
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
||||
} else {
|
||||
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
|
||||
}
|
||||
}
|
||||
|
||||
void WatchFacePineTimeStyle::Refresh() {
|
||||
isCharging = batteryController.IsCharging();
|
||||
if (isCharging.IsUpdated()) {
|
||||
|
@ -437,13 +465,12 @@ void WatchFacePineTimeStyle::Refresh() {
|
|||
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
|
||||
AlignIcons();
|
||||
lv_obj_realign(bleIcon);
|
||||
}
|
||||
|
||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||
if (notificationState.IsUpdated()) {
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
|
||||
AlignIcons();
|
||||
}
|
||||
|
||||
currentDateTime = dateTimeController.CurrentDateTime();
|
||||
|
@ -509,6 +536,35 @@ void WatchFacePineTimeStyle::Refresh() {
|
|||
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
if (weatherService.GetCurrentTemperature()->timestamp != 0 && weatherService.GetCurrentClouds()->timestamp != 0 &&
|
||||
weatherService.GetCurrentPrecipitation()->timestamp != 0) {
|
||||
nowTemp = (weatherService.GetCurrentTemperature()->temperature / 100);
|
||||
clouds = (weatherService.GetCurrentClouds()->amount);
|
||||
precip = (weatherService.GetCurrentPrecipitation()->amount);
|
||||
if (nowTemp.IsUpdated()) {
|
||||
lv_label_set_text_fmt(temperature, "%d°", nowTemp.Get());
|
||||
if ((clouds <= 30) && (precip == 0)) {
|
||||
lv_label_set_text(weatherIcon, Symbols::sun);
|
||||
} else if ((clouds >= 70) && (clouds <= 90) && (precip == 1)) {
|
||||
lv_label_set_text(weatherIcon, Symbols::cloudSunRain);
|
||||
} else if ((clouds > 90) && (precip == 0)) {
|
||||
lv_label_set_text(weatherIcon, Symbols::cloud);
|
||||
} else if ((clouds > 70) && (precip >= 2)) {
|
||||
lv_label_set_text(weatherIcon, Symbols::cloudShowersHeavy);
|
||||
} else {
|
||||
lv_label_set_text(weatherIcon, Symbols::cloudSun);
|
||||
};
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
} else {
|
||||
lv_label_set_text_static(temperature, "--");
|
||||
lv_label_set_text(weatherIcon, Symbols::ban);
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
|
||||
if (!lv_obj_get_hidden(btnSetColor)) {
|
||||
if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
|
||||
lv_obj_set_hidden(btnSetColor, true);
|
||||
|
@ -654,6 +710,37 @@ 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);
|
||||
|
@ -671,6 +758,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "displayapp/screens/BatteryIcon.h"
|
||||
#include "displayapp/Colors.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "components/ble/weather/WeatherService.h"
|
||||
#include "components/ble/BleController.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
|
||||
|
@ -30,7 +31,8 @@ namespace Pinetime {
|
|||
const Controllers::Ble& bleController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController);
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::WeatherService& weather);
|
||||
~WatchFacePineTimeStyle() override;
|
||||
|
||||
bool OnTouchEvent(TouchEvents event) override;
|
||||
|
@ -58,6 +60,9 @@ namespace Pinetime {
|
|||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
|
||||
Utility::DirtyValue<uint32_t> stepCount {};
|
||||
Utility::DirtyValue<bool> notificationState {};
|
||||
Utility::DirtyValue<int16_t> nowTemp {};
|
||||
int16_t clouds = 0;
|
||||
int16_t precip = 0;
|
||||
|
||||
static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
|
||||
static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
|
||||
|
@ -72,6 +77,7 @@ 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;
|
||||
|
@ -81,6 +87,8 @@ namespace Pinetime {
|
|||
lv_obj_t* dateDayOfWeek;
|
||||
lv_obj_t* dateDay;
|
||||
lv_obj_t* dateMonth;
|
||||
lv_obj_t* weatherIcon;
|
||||
lv_obj_t* temperature;
|
||||
lv_obj_t* plugIcon;
|
||||
lv_obj_t* bleIcon;
|
||||
lv_obj_t* calendarOuter;
|
||||
|
@ -93,8 +101,6 @@ namespace Pinetime {
|
|||
lv_obj_t* stepGauge;
|
||||
lv_obj_t* btnSetColor;
|
||||
lv_obj_t* btnSetOpts;
|
||||
lv_obj_t* lbl_btnSetColor;
|
||||
lv_obj_t* lbl_btnSetOpts;
|
||||
lv_obj_t* stepIcon;
|
||||
lv_obj_t* stepValue;
|
||||
lv_color_t needle_colors[1];
|
||||
|
@ -107,10 +113,10 @@ namespace Pinetime {
|
|||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::WeatherService& weatherService;
|
||||
|
||||
void SetBatteryIcon();
|
||||
void CloseMenu();
|
||||
void AlignIcons();
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
};
|
||||
|
|
|
@ -418,6 +418,7 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
|
|||
LV_FONT_DECLARE(jetbrains_mono_42) \
|
||||
LV_FONT_DECLARE(jetbrains_mono_76) \
|
||||
LV_FONT_DECLARE(open_sans_light) \
|
||||
LV_FONT_DECLARE(fontawesome_weathericons) \
|
||||
LV_FONT_DECLARE(lv_font_sys_48)
|
||||
|
||||
/* Enable it if you have fonts with a lot of characters.
|
||||
|
|
Loading…
Reference in a new issue