Add button counter test on GPIO22 with SoftSPI touch and LVGL.
Each press increments on-screen count; touch Reset clears. Flashable firmware/cyd package. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
10
include/button.h
Normal file
10
include/button.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void button_init();
|
||||
/** 轮询:检测按下边沿,返回本周期是否有一次有效按下 */
|
||||
bool button_poll_press();
|
||||
uint32_t button_count();
|
||||
void button_reset_count();
|
||||
bool button_is_down();
|
||||
1127
include/lv_conf.h
Normal file
1127
include/lv_conf.h
Normal file
File diff suppressed because it is too large
Load Diff
19
include/pins.h
Normal file
19
include/pins.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
// CYD ESP32-2432S028R — 触控/屏脚与 tftest 一致
|
||||
|
||||
#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
|
||||
|
||||
// 按钮传感器 SIG → GPIO22(内部上拉,按下为 LOW)
|
||||
#define BTN_PIN 22
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 320
|
||||
#define UI_HOR_RES 320
|
||||
#define UI_VER_RES 240
|
||||
12
include/touch.h
Normal file
12
include/touch.h
Normal 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
4
include/ui.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
void ui_create();
|
||||
void ui_refresh_count();
|
||||
Reference in New Issue
Block a user