Example of using the LittlevGL with the MbedOS (bare metal) on the Disco-F746NG board and also the GPU STM32 chrom-art accelerator is used
Dependencies: BSP_DISCO_F746NG
main.cpp@3:1c9c6f2a7fcf, 2020-07-21 (annotated)
- Committer:
- elelthvd
- Date:
- Tue Jul 21 19:59:09 2020 +0800
- Revision:
- 3:1c9c6f2a7fcf
- Parent:
- 2:afc050526249
Updated to LVGLv7 and Mbed-OSv6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JohnnyK | 2:afc050526249 | 1 | //Notebook page https://os.mbed.com/users/JohnnyK/notebook/how-start-with-the-littlevgl/ |
JohnnyK | 0:10c4b83c458d | 2 | #include "mbed.h" |
JohnnyK | 0:10c4b83c458d | 3 | #include "lvgl/lvgl.h" |
JohnnyK | 0:10c4b83c458d | 4 | #include "lv_port_disp.h" |
JohnnyK | 0:10c4b83c458d | 5 | #include "lv_port_indev.h" |
elelthvd | 3:1c9c6f2a7fcf | 6 | #include "lv_examples/lv_examples.h" |
JohnnyK | 0:10c4b83c458d | 7 | |
JohnnyK | 0:10c4b83c458d | 8 | Ticker ticker; //Ticker for lvgl |
JohnnyK | 0:10c4b83c458d | 9 | |
JohnnyK | 0:10c4b83c458d | 10 | //Callback function for lvgl timing. |
JohnnyK | 0:10c4b83c458d | 11 | void lv_ticker_func(){ |
elelthvd | 3:1c9c6f2a7fcf | 12 | lv_tick_inc(10); |
JohnnyK | 0:10c4b83c458d | 13 | //Call lv_tick_inc(x) every x milliseconds in a Timer or Task (x should be between 1 and 10). |
JohnnyK | 0:10c4b83c458d | 14 | //It is required for the internal timing of LittlevGL. |
JohnnyK | 0:10c4b83c458d | 15 | lv_task_handler(); |
JohnnyK | 0:10c4b83c458d | 16 | //Call lv_task_handler() periodically every few milliseconds. |
JohnnyK | 0:10c4b83c458d | 17 | //It will redraw the screen if required, handle input devices etc. |
JohnnyK | 0:10c4b83c458d | 18 | } |
JohnnyK | 0:10c4b83c458d | 19 | |
JohnnyK | 0:10c4b83c458d | 20 | int main() |
JohnnyK | 0:10c4b83c458d | 21 | { |
JohnnyK | 0:10c4b83c458d | 22 | printf("LittlevGL GUI-"); |
JohnnyK | 0:10c4b83c458d | 23 | lv_init(); //Initialize the LittlevGL |
JohnnyK | 0:10c4b83c458d | 24 | lv_port_disp_init(); //Initialize diplay |
JohnnyK | 0:10c4b83c458d | 25 | lv_port_indev_init(); //Initialize touchpad |
elelthvd | 3:1c9c6f2a7fcf | 26 | ticker.attach(callback(&lv_ticker_func), 10ms); //Attach callback to ticker |
elelthvd | 3:1c9c6f2a7fcf | 27 | |
elelthvd | 3:1c9c6f2a7fcf | 28 | lv_demo_widgets(); |
JohnnyK | 0:10c4b83c458d | 29 | |
JohnnyK | 0:10c4b83c458d | 30 | while(1) { |
JohnnyK | 1:627f26953c53 | 31 | //do something |
elelthvd | 3:1c9c6f2a7fcf | 32 | thread_sleep_for(100); |
JohnnyK | 0:10c4b83c458d | 33 | } |
JohnnyK | 0:10c4b83c458d | 34 | } |