Skip to content

Commit d61398a

Browse files
JustScottBurninTurtles
authored andcommitted
Improved the Terminal Watchfaces UI
+ Reorder code to match the widgets order in the UI. + Use InfintimeTheme Colors instead of hardcoded hex values + Added a new InfinitimeTheme color: gray, using it to turn certain values gray when they contain no data + Implement @vkareh's [variable battery icon](InfiniTimeOrg#1964) color to the battery percentage text. + Replaced the 'You have mail.' notification message with the message '[1]+ Notify' to better fit the terminal lore.
1 parent 373050c commit d61398a

File tree

3 files changed

+74
-75
lines changed

3 files changed

+74
-75
lines changed

src/displayapp/InfiniTimeTheme.h

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Colors {
88
static constexpr lv_color_t green = LV_COLOR_MAKE(0x0, 0xb0, 0x0);
99
static constexpr lv_color_t blue = LV_COLOR_MAKE(0x0, 0x50, 0xff);
1010
static constexpr lv_color_t lightGray = LV_COLOR_MAKE(0xb0, 0xb0, 0xb0);
11+
static constexpr lv_color_t gray = LV_COLOR_MAKE(0x50, 0x50, 0x50);
1112

1213
static constexpr lv_color_t bg = LV_COLOR_MAKE(0x5d, 0x69, 0x7e);
1314
static constexpr lv_color_t bgAlt = LV_COLOR_MAKE(0x38, 0x38, 0x38);

src/displayapp/screens/WatchFaceTerminal.cpp

+69-70
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "displayapp/screens/WatchFaceTerminal.h"
33
#include "displayapp/screens/BatteryIcon.h"
44
#include "displayapp/screens/NotificationIcon.h"
5-
#include "displayapp/screens/Symbols.h"
65
#include "components/battery/BatteryController.h"
76
#include "components/ble/BleController.h"
87
#include "components/ble/NotificationManager.h"
@@ -12,6 +11,7 @@
1211
#include "components/ble/SimpleWeatherService.h"
1312
#include "displayapp/screens/WeatherSymbols.h"
1413
#include "displayapp/InfiniTimeTheme.h"
14+
#include "displayapp/InfiniTimeTheme.h"
1515

1616
using namespace Pinetime::Applications::Screens;
1717

@@ -39,37 +39,45 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
3939
connectState = lv_label_create(lv_scr_act(), nullptr);
4040
lv_label_set_recolor(connectState, true);
4141
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
42+
motionController {motionController} {
4243

4344
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
44-
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
45-
46-
label_date = lv_label_create(lv_scr_act(), nullptr);
47-
lv_label_set_recolor(label_date, true);
48-
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
45+
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -90);
4946

5047
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
51-
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
48+
lv_obj_set_style_local_text_color(label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
49+
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -70);
5250
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
5351

54-
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
55-
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 80);
56-
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
57-
5852
label_time = lv_label_create(lv_scr_act(), nullptr);
5953
lv_label_set_recolor(label_time, true);
60-
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
54+
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -50);
6155

62-
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
63-
lv_label_set_recolor(heartbeatValue, true);
64-
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
56+
label_date = lv_label_create(lv_scr_act(), nullptr);
57+
lv_label_set_recolor(label_date, true);
58+
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -30);
59+
60+
batteryValue = lv_label_create(lv_scr_act(), nullptr);
61+
lv_label_set_recolor(batteryValue, true);
62+
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -10);
6563

6664
stepValue = lv_label_create(lv_scr_act(), nullptr);
6765
lv_label_set_recolor(stepValue, true);
68-
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
66+
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
67+
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 10);
68+
69+
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
70+
lv_label_set_recolor(heartbeatValue, true);
71+
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 30);
72+
73+
connectState = lv_label_create(lv_scr_act(), nullptr);
74+
lv_label_set_recolor(connectState, true);
75+
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 50);
6976

70-
weather = lv_label_create(lv_scr_act(), nullptr);
71-
lv_label_set_recolor(weather, true);
72-
lv_obj_align(weather, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
77+
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
78+
lv_obj_set_style_local_text_color(label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
79+
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 70);
80+
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
7381

7482
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
7583
Refresh();
@@ -81,33 +89,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
8189
}
8290

