|
|
|
@@ -29,28 +29,165 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
|
|
|
|
motionController {motionController} {
|
|
|
|
|
|
|
|
|
|
/*Create an array for the points of the line*/
|
|
|
|
|
progress_points[0] = {0, 0};
|
|
|
|
|
progress_points[1] = {0, 0};
|
|
|
|
|
// progress_points[0] = {0, 0};
|
|
|
|
|
// progress_points[1] = {0, 0};
|
|
|
|
|
|
|
|
|
|
/*Create style*/
|
|
|
|
|
static lv_style_t style_progress;
|
|
|
|
|
lv_style_init(&style_progress);
|
|
|
|
|
lv_style_set_line_width(&style_progress, LV_STATE_DEFAULT, LV_HOR_RES);
|
|
|
|
|
lv_style_set_line_color(&style_progress, LV_STATE_DEFAULT, LV_COLOR_BLUE); // todo: #11cc55
|
|
|
|
|
// lv_style_set_line_rounded(&style_progress, LV_STATE_DEFAULT, true);
|
|
|
|
|
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*/
|
|
|
|
|
progress_line = lv_line_create(lv_scr_act(), NULL);
|
|
|
|
|
lv_line_set_points(progress_line, progress_points, 2); /*Set the points*/
|
|
|
|
|
lv_obj_add_style(progress_line, LV_LINE_PART_MAIN, &style_progress); /*Set the points*/
|
|
|
|
|
lv_obj_align(progress_line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* Current calendar */
|
|
|
|
|
label_now = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(label_now, true);
|
|
|
|
|
lv_obj_align(label_now, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 10);
|
|
|
|
|
lv_label_set_long_mode(label_now, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(label_now, LV_HOR_RES-5);
|
|
|
|
|
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);
|
|
|
|
@@ -64,13 +201,6 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
|
|
|
|
|
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
|
|
|
|
|
|
|
|
|
|
label_next = lv_label_create(lv_scr_act(), nullptr);
|
|
|
|
|
lv_label_set_recolor(label_next, true);
|
|
|
|
|
lv_obj_align(label_next, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -40);
|
|
|
|
|
lv_label_set_long_mode(label_next, LV_LABEL_LONG_BREAK);
|
|
|
|
|
lv_obj_set_width(label_next, LV_HOR_RES-5);
|
|
|
|
|
// lv_obj_set_height(label_next, 40);
|
|
|
|
|
|
|
|
|
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
@@ -80,28 +210,40 @@ WatchFaceTerminal::~WatchFaceTerminal() {
|
|
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t timeOffset = 0;
|
|
|
|
|
void WatchFaceTerminal::Refresh() {
|
|
|
|
|
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, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 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, "");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
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*/
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
|
|
currentDuration++;
|
|
|
|
|
if (currentDuration>calendar[calIndex].duration) {
|
|
|
|
|
currentDuration = 0;
|
|
|
|
|
calIndex++;
|
|
|
|
|
if (calIndex > sizeof(calendar)/sizeof(CalendarEntry)-1) {
|
|
|
|
|
calIndex = 0;
|
|
|
|
|
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 {
|
|
|
|
|
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();
|
|
|
|
|