Use lvgl internal ticker

This commit is contained in:
fvanroie 2021-01-13 01:31:23 +01:00
parent b037be4a52
commit a66482b89f
4 changed files with 37 additions and 56 deletions

View File

@ -250,9 +250,9 @@ typedef void* lv_img_decoder_user_data_t;
/* 1: use a custom tick source. /* 1: use a custom tick source.
* It removes the need to manually update the tick with `lv_tick_inc`) */ * It removes the need to manually update the tick with `lv_tick_inc`) */
#define LV_TICK_CUSTOM 0 #define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM == 1 #if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/ #endif /*LV_TICK_CUSTOM*/

View File

@ -308,10 +308,10 @@ typedef void * lv_img_decoder_user_data_t;
/* 1: use a custom tick source. /* 1: use a custom tick source.
* It removes the need to manually update the tick with `lv_tick_inc`) */ * It removes the need to manually update the tick with `lv_tick_inc`) */
#define LV_TICK_CUSTOM 0 #define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM == 1 #if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/ #endif /*LV_TICK_CUSTOM*/
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/

View File

@ -98,10 +98,8 @@ build_flags =
-D NO_GLOBAL_HTTPUPDATE ; dont instantiate httpUpdate -D NO_GLOBAL_HTTPUPDATE ; dont instantiate httpUpdate
; -- lvgl build options ----------------------------- ; -- lvgl build options -----------------------------
-D LV_MEM_SIZE=61440U ; 60kB lvgl memory -D LV_MEM_SIZE=61440U ; 60kB lvgl memory
;-D LV_MEM_SIZE=10240U ; 10kB lvgl memory
; -- tft_espi build options ------------------------ ; -- tft_espi build options ------------------------
;-D USE_DMA_TO_TFT ;-D USE_DMA_TO_TFT
;-D ESP32_DMA ; Make touch reads wait for DMA
; -- hasp-lvgl build options ------------------------ ; -- hasp-lvgl build options ------------------------
-D HASP_USE_TELNET=1 -D HASP_USE_TELNET=1
-D HASP_USE_SPIFFS=1 -D HASP_USE_SPIFFS=1
@ -118,8 +116,11 @@ lib_ignore =
Adafruit GFX Library Adafruit GFX Library
sstaub/Ticker sstaub/Ticker
lv_drv_fsmc_ili9341 lv_drv_fsmc_ili9341
lv_drivers
AXP192
lib_deps = LittleFS_esp32 lib_deps =
; LittleFS_esp32
extra_scripts = extra_scripts =
tools/copy_partitions.py tools/copy_partitions.py
@ -178,7 +179,7 @@ build_flags=
-D HASP_USE_LITTLEFS=0 -D HASP_USE_LITTLEFS=0
lib_deps = lib_deps =
sstaub/Ticker @ ^3.2.0 ; sstaub/Ticker @ ^3.2.0
stm32duino/STM32duino LwIP @ ^2.1.2 stm32duino/STM32duino LwIP @ ^2.1.2
;https://github.com/stm32duino/LwIP.git ;https://github.com/stm32duino/LwIP.git

View File

