Add LCD1602A I2C test with SoftSPI touch and LVGL.

PCF8574 backpack on SDA=GPIO22/SCL=GPIO27, demo/hello/clear/backlight UI, and flashable firmware/cyd package.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-23 14:25:53 +08:00
commit a4c7d54d3e
23 changed files with 2100 additions and 0 deletions

20
include/lcd.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
void lcd_init();
bool lcd_ok();
uint8_t lcd_addr();
void lcd_set_backlight(bool on);
bool lcd_backlight();
void lcd_clear();
void lcd_set_line(uint8_t row, const char *text);
void lcd_get_line(uint8_t row, char *out, size_t out_len);
/** 写入两行示例文案并点亮背光 */
void lcd_demo(uint8_t index);
uint8_t lcd_demo_count();

1127
include/lv_conf.h Normal file

File diff suppressed because it is too large Load Diff

24
include/pins.h Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
// CYD ESP32-2432S028R — 触控/屏脚与 tftest 一致
// LCD1602A + I2C 转接板(PCF8574):SDA=GPIO22,SCL=GPIO27
// 常见地址 0x27 / 0x3F(上电扫描)
#define TFT_BL_PIN 21
#define CYD_TOUCH_IRQ 36
#define CYD_TOUCH_MOSI 32
#define CYD_TOUCH_MISO 39
#define CYD_TOUCH_CLK 25
#define CYD_TOUCH_CS 33
#define LCD_I2C_SDA_PIN 22
#define LCD_I2C_SCL_PIN 27
#define LCD_I2C_FREQ_HZ 100000
#define LCD_COLS 16
#define LCD_ROWS 2
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define UI_HOR_RES 320
#define UI_VER_RES 240

12
include/touch.h Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#include <lvgl.h>
#include <stdint.h>
void touch_init();
void touch_read_cb(lv_indev_t *indev, lv_indev_data_t *data);
// 调试:最近一次触点(物理 / LVGL 旋转后逻辑)
extern int16_t g_dbg_phys_x, g_dbg_phys_y;
extern int16_t g_dbg_logic_x, g_dbg_logic_y;
extern bool g_dbg_touch_down;

4
include/ui.h Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
void ui_create();
void ui_refresh_lcd();