fix memory leak + refactoring
This commit is contained in:
parent
917e46c684
commit
e7c0b2c5c2
|
@ -36,103 +36,94 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(DisplayApp* app,
|
|||
|
||||
label_battery_vallue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_battery_vallue, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_style_local_text_color(label_battery_vallue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_battery_vallue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_battery_vallue, "00%");
|
||||
|
||||
|
||||
batteryIcon.Create(lv_scr_act());
|
||||
batteryIcon.SetColor(lv_color_hex(0x98B69A));
|
||||
batteryIcon.SetColor(color_text);
|
||||
lv_obj_align(batteryIcon.GetObject(), label_battery_vallue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(batteryPlug, Symbols::plug);
|
||||
lv_obj_align(batteryPlug, batteryIcon.GetObject(), LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
bleIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
|
||||
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
|
||||
lv_obj_align(notificationIcon, bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
|
||||
label_day_of_week = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_week, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 10, 64);
|
||||
lv_obj_set_style_local_text_color(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_week, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_dots_40);
|
||||
lv_label_set_text_static(label_day_of_week, "SUN");
|
||||
|
||||
label_week_number = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_week_number, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 22);
|
||||
lv_obj_set_style_local_text_color(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_week_number, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_dots_40);
|
||||
lv_label_set_text_static(label_week_number, "WK26");
|
||||
|
||||
label_day_of_year = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_day_of_year, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 30);
|
||||
lv_obj_set_style_local_text_color(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_day_of_year, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_7segment_40);
|
||||
lv_label_set_text_static(label_day_of_year, "181-184");
|
||||
|
||||
static lv_style_t style_line;
|
||||
lv_style_init(&style_line);
|
||||
lv_style_set_line_width(&style_line, LV_STATE_DEFAULT, 2);
|
||||
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_style_set_line_color(&style_line, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_line, LV_STATE_DEFAULT, true);
|
||||
|
||||
static lv_style_t style_border;
|
||||
lv_style_init(&style_border);
|
||||
lv_style_set_line_width(&style_border, LV_STATE_DEFAULT, 6);
|
||||
lv_style_set_line_color(&style_border, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_style_set_line_color(&style_border, LV_STATE_DEFAULT, color_text);
|
||||
lv_style_set_line_rounded(&style_border, LV_STATE_DEFAULT, true);
|
||||
|
||||
line_icons = lv_line_create(lv_scr_act(), nullptr);
|
||||
static lv_point_t line_icons_points[] = {{0, 5}, {117, 5}, {122, 0}};
|
||||
lv_line_set_points(line_icons, line_icons_points, 3);
|
||||
lv_obj_add_style(line_icons, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_icons, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 18);
|
||||
|
||||
line_day_of_week_number = lv_line_create(lv_scr_act(), nullptr);
|
||||
static lv_point_t line_day_of_week_number_points[] = {{0, 0}, {100, 0}, {95, 95}, {0, 95}};
|
||||
lv_line_set_points(line_day_of_week_number, line_day_of_week_number_points, 4);
|
||||
lv_obj_add_style(line_day_of_week_number, LV_LINE_PART_MAIN, &style_border);
|
||||
lv_obj_align(line_day_of_week_number, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 8);
|
||||
|
||||
line_day_of_year = lv_line_create(lv_scr_act(), nullptr);
|
||||
static lv_point_t line_day_of_year_points[] = {{0, 5}, {130, 5}, {135, 0}};
|
||||
lv_line_set_points(line_day_of_year, line_day_of_year_points, 3);
|
||||
lv_obj_add_style(line_day_of_year, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_day_of_year, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 60);
|
||||
|
||||
label_date = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 100, 70);
|
||||
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_7segment_40);
|
||||
lv_label_set_text_static(label_date, "6-30");
|
||||
|
||||
line_date = lv_line_create(lv_scr_act(), nullptr);
|
||||
static lv_point_t line_date_points[] = {{0, 5}, {135, 5}, {140, 0}};
|
||||
lv_line_set_points(line_date, line_date_points, 3);
|
||||
lv_obj_add_style(line_date, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_date, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 100);
|
||||
|
||||
label_time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_7segment_115);
|
||||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
|
||||
|
||||
line_time = lv_line_create(lv_scr_act(), nullptr);
|
||||
static lv_point_t line_time_points[] = {{0, 0}, {230, 0}, {235, 5}};
|
||||
lv_line_set_points(line_time, line_time_points, 3);
|
||||
lv_obj_add_style(line_time, LV_LINE_PART_MAIN, &style_line);
|
||||
lv_obj_align(line_time, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -25);
|
||||
|
||||
label_time_ampm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(label_time_ampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(label_time_ampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(label_time_ampm, "");
|
||||
lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 5, -5);
|
||||
|
||||
|
@ -145,21 +136,21 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(DisplayApp* app,
|
|||
|
||||
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2);
|
||||
|
||||
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(heartbeatValue, "");
|
||||
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||
|
||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(stepValue, "0");
|
||||
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2);
|
||||
|
||||
stepIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_static(stepIcon, Symbols::shoe);
|
||||
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
|
||||
|
@ -169,6 +160,10 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(DisplayApp* app,
|
|||
|
||||
WatchFaceCasioStyleG7710::~WatchFaceCasioStyleG7710() {
|
||||
lv_task_del(taskRefresh);
|
||||
|
||||
lv_style_reset(&style_line);
|
||||
lv_style_reset(&style_border);
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
|
@ -291,7 +286,7 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
|||
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
|
||||
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
|
||||
if (heartbeatRunning.Get()) {
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x98B69A));
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, color_text);
|
||||
lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get());
|
||||
} else {
|
||||
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B));
|
||||
|
|
|
@ -56,6 +56,17 @@ namespace Pinetime {
|
|||
DirtyValue<bool> heartbeatRunning {};
|
||||
DirtyValue<bool> notificationState {};
|
||||
|
||||
lv_point_t line_icons_points[3] {{0, 5}, {117, 5}, {122, 0}};
|
||||
lv_point_t line_day_of_week_number_points[4] {{0, 0}, {100, 0}, {95, 95}, {0, 95}};
|
||||
lv_point_t line_day_of_year_points[3] {{0, 5}, {130, 5}, {135, 0}};
|
||||
lv_point_t line_date_points[3] {{0, 5}, {135, 5}, {140, 0}};
|
||||
lv_point_t line_time_points[3] {{0, 0}, {230, 0}, {235, 5}};
|
||||
|
||||
lv_color_t color_text = lv_color_hex(0x98B69A);
|
||||
|
||||
lv_style_t style_line;
|
||||
lv_style_t style_border;
|
||||
|
||||
lv_obj_t* label_time;
|
||||
lv_obj_t* line_time;
|
||||
lv_obj_t* label_time_ampm;
|
||||
|
|
Loading…
Reference in New Issue
Block a user