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"
12
11
#include " components/ble/SimpleWeatherService.h"
13
12
#include " displayapp/screens/WeatherSymbols.h"
14
13
#include " displayapp/InfiniTimeTheme.h"
14
+ #include " displayapp/InfiniTimeTheme.h"
15
15
16
16
using namespace Pinetime ::Applications::Screens;
17
17
@@ -39,37 +39,45 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
39
39
connectState = lv_label_create (lv_scr_act (), nullptr );
40
40
lv_label_set_recolor (connectState, true );
41
41
lv_obj_align (connectState, lv_scr_act (), LV_ALIGN_IN_LEFT_MID, 0 , 60 );
42
+ motionController {motionController} {
42
43
43
44
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 );
49
46
50
47
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 );
52
50
lv_label_set_text_static (label_prompt_1, " user@watch:~ $ now" );
53
51
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
-
58
52
label_time = lv_label_create (lv_scr_act (), nullptr );
59
53
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 );
61
55
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 );
65
63
66
64
stepValue = lv_label_create (lv_scr_act (), nullptr );
67
65
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 );
69
76
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:~ $" );
73
81
74
82
taskRefresh = lv_task_create (RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this );
75
83
Refresh ();
@@ -81,33 +89,10 @@ WatchFaceTerminal::~WatchFaceTerminal() {
81
89
}
82
90
83
91
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
-
107
92
notificationState = notificationManager.AreNewNotificationsAvailable ();
108
93
if (notificationState.IsUpdated ()) {
109
94
if (notificationState.Get ()) {
110
- lv_label_set_text_static (notificationIcon, " You have mail. " );
95
+ lv_label_set_text_static (notificationIcon, " [1]+ Notify " );
111
96
} else {
112
97
lv_label_set_text_static (notificationIcon, " " );
113
98
}
@@ -129,53 +114,67 @@ void WatchFaceTerminal::Refresh() {
129
114
hour = hour - 12 ;
130
115
ampmChar[0 ] = ' P' ;
131
116
}
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);
133
118
} 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);
135
120
}
136
121
137
122
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get ());
138
123
if (currentDate.IsUpdated ()) {
139
124
uint16_t year = dateTimeController.Year ();
140
125
Controllers::DateTime::Months month = dateTimeController.Month ();
141
126
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));
143
128
}
144
129
}
145
130
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
+
146
151
heartbeat = heartRateController.HeartRate ();
147
152
heartbeatRunning = heartRateController.State () != Controllers::HeartRateController::States::Stopped;
148
153
if (heartbeat.IsUpdated () || heartbeatRunning.IsUpdated ()) {
149
154
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 ());
151
158
} 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);
153
161
}
154
162
}
155
163
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);
177
170
} 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
+ }
179
178
}
180
179
}
181
180
}
0 commit comments