fix 3.5 backlight and GT911 for cyd_35r.
TFT_BL was wrongly GPIO21 (GT911 INT); use GPIO27, DRAW_BUF_DIV=20, and export firmware/cyd_35r. 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
42
include/pins.h
Normal file
42
include/pins.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
// Board pins — 2.8" default; 3.5" when CYD_BOARD_3248S035 is set (env:cyd_35r)
|
||||
|
||||
#if defined(CYD_BOARD_3248S035)
|
||||
#define TFT_BL_PIN 27
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 480
|
||||
#define UI_HOR_RES 480
|
||||
#define UI_VER_RES 320
|
||||
/* 3.5C capacitive GT911 (ESP32-3248S035C). GPIO33 is I2C SDA, not TOUCH_CS.
|
||||
* Backlight is GPIO27; INT is GPIO21 — they are NOT the same pin. */
|
||||
#define CYD_GT911_SDA 33
|
||||
#define CYD_GT911_SCL 32
|
||||
#define CYD_GT911_INT 21
|
||||
#define CYD_GT911_RST 25
|
||||
#else
|
||||
#define TFT_BL_PIN 21
|
||||
#define SCREEN_WIDTH 240
|
||||
#define SCREEN_HEIGHT 320
|
||||
#define UI_HOR_RES 320
|
||||
#define UI_VER_RES 240
|
||||
/* 2.8" CYD: dedicated SoftSPI touch bus. */
|
||||
#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
|
||||
#endif
|
||||
|
||||
/* Map 320x240 design coordinates onto the active UI resolution (identity on 2.8"). */
|
||||
#define UX(x) ((int)(((long)(x) * (UI_HOR_RES)) / 320))
|
||||
#define UY(y) ((int)(((long)(y) * (UI_VER_RES)) / 240))
|
||||
#define UW(w) UX(w)
|
||||
#define UH(h) UY(h)
|
||||
|
||||
/* Partial frame buffer: 3.5 needs smaller ratio to fit DRAM. */
|
||||
#if defined(CYD_BOARD_3248S035)
|
||||
#define DRAW_BUF_DIV 20
|
||||
#else
|
||||
#define DRAW_BUF_DIV 10
|
||||
#endif
|
||||
7
include/touch.h
Normal file
7
include/touch.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void touch_init();
|
||||
void touch_read_cb(lv_indev_t *indev, lv_indev_data_t *data);
|
||||
82
include/wifi_prov.h
Normal file
82
include/wifi_prov.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* 通用 WiFi 配网核心(无 LVGL 依赖)
|
||||
*
|
||||
* 流程:
|
||||
* 1. wifi_prov_begin() 读 NVS,有凭证则尝试 STA 连接
|
||||
* 2. 失败 / 无凭证 → 业务层开屏上 UI 或 SoftAP 门户
|
||||
* 3. wifi_prov_save() + wifi_prov_connect_to() 完成配网
|
||||
* 4. loop 里调用 wifi_prov_loop() 做断线重连与门户处理
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#ifndef WIFI_PROV_AP_SSID
|
||||
#define WIFI_PROV_AP_SSID "CYD-Setup"
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_PROV_CONNECT_TIMEOUT_MS
|
||||
#define WIFI_PROV_CONNECT_TIMEOUT_MS 20000u
|
||||
#endif
|
||||
|
||||
#ifndef WIFI_PROV_RECONNECT_MS
|
||||
#define WIFI_PROV_RECONNECT_MS 8000u
|
||||
#endif
|
||||
|
||||
static constexpr int WIFI_PROV_MAX_SCAN = 16;
|
||||
static constexpr size_t WIFI_PROV_SSID_MAX = 32;
|
||||
static constexpr size_t WIFI_PROV_PASS_MAX = 64;
|
||||
|
||||
struct WifiScanItem {
|
||||
char ssid[WIFI_PROV_SSID_MAX + 1];
|
||||
int32_t rssi;
|
||||
wifi_auth_mode_t auth;
|
||||
};
|
||||
|
||||
enum WifiProvState : uint8_t {
|
||||
WIFI_PROV_IDLE = 0,
|
||||
WIFI_PROV_CONNECTING,
|
||||
WIFI_PROV_CONNECTED,
|
||||
WIFI_PROV_FAILED,
|
||||
WIFI_PROV_PORTAL,
|
||||
};
|
||||
|
||||
using WifiProvStateCb = void (*)(WifiProvState state, void *user);
|
||||
|
||||
void wifi_prov_set_state_cb(WifiProvStateCb cb, void *user = nullptr);
|
||||
|
||||
/** 初始化 Preferences + WiFi STA;有凭证则异步开始连接。返回是否已有凭证。 */
|
||||
bool wifi_prov_begin();
|
||||
|
||||
bool wifi_prov_has_credentials();
|
||||
bool wifi_prov_is_connected();
|
||||
WifiProvState wifi_prov_state();
|
||||
|
||||
String wifi_prov_ssid();
|
||||
String wifi_prov_ip();
|
||||
int8_t wifi_prov_rssi();
|
||||
|
||||
void wifi_prov_save(const char *ssid, const char *password);
|
||||
void wifi_prov_clear();
|
||||
|
||||
/** 用已存凭证连接(异步,结果看 wifi_prov_loop / state) */
|
||||
void wifi_prov_connect_saved();
|
||||
|
||||
/** 连接指定网络并在成功后写入 NVS */
|
||||
void wifi_prov_connect_to(const char *ssid, const char *password);
|
||||
|
||||
/** 同步扫描,结果写入 out[],返回条数(≤ WIFI_PROV_MAX_SCAN) */
|
||||
int wifi_prov_scan(WifiScanItem *out, int max_items);
|
||||
|
||||
/**
|
||||
* SoftAP + 简易 Captive Portal(手机连 CYD-Setup → http://192.168.4.1)
|
||||
* 与屏上配网可并行;配网成功后会自动 stop。
|
||||
*/
|
||||
void wifi_prov_portal_start(const char *ap_ssid = WIFI_PROV_AP_SSID);
|
||||
void wifi_prov_portal_stop();
|
||||
bool wifi_prov_portal_active();
|
||||
|
||||
/** 每 loop 调用:重连、门户 HTTP、状态回调 */
|
||||
void wifi_prov_loop();
|
||||
17
include/wifi_ui.h
Normal file
17
include/wifi_ui.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* LVGL 屏上配网 UI(依赖 wifi_prov)
|
||||
* 复用:拷贝 wifi_ui.* + 在业务里 wifi_ui_create() / wifi_ui_tick()
|
||||
*/
|
||||
|
||||
void wifi_ui_create();
|
||||
void wifi_ui_tick();
|
||||
|
||||
/** 强制进入配网页(改密 / 首次) */
|
||||
void wifi_ui_show_setup();
|
||||
|
||||
/** 显示已连接状态页 */
|
||||
void wifi_ui_show_status();
|
||||
|
||||
bool wifi_ui_is_setup();
|
||||
Reference in New Issue
Block a user