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"
1110#include " components/settings/Settings.h"
1211#include " components/ble/SimpleWeatherService.h"
1312#include " displayapp/screens/WeatherSymbols.h"
13+ #include " displayapp/InfiniTimeTheme.h"
1414
1515using namespace Pinetime ::Applications::Screens;
1616
@@ -31,44 +31,47 @@ 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 );
74+
7275
7376 taskRefresh = lv_task_create (RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this );
7477 Refresh ();
@@ -80,33 +83,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
8083}
8184
8285void 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-
10686 notificationState = notificationManager.AreNewNotificationsAvailable ();
10787 if (notificationState.IsUpdated ()) {
10888 if (notificationState.Get ()) {
109- lv_label_set_text_static (notificationIcon, " You have mail. " );
89+ lv_label_set_text_static (notificationIcon, " [1]+ Notify " );
11090 } else {
11191 lv_label_set_text_static (notificationIcon, " " );
11292 }
@@ -128,35 +108,53 @@ void WatchFaceTerminal::Refresh() {
128108 hour = hour - 12 ;
129109 ampmChar[0 ] = ' P' ;
130110 }
131- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
111+ lv_label_set_text_fmt (label_time, " #fffff [TIME]# #11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
132112 } else {
133- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d" , hour, minute, second);
113+ lv_label_set_text_fmt (label_time, " #ffffff [TIME]# # 11cc55 %02d:%02d:%02d# " , hour, minute, second);
134114 }
135115
136116 currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get ());
137117 if (currentDate.IsUpdated ()) {
138118 uint16_t year = dateTimeController.Year ();
139119 Controllers::DateTime::Months month = dateTimeController.Month ();
140120 uint8_t day = dateTimeController.Day ();
141- lv_label_set_text_fmt (label_date, " [DATE]#007fff %04d-%02d-%02d#" , short (year), char (month), char (day));
121+ lv_label_set_text_fmt (label_date, " #ffffff [DATE]# #007fff %04d-%02d-%02d#" , short (year), char (month), char (day));
122+ }
123+ }
124+
125+ powerPresent = batteryController.IsPowerPresent ();
126+ batteryPercentRemaining = batteryController.PercentRemaining ();
127+ if (batteryPercentRemaining.IsUpdated () || powerPresent.IsUpdated ()) {
128+ // HSV color model has red at 0° and green at 120°.
129+ // We lock satuation and brightness at 100% and traverse the cilinder
130+ // between red and green, thus avoiding the darker RGB on medium battery
131+ // charges and giving us a much nicer color range.
132+ uint8_t hue = batteryPercentRemaining.Get () * 120 / 100 ;
133+ lv_obj_set_style_local_text_color (batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb (hue, 100 , 100 ));
134+ lv_label_set_text_fmt (batteryValue, " #ffffff [BATT]# %d%%" , batteryPercentRemaining.Get ());
135+ if (batteryController.IsCharging ()) {
136+ lv_label_ins_text (batteryValue, LV_LABEL_POS_LAST, " Charging" );
142137 }
143138 }
144139
140+ stepCount = motionController.NbSteps ();
141+ if (stepCount.IsUpdated ()) {
142+ lv_label_set_text_fmt (stepValue, " #ffffff [STEP]# %lu steps" , stepCount.Get ());
143+ }
144+
145145 heartbeat = heartRateController.HeartRate ();
146146 heartbeatRunning = heartRateController.State () != Controllers::HeartRateController::States::Stopped;
147147 if (heartbeat.IsUpdated () || heartbeatRunning.IsUpdated ()) {
148148 if (heartbeatRunning.Get ()) {
149- lv_label_set_text_fmt (heartbeatValue, " [L_HR]#ee3311 %d bpm#" , heartbeat.Get ());
149+
150+ lv_obj_set_style_local_text_color (heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange);
151+ lv_label_set_text_fmt (heartbeatValue, " #ffffff [L_HR]# %d bpm" , heartbeat.Get ());
150152 } else {
151- lv_label_set_text_static (heartbeatValue, " [L_HR]#ee3311 ---#" );
153+ lv_label_set_text_static (heartbeatValue, " #ffffff [L_HR]# ---" );
154+ lv_obj_set_style_local_text_color (heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
152155 }
153156 }
154157
155- stepCount = motionController.NbSteps ();
156- if (stepCount.IsUpdated ()) {
157- lv_label_set_text_fmt (stepValue, " [STEP]#ee3377 %lu steps#" , stepCount.Get ());
158- }
159-
160158 currentWeather = weatherService.Current ();
161159 if (currentWeather.IsUpdated ()) {
162160 auto optCurrentWeather = currentWeather.Get ();
@@ -172,4 +170,21 @@ void WatchFaceTerminal::Refresh() {
172170 lv_label_set_text (weather, " [WTHR]#ffdd00 ---" );
173171 }
174172 }
173+
174+ bleState = bleController.IsConnected ();
175+ bleRadioEnabled = bleController.IsRadioEnabled ();
176+ if (bleState.IsUpdated () || bleRadioEnabled.IsUpdated ()) {
177+ if (!bleRadioEnabled.Get ()) {
178+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Disabled" );
179+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
180+ } else {
181+ if (bleState.Get ()) {
182+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Connected" );
183+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue);
184+ } else {
185+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Disconnected" );
186+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
187+ }
188+ }
189+ }
175190}
0 commit comments