8391
void WatchFaceTerminal::Refresh() {
84-
powerPresent = batteryController.IsPowerPresent();
85-
batteryPercentRemaining = batteryController.PercentRemaining();
86-
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
87-
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
88-
if (batteryController.IsPowerPresent()) {
89-
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
90-
}
91-
}
92-
93-
bleState = bleController.IsConnected();
94-
bleRadioEnabled = bleController.IsRadioEnabled();
95-
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
96-
if (!bleRadioEnabled.Get()) {
97-
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
98-
} else {
99-
if (bleState.Get()) {
100-
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
101-
} else {
102-
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
103-
}
104-
}
105-
}
106-
10792
notificationState = notificationManager.AreNewNotificationsAvailable();
10893
if (notificationState.IsUpdated()) {
10994
if (notificationState.Get()) {
110-
lv_label_set_text_static(notificationIcon, "You have mail.");
95+
lv_label_set_text_static(notificationIcon, "[1]+ Notify");
11196
} else {
11297
lv_label_set_text_static(notificationIcon, "");
11398
}
@@ -129,53 +114,67 @@ void WatchFaceTerminal::Refresh() {
129114
hour = hour - 12;
130115
ampmChar[0] = 'P';
131116
}
132-
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
117+
lv_label_set_text_fmt(label_time, "#fffff [TIME]# #11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
133118
} else {
134-
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
119+
lv_label_set_text_fmt(label_time, "#ffffff [TIME]# #11cc55 %02d:%02d:%02d#", hour, minute, second);
135120
}
136121

137122
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
138123
if (currentDate.IsUpdated()) {
139124
uint16_t year = dateTimeController.Year();
140125
Controllers::DateTime::Months month = dateTimeController.Month();
141126
uint8_t day = dateTimeController.Day();
142-
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
127+
lv_label_set_text_fmt(label_date, "#ffffff [DATE]# #007fff %04d-%02d-%02d#", short(year), char(month), char(day));
143128
}
144129
}
145130

131+
powerPresent = batteryController.IsPowerPresent();
132+
batteryPercentRemaining = batteryController.PercentRemaining();
133+
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
134+
// HSV color model has red at 0° and green at 120°.
135+
// We lock satuation and brightness at 100% and traverse the cilinder
136+
// between red and green, thus avoiding the darker RGB on medium battery
137+
// charges and giving us a much nicer color range.
138+
uint8_t hue = batteryPercentRemaining.Get() * 120 / 100;
139+
lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(hue, 100, 100));
140+
lv_label_set_text_fmt(batteryValue, "#ffffff [BATT]# %d%%", batteryPercentRemaining.Get());
141+
if (batteryController.IsCharging()) {
142+
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
143+
}
144+
}
145+
146+
stepCount = motionController.NbSteps();
147+
if (stepCount.IsUpdated()) {
148+
lv_label_set_text_fmt(stepValue, "#ffffff [STEP]# %lu steps", stepCount.Get());
149+
}
150+
146151
heartbeat = heartRateController.HeartRate();
147152
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
148153
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
149154
if (heartbeatRunning.Get()) {
150-
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
155+
156+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange);
157+
lv_label_set_text_fmt(heartbeatValue, "#ffffff [L_HR]# %d bpm", heartbeat.Get());
151158
} else {
152-
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
159+
lv_label_set_text_static(heartbeatValue, "#ffffff [L_HR]# ---");
160+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
153161
}
154162
}
155163

156-
stepCount = motionController.NbSteps();
157-
if (stepCount.IsUpdated()) {
158-
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
159-
}
160-
161-
currentWeather = weatherService.Current();
162-
if (currentWeather.IsUpdated()) {
163-
auto optCurrentWeather = currentWeather.Get();
164-
if (optCurrentWeather) {
165-
int16_t temp = optCurrentWeather->temperature.Celsius();
166-
char tempUnit = 'C';
167-
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
168-
temp = optCurrentWeather->temperature.Fahrenheit();
169-
tempUnit = 'F';
170-
}
171-
lv_label_set_text_fmt(weather,
172-
"[WTHR]#ffdd00 %d°%c %s#",
173-
temp,
174-
tempUnit,
175-
// Change to GetSimpleCondition with pull request #2134 (Add shorter/simpler weather condition options)
176-
Symbols::GetCondition(optCurrentWeather->iconId));
164+
bleState = bleController.IsConnected();
165+
bleRadioEnabled = bleController.IsRadioEnabled();
166+
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
167+
if (!bleRadioEnabled.Get()) {
168+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disabled");
169+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
177170
} else {
178-
lv_label_set_text(weather, "[WTHR]#ffdd00 ---");
171+
if (bleState.Get()) {
172+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Connected");
173+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue);
174+
} else {
175+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disconnected");
176+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
177+
}
179178
}
180179
}
181180
}

src/displayapp/screens/WatchFaceTerminal.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ namespace Pinetime {
5050
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
5151
Utility::DirtyValue<std::optional<Controllers::SimpleWeatherService::CurrentWeather>> currentWeather {};
5252

53+
lv_obj_t* notificationIcon;
54+
lv_obj_t* label_prompt_1;
5355
lv_obj_t* label_time;
5456
lv_obj_t* label_date;
55-
lv_obj_t* label_prompt_1;
56-
lv_obj_t* label_prompt_2;
5757
lv_obj_t* batteryValue;
58-
lv_obj_t* heartbeatValue;
5958
lv_obj_t* stepValue;
60-
lv_obj_t* notificationIcon;
59+
lv_obj_t* heartbeatValue;
6160
lv_obj_t* connectState;
62-
lv_obj_t* weather;
61+
lv_obj_t* label_prompt_2;
6362

6463
Controllers::DateTime& dateTimeController;
6564
const Controllers::Battery& batteryController;

0 commit comments

Comments
 (0)