Files
lilygo-t-deck/lib/raylib-esp32/include/drivers/GC9A01/esp_lcd_gc9a01.h
T
Dejvino 0f22c6afca Add raylib-esp32 lib and FloorPlan3D demo (3D floor plan via rlsw)
Vendor raylib-esp32 v1.0.3 (63db94b) under lib/ — raylib 6.x core with
the rlsw software renderer plus the ESP32-S3 port layer (SPI display
drivers, async double-buffered flush). raylib/examples, projects, tools
and logo are trimmed (~80 MB of content nothing here compiles); see
lib/raylib-esp32/VENDOR.md for provenance.

New floorplan3d-demo (emulator-template base) renders the NetDeck demo
map (nd_demomap.h) as a 3D floor plan — bulkhead walls, blast door,
cover crates, airlock pad, terminal — through the real on-device 3D
stack on the desktop:

- rcore_emu.c: desktop PLATFORM_CUSTOM layer mirroring rcore_esp32.c,
  flushing the RGB565 sw-renderer buffer into emuGfx::fb instead of SPI
- raylib_emu_config.h: same module/limit defines as the device build
- HUD via 3x5 bitmap font into fb: rlsw's 2D textured-quad path
  (DrawText/DrawRectangle) misplaces/flips quads and samples wrong
  atlas texels in this build; the 3D path is pixel-accurate

Verified: dual build (make netdeck) green, demo smoke test clean at
~59 FPS, 600-frame stability run OK.
2026-11-16 21:46:31 +01:00

127 lines
4.9 KiB
C

/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief ESP LCD: GC9A01
*/
#pragma once
#include "esp_lcd_panel_vendor.h"
#include "esp_idf_version.h"
#ifndef ESP_LCD_GC9A01_VER_MAJOR
#define ESP_LCD_GC9A01_VER_MAJOR 1
#define ESP_LCD_GC9A01_VER_MINOR 0
#define ESP_LCD_GC9A01_VER_PATCH 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief LCD panel initialization commands.
*
*/
typedef struct {
int cmd; /*<! The specific LCD command */
const void *data; /*<! Buffer that holds the command specific data */
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
} gc9a01_lcd_init_cmd_t;
/**
* @brief LCD panel vendor configuration.
*
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
*
*/
typedef struct {
const gc9a01_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
* The array should be declared as `static const` and positioned outside the function.
* Please refer to `vendor_specific_init_default` in source file.
*/
uint16_t init_cmds_size; /*<! Number of commands in above array */
} gc9a01_vendor_config_t;
/**
* @brief Create LCD panel for model GC9A01
*
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
*
* @param[in] io LCD panel IO handle
* @param[in] panel_dev_config general panel device configuration
* @param[out] ret_panel Returned LCD panel handle
* @return
* - ESP_ERR_INVALID_ARG if parameter is invalid
* - ESP_ERR_NO_MEM if out of memory
* - ESP_OK on success
*/
esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
/**
* @brief LCD panel bus configuration structure
*
* @param[in] sclk SPI clock pin number
* @param[in] mosi SPI MOSI pin number
* @param[in] max_trans_sz Maximum transfer size in bytes
*
*/
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
#define GC9A01_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
{ \
.mosi_io_num = mosi, \
.miso_io_num = -1, \
.sclk_io_num = sclk, \
.quadwp_io_num = -1, \
.quadhd_io_num = -1, \
.data4_io_num = -1, \
.data5_io_num = -1, \
.data6_io_num = -1, \
.data7_io_num = -1, \
.max_transfer_sz = max_trans_sz, \
}
#else
#define GC9A01_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
{ \
.mosi_io_num = mosi, \
.miso_io_num = -1, \
.sclk_io_num = sclk, \
.quadwp_io_num = -1, \
.quadhd_io_num = -1, \
.max_transfer_sz = max_trans_sz, \
}
#endif
/**
* @brief LCD panel IO configuration structure
*
* @param[in] cs SPI chip select pin number
* @param[in] dc SPI data/command pin number
* @param[in] cb Callback function when SPI transfer is done
* @param[in] cb_ctx Callback function context
*
*/
#define GC9A01_PANEL_IO_SPI_CONFIG(cs, dc, callback, callback_ctx) \
{ \
.cs_gpio_num = cs, \
.dc_gpio_num = dc, \
.spi_mode = 0, \
.pclk_hz = 80 * 1000 * 1000, \
.trans_queue_depth = 10, \
.on_color_trans_done = callback, \
.user_ctx = callback_ctx, \
.lcd_cmd_bits = 8, \
.lcd_param_bits = 8, \
.flags = {} \
}
#ifdef __cplusplus
}
#endif