Skip to content

Commit

Permalink
add ble state text output
Browse files Browse the repository at this point in the history
  • Loading branch information
13werwolf13 committed Jan 20, 2022
1 parent fda1c08 commit eb8bd4d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
42 changes: 32 additions & 10 deletions src/displayapp/screens/WatchFaceTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
lv_obj_align(batteryPercent, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);

connectState = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(connectState, true);
lv_label_set_text(bleValue, "Connected");
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);

bleIcon = lv_label_create(lv_scr_act(), nullptr);
Expand Down Expand Up @@ -115,17 +115,18 @@ void WatchFaceTerminal::Refresh() {
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent();
lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));

}

char* bleValue;
/*char* bleValue;*/
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
if (bleState.Get() == true) {
lv_label_set_text(bleIcon, BleIcon::GetIcon(true));
bleValue = "Connected";
lv_label_set_text(bleValue, "Connected#");
} else {
lv_label_set_text(bleIcon, BleIcon::GetIcon(false));
bleValue = "Disconnected";
lv_label_set_text(bleValue, "Disonnected#");
}
}
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 5);
Expand All @@ -134,10 +135,11 @@ void WatchFaceTerminal::Refresh() {

notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
if (notificationState.Get() == true)
if (notificationState.Get() == true) {
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(true));
else
} else {
lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
}
}

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

char hoursChar[8];

char secondsChar[5];
sprintf(secondsChar, "%02d", static_cast<int>(second));
char ampmChar[3];
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
sprintf(hoursChar, "%02d", hour);
} else {
if (hour == 0 && hour != 12) {
hour = 12;
sprintf(ampmChar, "AM");
} else if (hour == 12 && hour != 0) {
hour = 12;
sprintf(ampmChar, "PM");
} else if (hour < 12 && hour != 0) {
sprintf(ampmChar, "AM");
} else if (hour > 12 && hour != 0) {
hour = hour - 12;
sprintf(ampmChar, "PM");
}
sprintf(hoursChar, "%02d", hour);
}

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

char battStr[24];
sprintf(battStr, "[BATT]#387b54 %d%\%#", batteryValue);
lv_label_set_text(batteryPercent, battStr);

char secondsChar[5];
sprintf(secondsChar, "%02d", static_cast<int>(second));

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

char timeStr[42];
sprintf(timeStr,
"[TIME]#11cc55 %c%c:%c%c:%c%c#",
"[TIME]#11cc55 %c%c:%c%c:%c%c %s#",
hoursChar[0],
hoursChar[1],
minutesChar[0],
minutesChar[1],
secondsChar[0],
secondsChar[1]);
secondsChar[1],
ampmChar);

lv_label_set_text(label_time, timeStr);
}
Expand Down
1 change: 1 addition & 0 deletions src/displayapp/screens/WatchFaceTerminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace Pinetime {
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;
lv_obj_t* connectState;
lv_obj_t* bleValue;

Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Expand Down

0 comments on commit eb8bd4d

Please sign in to comment.