Skip to content

Commit e2efb19

Browse files
committed
Merge branch 'lvgl_use_system_tick' of https://github.com/Riksu9000/InfiniTime into Riksu9000-lvgl_use_system_tick
# Conflicts: # src/displayapp/screens/BatteryInfo.cpp # src/displayapp/screens/BatteryInfo.h
2 parents af10747 + 99e26bd commit e2efb19

7 files changed

Lines changed: 11 additions & 49 deletions

File tree

src/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#define configENABLE_BACKWARD_COMPATIBILITY 1
7878

7979
/* Hook function related definitions. */
80-
#define configUSE_IDLE_HOOK 1
80+
#define configUSE_IDLE_HOOK 0
8181
#define configUSE_TICK_HOOK 0
8282
#define configCHECK_FOR_STACK_OVERFLOW 0
8383
#define configUSE_MALLOC_FAILED_HOOK 0

src/displayapp/screens/BatteryInfo.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ static void lv_update_task(struct _lv_task_t* task) {
99
user_data->UpdateScreen();
1010
}
1111

12-
static void lv_anim_task(struct _lv_task_t* task) {
13-
auto user_data = static_cast<BatteryInfo*>(task->user_data);
14-
user_data->UpdateAnim();
15-
}
16-
1712
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
1813
: Screen(app), batteryController {batteryController} {
1914

@@ -24,12 +19,12 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
2419
lv_obj_set_size(charging_bar, 200, 15);
2520
lv_bar_set_range(charging_bar, 0, 100);
2621
lv_obj_align(charging_bar, nullptr, LV_ALIGN_CENTER, 0, 10);
27-
lv_bar_set_anim_time(charging_bar, 2000);
22+
lv_bar_set_anim_time(charging_bar, 1000);
2823
lv_obj_set_style_local_radius(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
2924
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, lv_color_hex(0x222222));
3025
lv_obj_set_style_local_bg_opa(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100);
3126
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
32-
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_OFF);
27+
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
3328

3429
status = lv_label_create(lv_scr_act(), nullptr);
3530
lv_label_set_text_static(status, "Reading Battery status");
@@ -54,38 +49,15 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
5449
lv_obj_set_pos(backgroundLabel, 0, 0);
5550
lv_label_set_text_static(backgroundLabel, "");
5651

57-
taskUpdate = lv_task_create(lv_update_task, 500000, LV_TASK_PRIO_LOW, this);
58-
taskAnim = lv_task_create(lv_anim_task, 1000, LV_TASK_PRIO_LOW, this);
52+
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
5953
UpdateScreen();
6054
}
6155

6256
BatteryInfo::~BatteryInfo() {
6357
lv_task_del(taskUpdate);
64-
lv_task_del(taskAnim);
6558
lv_obj_clean(lv_scr_act());
6659
}
6760

68-
void BatteryInfo::UpdateAnim() {
69-
batteryPercent = batteryController.PercentRemaining();
70-
71-
if (batteryController.IsCharging() and batteryPercent < 100) {
72-
animation += 1;
73-
if (animation >= 100) {
74-
animation = 0;
75-
}
76-
77-
} else {
78-
if (animation > batteryPercent) {
79-
animation--;
80-
}
81-
if (animation < batteryPercent) {
82-
animation++;
83-
}
84-
}
85-
86-
lv_bar_set_value(charging_bar, animation, LV_ANIM_OFF);
87-
}
88-
8961
void BatteryInfo::UpdateScreen() {
9062

9163
batteryController.Update();
@@ -111,9 +83,9 @@ void BatteryInfo::UpdateScreen() {
11183

11284
lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
11385
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
86+
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
11487
}
11588

11689
bool BatteryInfo::Refresh() {
117-
11890
return running;
11991
}

src/displayapp/screens/BatteryInfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace Pinetime {
2222
bool Refresh() override;
2323

2424
void UpdateScreen();
25-
void UpdateAnim();
2625

2726
private:
2827
Pinetime::Controllers::Battery& batteryController;
@@ -33,9 +32,7 @@ namespace Pinetime {
3332
lv_obj_t* status;
3433

3534
lv_task_t* taskUpdate;
36-
lv_task_t* taskAnim;
3735

38-
int8_t animation = 0;
3936
uint8_t batteryPercent = 0;
4037
uint16_t batteryVoltage = 0;
4138
};

src/displayapp/screens/Tile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Tile::Tile(uint8_t screenID,
107107
lv_obj_set_pos(backgroundLabel, 0, 0);
108108
lv_label_set_text_static(backgroundLabel, "");
109109

110-
taskUpdate = lv_task_create(lv_update_task, 500000, LV_TASK_PRIO_MID, this);
110+
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
111111
}
112112

113113
Tile::~Tile() {

src/displayapp/screens/settings/QuickSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
110110
lv_obj_set_pos(backgroundLabel, 0, 0);
111111
lv_label_set_text_static(backgroundLabel, "");
112112

113-
taskUpdate = lv_task_create(lv_update_task, 500000, LV_TASK_PRIO_MID, this);
113+
taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this);
114114
}
115115

116116
QuickSettings::~QuickSettings() {

src/libs/lv_conf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ typedef void* lv_img_decoder_user_data_t;
293293

294294
/* 1: use a custom tick source.
295295
* It removes the need to manually update the tick with `lv_tick_inc`) */
296-
#define LV_TICK_CUSTOM 0
296+
#define LV_TICK_CUSTOM 1
297297
#if LV_TICK_CUSTOM == 1
298-
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
299-
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
298+
#define LV_TICK_CUSTOM_INCLUDE "FreeRTOS.h" /*Header for the system time function*/
299+
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (xTaskGetTickCount()) /*Expression evaluating to current system time in ms*/
300300
#endif /*LV_TICK_CUSTOM*/
301301

302302
typedef void* lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
@@ -759,4 +759,4 @@ typedef void* lv_obj_user_data_t;
759759

760760
/*--END OF LV_CONF_H--*/
761761

762-
#endif /*LV_CONF_H*/
762+
#endif /*LV_CONF_H*/

src/main.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,6 @@ void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action
178178
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
179179
}
180180

181-
extern "C" {
182-
void vApplicationIdleHook(void) {
183-
if (!isFactory)
184-
lv_tick_inc(1);
185-
}
186-
}
187-
188181
void DebounceTimerChargeCallback(TimerHandle_t xTimer) {
189182
xTimerStop(xTimer, 0);
190183
systemTask.PushMessage(Pinetime::System::Messages::OnChargingEvent);

0 commit comments

Comments
 (0)