L VD / Mbed OS DISCO-F746NG_MbedOs_LvGL_example

Dependencies:   BSP_DISCO_F746NG

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //Notebook page https://os.mbed.com/users/JohnnyK/notebook/how-start-with-the-littlevgl/
00002 #include "mbed.h"
00003 #include "lvgl/lvgl.h"
00004 #include "lv_port_disp.h"
00005 #include "lv_port_indev.h"
00006 #include "lv_examples/lv_examples.h"
00007 
00008 Ticker ticker;                                  //Ticker for lvgl                    
00009 
00010 //Callback function for lvgl timing.
00011 void lv_ticker_func(){
00012     lv_tick_inc(10); 
00013     //Call lv_tick_inc(x) every x milliseconds in a Timer or Task (x should be between 1 and 10). 
00014     //It is required for the internal timing of LittlevGL.
00015     lv_task_handler(); 
00016     //Call lv_task_handler() periodically every few milliseconds. 
00017     //It will redraw the screen if required, handle input devices etc.
00018 }
00019 
00020 int main()
00021 {
00022     printf("LittlevGL GUI-"); 
00023     lv_init();                                  //Initialize the LittlevGL
00024     lv_port_disp_init();                        //Initialize diplay 
00025     lv_port_indev_init();                       //Initialize touchpad
00026     ticker.attach(callback(&lv_ticker_func), 10ms); //Attach callback to ticker
00027 
00028     lv_demo_widgets();
00029 
00030     while(1) {
00031         //do something   
00032         thread_sleep_for(100);
00033     }
00034 }