@ -25,7 +25,7 @@
//#include "tpcal.h" //#include "tpcal.h"
#include "Ticker.h" //#include "Ticker.h"
#if HASP_USE_PNGDECODE > 0 #if HASP_USE_PNGDECODE > 0
#include "png_decoder.h" #include "png_decoder.h"
@ -62,19 +62,19 @@ static uint8_t guiRotation = TFT_ROTATION;
static uint8_t guiInvertDisplay = INVERT_COLORS; static uint8_t guiInvertDisplay = INVERT_COLORS;
static uint16_t calData[5] = {0, 65535, 0, 65535, 0}; static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) // #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
static Ticker tick; /* timer for interrupt handler */ // static Ticker tick; /* timer for interrupt handler */
#else // #else
static Ticker tick(lv_tick_handler, LVGL_TICK_PERIOD); // guiTickPeriod); // static Ticker tick(lv_tick_handler, LVGL_TICK_PERIOD); // guiTickPeriod);
#endif // #endif
/* **************************** GUI TICKER ************************************** */ /* **************************** GUI TICKER ************************************** */
/* Interrupt driven periodic handler */ /* Interrupt driven periodic handler */
static void ICACHE_RAM_ATTR lv_tick_handler(void) // static void ICACHE_RAM_ATTR lv_tick_handler(void)
{ // {
lv_tick_inc(LVGL_TICK_PERIOD); // lv_tick_inc(LVGL_TICK_PERIOD);
} // }
/* Reading input device (simulated encoder here) */ /* Reading input device (simulated encoder here) */
/*bool read_encoder(lv_indev_drv_t * indev, lv_indev_data_t * data) /*bool read_encoder(lv_indev_drv_t * indev, lv_indev_data_t * data)
@ -242,25 +242,7 @@ void guiCalibrate()
void guiSetup() void guiSetup()
{ {
// Driver intializations: lv_init();
drv_touch_init(guiRotation); // Touch
lv_init(); // GUI
#if 0
tft.begin();
tft.setSwapBytes(true); /* set endianess */
#ifdef USE_DMA_TO_TFT
// DMA - should work with STM32F2xx/F4xx/F7xx processors
// NOTE: >>>>>> DMA IS FOR SPI DISPLAYS ONLY <<<<<<
tft.initDMA(); // Initialise the DMA engine (tested with STM32F446 and STM32F767)
#endif
tft.setRotation(guiRotation); /* 1/3=Landscape or 0/2=Portrait orientation */
#if TOUCH_DRIVER == 2046 && USE_TFT_ESPI > 0
tft_espi_set_touch(calData);
#endif
#endif
/* Initialize the Virtual Device Buffers */ /* Initialize the Virtual Device Buffers */
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
@ -328,24 +310,21 @@ void guiSetup()
Log.verbose(TAG_GUI, F("Backlight: Pin %d"), guiBacklightPin); Log.verbose(TAG_GUI, F("Backlight: Pin %d"), guiBacklightPin);
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
// pinMode(guiBacklightPin, OUTPUT);
// configure LED PWM functionalitites
ledcSetup(BACKLIGHT_CHANNEL, 20000, 10); ledcSetup(BACKLIGHT_CHANNEL, 20000, 10);
// attach the channel to the GPIO to be controlled
ledcAttachPin(guiBacklightPin, BACKLIGHT_CHANNEL); ledcAttachPin(guiBacklightPin, BACKLIGHT_CHANNEL);
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP8266)
pinMode(guiBacklightPin, OUTPUT); pinMode(guiBacklightPin, OUTPUT);
#endif #endif
} }
Log.verbose(TAG_GUI, F("Rotation : %d"), guiRotation); Log.verbose(TAG_GUI, F("Rotation : %d"), guiRotation);
Log.verbose(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH, Log.verbose(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
PSTR(LVGL_VERSION_INFO)); PSTR(LVGL_VERSION_INFO));
#ifdef LV_MEM_SIZE #ifdef LV_MEM_SIZE
Log.verbose(TAG_LVGL, F("MEM size : %d"), LV_MEM_SIZE); Log.verbose(TAG_LVGL, F("MEM size : %d"), LV_MEM_SIZE);
#endif #endif
Log.verbose(TAG_LVGL, F("VFB size : %d"), (size_t)sizeof(lv_color_t) * guiVDBsize); Log.verbose(TAG_LVGL, F("VFB size : %d"), (size_t)sizeof(lv_color_t) * guiVDBsize);
#if LV_USE_LOG != 0 #if LV_USE_LOG != 0
Log.notice(TAG_LVGL, F("Registering lvgl logging handler")); Log.notice(TAG_LVGL, F("Registering lvgl logging handler"));
@ -417,6 +396,7 @@ void guiSetup()
#endif #endif
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/ lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
} }
drv_touch_init(guiRotation); // Touch driver
// guiStart(); // Ticker // guiStart(); // Ticker
} }
@ -426,7 +406,7 @@ void IRAM_ATTR guiLoop(void)
lv_task_handler(); // process animations lv_task_handler(); // process animations
#if defined(STM32F4xx) #if defined(STM32F4xx)
tick.update(); // tick.update();
#endif #endif
} }
@ -438,21 +418,21 @@ void guiEverySecond(void)
void guiStart() void guiStart()
{ {
/*Initialize the graphics library's tick*/ /*Initialize the graphics library's tick*/
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) // #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler); // tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler);
#else // #else
tick.start(); // tick.start();
#endif // #endif
} }
void guiStop() void guiStop()
{ {
/*Deinitialize the graphics library's tick*/ /*Deinitialize the graphics library's tick*/
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) // #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
tick.detach(); // tick.detach();
#else // #else
tick.stop(); // tick.stop();
#endif // #endif
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////