-
-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved the Terminal Watchfaces UI #2135
Open
JustScott
wants to merge
1
commit into
InfiniTimeOrg:main
Choose a base branch
from
JustScott:improve_terminal_watchface_ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
#include "displayapp/screens/WatchFaceTerminal.h" | ||
#include "displayapp/screens/BatteryIcon.h" | ||
#include "displayapp/screens/NotificationIcon.h" | ||
#include "displayapp/screens/Symbols.h" | ||
#include "components/battery/BatteryController.h" | ||
#include "components/ble/BleController.h" | ||
#include "components/ble/NotificationManager.h" | ||
#include "components/heartrate/HeartRateController.h" | ||
#include "components/motion/MotionController.h" | ||
#include "components/settings/Settings.h" | ||
#include "displayapp/InfiniTimeTheme.h" | ||
|
||
using namespace Pinetime::Applications::Screens; | ||
|
||
|
@@ -27,40 +27,44 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController, | |
settingsController {settingsController}, | ||
heartRateController {heartRateController}, | ||
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); | ||
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); | ||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100); | ||
|
||
label_date = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(label_date, true); | ||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40); | ||
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -90); | ||
|
||
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr); | ||
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80); | ||
lv_obj_set_style_local_text_color(label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray); | ||
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -70); | ||
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now"); | ||
|
||
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr); | ||
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60); | ||
lv_label_set_text_static(label_prompt_2, "user@watch:~ $"); | ||
|
||
label_time = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(label_time, true); | ||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60); | ||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -50); | ||
|
||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(heartbeatValue, true); | ||
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20); | ||
label_date = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(label_date, true); | ||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -30); | ||
|
||
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, -10); | ||
|
||
stepValue = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(stepValue, true); | ||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0); | ||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); | ||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 10); | ||
|
||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(heartbeatValue, true); | ||
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 30); | ||
|
||
connectState = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_recolor(connectState, true); | ||
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 50); | ||
|
||
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr); | ||
lv_obj_set_style_local_text_color(label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray); | ||
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 70); | ||
lv_label_set_text_static(label_prompt_2, "user@watch:~ $"); | ||
|
||
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); | ||
Refresh(); | ||
|
@@ -72,33 +76,10 @@ WatchFaceTerminal::~WatchFaceTerminal() { | |
} | ||
|
||
void WatchFaceTerminal::Refresh() { | ||
powerPresent = batteryController.IsPowerPresent(); | ||
batteryPercentRemaining = batteryController.PercentRemaining(); | ||
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { | ||
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get()); | ||
if (batteryController.IsPowerPresent()) { | ||
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); | ||
} | ||
} | ||
|
||
bleState = bleController.IsConnected(); | ||
bleRadioEnabled = bleController.IsRadioEnabled(); | ||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { | ||
if (!bleRadioEnabled.Get()) { | ||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#"); | ||
} else { | ||
if (bleState.Get()) { | ||
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#"); | ||
} else { | ||
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#"); | ||
} | ||
} | ||
} | ||
|
||
notificationState = notificationManager.AreNewNotificationsAvailable(); | ||
if (notificationState.IsUpdated()) { | ||
if (notificationState.Get()) { | ||
lv_label_set_text_static(notificationIcon, "You have mail."); | ||
lv_label_set_text_static(notificationIcon, "[1]+ Notify"); | ||
} else { | ||
lv_label_set_text_static(notificationIcon, ""); | ||
} | ||
|
@@ -120,32 +101,67 @@ void WatchFaceTerminal::Refresh() { | |
hour = hour - 12; | ||
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, "#fffff [TIME]# #11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); | ||
} else { | ||
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second); | ||
lv_label_set_text_fmt(label_time, "#ffffff [TIME]# #11cc55 %02d:%02d:%02d#", hour, minute, second); | ||
} | ||
|
||
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get()); | ||
if (currentDate.IsUpdated()) { | ||
uint16_t year = dateTimeController.Year(); | ||
Controllers::DateTime::Months month = dateTimeController.Month(); | ||
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, "#ffffff [DATE]# #007fff %04d-%02d-%02d#", short(year), char(month), char(day)); | ||
} | ||
} | ||
|
||
powerPresent = batteryController.IsPowerPresent(); | ||
batteryPercentRemaining = batteryController.PercentRemaining(); | ||
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { | ||
// HSV color model has red at 0° and green at 120°. | ||
// We lock satuation and brightness at 100% and traverse the cilinder | ||
// between red and green, thus avoiding the darker RGB on medium battery | ||
// charges and giving us a much nicer color range. | ||
uint8_t hue = batteryPercentRemaining.Get() * 120 / 100; | ||
lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(hue, 100, 100)); | ||
lv_label_set_text_fmt(batteryValue, "#ffffff [BATT]# %d%%", batteryPercentRemaining.Get()); | ||
if (batteryController.IsCharging()) { | ||
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); | ||
} | ||
} | ||
|
||
stepCount = motionController.NbSteps(); | ||
if (stepCount.IsUpdated()) { | ||
lv_label_set_text_fmt(stepValue, "#ffffff [STEP]# %lu steps", stepCount.Get()); | ||
} | ||
|
||
heartbeat = heartRateController.HeartRate(); | ||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; | ||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { | ||
if (heartbeatRunning.Get()) { | ||
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline |
||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::deepOrange); | ||
lv_label_set_text_fmt(heartbeatValue, "#ffffff [L_HR]# %d bpm", heartbeat.Get()); | ||
} else { | ||
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#"); | ||
lv_label_set_text_static(heartbeatValue, "#ffffff [L_HR]# ---"); | ||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray); | ||
} | ||
} | ||
|
||
stepCount = motionController.NbSteps(); | ||
if (stepCount.IsUpdated()) { | ||
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get()); | ||
bleState = bleController.IsConnected(); | ||
bleRadioEnabled = bleController.IsRadioEnabled(); | ||
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { | ||
if (!bleRadioEnabled.Get()) { | ||
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disabled"); | ||
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray); | ||
} else { | ||
if (bleState.Get()) { | ||
lv_label_set_text_static(connectState, "#ffffff [STAT]# Connected"); | ||
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::blue); | ||
} else { | ||
lv_label_set_text_static(connectState, "#ffffff [STAT]# Disconnected"); | ||
lv_obj_set_style_local_text_color(connectState, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::gray); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think colours here are nice, but this shows yellow at 50% right? I think it would make more sense to follow a curve closer to the current battery icon (yellow at 15, red at 5). Not sure what function would represent this well but coming up with something in Desmos/similar would be easy
Also if this is to be used in other places as well, it should probably be moved out so other screens can use it. I don't know if that's the goal here though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is from #1964 , so I think it definitely makes sense to move the colour calculation algorithm to somewhere where other apps can use it