From 54b2395733df1e49782c18951a08e4608591973d Mon Sep 17 00:00:00 2001 From: zaltora Date: Wed, 17 Oct 2018 15:52:52 +0200 Subject: [PATCH] Update submodule and example --- examples/lvgl_ssd1306/lv_conf.h | 88 ++++++++++++++++++++------------- examples/lvgl_ssd1306/main.c | 34 ++++++++----- lvgl/lv_drivers | 2 +- lvgl/lvgl | 2 +- 4 files changed, 77 insertions(+), 49 deletions(-) diff --git a/examples/lvgl_ssd1306/lv_conf.h b/examples/lvgl_ssd1306/lv_conf.h index 69c4c55..48235dd 100644 --- a/examples/lvgl_ssd1306/lv_conf.h +++ b/examples/lvgl_ssd1306/lv_conf.h @@ -2,15 +2,15 @@ * @file lv_conf.h * */ - -#if 1 /*Remove this to enable the content (Delete the last #endif too!)*/ - #ifndef LV_CONF_H #define LV_CONF_H -/*---------------- - * Dynamic memory - *----------------*/ +//include complement to LV_TICK_CUSTOM_INCLUDE. +#include "FreeRTOS.h" + +/*=================== + Dynamic memory + *===================*/ /* Memory size which will be used by the library * to store the graphical objects and other data */ @@ -38,13 +38,14 @@ * Required for buffered drawing, opacity and anti-aliasing * VDB makes the double buffering, you don't need to deal with it! * Typical size: ~1/10 screen */ -#define LV_VDB_SIZE (0 * LV_HOR_RES) /*Size of VDB in pixel count (1/10 screen size is good for first)*/ -#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate automatically into RAM)*/ +#define LV_VDB_SIZE (LV_VER_RES * LV_HOR_RES / 2) /*Size of VDB in pixel count (1/10 screen size is good for first)*/ +#define LV_VDB_PX_BPP 1 /*Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. (Set `disp_drv->vdb_wr` and `disp_drv->vdb_rd` too)*/ +#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/ /* Use two Virtual Display buffers (VDB) parallelize rendering and flushing (optional) * The flushing should use DMA to write the frame buffer in the background*/ #define LV_VDB_DOUBLE 0 /*1: Enable the use of 2 VDBs*/ -#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate automatically into RAM)*/ +#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/ /* Enable anti-aliasing (lines, and radiuses will be smoothed) */ #define LV_ANTIALIAS 0 /*1: Enable anti-aliasing*/ @@ -66,46 +67,57 @@ #define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */ /*Color settings*/ -#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/24*/ +#define LV_COLOR_DEPTH 1 /*Color depth: 1/8/16/32*/ +#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/ +#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/ #define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/ /*Text settings*/ -#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */ +#define LV_TXT_UTF8 0 /*Enable UTF-8 coded Unicode character usage */ #define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/ /*Graphics feature usage*/ #define USE_LV_ANIMATION 1 /*1: Enable all animations*/ -#define USE_LV_SHADOW 1 /*1: Enable shadows*/ +#define USE_LV_SHADOW 0 /*1: Enable shadows*/ #define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/ -#define USE_LV_GPU 1 /*1: Enable GPU interface*/ +#define USE_LV_GPU 0 /*1: Enable GPU interface*/ #define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/ #define USE_LV_FILESYSTEM 1 /*1: Enable file system (required by images*/ /*Compiler settings*/ -#define LV_ATTRIBUTE_TICK_INC __attribute__((section(".iram1.text"))) /* Define a custom attribute to `lv_tick_inc` function */ -#define LV_ATTRIBUTE_TASK_HANDLER __attribute__((section(".iram1.text"))) /* Define a custom attribute to `lv_task_handler` function */ -#define LV_COMPILER_VLA_SUPPORTED 0 /* 1: Variable length array is supported. (In Visual studio it is not supported)*/ -#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 0 /* 1: Initialization with non constant values are supported (In Visual studio it is not supported)*/ -//#define _CRT_SECURE_NO_WARNINGS /* Visual Studio needs it to use `strcpy`, `sprintf` etc*/ +#define LV_ATTRIBUTE_TICK_INC __attribute__((section(".iram1.text"))) /* Define a custom attribute to `lv_tick_inc` function */ +#define LV_ATTRIBUTE_TASK_HANDLER __attribute__((section(".iram1.text"))) /* Define a custom attribute to `lv_task_handler` function */ +#define LV_COMPILER_VLA_SUPPORTED 0 /* 1: Variable length array is supported*/ +#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 0 /* 1: Initialization with non constant values are supported */ + +/*HAL settings*/ +#define LV_TICK_CUSTOM 1 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */ +#if LV_TICK_CUSTOM == 1 +#define LV_TICK_CUSTOM_INCLUDE "task.h" +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (xTaskGetTickCount()*10) /*Expression evaluating to current systime in ms*/ +#endif /*LV_TICK_CUSTOM*/ + /*Log settings*/ -#define USE_LV_LOG 1 /*Enable/disable the log module*/ +#define USE_LV_LOG 0 /*Enable/disable the log module*/ #if USE_LV_LOG /* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + * LV_LOG_LEVEL_INFO Log important events + * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem + * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail */ -#define LV_LOG_LEVEL LV_LOG_LEVEL_INFO +#define LV_LOG_LEVEL LV_LOG_LEVEL_INFO /* 1: Print the log with 'printf'; 0: user need to register a callback*/ -#define LV_LOG_PRINTF 0 +#define LV_LOG_PRINTF 0 #endif /*USE_LV_LOG*/ /*================ * THEME USAGE *================*/ +#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/ + #define USE_LV_THEME_TEMPL 0 /*Just for test*/ #define USE_LV_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/ #define USE_LV_THEME_ALIEN 0 /*Dark futuristic theme*/ @@ -113,6 +125,7 @@ #define USE_LV_THEME_MONO 0 /*Mono color theme for monochrome displays*/ #define USE_LV_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/ #define USE_LV_THEME_ZEN 0 /*Peaceful, mainly light theme */ +#define USE_LV_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/ /*================== * FONT USAGE @@ -141,18 +154,18 @@ #define USE_LV_FONT_DEJAVU_40_CYRILLIC 0 #define USE_LV_FONT_SYMBOL_40 0 -#define USE_LV_FONT_MONOSPACE_8 0 +#define USE_LV_FONT_MONOSPACE_8 0 /* Optionally declare your custom fonts here. - * You can use these fonts as defult font too - * and they will be avialale globally. E.g. + * You can use these fonts as default font too + * and they will be available globally. E.g. * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) \ + * LV_FONT_DECLARE(my_font_2) \ */ +#define LV_FONT_CUSTOM_DECLARE -#ifndef LV_FONT_DEFAULT #define LV_FONT_DEFAULT &lv_font_dejavu_10 /*Always set a default font from the built-in fonts*/ -#endif + /*=================== * LV_OBJ SETTINGS *==================*/ @@ -178,6 +191,10 @@ /*Image (dependencies: lv_label*/ #define USE_LV_IMG 1 +#if USE_LV_IMG != 0 +#define LV_IMG_CF_INDEXED 1 /*Enable indexed (palette) images*/ +#define LV_IMG_CF_ALPHA 1 /*Enable alpha indexed images*/ +#endif /*Line (dependencies: -*/ #define USE_LV_LINE 1 @@ -249,6 +266,12 @@ /*Button (dependencies: lv_cont*/ #define USE_LV_BTN 1 +#if USE_LV_BTN != 0 +#define LV_BTN_INK_EFFECT 1 /*Enable button-state animations - draw a circle on click (dependencies: USE_LV_ANIMATION)*/ +#endif + +/*Image Button (dependencies: lv_btn*/ +#define USE_LV_IMGBTN 1 /*Button matrix (dependencies: -)*/ #define USE_LV_BTNM 1 @@ -291,6 +314,3 @@ #endif #endif /*LV_CONF_H*/ - - -#endif /*Remove this to enable the content*/ diff --git a/examples/lvgl_ssd1306/main.c b/examples/lvgl_ssd1306/main.c index d33f054..925ce7c 100644 --- a/examples/lvgl_ssd1306/main.c +++ b/examples/lvgl_ssd1306/main.c @@ -63,30 +63,34 @@ static void ssd1306_task(void *pvParameters) vTaskDelay(SECOND); ssd1306_set_whole_display_lighting(&dev, false); + //Set a style for the obj + lv_style_copy(&style, &lv_style_transp); + style.text.font = &lv_font_dejavu_10; /*Unicode and symbol fonts already assigned by the library*/ + style.text.color.full = 1; + style.body.main_color.full = 0; + style.body.grad_color.full = 0; + style.body.shadow.color.full = 0; + style.body.border.color.full = 0; + style.body.empty = 0; + //Create main screen obj lv_obj_t * scr = lv_obj_create(NULL, NULL); lv_scr_load(scr); + lv_obj_set_style(scr, &style); //Create a simple label label = lv_label_create(lv_scr_act(), NULL); + lv_obj_set_style(label, &style); + lv_obj_align(label, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0); lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); lv_label_set_text(label, "lvgl work with esp-open-rtos"); lv_obj_set_width(label, LV_HOR_RES); - //Set a style for the obj - lv_style_copy(&style, &lv_style_plain); - style.text.font = &lv_font_dejavu_10; /*Unicode and symbol fonts already assigned by the library*/ - lv_label_set_style(label, &style); - while (1) { /*draw system call */ lv_task_handler(); - if(ssd1306_need_redraw()) - { - ssd1306_load_frame_buffer(&dev); - } vTaskDelay(1); } } @@ -118,6 +122,7 @@ void font_timer(TimerHandle_t h) } +#if (!LV_TICK_CUSTOM) #if (TICK_HANDLER) void IRAM vApplicationTickHook(void) { lv_tick_inc(portTICK_PERIOD_MS); @@ -128,6 +133,7 @@ void lvgl_timer(TimerHandle_t xTimerHandle) lv_tick_inc(TICK_INC_MS); } #endif +#endif void user_init(void) { @@ -172,6 +178,7 @@ void user_init(void) printf("%s: failed to init SSD1306 lcd\n", __func__); vTaskDelay(SECOND); } + ssd1306_set_whole_display_lighting(&dev, true); /*inverse screen (180°) */ @@ -184,17 +191,18 @@ void user_init(void) lv_disp_drv_init(&disp_drv); /*Set up the functions to access to your display*/ disp_drv.disp_flush = ssd1306_flush; /*Used in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/ - disp_drv.disp_fill = ssd1306_fill;//ex_disp_fill; /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ - disp_drv.disp_map = ssd1306_map;//ex_disp_map; /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ + disp_drv.disp_fill = NULL;//ex_disp_fill; /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ + disp_drv.disp_map = NULL;//ex_disp_map; /*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/ + disp_drv.vdb_wr = ssd1306_vdb_wr; lv_disp_drv_register(&disp_drv); /* Create user interface task */ - xTaskCreate(ssd1306_task, "ssd1306_task", 256, NULL, 2, NULL); + xTaskCreate(ssd1306_task, "ssd1306_task", 512, NULL, 2, NULL); font_timer_handle = xTimerCreate("font_timer", 5 * SECOND, pdTRUE, NULL, font_timer); xTimerStart(font_timer_handle, 0); -#if (!TICK_HANDLER) +#if (!TICK_HANDLER && !LV_TICK_CUSTOM) lvgl_timer_handle = xTimerCreate("lvgl_timer", TICK_INC_MS/portTICK_PERIOD_MS, pdTRUE, NULL, lvgl_timer); xTimerStart(lvgl_timer_handle, 0); #endif diff --git a/lvgl/lv_drivers b/lvgl/lv_drivers index eafd24d..3769077 160000 --- a/lvgl/lv_drivers +++ b/lvgl/lv_drivers @@ -1 +1 @@ -Subproject commit eafd24d14e3c914b870e9575e5ec33d06280d313 +Subproject commit 3769077d58003cf1402183b8b634e557f853f015 diff --git a/lvgl/lvgl b/lvgl/lvgl index 675715a..41695bf 160000 --- a/lvgl/lvgl +++ b/lvgl/lvgl @@ -1 +1 @@ -Subproject commit 675715a917d9a6c35e4bd331d6600e829e361238 +Subproject commit 41695bf9ac758ae3276424e06308e1bb89c4c019