Skip to content

Commit

Permalink
Add inline init/next functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mzyy94 committed Jan 28, 2024
1 parent eae2486 commit e8dbedc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
11 changes: 2 additions & 9 deletions examples/dial_number/src/dial_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,12 @@ void dial_arc(void)

void main_task(void *)
{
M5.begin();
lv_init();
lv_port_disp_init();
lv_port_indev_init();

m5dial_lvgl_init();
dial_arc();

for (;;)
{
M5.update();
uint32_t wait_ms = lv_timer_handler();
M5.delay(wait_ms);
lv_tick_inc(wait_ms);
m5dial_lvgl_next();
}
vTaskDelete(nullptr);
}
Expand Down
10 changes: 2 additions & 8 deletions examples/hello_world/src/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ void hello_world(void)

void main_task(void *)
{
M5.begin();
lv_init();
lv_port_disp_init();

m5dial_lvgl_init();
hello_world();

for (;;)
{
M5.update();
uint32_t wait_ms = lv_timer_handler();
M5.delay(wait_ms);
lv_tick_inc(wait_ms);
m5dial_lvgl_next();
}
vTaskDelete(nullptr);
}
Expand Down
11 changes: 2 additions & 9 deletions examples/touch_button/src/touch_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,12 @@ void touch_button(void)

void main_task(void *)
{
M5.begin();
lv_init();
lv_port_disp_init();
lv_port_indev_init();

m5dial_lvgl_init();
touch_button();

for (;;)
{
M5.update();
uint32_t wait_ms = lv_timer_handler();
M5.delay(wait_ms);
lv_tick_inc(wait_ms);
m5dial_lvgl_next();
}
vTaskDelete(nullptr);
}
Expand Down
17 changes: 17 additions & 0 deletions src/M5Dial-LVGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,25 @@
#define LV_LVGL_H_INCLUDE_SIMPLE
#endif

#include <M5Unified.hpp>
#include "lvgl.h"
#include "lv_port_disp.h"
#include "lv_port_indev.h"

inline void m5dial_lvgl_init()
{
M5.begin();
lv_init();
lv_port_disp_init();
lv_port_indev_init();
}

inline void m5dial_lvgl_next()
{
M5.update();
uint32_t wait_ms = lv_timer_handler();
M5.delay(wait_ms);
lv_tick_inc(wait_ms);
}

#endif

0 comments on commit e8dbedc

Please sign in to comment.