|
|
|
|
@@ -27,41 +27,180 @@ 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);
|
|
|
|
|
/*Create an array for the points of the line*/
|
|
|
|
|
// progress_points[0] = {0, 0};
|
|
|
|
|
// progress_points[1] = {0, 0};
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_now_line;
|
|
|
|
|
lv_style_init(&style_now_line);
|
|
|
|
|
lv_style_set_line_width(&style_now_line, LV_STATE_DEFAULT, 1);
|
|
|
|
|
lv_style_set_line_color(&style_now_line, LV_STATE_DEFAULT, LV_COLOR_RED);
|
|
|
|
|
// lv_style_set_line_rounded(&style_now_line, LV_STATE_DEFAULT, true);
|
|
|
|
|
|
|
|
|
|
/*Create a line and apply the new style*/
|
|
|
|
|
now_line = lv_line_create(lv_scr_act(), NULL);
|
|
|
|
|
static lv_point_t line_points[] = { {40, 2}, {40, 50}};
|
|
|
|
|
lv_line_set_points(now_line, line_points, 2);
|
|
|
|
|
lv_obj_add_style(now_line, LV_LINE_PART_MAIN, &style_now_line);
|
|
|
|
|
lv_obj_align(now_line, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_event;
|
|
|
|
|
lv_style_init(&style_event);
|
|
|
|
|
lv_style_set_radius(&style_event, LV_STATE_DEFAULT, 5);
|
|
|
|
|
lv_style_set_bg_opa(&style_event, LV_STATE_DEFAULT, LV_OPA_COVER);
|
|
|
|
|
lv_style_set_bg_color(&style_event, LV_STATE_DEFAULT, LV_COLOR_MAGENTA);
|
|
|
|
|
lv_style_set_pad_top(&style_event, LV_STATE_DEFAULT, 2);
|
|
|
|
|
lv_style_set_pad_bottom(&style_event, LV_STATE_DEFAULT, 2);
|
|
|
|
|
lv_style_set_pad_left(&style_event, LV_STATE_DEFAULT, 5);
|
|
|
|
|
lv_style_set_pad_right(&style_event, LV_STATE_DEFAULT, 5);
|
|
|
|
|
lv_style_set_text_font(&style_event, LV_STATE_DEFAULT, &jetbrains_mono_14);
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_flex;
|
|
|
|
|
lv_style_init(&style_flex);
|
|
|
|
|
lv_style_copy(&style_flex, &style_event);
|
|
|
|
|
lv_style_set_bg_color(&style_flex, LV_STATE_DEFAULT, LV_COLOR_PURPLE);
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_season;
|
|
|
|
|
lv_style_init(&style_season);
|
|
|
|
|
lv_style_copy(&style_season, &style_event);
|
|
|
|
|
lv_style_set_bg_color(&style_season, LV_STATE_DEFAULT, LV_COLOR_GREEN);
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_actualization;
|
|
|
|
|
lv_style_init(&style_actualization);
|
|
|
|
|
lv_style_copy(&style_actualization, &style_event);
|
|
|
|
|
lv_style_set_bg_color(&style_actualization, LV_STATE_DEFAULT, LV_COLOR_TEAL);
|
|
|
|
|
|
|
|
|
|
static lv_style_t style_community;
|
|
|
|
|
lv_style_init(&style_community);
|
|
|
|
|
lv_style_copy(&style_community, &style_event);
|
|
|
|
|
lv_style_set_bg_color(&style_community, LV_STATE_DEFAULT, LV_COLOR_OLIVE);
|
|
|
|
|
|
|
|
|
|
/* Fixed events */
|
|
|
|
|
// lv_obj_t* lbl_event;
|
|
|
|
|
// lbl_event = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
// lv_label_set_recolor(lbl_event, true);
|
|
|
|
|
// lv_obj_add_style(lbl_event, LV_LABEL_PART_MAIN, &style_event);
|
|
|
|
|
// lv_obj_align(lbl_event, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 10);
|
|
|
|
|
// lv_label_set_long_mode(lbl_event, LV_LABEL_LONG_BREAK);
|
|
|
|
|
// lv_obj_set_width(lbl_event, LV_HOR_RES/3);
|
|
|
|
|
// lv_label_set_text_fmt(lbl_event, "Foo Bar");
|
|
|
|
|
|
|
|
|
|
lv_obj_t* lbl_prior_event;
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<sizeof(fixedtime)/sizeof(CalendarEntry);i++){
|
|
|
|
|
lv_obj_t* lbl_event2;
|
|
|
|
|
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_event);
|
|
|
|
|
|
|
|
|
|
if (i==0) {
|
|
|
|
|
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 10);
|
|
|
|
|
} else {
|
|
|
|
|
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(lbl_event2, LV_HOR_RES/3);
|
|
|
|
|
lv_label_set_text_fmt(lbl_event2, fixedtime[i].name);
|
|
|
|
|
fixedtime_labels[i] = lbl_event2;
|
|
|
|
|
lbl_prior_event = lbl_event2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<sizeof(flextime)/sizeof(TaskEntry);i++){
|
|
|
|
|
lv_obj_t* lbl_event2;
|
|
|
|
|
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_flex);
|
|
|
|
|
|
|
|
|
|
if (i==0) {
|
|
|
|
|
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 60);
|
|
|
|
|
} else {
|
|
|
|
|
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(lbl_event2, LV_HOR_RES/3);
|
|
|
|
|
lv_label_set_text_fmt(lbl_event2, flextime[i].name);
|
|
|
|
|
lbl_prior_event = lbl_event2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<sizeof(season)/sizeof(TaskEntry);i++){
|
|
|
|
|
lv_obj_t* lbl_event2;
|
|
|
|
|
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_season);
|
|
|
|
|
|
|
|
|
|
if (i==0) {
|
|
|
|
|
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 125);
|
|
|
|
|
} else {
|
|
|
|
|
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(lbl_event2, LV_HOR_RES-10);
|
|
|
|
|
lv_label_set_text_fmt(lbl_event2, season[i].name);
|
|
|
|
|
lv_label_set_align(lbl_event2, LV_LABEL_ALIGN_CENTER);
|
|
|
|
|
lbl_prior_event = lbl_event2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<sizeof(actualization)/sizeof(TaskEntry);i++){
|
|
|
|
|
lv_obj_t* lbl_event2;
|
|
|
|
|
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_actualization);
|
|
|
|
|
|
|
|
|
|
if (i==0) {
|
|
|
|
|
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 155);
|
|
|
|
|
} else {
|
|
|
|
|
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(lbl_event2, LV_HOR_RES/2-5);
|
|
|
|
|
lv_label_set_text_fmt(lbl_event2, actualization[i].name);
|
|
|
|
|
lbl_prior_event = lbl_event2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<sizeof(community)/sizeof(TaskEntry);i++){
|
|
|
|
|
lv_obj_t* lbl_event2;
|
|
|
|
|
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_community);
|
|
|
|
|
|
|
|
|
|
if (i==0) {
|
|
|
|
|
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 205);
|
|
|
|
|
} else {
|
|
|
|
|
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
|
|
|
|
|
// lv_obj_set_width(lbl_event2, LV_HOR_RES*0.55);
|
|
|
|
|
lv_label_set_text_fmt(lbl_event2, community[i].name);
|
|
|
|
|
lbl_prior_event = lbl_event2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lv_obj_t* lbl_event2;
|
|
|
|
|
// lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
// lv_label_set_recolor(lbl_event2, true);
|
|
|
|
|
// lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_event);
|
|
|
|
|
// lv_obj_align(lbl_event2, lbl_event, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
|
|
|
|
// // lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_SROLL);
|
|
|
|
|
// lv_label_set_text_fmt(lbl_event2, "Baz Bing Boom");
|
|
|
|
|
// lv_obj_set_width(lbl_event2, LV_HOR_RES-5);
|
|
|
|
|
// lv_obj_set_height(label_now, 40);
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
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_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);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
@@ -71,29 +210,41 @@ WatchFaceTerminal::~WatchFaceTerminal() {
|
|
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t timeOffset = 0;
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if (currentDuration == 0) {
|
|
|
|
|
// lv_label_set_text_fmt(label_now, "#007fff Now:# %s",calendar[calIndex].name);
|
|
|
|
|
// if (calIndex+1 < sizeof(calendar)/sizeof(CalendarEntry)) {
|
|
|
|
|
// lv_label_set_text_fmt(label_next, "#ee3377 Next:# %s", calendar[calIndex+1].name);
|
|
|
|
|
// } else {
|
|
|
|
|
// lv_label_set_text_fmt(label_next, "");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
bleState = bleController.IsConnected();
|
|
|
|
|
bleRadioEnabled = bleController.IsRadioEnabled();
|
|
|
|
|
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
|
|
|
|
|
if (!bleRadioEnabled.Get()) {
|
|
|
|
|
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
|
|
|
|
|
// progress_points[1] = {0,(lv_coord_t)((double)LV_VER_RES*currentDuration/calendar[calIndex].duration)};
|
|
|
|
|
// lv_line_set_points(progress_line, progress_points, 2); /*Set the points*/
|
|
|
|
|
// lv_label_set_text_fmt(batteryValue, "cI %d sO %d",calIndex, sizeof(calendar)/sizeof(CalendarEntry));
|
|
|
|
|
int last_width=0;
|
|
|
|
|
for(int i=0;i<sizeof(fixedtime_labels)/sizeof(CalendarEntry);i++){
|
|
|
|
|
lv_obj_set_width(fixedtime_labels[i], pow(log(fixedtime[i].duration),2)*10);
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
lv_obj_align(fixedtime_labels[i], fixedtime_labels[i-1], LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
|
|
|
|
|
} else {
|
|
|
|
|
if (bleState.Get()) {
|
|
|
|
|
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
|
|
|
|
|
} else {
|
|
|
|
|
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
|
|
|
|
|
}
|
|
|
|
|
lv_obj_align(fixedtime_labels[i], lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5-timeOffset, 10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
timeOffset++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// currentDuration++;
|
|
|
|
|
// if (currentDuration>calendar[calIndex].duration) {
|
|
|
|
|
// currentDuration = 0;
|
|
|
|
|
// calIndex++;
|
|
|
|
|
// if (calIndex > sizeof(calendar)/sizeof(CalendarEntry)-1) {
|
|
|
|
|
// calIndex = 0;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notificationState = notificationManager.AreNewNotificationsAvailable();
|
|
|
|
|
if (notificationState.IsUpdated()) {
|
|
|
|
|
@@ -106,46 +257,8 @@ void WatchFaceTerminal::Refresh() {
|
|
|
|
|
|
|
|
|
|
currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(dateTimeController.CurrentDateTime());
|
|
|
|
|
if (currentDateTime.IsUpdated()) {
|
|
|
|
|
uint8_t hour = dateTimeController.Hours();
|
|
|
|
|
uint8_t minute = dateTimeController.Minutes();
|
|
|
|
|
uint8_t second = dateTimeController.Seconds();
|
|
|
|
|
|
|
|
|
|
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
|
|
|
|
char ampmChar[3] = "AM";
|
|
|
|
|
if (hour == 0) {
|
|
|
|
|
hour = 12;
|
|
|
|
|
} else if (hour == 12) {
|
|
|
|
|
ampmChar[0] = 'P';
|
|
|
|
|
} else if (hour > 12) {
|
|
|
|
|
hour = hour - 12;
|
|
|
|
|
ampmChar[0] = 'P';
|
|
|
|
|
}
|
|
|
|
|
lv_label_set_text_fmt(label_time, "[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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
} else {
|
|
|
|
|
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stepCount = motionController.NbSteps();
|
|
|
|
|
if (stepCount.IsUpdated()) {
|
|
|
|
|
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
|
|
|
|
|
// uint8_t hour = dateTimeController.Hours();
|
|
|
|
|
// uint8_t minute = dateTimeController.Minutes();
|
|
|
|
|
// uint8_t second = dateTimeController.Seconds();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|