Add human IR (PIR) module test on GPIO22 with SoftSPI touch and LVGL.
Motion-start count, hold bar, auto polarity, and flashable firmware/cyd package. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
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
|
||||
|
||||
// 人体红外感应模块 OUT → GPIO22(VCC→3.3V 或 5V 视模块,GND→GND)
|
||||
#define PIR_PIN 22
|
||||
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 320
|
||||
#define UI_HOR_RES 320
|
||||
#define UI_VER_RES 240
|
||||
16
include/pir.h
Normal file
16
include/pir.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void pir_init();
|
||||
/** 轮询:检测运动开始边沿,返回本周期是否有一次新感应 */
|
||||
bool pir_poll_detect();
|
||||
uint32_t pir_count();
|
||||
void pir_reset_count();
|
||||
bool pir_is_active();
|
||||
/** 原始电平:1=HIGH,0=LOW */
|
||||
int pir_raw_level();
|
||||
/** 有人/运动时的有效电平(开机按空闲电平自动判定) */
|
||||
int pir_active_level();
|
||||
/** 当前连续有人时长 ms;空闲为 0 */
|
||||
uint32_t pir_hold_ms();
|
||||
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();
|
||||
Reference in New Issue
Block a user