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

Dependents:   LvGL_F746NG_test

lvgl_f746ng.cpp

Committer:
elelthvd
Date:
2020-09-08
Revision:
0:cffa136e7f8f
Child:
1:a23fffad1321

File content as of revision 0:cffa136e7f8f:

/**
 * @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(); 
}