2
2
#include " displayapp/screens/WatchFaceTerminal.h"
3
3
#include " displayapp/screens/BatteryIcon.h"
4
4
#include " displayapp/screens/NotificationIcon.h"
5
- #include " displayapp/screens/Symbols.h"
6
5
#include " components/battery/BatteryController.h"
7
6
#include " components/ble/BleController.h"
8
7
#include " components/ble/NotificationManager.h"
9
8
#include " components/heartrate/HeartRateController.h"
10
9
#include " components/motion/MotionController.h"
11
10
#include " components/settings/Settings.h"
11
+ #include " displayapp/InfiniTimeTheme.h"
12
12
13
13
using namespace Pinetime ::Applications::Screens;
14
14
@@ -27,40 +27,44 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
27
27
settingsController {settingsController},
28
28
heartRateController {heartRateController},
29
29
motionController {motionController} {
30
- batteryValue = lv_label_create (lv_scr_act (), nullptr );
31
- lv_label_set_recolor (batteryValue, true );
32
- lv_obj_align (batteryValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -20 );
33
-
34
- connectState = lv_label_create (lv_scr_act (), nullptr );
35
- lv_label_set_recolor (connectState, true );
36
- lv_obj_align (connectState, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 40 );
37
30
38
31
notificationIcon = lv_label_create (lv_scr_act (), nullptr );
39
- lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_LEFT_MID, 0 , -100 );
40
-
41
- label_date = lv_label_create (lv_scr_act (), nullptr );
42
- lv_label_set_recolor (label_date, true );
43
- lv_obj_align (label_date, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -40 );
32
+ lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_LEFT_MID, 0 , -90 );
44
33
45
34
label_prompt_1 = lv_label_create (lv_scr_act (), nullptr );
46
- lv_obj_align (label_prompt_1, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -80 );
35
+ lv_obj_set_style_local_text_color (label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
36
+ lv_obj_align (label_prompt_1, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -70 );
47
37
lv_label_set_text_static (label_prompt_1, " user@watch:~ $ now" );
48
38
49
- label_prompt_2 = lv_label_create (lv_scr_act (), nullptr );
50
- lv_obj_align (label_prompt_2, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 60 );
51
- lv_label_set_text_static (label_prompt_2, " user@watch:~ $" );
52
-
53
39
label_time = lv_label_create (lv_scr_act (), nullptr );
54
40
lv_label_set_recolor (label_time, true );
55
- lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -60 );
41
+ lv_obj_align (label_time, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -50 );
56
42
57
- heartbeatValue = lv_label_create (lv_scr_act (), nullptr );
58
- lv_label_set_recolor (heartbeatValue, true );
59
- lv_obj_align (heartbeatValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 20 );
43
+ label_date = lv_label_create (lv_scr_act (), nullptr );
44
+ lv_label_set_recolor (label_date, true );
45
+ lv_obj_align (label_date, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -30 );
46
+
47
+ batteryValue = lv_label_create (lv_scr_act (), nullptr );
48
+ lv_label_set_recolor (batteryValue, true );
49
+ lv_obj_align (batteryValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , -10 );
60
50
61
51
stepValue = lv_label_create (lv_scr_act (), nullptr );
62
52
lv_label_set_recolor (stepValue, true );
63
- lv_obj_align (stepValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 0 );
53
+ lv_obj_set_style_local_text_color (stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
54
+ lv_obj_align (stepValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 10 );
55
+
56
+ heartbeatValue = lv_label_create (lv_scr_act (), nullptr );
57
+ lv_label_set_recolor (heartbeatValue, true );
58
+ lv_obj_align (heartbeatValue, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 30 );
59
+
60
+ connectState = lv_label_create (lv_scr_act (), nullptr );
61
+ lv_label_set_recolor (connectState, true );
62
+ lv_obj_align (connectState, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 50 );
63
+
64
+ label_prompt_2 = lv_label_create (lv_scr_act (), nullptr );
65
+ lv_obj_set_style_local_text_color (label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
66
+ lv_obj_align (label_prompt_2, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 70 );
67
+ lv_label_set_text_static (label_prompt_2, " user@watch:~ $" );
64
68
65
69
taskRefresh = lv_task_create (RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this );
66
70
Refresh ();
@@ -72,33 +76,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
72
76
}
73
77
74
78
void WatchFaceTerminal::Refresh () {
75
- powerPresent = batteryController.IsPowerPresent ();
76
- batteryPercentRemaining = batteryController.PercentRemaining ();
77
- if (batteryPercentRemaining.IsUpdated () || powerPresent.IsUpdated ()) {
78
- lv_label_set_text_fmt (batteryValue, " [BATT]#387b54 %d%%" , batteryPercentRemaining.Get ());
79
- if (batteryController.IsPowerPresent ()) {
80
- lv_label_ins_text (batteryValue, LV_LABEL_POS_LAST, " Charging" );
81
- }
82
- }
83
-
84
- bleState = bleController.IsConnected ();
85
- bleRadioEnabled = bleController.IsRadioEnabled ();
86
- if (bleState.IsUpdated () || bleRadioEnabled.IsUpdated ()) {
87
- if (!bleRadioEnabled.Get ()) {
88
- lv_label_set_text_static (connectState, " [STAT]#0082fc Disabled#" );
89
- } else {
90
- if (bleState.Get ()) {
91
- lv_label_set_text_static (connectState, " [STAT]#0082fc Connected#" );
92
- } else {
93
- lv_label_set_text_static (connectState, " [STAT]#0082fc Disconnected#" );
94
- }
95
- }
96
- }
97
-
98
79
notificationState = notificationManager.AreNewNotificationsAvailable ();
99
80
if (notificationState.IsUpdated ()) {
100
81
if (notificationState.Get ()) {
101
- lv_label_set_text_static (notificationIcon, " You have mail. " );
82
+ lv_label_set_text_static (notificationIcon, " [1]+ Notify " );
102
83
} else {
103
84
lv_label_set_text_static (notificationIcon, " " );
104
85
}
@@ -120,32 +101,67 @@ void WatchFaceTerminal::Refresh() {
120
101
hour = hour - 12 ;
121
102
ampmChar[0 ] = ' P' ;
122
103
}
123
- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
104
+ lv_label_set_text_fmt (label_time, " #fffff [TIME]# #11cc55 %02d:%02d:%02d %s#" , hour, minute, second, ampmChar);
124
105
} else {
125
- lv_label_set_text_fmt (label_time, " [TIME]#11cc55 %02d:%02d:%02d" , hour, minute, second);
106
+ lv_label_set_text_fmt (label_time, " #ffffff [TIME]# # 11cc55 %02d:%02d:%02d# " , hour, minute, second);
126
107
}
127
108
128
109
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get ());
129
110
if (currentDate.IsUpdated ()) {
130
111
uint16_t year = dateTimeController.Year ();
131
112
Controllers::DateTime::Months month = dateTimeController.Month ();
132
113
uint8_t day = dateTimeController.Day ();
133
- lv_label_set_text_fmt (label_date, " [DATE]#007fff %04d-%02d-%02d#" , short (year), char (month), char (day));
114
+ lv_label_set_text_fmt (label_date, " #ffffff [DATE]# #007fff %04d-%02d-%02d#" , short (year), char (month), char (day));
115
+ }
116
+ }
117
+
118
+ powerPresent = batteryController.IsPowerPresent ();
119
+ batteryPercentRemaining = batteryController.PercentRemaining ();
120
+ if (batteryPercentRemaining.IsUpdated () || powerPresent.IsUpdated ()) {
121
+ // HSV color model has red at 0° and green at 120°.
122
+ // We lock satuation and brightness at 100% and traverse the cilinder
123
+ // between red and green, thus avoiding the darker RGB on medium battery
124
+ // charges and giving us a much nicer color range.
125
+ uint8_t hue = batteryPercentRemaining.Get () * 120 / 100 ;
126
+ lv_obj_set_style_local_text_color (batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb (hue, 100 , 100 ));
127
+ lv_label_set_text_fmt (batteryValue, " #ffffff [BATT]# %d%%" , batteryPercentRemaining.Get ());
128
+ if (batteryController.IsCharging ()) {
129
+ lv_label_ins_text (batteryValue, LV_LABEL_POS_LAST, " Charging" );
134
130
}
135
131
}
136
132
133
+ stepCount = motionController.NbSteps ();
134
+ if (stepCount.IsUpdated ()) {
135
+ lv_label_set_text_fmt (stepValue, " #ffffff [STEP]# %lu steps" , stepCount.Get ());
136
+ }
137
+
137
138
heartbeat = heartRateController.HeartRate ();
138
139
heartbeatRunning = heartRateController.State () != Controllers::HeartRateController::States::Stopped;
139
140
if (heartbeat.IsUpdated () || heartbeatRunning.IsUpdated ()) {
140
141
if (heartbeatRunning.Get ()) {
141
- lv_label_set_text_fmt (heartbeatValue, " [L_HR]#ee3311 %d bpm#" , heartbeat.Get ());
142
+
143
+ lv_obj_set_style_local_text_color (heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange);
144
+ lv_label_set_text_fmt (heartbeatValue, " #ffffff [L_HR]# %d bpm" , heartbeat.Get ());
142
145
} else {
143
- lv_label_set_text_static (heartbeatValue, " [L_HR]#ee3311 ---#" );
146
+ lv_label_set_text_static (heartbeatValue, " #ffffff [L_HR]# ---" );
147
+ lv_obj_set_style_local_text_color (heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
144
148
}
145
149
}
146
150
147
- stepCount = motionController.NbSteps ();
148
- if (stepCount.IsUpdated ()) {
149
- lv_label_set_text_fmt (stepValue, " [STEP]#ee3377 %lu steps#" , stepCount.Get ());
151
+ bleState = bleController.IsConnected ();
152
+ bleRadioEnabled = bleController.IsRadioEnabled ();
153
+ if (bleState.IsUpdated () || bleRadioEnabled.IsUpdated ()) {
154
+ if (!bleRadioEnabled.Get ()) {
155
+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Disabled" );
156
+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
157
+ } else {
158
+ if (bleState.Get ()) {
159
+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Connected" );
160
+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue);
161
+ } else {
162
+ lv_label_set_text_static (connectState, " #ffffff [STAT]# Disconnected" );
163
+ lv_obj_set_style_local_text_color (connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray);
164
+ }
165
+ }
150
166
}
151
167
}
0 commit comments