Skip to content

Commit 9d18ae9

Browse files
JustScottmark9064
authored andcommitted
Improved the Terminal Watchfaces UI
+ Reorder code to match the widgets order in the UI. + Moved all objects (rows) into a container + 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 51a6fb6 commit 9d18ae9

File tree

3 files changed

+83
-67
lines changed

3 files changed

+83
-67
lines changed

src/displayapp/InfiniTimeTheme.h

Lines changed: 1 addition & 0 deletions
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

Lines changed: 76 additions & 62 deletions
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"
@@ -11,6 +10,7 @@
1110
#include "components/settings/Settings.h"
1211
#include "components/ble/SimpleWeatherService.h"
1312
#include "displayapp/screens/WeatherSymbols.h"
13+
#include "displayapp/InfiniTimeTheme.h"
1414

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

@@ -31,44 +31,46 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
3131
heartRateController {heartRateController},
3232
motionController {motionController},
3333
weatherService {weatherService} {
34-
batteryValue = lv_label_create(lv_scr_act(), nullptr);
35-
lv_label_set_recolor(batteryValue, true);
36-
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
37-
38-
connectState = lv_label_create(lv_scr_act(), nullptr);
39-
lv_label_set_recolor(connectState, true);
40-
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
4134

42-
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
43-
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
35+
container = lv_cont_create(lv_scr_act(), nullptr);
36+
lv_cont_set_layout(container, LV_LAYOUT_COLUMN_LEFT);
37+
lv_cont_set_fit(container, LV_FIT_TIGHT);
38+
lv_obj_set_style_local_pad_inner(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, -3);
39+
lv_obj_set_style_local_bg_opa(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
4440

45-
label_date = lv_label_create(lv_scr_act(), nullptr);
46-
lv_label_set_recolor(label_date, true);
47-
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
41+
notificationIcon = lv_label_create(container, nullptr);
4842

49-
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
50-
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
43+
label_prompt_1 = lv_label_create(container, nullptr);
44+
lv_obj_set_style_local_text_color(label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
5145
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
5246

53-
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
54-
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 80);
55-
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
56-
57-
label_time = lv_label_create(lv_scr_act(), nullptr);
47+
label_time = lv_label_create(container, nullptr);
5848
lv_label_set_recolor(label_time, true);
59-
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
6049

61-
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
62-
lv_label_set_recolor(heartbeatValue, true);
63-
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
50+
label_date = lv_label_create(container, nullptr);
51+
lv_label_set_recolor(label_date, true);
6452

65-
stepValue = lv_label_create(lv_scr_act(), nullptr);
53+
batteryValue = lv_label_create(container, nullptr);
54+
lv_label_set_recolor(batteryValue, true);
55+
56+
stepValue = lv_label_create(container, nullptr);
6657
lv_label_set_recolor(stepValue, true);
67-
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
58+
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
59+
60+
heartbeatValue = lv_label_create(container, nullptr);
61+
lv_label_set_recolor(heartbeatValue, true);
6862

69-
weather = lv_label_create(lv_scr_act(), nullptr);
63+
weather = lv_label_create(container, nullptr);
7064
lv_label_set_recolor(weather, true);
71-
lv_obj_align(weather, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
65+
66+
connectState = lv_label_create(container, nullptr);
67+
lv_label_set_recolor(connectState, true);
68+
69+
label_prompt_2 = lv_label_create(container, nullptr);
70+
lv_obj_set_style_local_text_color(label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
71+
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
72+
73+
lv_obj_align(container, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 20);
7274

7375
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
7476
Refresh();
@@ -80,33 +82,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
8082
}
8183

8284
void WatchFaceTerminal::Refresh() {
83-
powerPresent = batteryController.IsPowerPresent();
84-
batteryPercentRemaining = batteryController.PercentRemaining();
85-
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
86-
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
87-
if (batteryController.IsPowerPresent()) {
88-
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
89-
}
90-
}
91-
92-
bleState = bleController.IsConnected();
93-
bleRadioEnabled = bleController.IsRadioEnabled();
94-
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
95-
if (!bleRadioEnabled.Get()) {
96-
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
97-
} else {
98-
if (bleState.Get()) {
99-
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
100-
} else {
101-
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
102-
}
103-
}
104-
}
105-
10685
notificationState = notificationManager.AreNewNotificationsAvailable();
10786
if (notificationState.IsUpdated()) {
10887
if (notificationState.Get()) {
109-
lv_label_set_text_static(notificationIcon, "You have mail.");
88+
lv_label_set_text_static(notificationIcon, "[1]+ Notify");
11089
} else {
11190
lv_label_set_text_static(notificationIcon, "");
11291
}
@@ -128,35 +107,53 @@ void WatchFaceTerminal::Refresh() {
128107
hour = hour - 12;
129108
ampmChar[0] = 'P';
130109
}
131-
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
110+
lv_label_set_text_fmt(label_time, "#fffff [TIME]# #11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
132111
} else {
133-
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
112+
lv_label_set_text_fmt(label_time, "#ffffff [TIME]# #11cc55 %02d:%02d:%02d#", hour, minute, second);
134113
}
135114

136115
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
137116
if (currentDate.IsUpdated()) {
138117
uint16_t year = dateTimeController.Year();
139118
Controllers::DateTime::Months month = dateTimeController.Month();
140119
uint8_t day = dateTimeController.Day();
141-
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
120+
lv_label_set_text_fmt(label_date, "#ffffff [DATE]# #007fff %04d-%02d-%02d#", short(year), char(month), char(day));
121+
}
122+
}
123+
124+
powerPresent = batteryController.IsPowerPresent();
125+
batteryPercentRemaining = batteryController.PercentRemaining();
126+
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
127+
// HSV color model has red at 0° and green at 120°.
128+
// We lock satuation and brightness at 100% and traverse the cilinder
129+
// between red and green, thus avoiding the darker RGB on medium battery
130+
// charges and giving us a much nicer color range.
131+
uint8_t hue = batteryPercentRemaining.Get() * 120 / 100;
132+
lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(hue, 100, 100));
133+
lv_label_set_text_fmt(batteryValue, "#ffffff [BATT]# %d%%", batteryPercentRemaining.Get());
134+
if (batteryController.IsCharging()) {
135+
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
142136
}
143137
}
144138

