Terminal: tweak text, colour, lower case; refactor source
This commit is contained in:
parent
118d23cd4c
commit
b572e2ec91
1 changed files with 45 additions and 37 deletions
|
@ -12,6 +12,30 @@
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
// for the LV "recolor" feature within labels
|
||||||
|
#define R_LTGREY(str) "#aaaaaa " str "#"
|
||||||
|
#define R_LTPINK(str) "#ffaaaa " str "#"
|
||||||
|
|
||||||
|
// convert a row number (rows of text) to a y-coordinate
|
||||||
|
lv_coord_t y_ofs(int8_t row) {
|
||||||
|
return row * 22 + 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make a label representing a terminal output text
|
||||||
|
lv_obj_t* mkoutput(int8_t row) {
|
||||||
|
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_obj_align(label, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, y_ofs(row));
|
||||||
|
lv_label_set_recolor(label, true);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make a label representing a terminal prompt with command 'cmd'
|
||||||
|
lv_obj_t* mkprompt(int8_t row, const char *cmd) {
|
||||||
|
lv_obj_t* label = mkoutput(row);
|
||||||
|
lv_label_set_text_fmt(label, R_LTPINK("%s") R_LTGREY("@") R_LTPINK("watch") R_LTGREY(":~") " $ %s", Pinetime::Applications::OwnerTextShort, cmd);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
||||||
const Controllers::Battery& batteryController,
|
const Controllers::Battery& batteryController,
|
||||||
const Controllers::Ble& bleController,
|
const Controllers::Ble& bleController,
|
||||||
|
@ -27,40 +51,24 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
heartRateController {heartRateController},
|
heartRateController {heartRateController},
|
||||||
motionController {motionController} {
|
motionController {motionController} {
|
||||||
batteryValue = lv_label_create(lv_scr_act(), nullptr);
|
|
||||||
lv_label_set_recolor(batteryValue, true);
|
|
||||||
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
|
|
||||||
|
|
||||||
connectState = lv_label_create(lv_scr_act(), nullptr);
|
notificationIcon = mkoutput(-5);
|
||||||
lv_label_set_recolor(connectState, true);
|
|
||||||
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
|
|
||||||
|
|
||||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
label_prompt_1 = mkprompt(-4, "now");
|
||||||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
|
|
||||||
|
|
||||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
label_time = mkoutput(-3);
|
||||||
lv_label_set_recolor(label_date, true);
|
|
||||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
|
|
||||||
|
|
||||||
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
|
label_date = mkoutput(-2);
|
||||||
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
|
|
||||||
lv_label_set_text_fmt(label_prompt_1, "%s@watch:~ $ now", Pinetime::Applications::OwnerTextShort);
|
|
||||||
|
|
||||||
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
|
batteryValue = mkoutput(-1);
|
||||||
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
|
|
||||||
lv_label_set_text_fmt(label_prompt_2, "%s@watch:~ $", Pinetime::Applications::OwnerTextShort);
|
|
||||||
|
|
||||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
stepValue = mkoutput(0);
|
||||||
lv_label_set_recolor(label_time, true);
|
|
||||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
|
|
||||||
|
|
||||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
heartbeatValue = mkoutput(1);
|
||||||
lv_label_set_recolor(heartbeatValue, true);
|
|
||||||
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
|
|
||||||
|
|
||||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
connectState = mkoutput(2);
|
||||||
lv_label_set_recolor(stepValue, true);
|
|
||||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
|
label_prompt_2 = mkprompt(3, "_");
|
||||||
|
|
||||||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
||||||
Refresh();
|
Refresh();
|
||||||
|
@ -75,7 +83,7 @@ void WatchFaceTerminal::Refresh() {
|
||||||
powerPresent = batteryController.IsPowerPresent();
|
powerPresent = batteryController.IsPowerPresent();
|
||||||
batteryPercentRemaining = batteryController.PercentRemaining();
|
batteryPercentRemaining = batteryController.PercentRemaining();
|
||||||
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
|
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
|
||||||
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
|
lv_label_set_text_fmt(batteryValue, R_LTGREY("batt=")"#387b54 %d%%", batteryPercentRemaining.Get());
|
||||||
if (batteryController.IsPowerPresent()) {
|
if (batteryController.IsPowerPresent()) {
|
||||||
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
|
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
|
||||||
}
|
}
|
||||||
|
@ -85,12 +93,12 @@ void WatchFaceTerminal::Refresh() {
|
||||||
bleRadioEnabled = bleController.IsRadioEnabled();
|
bleRadioEnabled = bleController.IsRadioEnabled();
|
||||||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
||||||
if (!bleRadioEnabled.Get()) {
|
if (!bleRadioEnabled.Get()) {
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
|
lv_label_set_text_static(connectState, R_LTGREY("stat=")"#0082fc Disabled#");
|
||||||
} else {
|
} else {
|
||||||
if (bleState.Get()) {
|
if (bleState.Get()) {
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
|
lv_label_set_text_static(connectState, R_LTGREY("stat=")"#0082fc Connected#");
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
|
lv_label_set_text_static(connectState, R_LTGREY("stat=")"#0082fc Disconnected#");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +106,7 @@ void WatchFaceTerminal::Refresh() {
|
||||||
notificationState = notificationManager.AreNewNotificationsAvailable();
|
notificationState = notificationManager.AreNewNotificationsAvailable();
|
||||||
if (notificationState.IsUpdated()) {
|
if (notificationState.IsUpdated()) {
|
||||||
if (notificationState.Get()) {
|
if (notificationState.Get()) {
|
||||||
lv_label_set_text_static(notificationIcon, "You have mail.");
|
lv_label_set_text_static(notificationIcon, "You have messages.");
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(notificationIcon, "");
|
lv_label_set_text_static(notificationIcon, "");
|
||||||
}
|
}
|
||||||
|
@ -120,9 +128,9 @@ void WatchFaceTerminal::Refresh() {
|
||||||
hour = hour - 12;
|
hour = hour - 12;
|
||||||
ampmChar[0] = 'p';
|
ampmChar[0] = 'p';
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
|
lv_label_set_text_fmt(label_time, R_LTGREY("time=")"#11cc55 %1d:%02d:%02d %s#", hour, minute, second, ampmChar);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
|
lv_label_set_text_fmt(label_time, R_LTGREY("time=")"#11cc55 %02d:%02d:%02d", hour, minute, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
|
||||||
|
@ -130,7 +138,7 @@ void WatchFaceTerminal::Refresh() {
|
||||||
uint16_t year = dateTimeController.Year();
|
uint16_t year = dateTimeController.Year();
|
||||||
Controllers::DateTime::Months month = dateTimeController.Month();
|
Controllers::DateTime::Months month = dateTimeController.Month();
|
||||||
uint8_t day = dateTimeController.Day();
|
uint8_t day = dateTimeController.Day();
|
||||||
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
|
lv_label_set_text_fmt(label_date, R_LTGREY("date=")"#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,14 +146,14 @@ void WatchFaceTerminal::Refresh() {
|
||||||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||||
if (heartbeatRunning.Get()) {
|
if (heartbeatRunning.Get()) {
|
||||||
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
|
lv_label_set_text_fmt(heartbeatValue, R_LTGREY("puls=")"#ee3311 %d bpm#", heartbeat.Get());
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
|
lv_label_set_text_static(heartbeatValue, R_LTGREY("puls=")"#ee3311 ---#");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stepCount = motionController.NbSteps();
|
stepCount = motionController.NbSteps();
|
||||||
if (stepCount.IsUpdated()) {
|
if (stepCount.IsUpdated()) {
|
||||||
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
|
lv_label_set_text_fmt(stepValue, R_LTGREY("step=")"#ee3377 %lu steps#", stepCount.Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue