From b66935af52e8a74a2145990c21db845a03dfde86 Mon Sep 17 00:00:00 2001 From: Michele Bini Date: Wed, 30 Mar 2022 01:18:19 +0200 Subject: Brief digression into alalog24 display using lv_linemeter diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 68c6acb..1436a79 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -33,6 +33,29 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, settingsController {settingsController}, motionController {motionController} { + /*Create a line meter */ + lmeter = lv_linemeter_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_pad_top(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_local_pad_bottom(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_local_pad_left(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_local_pad_right(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_width_margin(lmeter, 0); + lv_obj_set_height_margin(lmeter, 0); + lv_obj_set_size(lmeter, 240, 240); + lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/ + lv_linemeter_set_value(lmeter, 30); /*Set the current value*/ + lv_linemeter_set_angle_offset(lmeter, 180); + lv_linemeter_set_scale(lmeter, 360, 97); /*Set the angle and number of lines*/ + + lv_obj_set_style_local_scale_end_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(255, 0, 0)); + lv_obj_set_style_local_scale_grad_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(160, 0, 0)); + lv_obj_set_style_local_scale_end_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); + lv_obj_set_style_local_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); + lv_obj_set_style_local_line_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_SILVER); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_fmt(batteryIcon, "B##%%"); lv_obj_set_style_local_text_font(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &neofont1); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 8382996..aef486c 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -56,6 +56,9 @@ namespace Pinetime { DirtyValue stepCount {}; DirtyValue notificationState {}; + lv_style_t style_lmeter; + lv_obj_t* lmeter; + lv_obj_t* label_temp; lv_obj_t* label_time; lv_obj_t* label_time_sec; diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index dfec64a..cbaf64b 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -673,7 +673,7 @@ typedef void* lv_obj_user_data_t; * 1: Some extra precision * 2: Best precision */ -#define LV_LINEMETER_PRECISE 0 +#define LV_LINEMETER_PRECISE 2 #endif /*Mask (dependencies: -)*/ -- cgit v0.10.2