ref: 0.12.0
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 37 38 39 40 41 42 43 44 45 46 47 |
#include "Meter.h" #include <lvgl/lvgl.h> #include "../DisplayApp.h" using namespace Pinetime::Applications::Screens; extern lv_font_t jetbrains_mono_extrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; Meter::Meter(Pinetime::Applications::DisplayApp *app) : Screen(app) { lv_style_copy(&style_lmeter, &lv_style_pretty_color); style_lmeter.line.width = 2; style_lmeter.line.color = LV_COLOR_SILVER; style_lmeter.body.main_color = lv_color_make(255,0,0); style_lmeter.body.grad_color = lv_color_make(160,0,0); style_lmeter.body.padding.left = 16; /*Line length*/ /*Create a line meter */ lmeter = lv_lmeter_create(lv_scr_act(), nullptr); lv_lmeter_set_range(lmeter, 0, 60); /*Set the range*/ lv_lmeter_set_value(lmeter, value); /*Set the current value*/ lv_lmeter_set_angle_offset(lmeter, 180); lv_lmeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/ lv_lmeter_set_style(lmeter, LV_LMETER_STYLE_MAIN, &style_lmeter); /*Apply the new style*/ lv_obj_set_size(lmeter, 150, 150); lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); } Meter::~Meter() { lv_obj_clean(lv_scr_act()); } bool Meter::Refresh() { lv_lmeter_set_value(lmeter, value++); /*Set the current value*/ if(value>=60) value = 0; return running; } bool Meter::OnButtonPushed() { running = false; return true; } |