Files
Dual-PID/JC_Display_Firmware/lvgl_port_v9.h
T
raw-designsandClaude Opus 5 92c1446824 feat(P4): 7-Zoll-Display JC1060P470C-I-W unterstützen (1.5.0)
Dieselbe Display-Firmware bedient jetzt wahlweise das bisherige 4,3-Zoll-Panel
JC4880P443C-I-W (ST7701, 480x800) oder das neue 7-Zoll-Panel JC1060P470C-I-W
(JD9165, 1024x600). Umgeschaltet wird über JC_PANEL_TYPE in config.h
(JC_PANEL_43 / JC_PANEL_70) oder per Compiler-Flag -DJC_PANEL_TYPE=70. Vorgabe
bleibt das 4,3-Zoll-Panel; dessen Verhalten ändert sich nicht.

- src/lcd/esp_lcd_jd9165.c/.h aus dem Hersteller-Paket übernommen;
  board_bringup.c legt je nach Panel DSI-Bus, DPI-Zeitbasis und Herstellertreiber an.
- pins_config.h liefert Auflösung, LCD-Reset (4,3": GPIO5, 7,0": GPIO27) und
  Ausrichtung panelabhängig. Das 7-Zoll-Panel ist nativ Querformat, deshalb
  entfallen dort die 270-Grad-Rotation und die PPA-Beschleunigung.
- lvgl_port_v9.h bezieht LVGL_PORT_H/V_RES aus pins_config.h statt fest 480/800.
- Der GT911 des 7-Zöllers meldet Rohkoordinaten im Raster 800x480 statt 1024x600.
  Die Umrechnung hängt am process_coordinates-Hook von esp_lcd_touch, damit die
  Herstellerdatei esp_lcd_touch_gt911.c unverändert bleibt.
- ui.cpp rechnet nicht mehr mit fest verdrahteten 480 Pixeln Höhe, sondern mit
  DISP_VER_RES. Layout und Schriften bleiben sonst unverändert.
- Hersteller-Paket des 7-Zöllers unter JC_Display_Firmware_7zoll/ abgelegt;
  Werkzeuge, Archive und mitgelieferte Fremdbibliotheken per .gitignore
  ausgeschlossen (587 MB im Original, 21 MB im Repo).

Kompiliertest ESP32-P4, beide Varianten:
  4,3": 1.173.768 B Flash (37 %), 322.880 B RAM (98 %)
  7,0": 1.138.752 B Flash (36 %), 322.600 B RAM (98 %)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 02:35:40 +02:00

184 lines
5.5 KiB
C

