Skip to content

Commit eb8bd4d

Browse files
committed
add ble state text output
1 parent fda1c08 commit eb8bd4d

2 files changed

Lines changed: 33 additions & 10 deletions

File tree

src/displayapp/screens/WatchFaceTerminal.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
5555
lv_obj_align(batteryPercent, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
5656

5757
connectState = lv_label_create(lv_scr_act(), nullptr);
58-
lv_label_set_recolor(connectState, true);
58+
lv_label_set_text(bleValue, "Connected");
5959
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
6060

6161
bleIcon = lv_label_create(lv_scr_act(), nullptr);
@@ -115,17 +115,18 @@ void WatchFaceTerminal::Refresh() {
115115
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
116116
auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent();
117117
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));
118+
118119
}
119120

120-
char* bleValue;
121+
/*char* bleValue;*/
121122
bleState = bleController.IsConnected();
122123
if (bleState.IsUpdated()) {
123124
if (bleState.Get() == true) {
124125
lv_label_set_text(bleIcon, BleIcon::GetIcon(true));
125-
bleValue = "Connected";
126+
lv_label_set_text(bleValue, "Connected#");
126127
} else {
127128
lv_label_set_text(bleIcon, BleIcon::GetIcon(false));
128-
bleValue = "Disconnected";
129+
lv_label_set_text(bleValue, "Disonnected#");
129130
}
130131
}
131132
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 5);
@@ -134,10 +135,11 @@ void WatchFaceTerminal::Refresh() {
134135

135136
notificationState = notificatioManager.AreNewNotificationsAvailable();
136137
if (notificationState.IsUpdated()) {
137-
if (notificationState.Get() == true)
138+
if (notificationState.Get() == true) {
138139
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
139-
else
140+
} else {
140141
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
142+
}
141143
}
142144

143145
currentDateTime = dateTimeController.CurrentDateTime();
@@ -163,14 +165,33 @@ void WatchFaceTerminal::Refresh() {
163165

164166
char hoursChar[8];
165167

166-
char secondsChar[5];
167-
sprintf(secondsChar, "%02d", static_cast<int>(second));
168+
char ampmChar[3];
169+
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
170+
sprintf(hoursChar, "%02d", hour);
171+
} else {
172+
if (hour == 0 && hour != 12) {
173+
hour = 12;
174+
sprintf(ampmChar, "AM");
175+
} else if (hour == 12 && hour != 0) {
176+
hour = 12;
177+
sprintf(ampmChar, "PM");
178+
} else if (hour < 12 && hour != 0) {
179+
sprintf(ampmChar, "AM");
180+
} else if (hour > 12 && hour != 0) {
181+
hour = hour - 12;
182+
sprintf(ampmChar, "PM");
183+
}
184+
sprintf(hoursChar, "%02d", hour);
185+
}
168186

169187
auto batteryValue = static_cast<uint8_t>(batteryController.PercentRemaining());
170188

171189
char battStr[24];
172190
sprintf(battStr, "[BATT]#387b54 %d%\%#", batteryValue);
173191
lv_label_set_text(batteryPercent, battStr);
192+
193+
char secondsChar[5];
194+
sprintf(secondsChar, "%02d", static_cast<int>(second));
174195

175196
char bleStr[24];
176197
sprintf(bleStr, "[STAT]#387b54 %s#", bleValue);
@@ -193,13 +214,14 @@ void WatchFaceTerminal::Refresh() {
193214

194215
char timeStr[42];
195216
sprintf(timeStr,
196-
"[TIME]#11cc55 %c%c:%c%c:%c%c#",
217+
"[TIME]#11cc55 %c%c:%c%c:%c%c %s#",
197218
hoursChar[0],
198219
hoursChar[1],
199220
minutesChar[0],
200221
minutesChar[1],
201222
secondsChar[0],
202-
secondsChar[1]);
223+
secondsChar[1],
224+
ampmChar);
203225

204226
lv_label_set_text(label_time, timeStr);
205227
}

src/displayapp/screens/WatchFaceTerminal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace Pinetime {
6868
lv_obj_t* stepValue;
6969
lv_obj_t* notificationIcon;
7070
lv_obj_t* connectState;
71+
lv_obj_t* bleValue;
7172

7273
Controllers::DateTime& dateTimeController;
7374
Controllers::Battery& batteryController;

0 commit comments

Comments
 (0)