2020-02-26 14:49:26 -05:00
|
|
|
#include "Meter.h"
|
2020-11-15 10:49:36 -05:00
|
|
|
#include <lvgl/lvgl.h>
|
2020-02-26 14:49:26 -05:00
|
|
|
#include "../DisplayApp.h"
|
|
|
|
|
|
|
|
using namespace Pinetime::Applications::Screens;
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
|
2020-02-26 14:49:26 -05:00
|
|
|
|
|
|
|
/*Create a line meter */
|
2021-01-28 12:13:28 -05:00
|
|
|
lmeter = lv_linemeter_create(lv_scr_act(), nullptr);
|
2021-04-18 13:28:14 -04:00
|
|
|
lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/
|
|
|
|
lv_linemeter_set_value(lmeter, value); /*Set the current value*/
|
2021-01-28 12:13:28 -05:00
|
|
|
lv_linemeter_set_angle_offset(lmeter, 180);
|
2021-04-18 13:28:14 -04:00
|
|
|
lv_linemeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/
|
2021-01-28 12:13:28 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
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));
|
2021-01-28 12:13:28 -05:00
|
|
|
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);
|
2020-10-04 07:53:11 -04:00
|
|
|
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
|
2021-07-19 09:26:12 -04:00
|
|
|
|
|
|
|
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
|
2020-02-26 14:49:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Meter::~Meter() {
|
2021-07-19 09:26:12 -04:00
|
|
|
lv_task_del(taskRefresh);
|
2020-02-26 14:49:26 -05:00
|
|
|
lv_obj_clean(lv_scr_act());
|
|
|
|
}
|
|
|
|
|
2021-07-19 09:26:12 -04:00
|
|
|
void Meter::Refresh() {
|
2021-04-18 13:28:14 -04:00
|
|
|
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
|
|
|
|
if (value >= 60)
|
|
|
|
value = 0;
|
2020-02-26 14:49:26 -05:00
|
|
|
}
|