ref: 0ce98c7ac7ba66acaf504be9bb042796e12f2733
src/displayapp/screens/Meter.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include "Meter.h" #include <lvgl/lvgl.h> #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) { /*Create a line meter */ lmeter = lv_linemeter_create(lv_scr_act(), nullptr); lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/ lv_linemeter_set_value(lmeter, value); /*Set the current value*/ lv_linemeter_set_angle_offset(lmeter, 180); lv_linemeter_set_scale(lmeter, 360, 60); /*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_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); lv_obj_set_size(lmeter, 200, 200); lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); } Meter::~Meter() { lv_obj_clean(lv_scr_act()); } bool Meter::Refresh() { lv_linemeter_set_value(lmeter, value++); /*Set the current value*/ if (value >= 60) value = 0; return running; } |