Boilerplate library to get started with LvGL on STM DISCO F746NG board. Adapted from https://os.mbed.com/users/JohnnyK/code/DISCO-F746NG_MbedOs_LvGL_example/
Dependencies: BSP_DISCO_F746NG
Diff: lvgl_f746ng.cpp
- Revision:
- 0:cffa136e7f8f
- Child:
- 1:a23fffad1321
diff -r 000000000000 -r cffa136e7f8f lvgl_f746ng.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lvgl_f746ng.cpp Tue Sep 08 05:23:58 2020 +0000 @@ -0,0 +1,64 @@ +/** + * @file lvgl_f746ng.cpp + * + */ + +/********************* + * INCLUDES + *********************/ +#include "mbed.h" +#include "lvgl_f746ng.h" +#include <cstdio> +#include "../lvgl/lvgl.h" +#include "lv_port_disp.h" +#include "lv_port_indev.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +void lv_ticker_func(void); + +/********************** + * STATIC VARIABLES + **********************/ +Ticker lvgl_ticker; // mbed Ticker for lvgl + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/* Initialize lvgl + target port specifics + mbed ticker. */ +void lvgl_f746ng_init() +{ + debug("lvgl_f746ng_init\r\n"); + lv_init(); //Initialize the LittlevGL + lv_port_disp_init(); //Initialize diplay + lv_port_indev_init(); //Initialize touchpad + lvgl_ticker.attach(callback(&lv_ticker_func), 10ms); //Attach callback to ticker +} + +/********************** + * STATIC FUNCTIONS + **********************/ +/* Callback function for lvgl timing. */ +void lv_ticker_func() +{ + //Call lv_tick_inc(x) every x milliseconds in a Timer or Task (x should be between 1 and 10). + //It is required for the internal timing of LittlevGL. + lv_tick_inc(10); + //Call lv_task_handler() periodically every few milliseconds. + //It will redraw the screen if required, handle input devices etc. + lv_task_handler(); +}