diff options
Diffstat (limited to 'src/libs/lvgl/porting')
-rw-r--r-- | src/libs/lvgl/porting/lv_port_disp_template.c | 196 | ||||
-rw-r--r-- | src/libs/lvgl/porting/lv_port_disp_template.h | 44 | ||||
-rw-r--r-- | src/libs/lvgl/porting/lv_port_fs_template.c | 379 | ||||
-rw-r--r-- | src/libs/lvgl/porting/lv_port_fs_template.h | 44 | ||||
-rw-r--r-- | src/libs/lvgl/porting/lv_port_indev_template.c | 428 | ||||
-rw-r--r-- | src/libs/lvgl/porting/lv_port_indev_template.h | 45 |
6 files changed, 0 insertions, 1136 deletions
diff --git a/src/libs/lvgl/porting/lv_port_disp_template.c b/src/libs/lvgl/porting/lv_port_disp_template.c deleted file mode 100644 index 9752d5d9..00000000 --- a/src/libs/lvgl/porting/lv_port_disp_template.c +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @file lv_port_disp_templ.c - * - */ - - /*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/ -#if 0 - -/********************* - * INCLUDES - *********************/ -#include "lv_port_disp_template.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ -static void disp_init(void); - -static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); -#if LV_USE_GPU -static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); -static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, - const lv_area_t * fill_area, lv_color_t color); -#endif - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_port_disp_init(void) -{ - /*------------------------- - * Initialize your display - * -----------------------*/ - disp_init(); - - /*----------------------------- - * Create a buffer for drawing - *----------------------------*/ - - /* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row - * - * There are three buffering configurations: - * 1. Create ONE buffer with some rows: - * LittlevGL will draw the display's content here and writes it to your display - * - * 2. Create TWO buffer with some rows: - * LittlevGL will draw the display's content to a buffer and writes it your display. - * You should use DMA to write the buffer's content to the display. - * It will enable LittlevGL to draw the next part of the screen to the other buffer while - * the data is being sent form the first buffer. It makes rendering and flushing parallel. - * - * 3. Create TWO screen-sized buffer: - * Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the - * whole frame to display. This way you only need to change the frame buffer's address instead of - * copying the pixels. - * */ - - /* Example for 1) */ - static lv_disp_buf_t disp_buf_1; - static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ - - /* Example for 2) */ - static lv_disp_buf_t disp_buf_2; - static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ - static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ - - /* Example for 3) */ - static lv_disp_buf_t disp_buf_3; - static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ - static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ - lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ - - - /*----------------------------------- - * Register the display in LittlevGL - *----------------------------------*/ - - lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/ - lv_disp_drv_init(&disp_drv); /*Basic initialization*/ - - /*Set up the functions to access to your display*/ - - /*Set the resolution of the display*/ - disp_drv.hor_res = 480; - disp_drv.ver_res = 320; - - /*Used to copy the buffer's content to the display*/ - disp_drv.flush_cb = disp_flush; - - /*Set a display buffer*/ - disp_drv.buffer = &disp_buf_2; - -#if LV_USE_GPU - /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ - - /*Blend two color array using opacity*/ - disp_drv.gpu_blend_cb = gpu_blend; - - /*Fill a memory array with a color*/ - disp_drv.gpu_fill_cb = gpu_fill; -#endif - - /*Finally register the driver*/ - lv_disp_drv_register(&disp_drv); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/* Initialize your display and the required peripherals. */ -static void disp_init(void) -{ - /*You code here*/ -} - -/* Flush the content of the internal buffer the specific area on the display - * You can use DMA or any hardware acceleration to do this operation in the background but - * 'lv_disp_flush_ready()' has to be called when finished. */ -static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) -{ - /*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/ - - int32_t x; - int32_t y; - for(y = area->y1; y <= area->y2; y++) { - for(x = area->x1; x <= area->x2; x++) { - /* Put a pixel to the display. For example: */ - /* put_px(x, y, *color_p)*/ - color_p++; - } - } - - /* IMPORTANT!!! - * Inform the graphics library that you are ready with the flushing*/ - lv_disp_flush_ready(disp_drv); -} - - -/*OPTIONAL: GPU INTERFACE*/ -#if LV_USE_GPU - -/* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity - * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ -static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa) -{ - /*It's an example code which should be done by your GPU*/ - uint32_t i; - for(i = 0; i < length; i++) { - dest[i] = lv_color_mix(dest[i], src[i], opa); - } -} - -/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color - * It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ -static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, - const lv_area_t * fill_area, lv_color_t color) -{ - /*It's an example code which should be done by your GPU*/ - int32_t x, y; - dest_buf += dest_width * fill_area->y1; /*Go to the first line*/ - - for(y = fill_area->y1; y < fill_area->y2; y++) { - for(x = fill_area->x1; x < fill_area->x2; x++) { - dest_buf[x] = color; - } - dest_buf+=dest_width; /*Go to the next line*/ - } -} - -#endif /*LV_USE_GPU*/ - -#else /* Enable this file at the top */ - -/* This dummy typedef exists purely to silence -Wpedantic. */ -typedef int keep_pedantic_happy; -#endif diff --git a/src/libs/lvgl/porting/lv_port_disp_template.h b/src/libs/lvgl/porting/lv_port_disp_template.h deleted file mode 100644 index eeca802b..00000000 --- a/src/libs/lvgl/porting/lv_port_disp_template.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file lv_port_disp_templ.h - * - */ - - /*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/ -#if 0 - -#ifndef LV_PORT_DISP_TEMPL_H -#define LV_PORT_DISP_TEMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "lvgl/lvgl.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_PORT_DISP_TEMPL_H*/ - -#endif /*Disable/Enable content*/ diff --git a/src/libs/lvgl/porting/lv_port_fs_template.c b/src/libs/lvgl/porting/lv_port_fs_template.c deleted file mode 100644 index 454899d6..00000000 --- a/src/libs/lvgl/porting/lv_port_fs_template.c +++ /dev/null @@ -1,379 +0,0 @@ -/** - * @file lv_port_fs_templ.c - * - */ - - /*Copy this file as "lv_port_fs.c" and set this value to "1" to enable content*/ -#if 0 - -/********************* - * INCLUDES - *********************/ -#include "lv_port_fs_template.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/* Create a type to store the required data about your file. - * If you are using a File System library - * it already should have a File type. - * For example FatFS has `FIL`. In this case use `typedef FIL file_t`*/ -typedef struct { - /*Add the data you need to store about a file*/ - uint32_t dummy1; - uint32_t dummy2; -}file_t; - -/*Similarly to `file_t` create a type for directory reading too */ -typedef struct { - /*Add the data you need to store about directory reading*/ - uint32_t dummy1; - uint32_t dummy2; -}dir_t; - - -/********************** - * STATIC PROTOTYPES - **********************/ -static void fs_init(void); - -static lv_fs_res_t fs_open (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode); -static lv_fs_res_t fs_close (lv_fs_drv_t * drv, void * file_p); -static lv_fs_res_t fs_read (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br); -static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw); -static lv_fs_res_t fs_seek (lv_fs_drv_t * drv, void * file_p, uint32_t pos); -static lv_fs_res_t fs_size (lv_fs_drv_t * drv, void * file_p, uint32_t * size_p); -static lv_fs_res_t fs_tell (lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); -static lv_fs_res_t fs_remove (lv_fs_drv_t * drv, const char *path); -static lv_fs_res_t fs_trunc (lv_fs_drv_t * drv, void * file_p); -static lv_fs_res_t fs_rename (lv_fs_drv_t * drv, const char * oldname, const char * newname); -static lv_fs_res_t fs_free (lv_fs_drv_t * drv, uint32_t * total_p, uint32_t * free_p); -static lv_fs_res_t fs_dir_open (lv_fs_drv_t * drv, void * rddir_p, const char *path); -static lv_fs_res_t fs_dir_read (lv_fs_drv_t * drv, void * rddir_p, char *fn); -static lv_fs_res_t fs_dir_close (lv_fs_drv_t * drv, void * rddir_p); - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_port_fs_init(void) -{ - /*---------------------------------------------------- - * Initialize your storage device and File System - * -------------------------------------------------*/ - fs_init(); - - /*--------------------------------------------------- - * Register the file system interface in LittlevGL - *--------------------------------------------------*/ - - /* Add a simple drive to open images */ - lv_fs_drv_t fs_drv; - lv_fs_drv_init(&fs_drv); - - /*Set up fields...*/ - fs_drv.file_size = sizeof(file_t); - fs_drv.letter = 'P'; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; - fs_drv.free_space_cb = fs_free; - fs_drv.size_cb = fs_size; - fs_drv.remove_cb = fs_remove; - fs_drv.rename_cb = fs_rename; - fs_drv.trunc_cb = fs_trunc; - - fs_drv.rddir_size = sizeof(dir_t); - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; - - lv_fs_drv_register(&fs_drv); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -/* Initialize your Storage device and File system. */ -static void fs_init(void) -{ - /*E.g. for FatFS initalize the SD card and FatFS itself*/ - - /*You code here*/ -} - -/** - * Open a file - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable - * @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt) - * @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_open (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - if(mode == LV_FS_MODE_WR) - { - /*Open a file for write*/ - - /* Add your code here*/ - } - else if(mode == LV_FS_MODE_RD) - { - /*Open a file for read*/ - - /* Add your code here*/ - } - else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) - { - /*Open a file for read and write*/ - - /* Add your code here*/ - } - - return res; -} - - -/** - * Close an opened file - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable. (opened with lv_ufs_open) - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_close (lv_fs_drv_t * drv, void * file_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Read data from an opened file - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable. - * @param buf pointer to a memory block where to store the read data - * @param btr number of Bytes To Read - * @param br the real number of read bytes (Byte Read) - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_read (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Write into a file - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable - * @param buf pointer to a buffer with the bytes to write - * @param btr Bytes To Write - * @param br the number of real written bytes (Bytes Written). NULL if unused. - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Set the read write pointer. Also expand the file size if necessary. - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable. (opened with lv_ufs_open ) - * @param pos the new position of read write pointer - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_seek (lv_fs_drv_t * drv, void * file_p, uint32_t pos) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Give the size of a file bytes - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable - * @param size pointer to a variable to store the size - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_size (lv_fs_drv_t * drv, void * file_p, uint32_t * size_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} -/** - * Give the position of the read write pointer - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to a file_t variable. - * @param pos_p pointer to to store the result - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_tell (lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Delete a file - * @param drv pointer to a driver where this function belongs - * @param path path of the file to delete - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_remove (lv_fs_drv_t * drv, const char *path) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Truncate the file size to the current position of the read write pointer - * @param drv pointer to a driver where this function belongs - * @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open ) - * @return LV_FS_RES_OK: no error, the file is read - * any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_trunc (lv_fs_drv_t * drv, void * file_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Rename a file - * @param drv pointer to a driver where this function belongs - * @param oldname path to the file - * @param newname path with the new name - * @return LV_FS_RES_OK or any error from 'fs_res_t' - */ -static lv_fs_res_t fs_rename (lv_fs_drv_t * drv, const char * oldname, const char * newname) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Get the free and total size of a driver in kB - * @param drv pointer to a driver where this function belongs - * @param letter the driver letter - * @param total_p pointer to store the total size [kB] - * @param free_p pointer to store the free size [kB] - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_free (lv_fs_drv_t * drv, uint32_t * total_p, uint32_t * free_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Initialize a 'fs_read_dir_t' variable for directory reading - * @param drv pointer to a driver where this function belongs - * @param rddir_p pointer to a 'fs_read_dir_t' variable - * @param path path to a directory - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_dir_open (lv_fs_drv_t * drv, void * rddir_p, const char *path) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Read the next filename form a directory. - * The name of the directories will begin with '/' - * @param drv pointer to a driver where this function belongs - * @param rddir_p pointer to an initialized 'fs_read_dir_t' variable - * @param fn pointer to a buffer to store the filename - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_dir_read (lv_fs_drv_t * drv, void * rddir_p, char *fn) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -/** - * Close the directory reading - * @param drv pointer to a driver where this function belongs - * @param rddir_p pointer to an initialized 'fs_read_dir_t' variable - * @return LV_FS_RES_OK or any error from lv_fs_res_t enum - */ -static lv_fs_res_t fs_dir_close (lv_fs_drv_t * drv, void * rddir_p) -{ - lv_fs_res_t res = LV_FS_RES_NOT_IMP; - - /* Add your code here*/ - - return res; -} - -#else /* Enable this file at the top */ - -/* This dummy typedef exists purely to silence -Wpedantic. */ -typedef int keep_pedantic_happy; -#endif diff --git a/src/libs/lvgl/porting/lv_port_fs_template.h b/src/libs/lvgl/porting/lv_port_fs_template.h deleted file mode 100644 index 7db06f65..00000000 --- a/src/libs/lvgl/porting/lv_port_fs_template.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file lv_port_fs_templ.h - * - */ - - /*Copy this file as "lv_port_fs.h" and set this value to "1" to enable content*/ -#if 0 - -#ifndef LV_PORT_FS_TEMPL_H -#define LV_PORT_FS_TEMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "lvgl/lvgl.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_PORT_FS_TEMPL_H*/ - -#endif /*Disable/Enable content*/ diff --git a/src/libs/lvgl/porting/lv_port_indev_template.c b/src/libs/lvgl/porting/lv_port_indev_template.c deleted file mode 100644 index 54b8c9fd..00000000 --- a/src/libs/lvgl/porting/lv_port_indev_template.c +++ /dev/null @@ -1,428 +0,0 @@ -/** - * @file lv_port_indev_templ.c - * - */ - - /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/ -#if 0 - -/********************* - * INCLUDES - *********************/ -#include "lv_port_indev_template.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -static void touchpad_init(void); -static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static bool touchpad_is_pressed(void); -static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y); - -static void mouse_init(void); -static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static bool mouse_is_pressed(void); -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y); - -static void keypad_init(void); -static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static uint32_t keypad_get_key(void); - -static void encoder_init(void); -static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static void encoder_handler(void); - -static void button_init(void); -static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static int8_t button_get_pressed_id(void); -static bool button_is_pressed(uint8_t id); - -/********************** - * STATIC VARIABLES - **********************/ -lv_indev_t * indev_touchpad; -lv_indev_t * indev_mouse; -lv_indev_t * indev_keypad; -lv_indev_t * indev_encoder; -lv_indev_t * indev_button; - -static int32_t encoder_diff; -static lv_indev_state_t encoder_state; - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void lv_port_indev_init(void) -{ - /* Here you will find example implementation of input devices supported by LittelvGL: - * - Touchpad - * - Mouse (with cursor support) - * - Keypad (supports GUI usage only with key) - * - Encoder (supports GUI usage only with: left, right, push) - * - Button (external buttons to press points on the screen) - * - * The `..._read()` function are only examples. - * You should shape them according to your hardware - */ - - - lv_indev_drv_t indev_drv; - - /*------------------ - * Touchpad - * -----------------*/ - - /*Initialize your touchpad if you have*/ - touchpad_init(); - - /*Register a touchpad input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = touchpad_read; - indev_touchpad = lv_indev_drv_register(&indev_drv); - - /*------------------ - * Mouse - * -----------------*/ - - /*Initialize your touchpad if you have*/ - mouse_init(); - - /*Register a mouse input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = mouse_read; - indev_mouse = lv_indev_drv_register(&indev_drv); - - /*Set cursor. For simplicity set a HOME symbol now.*/ - lv_obj_t * mouse_cursor = lv_img_create(lv_disp_get_scr_act(NULL), NULL); - lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME); - lv_indev_set_cursor(indev_mouse, mouse_cursor); - - /*------------------ - * Keypad - * -----------------*/ - - /*Initialize your keypad or keyboard if you have*/ - keypad_init(); - - /*Register a keypad input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_KEYPAD; - indev_drv.read_cb = keypad_read; - indev_keypad = lv_indev_drv_register(&indev_drv); - - /* Later you should create group(s) with `lv_group_t * group = lv_group_create()`, - * add objects to the group with `lv_group_add_obj(group, obj)` - * and assign this input device to group to navigate in it: - * `lv_indev_set_group(indev_keypad, group);` */ - - /*------------------ - * Encoder - * -----------------*/ - - /*Initialize your encoder if you have*/ - encoder_init(); - - /*Register a encoder input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_KEYPAD; - indev_drv.read_cb = encoder_read; - indev_encoder = lv_indev_drv_register(&indev_drv); - - /* Later you should create group(s) with `lv_group_t * group = lv_group_create()`, - * add objects to the group with `lv_group_add_obj(group, obj)` - * and assign this input device to group to navigate in it: - * `lv_indev_set_group(indev_keypad, group);` */ - - /*------------------ - * Button - * -----------------*/ - - /*Initialize your button if you have*/ - button_init(); - - /*Register a button input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_BUTTON; - indev_drv.read_cb = button_read; - indev_button = lv_indev_drv_register(&indev_drv); - - /*Assign buttons to points on the screen*/ - static const lv_point_t btn_points[2] = { - {10, 10}, /*Button 0 -> x:10; y:10*/ - {40, 100}, /*Button 1 -> x:40; y:100*/ - }; - lv_indev_set_button_points(indev_button, btn_points); -} - -/********************** - * STATIC FUNCTIONS - **********************/ - - - -/*------------------ - * Touchpad - * -----------------*/ - -/*Initialize your touchpad*/ -static void touchpad_init(void) -{ - /*Your code comes here*/ -} - -/* Will be called by the library to read the touchpad */ -static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - static lv_coord_t last_x = 0; - static lv_coord_t last_y = 0; - - /*Save the pressed coordinates and the state*/ - if(touchpad_is_pressed()) { - touchpad_get_xy(&last_x, &last_y); - data->state = LV_INDEV_STATE_PR; - } else { - data->state = LV_INDEV_STATE_REL; - } - - /*Set the last pressed coordinates*/ - data->point.x = last_x; - data->point.y = last_y; - - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -/*Return true is the touchpad is pressed*/ -static bool touchpad_is_pressed(void) -{ - /*Your code comes here*/ - - return false; -} - -/*Get the x and y coordinates if the touchpad is pressed*/ -static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) -{ - /*Your code comes here*/ - - (*x) = 0; - (*y) = 0; -} - - -/*------------------ - * Mouse - * -----------------*/ - -/* Initialize your mouse */ -static void mouse_init(void) -{ - /*Your code comes here*/ -} - -/* Will be called by the library to read the mouse */ -static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - /*Get the current x and y coordinates*/ - mouse_get_xy(&data->point.x, &data->point.y); - - /*Get whether the mouse button is pressed or released*/ - if(mouse_is_pressed()) { - data->state = LV_INDEV_STATE_PR; - } else { - data->state = LV_INDEV_STATE_REL; - } - - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -/*Return true is the mouse button is pressed*/ -static bool mouse_is_pressed(void) -{ - /*Your code comes here*/ - - return false; -} - -/*Get the x and y coordinates if the mouse is pressed*/ -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y) -{ - /*Your code comes here*/ - - (*x) = 0; - (*y) = 0; -} - -/*------------------ - * Keypad - * -----------------*/ - -/* Initialize your keypad */ -static void keypad_init(void) -{ - /*Your code comes here*/ -} - -/* Will be called by the library to read the mouse */ -static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - static uint32_t last_key = 0; - - /*Get the current x and y coordinates*/ - mouse_get_xy(&data->point.x, &data->point.y); - - /*Get whether the a key is pressed and save the pressed key*/ - uint32_t act_key = keypad_get_key(); - if(act_key != 0) { - data->state = LV_INDEV_STATE_PR; - - /*Translate the keys to LittlevGL control characters according to your key definitions*/ - switch(act_key) { - case 1: - act_key = LV_KEY_NEXT; - break; - case 2: - act_key = LV_KEY_PREV; - break; - case 3: - act_key = LV_KEY_LEFT; - break; - case 4: - act_key = LV_KEY_RIGHT; - break; - case 5: - act_key = LV_KEY_ENTER; - break; - } - - last_key = act_key; - } else { - data->state = LV_INDEV_STATE_REL; - } - - data->key = last_key; - - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -/*Get the currently being pressed key. 0 if no key is pressed*/ -static uint32_t keypad_get_key(void) -{ - /*Your code comes here*/ - - return 0; -} - -/*------------------ - * Encoder - * -----------------*/ - -/* Initialize your keypad */ -static void encoder_init(void) -{ - /*Your code comes here*/ -} - -/* Will be called by the library to read the encoder */ -static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - - data->enc_diff = encoder_diff; - data->state = encoder_state; - - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -/*Call this function in an interrupt to process encoder events (turn, press)*/ -static void encoder_handler(void) -{ - /*Your code comes here*/ - - encoder_diff += 0; - encoder_state = LV_INDEV_STATE_REL; -} - - -/*------------------ - * Button - * -----------------*/ - -/* Initialize your buttons */ -static void button_init(void) -{ - /*Your code comes here*/ -} - -/* Will be called by the library to read the button */ -static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - - static uint8_t last_btn = 0; - - /*Get the pressed button's ID*/ - int8_t btn_act = button_get_pressed_id(); - - if(btn_act >= 0) { - data->state = LV_INDEV_STATE_PR; - last_btn = btn_act; - } else { - data->state = LV_INDEV_STATE_REL; - } - - /*Save the last pressed button's ID*/ - data->btn_id = last_btn; - - /*Return `false` because we are not buffering and no more data to read*/ - return false; -} - -/*Get ID (0, 1, 2 ..) of the pressed button*/ -static int8_t button_get_pressed_id(void) -{ - uint8_t i; - - /*Check to buttons see which is being pressed (assume there are 2 buttons)*/ - for(i = 0; i < 2; i++) { - /*Return the pressed button's ID*/ - if(button_is_pressed(i)) { - return i; - } - } - - /*No button pressed*/ - return -1; -} - -/*Test if `id` button is pressed or not*/ -static bool button_is_pressed(uint8_t id) -{ - - /*Your code comes here*/ - - return false; -} - -#else /* Enable this file at the top */ - -/* This dummy typedef exists purely to silence -Wpedantic. */ -typedef int keep_pedantic_happy; -#endif diff --git a/src/libs/lvgl/porting/lv_port_indev_template.h b/src/libs/lvgl/porting/lv_port_indev_template.h deleted file mode 100644 index ca0274e8..00000000 --- a/src/libs/lvgl/porting/lv_port_indev_template.h +++ /dev/null @@ -1,45 +0,0 @@ - -/** - * @file lv_port_indev_templ.h - * - */ - - /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/ -#if 0 - -#ifndef LV_PORT_INDEV_TEMPL_H -#define LV_PORT_INDEV_TEMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "lvgl/lvgl.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*LV_PORT_INDEV_TEMPL_H*/ - -#endif /*Disable/Enable content*/ |