/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "esp_err.h"
#include "esp_lcd_types.h"
#include "src/touch/esp_lcd_touch.h"
#include "lvgl.h"
#include "pins_config.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief LVGL port interface type
*
*/
typedef enum {
LVGL_PORT_INTERFACE_RGB,
LVGL_PORT_INTERFACE_MIPI_DSI_DMA,
LVGL_PORT_INTERFACE_MIPI_DSI_NO_DMA,
LVGL_PORT_INTERFACE_MAX,
} lvgl_port_interface_t;
/**
* LVGL related parameters, can be adjusted by users
*
*/
/* Native Panel-Aufloesung - kommt aus pins_config.h, damit beide Panel-Typen
* (JC_PANEL_43: 480x800 / JC_PANEL_70: 1024x600) denselben Port nutzen koennen. */
#define LVGL_PORT_H_RES (LCD_H_RES)
#define LVGL_PORT_V_RES (LCD_V_RES)
#define LVGL_PORT_TICK_PERIOD_MS (EXAMPLE_LVGL_PORT_TICK)
/**
* LVGL timer handle task related parameters, can be adjusted by users
*
*/
#define LVGL_PORT_TASK_MAX_DELAY_MS (EXAMPLE_LVGL_PORT_TASK_MAX_DELAY_MS) // The maximum delay of the LVGL timer task, in milliseconds
#define LVGL_PORT_TASK_MIN_DELAY_MS (EXAMPLE_LVGL_PORT_TASK_MIN_DELAY_MS) // The minimum delay of the LVGL timer task, in milliseconds
#define LVGL_PORT_TASK_STACK_SIZE (EXAMPLE_LVGL_PORT_TASK_STACK_SIZE_KB * 1024) // The stack size of the LVGL timer task, in bytes
#define LVGL_PORT_TASK_PRIORITY (EXAMPLE_LVGL_PORT_TASK_PRIORITY) // The priority of the LVGL timer task
#define LVGL_PORT_TASK_CORE (EXAMPLE_LVGL_PORT_TASK_CORE) // The core of the LVGL timer task,
// `-1` means the don't specify the core
/**
*
* LVGL buffer related parameters, can be adjusted by users:
* (These parameters will be useless if the avoid tearing function is enabled)
*
* - Memory type for buffer allocation:
* - MALLOC_CAP_SPIRAM: Allocate LVGL buffer in PSRAM
* - MALLOC_CAP_INTERNAL: Allocate LVGL buffer in SRAM
* (The SRAM is faster than PSRAM, but the PSRAM has a larger capacity)
*
*/
#if CONFIG_EXAMPLE_LVGL_PORT_BUF_PSRAM
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM)
#elif CONFIG_EXAMPLE_LVGL_PORT_BUF_INTERNAL
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#endif
#define LVGL_PORT_BUFFER_HEIGHT (CONFIG_EXAMPLE_LVGL_PORT_BUF_HEIGHT)
/**
* Avoid tering related configurations, can be adjusted by users.
*
*/
#define LVGL_PORT_AVOID_TEAR_ENABLE (EXAMPLE_LVGL_PORT_AVOID_TEAR_ENABLE) // Set to 1 to enable
#if LVGL_PORT_AVOID_TEAR_ENABLE
/**
* Set the avoid tearing mode:
* - 0: Disable avoid tearing function
* - 1: LCD double-buffer & LVGL full-refresh
* - 2: LCD triple-buffer & LVGL full-refresh
* - 3: LCD double-buffer & LVGL direct-mode (recommended)
*
*/
#define LVGL_PORT_AVOID_TEAR_MODE (EXAMPLE_LVGL_PORT_AVOID_TEAR_MODE)
/**
* Set the PPA rotation enable:
* - 0: Disable PPA rotation
* - 1: Enable PPA rotation
*
*/
#define LVGL_PORT_PPA_ROTATION_ENABLE (EXAMPLE_LVGL_PORT_PPA_ROTATION_ENABLE)
/**
* Set the rotation degree of the LCD panel when the avoid tearing function is enabled:
* - 0: 0 degree
* - 90: 90 degree
* - 180: 180 degree
* - 270: 270 degree
*
*/
#define EXAMPLE_LVGL_PORT_ROTATION_DEGREE (EXAMPLE_LVGL_PORT_ROTATION_DEGREE_)
/**
* Below configurations are automatically set according to the above configurations, users do not need to modify them.
*
*/
#if LVGL_PORT_AVOID_TEAR_MODE == 1
#define LVGL_PORT_LCD_BUFFER_NUMS (2)
#define LVGL_PORT_FULL_REFRESH (1)
#elif LVGL_PORT_AVOID_TEAR_MODE == 2
#define LVGL_PORT_LCD_BUFFER_NUMS (3)
#define LVGL_PORT_FULL_REFRESH (1)
#elif LVGL_PORT_AVOID_TEAR_MODE == 3
#define LVGL_PORT_LCD_BUFFER_NUMS (2)
#define LVGL_PORT_DIRECT_MODE (1)
#endif /* LVGL_PORT_AVOID_TEAR_MODE */
#if EXAMPLE_LVGL_PORT_ROTATION_DEGREE == 0
#define EXAMPLE_LVGL_PORT_ROTATION_0 (1)
#else
#if EXAMPLE_LVGL_PORT_ROTATION_DEGREE == 90
#define EXAMPLE_LVGL_PORT_ROTATION_90 (1)
#elif EXAMPLE_LVGL_PORT_ROTATION_DEGREE == 180
#define EXAMPLE_LVGL_PORT_ROTATION_180 (1)
#elif EXAMPLE_LVGL_PORT_ROTATION_DEGREE == 270
#define EXAMPLE_LVGL_PORT_ROTATION_270 (1)
#endif
#ifdef LVGL_PORT_LCD_BUFFER_NUMS
#undef LVGL_PORT_LCD_BUFFER_NUMS
#define LVGL_PORT_LCD_BUFFER_NUMS (3)
#endif
#endif /* EXAMPLE_LVGL_PORT_ROTATION_DEGREE */
#else
#define LVGL_PORT_LCD_BUFFER_NUMS (1)
#define LVGL_PORT_FULL_REFRESH (0)
#define LVGL_PORT_DIRECT_MODE (0)
#endif /* LVGL_PORT_AVOID_TEAR_ENABLE */
/**
* @brief Initialize LVGL port
*
* @param[in] lcd_handle: LCD panel handle
* @param[in] tp_handle: Touch panel handle
*
* @return
* - ESP_OK: Success
* - ESP_ERR_INVALID_ARG: Invalid argument
* - Others: Fail
*/
esp_err_t lvgl_port_init(esp_lcd_panel_handle_t lcd_handle, esp_lcd_touch_handle_t tp_handle, lvgl_port_interface_t interface);
/**
* @brief Take LVGL mutex
*
* @param[in] timeout_ms: Timeout in [ms]. 0 will block indefinitely.
*
* @return
* - true: Mutex was taken
* - false: Mutex was NOT taken
*/
bool lvgl_port_lock(int timeout_ms);
/**
* @brief Give LVGL mutex
*
*/
void lvgl_port_unlock(void);
/**
* @brief Notifies the LVGL task when the transmission of the RGB frame buffer is completed.
*
* @return
* - true: The tasks need to be re-scheduled
* - false: The tasks don't need to be re-scheduled
*/
bool lvgl_port_notify_lcd_vsync(void);
void lvgl_sw_rotation_main(void);
#ifdef __cplusplus
}
#endif