InfiniTime/src/displayapp/screens/Meter.cpp

48 lines
1.4 KiB
C++
Raw Normal View History

2020-02-26 19:49:26 +00:00
#include "Meter.h"
2020-11-15 15:49:36 +00:00
#include <lvgl/lvgl.h>
2020-02-26 19:49:26 +00:00
#include "../DisplayApp.h"
using namespace Pinetime::Applications::Screens;
extern lv_font_t jetbrains_mono_extrabold_compressed;
2020-02-26 19:49:26 +00:00
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 */
2020-10-04 11:53:11 +00:00
lmeter = lv_lmeter_create(lv_scr_act(), nullptr);
2020-02-26 19:49:26 +00:00
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);
2020-10-04 11:53:11 +00:00
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
2020-02-26 19:49:26 +00:00
}
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;
}