139+
stepCount = motionController.NbSteps();
140+
if (stepCount.IsUpdated()) {
141+
lv_label_set_text_fmt(stepValue, "#ffffff [STEP]# %lu steps", stepCount.Get());
142+
}
143+
145144
heartbeat = heartRateController.HeartRate();
146145
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
147146
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
148147
if (heartbeatRunning.Get()) {
149-
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
148+
149+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange);
150+
lv_label_set_text_fmt(heartbeatValue, "#ffffff [L_HR]# %d bpm", heartbeat.Get());
150151
} else {
151-
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
152+
lv_label_set_text_static(heartbeatValue, "#ffffff [L_HR]# ---");
153+
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
152154
}
153155
}
154156

155-
stepCount = motionController.NbSteps();
156-
if (stepCount.IsUpdated()) {
157-
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
158-
}
159-
160157
currentWeather = weatherService.Current();
161158
if (currentWeather.IsUpdated()) {
162159
auto optCurrentWeather = currentWeather.Get();
@@ -172,4 +169,21 @@ void WatchFaceTerminal::Refresh() {
172169
lv_label_set_text(weather, "[WTHR]#ffdd00 ---");
173170
}
174171
}
172+
173+
bleState = bleController.IsConnected();
174+
bleRadioEnabled = bleController.IsRadioEnabled();
175+
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
176+
if (!bleRadioEnabled.Get()) {
177+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disabled");
178+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
179+
} else {
180+
if (bleState.Get()) {
181+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Connected");
182+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue);
183+
} else {
184+
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disconnected");
185+
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
186+
}
187+
}
188+
}
175189
}

src/displayapp/screens/WatchFaceTerminal.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@ 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* container;
54+
lv_obj_t* notificationIcon;
55+
lv_obj_t* label_prompt_1;
5356
lv_obj_t* label_time;
5457
lv_obj_t* label_date;
55-
lv_obj_t* label_prompt_1;
56-
lv_obj_t* label_prompt_2;
5758
lv_obj_t* batteryValue;
58-
lv_obj_t* heartbeatValue;
5959
lv_obj_t* stepValue;
60-
lv_obj_t* notificationIcon;
61-
lv_obj_t* connectState;
60+
lv_obj_t* heartbeatValue;
6261
lv_obj_t* weather;
62+
lv_obj_t* connectState;
63+
lv_obj_t* label_prompt_2;
6364

6465
Controllers::DateTime& dateTimeController;
6566
const Controllers::Battery& batteryController;

0 commit comments

Comments
 (0)