aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/WatchFaceTerminal.cpp
diff options
context:
space:
mode:
authorJustScott <development@justscott.me>2024-12-19 00:45:05 -0600
committermark9064 <30447455+mark9064@users.noreply.github.com>2025-12-31 18:21:16 +0000
commitedd67caa7b182c98db8a75fa9fa13a3c8d59cfdc (patch)
treec6f5c6e7b795be87baaea4f29ddb2a128a7fb237 /src/displayapp/screens/WatchFaceTerminal.cpp
parent41050e6a9851eddb5735b7888e3e48d94604daed (diff)
Add weather to the terminal watchface
Diffstat (limited to 'src/displayapp/screens/WatchFaceTerminal.cpp')
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp
index 96d77741..4d693984 100644
--- a/src/displayapp/screens/WatchFaceTerminal.cpp
+++ b/src/displayapp/screens/WatchFaceTerminal.cpp
@@ -9,6 +9,9 @@
#include "components/heartrate/HeartRateController.h"
#include "components/motion/MotionController.h"
#include "components/settings/Settings.h"
+#include "components/ble/SimpleWeatherService.h"
+#include "displayapp/screens/WeatherSymbols.h"
+#include "displayapp/InfiniTimeTheme.h"
using namespace Pinetime::Applications::Screens;
@@ -18,7 +21,8 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::HeartRateController& heartRateController,
- Controllers::MotionController& motionController)
+ Controllers::MotionController& motionController,
+ Controllers::SimpleWeatherService& weatherService)
: currentDateTime {{}},
dateTimeController {dateTimeController},
batteryController {batteryController},
@@ -26,7 +30,8 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
notificationManager {notificationManager},
settingsController {settingsController},
heartRateController {heartRateController},
- motionController {motionController} {
+ motionController {motionController},
+ weatherService {weatherService} {
batteryValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(batteryValue, true);
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
@@ -47,7 +52,7 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
+ lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 80);
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
label_time = lv_label_create(lv_scr_act(), nullptr);
@@ -62,6 +67,10 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
lv_label_set_recolor(stepValue, true);
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
+ weather = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(weather, true);
+ lv_obj_align(weather, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
+
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
}
@@ -148,4 +157,25 @@ void WatchFaceTerminal::Refresh() {
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
}
+
+ currentWeather = weatherService.Current();
+ if (currentWeather.IsUpdated()) {
+ auto optCurrentWeather = currentWeather.Get();
+ if (optCurrentWeather) {
+ int16_t temp = optCurrentWeather->temperature.Celsius();
+ char tempUnit = 'C';
+ if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
+ temp = optCurrentWeather->temperature.Fahrenheit();
+ tempUnit = 'F';
+ }
+ lv_label_set_text_fmt(weather,
+ "[WTHR]#ffdd00 %d°%c %s#",
+ temp,
+ tempUnit,
+ // Change to GetSimpleCondition with pull request #2134 (Add shorter/simpler weather condition options)
+ Symbols::GetCondition(optCurrentWeather->iconId));
+ } else {
+ lv_label_set_text(weather, "[WTHR]#ffdd00 ---°");
+ }
+ }
}