Add KY-009 RGB LED test with SoftSPI touch and LVGL.

R/G/B color switch (GPIO22/27/4), PWM brightness, and flashable firmware/cyd package.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-23 11:17:31 +08:00
commit 53c57f1cfd
23 changed files with 1958 additions and 0 deletions

17
include/lamp.h Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
enum lamp_color_t : uint8_t {
LAMP_COLOR_R = 0,
LAMP_COLOR_G = 1,
LAMP_COLOR_B = 2,
};
void lamp_init();
void lamp_set_on(bool on);
bool lamp_is_on();
void lamp_set_color(lamp_color_t c);
lamp_color_t lamp_color();
void lamp_set_brightness(uint8_t percent); // 0..100,只作用于当前颜色
uint8_t lamp_brightness();

1127
include/lv_conf.h Normal file

File diff suppressed because it is too large Load Diff

21
include/pins.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
// CYD ESP32-2432S028R — 触控/屏脚与 tftest / hw269test 一致
#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
// KY-009 SMD RGB LED(26 留给喇叭,B 用 4)
#define KY009_R_PIN 22 // R -> GPIO22
#define KY009_G_PIN 27 // G -> GPIO27
#define KY009_B_PIN 4 // B -> GPIO4
#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_lamp();