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