From 0acbfef0ed3c08a464ab046cca66708a4ad2ee8f Mon Sep 17 00:00:00 2001 From: Felix Biego Date: Fri, 29 Nov 2024 10:48:55 +0300 Subject: [PATCH] esp32 support add comments --- hal/esp32/app_hal.cpp | 12 ++++++++++-- hal/esp32/app_hal.h | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hal/esp32/app_hal.cpp b/hal/esp32/app_hal.cpp index efed72a..e155e3c 100644 --- a/hal/esp32/app_hal.cpp +++ b/hal/esp32/app_hal.cpp @@ -3,6 +3,8 @@ #include "lvgl.h" #include "PanelLan.h" + +/* Set the board type. (Uses LovyanGFX internally to manage display drivers) */ PanelLan tft(BOARD_SC01_PLUS); static const uint32_t screenWidth = 480; @@ -56,6 +58,7 @@ void my_touchpad_read(lv_indev_t *indev_driver, lv_indev_data_t *data) } } +/* Tick source, tell LVGL how much time (milliseconds) has passed */ static uint32_t my_tick(void) { return millis(); @@ -64,28 +67,33 @@ static uint32_t my_tick(void) void hal_setup(void) { + /* Initialize the display drivers */ tft.init(); tft.initDMA(); tft.startWrite(); tft.fillScreen(TFT_BLACK); + + /* Set display rotation to landscape */ tft.setRotation(1); + /* Set the tick callback */ lv_tick_set_cb(my_tick); + /* Create LVGL display and set the flush function */ lvDisplay = lv_display_create(screenWidth, screenHeight); lv_display_set_color_format(lvDisplay, LV_COLOR_FORMAT_RGB565); lv_display_set_flush_cb(lvDisplay, my_disp_flush); lv_display_set_buffers(lvDisplay, lvBuffer[0], lvBuffer[1], lvBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL); + /* Set the touch input function */ lvInput = lv_indev_create(); lv_indev_set_type(lvInput, LV_INDEV_TYPE_POINTER); lv_indev_set_read_cb(lvInput, my_touchpad_read); - } void hal_loop(void) { - // NO while loop in this function! (handled by framework) + /* NO while loop in this function! (handled by framework) */ lv_timer_handler(); // Update the UI- delay(5); } diff --git a/hal/esp32/app_hal.h b/hal/esp32/app_hal.h index cfd0e71..fa2158c 100644 --- a/hal/esp32/app_hal.h +++ b/hal/esp32/app_hal.h @@ -7,9 +7,16 @@ extern "C" { /** - * Add some description please + * This function runs once and typically includes: + * - Setting up display drivers. + * - Configuring LVGL display and input.= */ void hal_setup(void); + +/** + * This function is continuously executed and typically includes: + * - Updating LVGL's internal state & UI. + */ void hal_loop(void);