mirror of
https://github.com/fsender/readguy.git
synced 2025-12-10 12:08:13 +08:00
feat: user pin-config data & button lib
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
## Release 1.3.7 - 2024/3/11
|
||||||
|
|
||||||
|
1. 配网页面, 增加了用户引脚数据 (可以配置其他功能的引脚. 此功能似乎是为了准备给esp32s3用sdmmc库驱动sd卡用的)
|
||||||
|
|
||||||
|
2. 增加 `guy_button` 按键库功能的接口函数
|
||||||
|
|
||||||
|
3. 修复部分bug
|
||||||
|
|
||||||
## Release 1.3.6 - 2024/3/11
|
## Release 1.3.6 - 2024/3/11
|
||||||
|
|
||||||
1. 按键功能: 正式更新特殊操作按法, 此按法可用于切换输入法或菜单定位等功能. 同时更新ex03演示, 演示更清晰.
|
1. 按键功能: 正式更新特殊操作按法, 此按法可用于切换输入法或菜单定位等功能. 同时更新ex03演示, 演示更清晰.
|
||||||
|
|||||||
26
README.md
26
README.md
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<img src="extra/artset/readguy_theme3.png" width="30%" height="auto">
|
<img src="extra/artset/readguy_theme3.png" width="30%" height="auto">
|
||||||
|
|
||||||
**版本1.3.6正式发布!欢迎分享、star和fork~** 上面的图是项目看板娘, 盖. 可爱的盖姐在等你哟~
|
**版本1.3.7正式发布!欢迎分享、star和fork~** 上面的图是项目看板娘, 盖. 可爱的盖姐在等你哟~
|
||||||
|
|
||||||
**即将发布7个全新的屏幕驱动: 欢迎支持! (详见后面的驱动表格)**
|
**即将发布7个全新的屏幕驱动: 欢迎支持! (详见后面的驱动表格)**
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ firmware.bin 0x10000
|
|||||||
|
|
||||||
**如果想要使用纯arduino环境, 需要更改platformio.ini, 并将framework更改为`arduino`. 此时可以跳过 5~6 步骤**.
|
**如果想要使用纯arduino环境, 需要更改platformio.ini, 并将framework更改为`arduino`. 此时可以跳过 5~6 步骤**.
|
||||||
|
|
||||||
5. 编译目标是`ESP32`时, 需要单独安装[`LittleFS`](https://github.com/joltwallet/esp_littlefs)库来实现相关功能. 在项目内新建文件夹`components`, 在`components`文件夹内放入刚刚克隆的`LittleFS`库. *详见下图**上**方红框*. (使用纯arduino时跳过此步骤)
|
5. 编译目标是`ESP32`且使用`ESP-IDF arduino component`时, 需要单独安装[`LittleFS`](https://github.com/joltwallet/esp_littlefs)库来实现相关功能. 在项目内新建文件夹`components`, 在`components`文件夹内放入刚刚克隆的`LittleFS`库. *详见下图**上**方红框*. (使用纯arduino时跳过此步骤)
|
||||||
|
|
||||||
<img src="extra/artset/build_dir_structure.png" width="20%" height="auto">
|
<img src="extra/artset/build_dir_structure.png" width="20%" height="auto">
|
||||||
|
|
||||||
@@ -235,14 +235,32 @@ firmware.bin 0x10000
|
|||||||
|
|
||||||
其中的WiFi功能, 其实是可以禁掉的. 只要你提前配置成功, 那么就可以摆脱WiFi配网配引脚功能.
|
其中的WiFi功能, 其实是可以禁掉的. 只要你提前配置成功, 那么就可以摆脱WiFi配网配引脚功能.
|
||||||
|
|
||||||
使用方法: 打开文件[guy_driver_config.h](src/guy_driver_config.h), 随后便根据注释来选择性的开启或关闭一些系统功能.
|
使用方法: 打开文件[`guy_driver_config.h`](src/guy_driver_config.h), 随后便根据注释来选择性的开启或关闭一些系统功能.
|
||||||
|
|
||||||
**不推荐的做法!**: 其中有些屏幕用不到, 也可以通过`guy_epaper_config`来配置.
|
**不推荐的做法!**: 其中有些屏幕用不到, 也可以通过`guy_epaper_config`来配置.
|
||||||
|
|
||||||
使用方法: 打开文件[guy_epaper_config.h](src/guy_epaper/guy_epaper_config.h), 随后便可以设置不加载哪些屏幕的驱动程序.
|
使用方法: 打开文件[`guy_epaper_config.h`](src/guy_epaper/guy_epaper_config.h), 随后便可以设置不加载哪些屏幕的驱动程序.
|
||||||
|
|
||||||
此操作可以节约flash和RAM消耗, **但是实际上此操作并不能节省太多的flash.** 为确保编译获得的程序兼容性, 应尽量不要更改这个文件.
|
此操作可以节约flash和RAM消耗, **但是实际上此操作并不能节省太多的flash.** 为确保编译获得的程序兼容性, 应尽量不要更改这个文件.
|
||||||
|
|
||||||
|
- 还有一部分功能可以通过更改这两个文件来进行编辑 (如你想自己实现一个SD卡驱动)
|
||||||
|
|
||||||
|
- 但是如果自己更改了WiFi配置引脚的功能, ***这样编译出的程序就不能实现跨硬件运行了***
|
||||||
|
|
||||||
|
*有一些宏定义的组合是没有检验是否能够通过编译的. 如果有问题请提issue或者群里反馈*
|
||||||
|
|
||||||
|
## ESP32 项目配置 (使用 PlatformIO + Arduino as ESP-IDF component 环境)
|
||||||
|
|
||||||
|
menuconfig 内容:
|
||||||
|
|
||||||
|
```
|
||||||
|
FREERTOS_HZ = 1000
|
||||||
|
ESP32_DEFAULT_CPU_FREQ_MHZ = 240
|
||||||
|
ESP32_BROWNOUT_DET_LVL = 0
|
||||||
|
ESP_PHY_REDUCE_TX_POWER=y
|
||||||
|
FATFS_API_ENCODING_UTF_8 = true
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Copyright © 2022-2023 FriendshipEnder. All Rights reserved.
|
Copyright © 2022-2023 FriendshipEnder. All Rights reserved.
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ void setup(){
|
|||||||
//这些服务器响应回调函数会打包进入初始化参数列表中.
|
//这些服务器响应回调函数会打包进入初始化参数列表中.
|
||||||
//上方的字符串可以在用户访问主页时, 显示在主页的第二行.(作为通知显示, 但并不是通知)
|
//上方的字符串可以在用户访问主页时, 显示在主页的第二行.(作为通知显示, 但并不是通知)
|
||||||
guy.println("名称:readguy 密码:12345678");
|
guy.println("名称:readguy 密码:12345678");
|
||||||
|
guy.println("连接后浏览器访问: 192.168.4.1");
|
||||||
guy.display();
|
guy.display();
|
||||||
}
|
}
|
||||||
void loop(){
|
void loop(){
|
||||||
|
|||||||
@@ -55,9 +55,9 @@
|
|||||||
|
|
||||||
ReadguyDriver guy;//新建一个readguy对象, 用于显示驱动.
|
ReadguyDriver guy;//新建一个readguy对象, 用于显示驱动.
|
||||||
|
|
||||||
extern const uint8_t ctg_wqy9pt_chinese1[]; //声明中文字体文件
|
extern const uint8_t ctg_u8g2_wqy12_chinese1[]; //声明中文字体文件
|
||||||
|
|
||||||
const lgfx::U8g2font cn_font(ctg_wqy9pt_chinese1); //U8G2格式中文字体转化为LGFX格式字体
|
const lgfx::U8g2font cn_font(ctg_u8g2_wqy12_chinese1); //U8G2格式中文字体转化为LGFX格式字体
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/fsender/readguy"
|
"url": "https://github.com/fsender/readguy"
|
||||||
},
|
},
|
||||||
"version": "1.3.6",
|
"version": "1.3.7",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": ["espressif32", "espressif8266"],
|
"platforms": ["espressif32", "espressif8266"],
|
||||||
"headers": "readguy.h",
|
"headers": "readguy.h",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name=readguy
|
name=readguy
|
||||||
version=1.3.6
|
version=1.3.7
|
||||||
author=fsender <f_ender@163.com>
|
author=fsender <f_ender@163.com>
|
||||||
maintainer=fsender <f_ender@163.com>
|
maintainer=fsender <f_ender@163.com>
|
||||||
sentence=A free E-paper display driver library supports 16-level greyscale.
|
sentence=A free E-paper display driver library supports 16-level greyscale.
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ void guy_button::begin(uint8_t _pin, std_U8_function_U8 f, bool activeLow/*=true
|
|||||||
pin = _pin;
|
pin = _pin;
|
||||||
state = get_state_cb(pin);
|
state = get_state_cb(pin);
|
||||||
min_debounce =25; //去抖时间
|
min_debounce =25; //去抖时间
|
||||||
long_press_ms =300; //长按持续时间+双击识别间隔最大时间
|
long_press_ms =300; //长按持续时间
|
||||||
|
double_press_ms =300; //双击识别间隔最大时间
|
||||||
long_repeat_ms =200; //长按连按间隔时间
|
long_repeat_ms =200; //长按连按间隔时间
|
||||||
scanDT =1; // =1识别双击或三击, =0则不识别双击或三击等需要延时返回的情况
|
scanDT =1; // =1识别双击或三击, =0则不识别双击或三击等需要延时返回的情况
|
||||||
lk=0;
|
lk=0;
|
||||||
@@ -144,7 +145,7 @@ void guy_button::loop() {
|
|||||||
longclick_detected = true;
|
longclick_detected = true;
|
||||||
}
|
}
|
||||||
// is the button released and the time has passed for multiple clicks?
|
// is the button released and the time has passed for multiple clicks?
|
||||||
} else if (now - click_ms > (scanDT?long_press_ms:min_debounce)) {
|
} else if (now - click_ms > (scanDT?double_press_ms:min_debounce)) {
|
||||||
// was there a longclick?
|
// was there a longclick?
|
||||||
if (longclick_detected) {
|
if (longclick_detected) {
|
||||||
// was it part of a combination?
|
// was it part of a combination?
|
||||||
|
|||||||
@@ -71,20 +71,21 @@ SOFTWARE.
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#define GUYBUTTON_empty 0
|
#define GUYBUTTON_empty 0 //没按下
|
||||||
#define GUYBUTTON_single_click 1
|
#define GUYBUTTON_single_click 1 //单击
|
||||||
#define GUYBUTTON_double_click 2
|
#define GUYBUTTON_double_click 2 //双击
|
||||||
#define GUYBUTTON_triple_click 3
|
#define GUYBUTTON_triple_click 3 //三击
|
||||||
#define GUYBUTTON_long_click 4
|
#define GUYBUTTON_long_click 4 //长按
|
||||||
#define GUYBUTTON_xlong_click 5
|
#define GUYBUTTON_xlong_click 5 //点击后接长按
|
||||||
#define GUYBUTTON_xxlong_click 6
|
#define GUYBUTTON_xxlong_click 6 //双击后接长按
|
||||||
#define GUYBTN_READ_TIMEOUT 100
|
#define GUYBTN_READ_TIMEOUT 100 //读取延时
|
||||||
#define GUYBTN_LOOP_TIMEOUT 10
|
#define GUYBTN_LOOP_TIMEOUT 10 //循环扫描延时
|
||||||
|
|
||||||
class guy_button{
|
class guy_button{
|
||||||
public:
|
public:
|
||||||
uint16_t min_debounce ; //去抖时间
|
uint16_t min_debounce ; //去抖时间
|
||||||
uint16_t long_press_ms ; //长按持续时间+双击识别间隔最大时间
|
uint16_t long_press_ms ; //长按持续时间
|
||||||
|
uint16_t double_press_ms ; //双击识别间隔最大时间
|
||||||
uint16_t long_repeat_ms ; //长按连按间隔时间
|
uint16_t long_repeat_ms ; //长按连按间隔时间
|
||||||
protected:
|
protected:
|
||||||
uint8_t pin = 255; //未定义引脚
|
uint8_t pin = 255; //未定义引脚
|
||||||
@@ -113,16 +114,39 @@ class guy_button{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
guy_button();
|
guy_button();
|
||||||
|
/// @brief 初始化
|
||||||
|
/// @param _pin 引脚ID. 传入的引脚在内部将会使用digitalRead函数实现
|
||||||
|
/// @param activeLow 设置为true时, 当读取到低电平视为按下
|
||||||
|
void begin(uint8_t _pin, bool activeLow = true){
|
||||||
|
begin(_pin,[](uint8_t p)->uint8_t { return digitalRead(p); },activeLow);
|
||||||
|
}
|
||||||
|
/// @brief 初始化
|
||||||
|
/// @param _pin 引脚ID. 传入的引脚在内部将会使用digitalRead函数实现
|
||||||
|
/// @param f 触发函数: 当activeLow为false时, 返回1表示按下, 0表示没按下 为true时相反
|
||||||
|
/// @note 默认的 f 是 匿名函数 [](uint8_t p)->uint8_t { return digitalRead(p); }
|
||||||
|
/// 如果自己指定了函数而且没有用到内置的参数, 那么 _pin 参数可能是没有任何用处的
|
||||||
void begin(uint8_t _pin, std_U8_function_U8 f, bool activeLow = true);
|
void begin(uint8_t _pin, std_U8_function_U8 f, bool activeLow = true);
|
||||||
|
/// @brief 设置长按连按触发模式
|
||||||
|
/// @param trigMode 0:单次长按 1:连续长按
|
||||||
void setLongRepeatMode(bool trigMode) { trig_mode = trigMode; }
|
void setLongRepeatMode(bool trigMode) { trig_mode = trigMode; }
|
||||||
|
/// @brief 长按了多久按钮
|
||||||
unsigned int wasPressedFor() const { return down_time_ms; }
|
unsigned int wasPressedFor() const { return down_time_ms; }
|
||||||
|
/// @brief 返回是否处于被按下的状态 受loop扫描的限制, 如果没loop扫描则可以先手动调用扫描后使用
|
||||||
bool isPressed() const { return (state == _pressedState); }
|
bool isPressed() const { return (state == _pressedState); }
|
||||||
|
/// @brief 读取原始的按钮状态 (不去抖动), 此函数不受loop扫描的限制
|
||||||
bool isPressedRaw(); // { return (get_state_cb(pin) == _pressedState); }
|
bool isPressedRaw(); // { return (get_state_cb(pin) == _pressedState); }
|
||||||
|
/// @brief 曾经按下的状态 是否是点击后立即松开
|
||||||
bool wasPressed(){ if(was_pressed){ was_pressed = false; return true; } return false; }
|
bool wasPressed(){ if(was_pressed){ was_pressed = false; return true; } return false; }
|
||||||
|
/// @brief 连击了几下
|
||||||
uint8_t getNumberOfClicks() const{ return click_count;}
|
uint8_t getNumberOfClicks() const{ return click_count;}
|
||||||
|
/// @brief [已经弃用] 获取上次按钮的按下数据. 返回按钮状态(按钮状态参考read函数的说明)
|
||||||
uint8_t getType() const { return last_click_type; }
|
uint8_t getType() const { return last_click_type; }
|
||||||
|
/// @brief 读取按钮的按下数据. 返回按钮状态 0没按 1单击 2双击 3三击 4长按 5点击后长按 6双击后长按
|
||||||
uint8_t read();
|
uint8_t read();
|
||||||
|
/// @brief 连续循环扫描按钮. 必须多次反复调用, 最好是单独开一个task来实现
|
||||||
void loop();
|
void loop();
|
||||||
|
/// @brief 设置是否识别双击 三连击等高级手势
|
||||||
|
/// @param scan =1识别双击或三击, =0则不识别双击或三击等需要延时返回的情况
|
||||||
void enScanDT(uint8_t scan) { scanDT = scan; }
|
void enScanDT(uint8_t scan) { scanDT = scan; }
|
||||||
/* void setMinDebounce(short n) { min_debounce =n;} //去抖时间
|
/* void setMinDebounce(short n) { min_debounce =n;} //去抖时间
|
||||||
void setLongPressMs(short n) { long_press_ms =n;} //长按持续时间+双击识别间隔最大时间
|
void setLongPressMs(short n) { long_press_ms =n;} //长按持续时间+双击识别间隔最大时间
|
||||||
|
|||||||
@@ -73,9 +73,10 @@
|
|||||||
#define READGUY_ENABLE_WIFI
|
#define READGUY_ENABLE_WIFI
|
||||||
|
|
||||||
/// @brief 启用I2C功能. 可用于联网时钟, 温度计, 陀螺仪等外设. 目前暂不支持库内使用类似函数. 仅可以提供引脚定义
|
/// @brief 启用I2C功能. 可用于联网时钟, 温度计, 陀螺仪等外设. 目前暂不支持库内使用类似函数. 仅可以提供引脚定义
|
||||||
#define READGUY_ENABLE_I2C
|
//#define READGUY_ENABLE_I2C
|
||||||
|
/// @note 现在库不提供任何I2C驱动, 只提供引脚定义的存储和读取, 这几乎不增加多少代码. 因此本宏不再使用
|
||||||
|
|
||||||
/** @brief (即将推出) 启用SD卡功能. 开启此功能将会使用内置SD卡管理功能. 关闭后仅可保存SD卡用到的引脚.
|
/** @brief 启用SD卡功能. 开启此功能将会使用内置SD卡管理功能. 关闭后仅可保存SD卡用到的引脚.
|
||||||
@note 会破坏兼容性. 若没有启用通用的SD卡驱动程序, 那么那些跨屏台编译的程序将无法用guyFS读取到SD卡.
|
@note 会破坏兼容性. 若没有启用通用的SD卡驱动程序, 那么那些跨屏台编译的程序将无法用guyFS读取到SD卡.
|
||||||
若用户程序希望能从外部加载SD卡, 可以使用getSdMiso()等函数获取SD卡的Miso等引脚, 再由用户程序初始化SD卡. */
|
若用户程序希望能从外部加载SD卡, 可以使用getSdMiso()等函数获取SD卡的Miso等引脚, 再由用户程序初始化SD卡. */
|
||||||
#define READGUY_ENABLE_SD
|
#define READGUY_ENABLE_SD
|
||||||
@@ -83,9 +84,13 @@
|
|||||||
/// @brief 使用LittleFS作为片上文件系统, 注释此行则用SPIFFS(功能少, 不好用)
|
/// @brief 使用LittleFS作为片上文件系统, 注释此行则用SPIFFS(功能少, 不好用)
|
||||||
#define READGUY_USE_LITTLEFS 1
|
#define READGUY_USE_LITTLEFS 1
|
||||||
|
|
||||||
|
/// @brief 使用esp8266时, EEPROM(类似NVS)的存储位置起点 (从起点开始的40字节被readguy所使用) 可选值: 0~4045
|
||||||
|
/// @note 对于单一项目来说, 此选项不建议更改, 请在项目初期就确定此变量的值.
|
||||||
|
#define READGUY_ESP8266_EEPROM_OFFSET 2
|
||||||
|
|
||||||
/// @brief ESP32按键服务任务的栈空间大小, 不建议普通用户更改. 默认值1024字节. 小于此大小会使程序栈溢出.
|
/// @brief ESP32按键服务任务的栈空间大小, 不建议普通用户更改. 默认值1024字节. 小于此大小会使程序栈溢出.
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32S3
|
#ifdef CONFIG_IDF_TARGET_ESP32S3
|
||||||
#define BTN_LOOPTASK_STACK 1280
|
#define BTN_LOOPTASK_STACK 1536
|
||||||
#else
|
#else
|
||||||
#define BTN_LOOPTASK_STACK 1024
|
#define BTN_LOOPTASK_STACK 1024
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,9 +41,9 @@
|
|||||||
//另外, 在提交新版本之前, 不要忘记在github上创建release, 否则Arduino IDE会读不到
|
//另外, 在提交新版本之前, 不要忘记在github上创建release, 否则Arduino IDE会读不到
|
||||||
#define READGUY_V_MAJOR 1
|
#define READGUY_V_MAJOR 1
|
||||||
#define READGUY_V_MINOR 3
|
#define READGUY_V_MINOR 3
|
||||||
#define READGUY_V_PATCH 6
|
#define READGUY_V_PATCH 7
|
||||||
#define READGUY_VERSION_VAL (READGUY_V_MAJOR*1000+READGUY_V_MINOR*100+READGUY_V_PATCH*10)
|
#define READGUY_VERSION_VAL (READGUY_V_MAJOR*1000+READGUY_V_MINOR*100+READGUY_V_PATCH*10)
|
||||||
#define READGUY_VERSION "1.3.6"
|
#define READGUY_VERSION "1.3.7"
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define _READGUY_PLATFORM "ESP8266"
|
#define _READGUY_PLATFORM "ESP8266"
|
||||||
|
|||||||
@@ -33,10 +33,10 @@
|
|||||||
static const PROGMEM char NOT_SUPPORTED[] = "(不支持此屏幕)";
|
static const PROGMEM char NOT_SUPPORTED[] = "(不支持此屏幕)";
|
||||||
static const PROGMEM char TEXT_HTML[] = "text/html";
|
static const PROGMEM char TEXT_HTML[] = "text/html";
|
||||||
static const PROGMEM char TEXT_PLAIN [] = "text/plain";
|
static const PROGMEM char TEXT_PLAIN [] = "text/plain";
|
||||||
static const PROGMEM char args_name[23][8]={
|
static const PROGMEM char args_name[24][8]={
|
||||||
"share","epdtype","EpdMOSI","EpdSCLK","Epd_CS","Epd_DC","Epd_RST","EpdBusy",
|
"share","epdtype","EpdMOSI","EpdSCLK","Epd_CS","Epd_DC","Epd_RST","EpdBusy",
|
||||||
"SD_MISO","SD_MOSI","SD_SCLK","SD_CS","I2C_SDA","I2C_SCL",
|
"SD_MISO","SD_MOSI","SD_SCLK","SD_CS","I2C_SDA","I2C_SCL",
|
||||||
"btn_cnt","btn1","btn1c","btn2","btn2c","btn3","btn3c","bklight","rtc"
|
"btn_cnt","btn1","btn1c","btn2","btn2c","btn3","btn3c","bklight","rtc","user"
|
||||||
};
|
};
|
||||||
#ifdef READGUY_DEV_154A
|
#ifdef READGUY_DEV_154A
|
||||||
static const PROGMEM char NAME_guyDev154[]="1.54寸标准";
|
static const PROGMEM char NAME_guyDev154[]="1.54寸标准";
|
||||||
@@ -300,12 +300,14 @@ void ReadguyDriver::handleInitPost(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
config_data[0]=1; //默认只要运行到此处, 就已经初始化好了的
|
config_data[0]=1; //默认只要运行到此处, 就已经初始化好了的
|
||||||
for(int i=0;i<23;i++){
|
for(int i=0;i<33;i++){
|
||||||
Serial.print(F("Argument "));
|
Serial.print(F("Argument "));
|
||||||
Serial.print(FPSTR(args_name[i]));
|
String a_name = String(FPSTR(args_name[23])) + (i-22);
|
||||||
|
if(i<=22) a_name = FPSTR(args_name[i]);
|
||||||
|
Serial.print(a_name);
|
||||||
Serial.write(':');
|
Serial.write(':');
|
||||||
if(sv.hasArg(FPSTR(args_name[i]))) {
|
if(sv.hasArg(a_name)) {
|
||||||
Serial.println(sv.arg(FPSTR(args_name[i])));
|
Serial.println(sv.arg(a_name));
|
||||||
if(i<14){ //这12个引脚是不可以重复的, 如果有重复, config_data[0]设为0
|
if(i<14){ //这12个引脚是不可以重复的, 如果有重复, config_data[0]设为0
|
||||||
config_data[i+1] = sv.arg(FPSTR(args_name[i])).toInt();
|
config_data[i+1] = sv.arg(FPSTR(args_name[i])).toInt();
|
||||||
}
|
}
|
||||||
@@ -318,6 +320,9 @@ void ReadguyDriver::handleInitPost(){
|
|||||||
else if(i==20&&btn_count_>2) config_data[17]=-config_data[17];
|
else if(i==20&&btn_count_>2) config_data[17]=-config_data[17];
|
||||||
else if(i==21) config_data[18] = sv.arg(FPSTR(args_name[21])).toInt();
|
else if(i==21) config_data[18] = sv.arg(FPSTR(args_name[21])).toInt();
|
||||||
else if(i==22) config_data[19] = sv.arg(FPSTR(args_name[22])).toInt(); //保留RTC功能
|
else if(i==22) config_data[19] = sv.arg(FPSTR(args_name[22])).toInt(); //保留RTC功能
|
||||||
|
else if(i>22){ //用户数据
|
||||||
|
config_data[i-1] = sv.arg(a_name).toInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.write('\n');
|
Serial.write('\n');
|
||||||
@@ -535,7 +540,7 @@ void ReadguyDriver::handlePinSetup(){
|
|||||||
s += FPSTR(args_name[i+2]);
|
s += FPSTR(args_name[i+2]);
|
||||||
s += FPSTR(index_cn_html3);
|
s += FPSTR(index_cn_html3);
|
||||||
s += FPSTR(args_name[i+2]);
|
s += FPSTR(args_name[i+2]);
|
||||||
s += ("\" min=\"-1\" max=\"99\" step=\"1\" value=\"");
|
s += F("\" min=\"-1\" max=\"99\" step=\"1\" value=\"");
|
||||||
s += (READGUY_cali?(int)config_data[i+3] :-1);
|
s += (READGUY_cali?(int)config_data[i+3] :-1);
|
||||||
s += F("\"/>");
|
s += F("\"/>");
|
||||||
}
|
}
|
||||||
@@ -562,6 +567,17 @@ void ReadguyDriver::handlePinSetup(){
|
|||||||
if(i==3) s += (READGUY_cali?(int)READGUY_bl_pin :-1);
|
if(i==3) s += (READGUY_cali?(int)READGUY_bl_pin :-1);
|
||||||
else s += ((READGUY_cali && config_data[15+i])?(int)abs(config_data[15+i])-1:-1);
|
else s += ((READGUY_cali && config_data[15+i])?(int)abs(config_data[15+i])-1:-1);
|
||||||
}
|
}
|
||||||
|
for(int i=0;i<10;i++){
|
||||||
|
s += F("\"/><br/>用户数据 ");
|
||||||
|
s += (i+1);
|
||||||
|
s += F("<input type=\"number\" id=\"user");
|
||||||
|
s += (i+1);
|
||||||
|
s += FPSTR(index_cn_html3);
|
||||||
|
s += ("user");
|
||||||
|
s += (i+1);
|
||||||
|
s += F("\" min=\"-1\" max=\"99\" step=\"1\" value=\"");
|
||||||
|
s += (READGUY_cali?(int)config_data[i+22] :-1);
|
||||||
|
} //---------------------------------此部分代码需要配合硬件测试 + 查看网页源代码 才可以实现
|
||||||
s += FPSTR(index_cn_html16); //s += (READGUY_cali?(int)0 :-1);
|
s += FPSTR(index_cn_html16); //s += (READGUY_cali?(int)0 :-1);
|
||||||
sv.send_P(200, TEXT_HTML, (s+FPSTR(end_html)).c_str());
|
sv.send_P(200, TEXT_HTML, (s+FPSTR(end_html)).c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const PROGMEM char ReadguyDriver::projname[8] = "readguy";
|
|||||||
const PROGMEM char ReadguyDriver::tagname[7] = "hwconf";
|
const PROGMEM char ReadguyDriver::tagname[7] = "hwconf";
|
||||||
volatile uint8_t ReadguyDriver::spibz=0;
|
volatile uint8_t ReadguyDriver::spibz=0;
|
||||||
#ifndef DYNAMIC_PIN_SETTINGS
|
#ifndef DYNAMIC_PIN_SETTINGS
|
||||||
const int8_t ReadguyDriver::config_data[22] = {
|
const int8_t ReadguyDriver::config_data[32] = {
|
||||||
127 , //READGUY_cali
|
127 , //READGUY_cali
|
||||||
READGUY_shareSpi ,
|
READGUY_shareSpi ,
|
||||||
READGUY_epd_type ,// 对应的epd驱动程序代号, -1为未指定
|
READGUY_epd_type ,// 对应的epd驱动程序代号, -1为未指定
|
||||||
@@ -51,10 +51,10 @@ const int8_t ReadguyDriver::config_data[22] = {
|
|||||||
READGUY_epd_rst ,// 目标显示器的 RST 引脚
|
READGUY_epd_rst ,// 目标显示器的 RST 引脚
|
||||||
READGUY_epd_busy ,// 目标显示器的 BUSY 引脚
|
READGUY_epd_busy ,// 目标显示器的 BUSY 引脚
|
||||||
//sd卡驱动部分, 默认使用hspi (sd卡建议用hspi)
|
//sd卡驱动部分, 默认使用hspi (sd卡建议用hspi)
|
||||||
READGUY_sd_miso ,// 目标sd卡的 MISO 引脚, sd_share_spi == 1 时无效
|
READGUY_sd_miso ,// 目标sd卡的 MISO 引脚, 或esp32s3使用SDIO的 DAT0 引脚, sd_share_spi == 1 时无效
|
||||||
READGUY_sd_mosi ,// 目标sd卡的 MOSI 引脚, sd_share_spi == 1 时无效
|
READGUY_sd_mosi ,// 目标sd卡的 MOSI 引脚, 或esp32s3使用SDIO的 CMD 引脚, sd_share_spi == 1 时无效
|
||||||
READGUY_sd_sclk ,// 目标sd卡的 SCLK 引脚, sd_share_spi == 1 时无效
|
READGUY_sd_sclk ,// 目标sd卡的 SCLK 引脚, 或esp32s3使用SDIO的 CLK 引脚, sd_share_spi == 1 时无效
|
||||||
READGUY_sd_cs ,// 目标sd卡的 CS 引脚.
|
READGUY_sd_cs ,// 目标sd卡的 CS 引脚, 或esp32s3使用SDIO的 DAT3 引脚,
|
||||||
READGUY_i2c_sda ,// 目标i2c总线的SDA引脚, 当且仅当启用i2c总线时才生效
|
READGUY_i2c_sda ,// 目标i2c总线的SDA引脚, 当且仅当启用i2c总线时才生效
|
||||||
READGUY_i2c_scl ,// 目标i2c总线的SCL引脚, 当且仅当启用i2c总线时才生效
|
READGUY_i2c_scl ,// 目标i2c总线的SCL引脚, 当且仅当启用i2c总线时才生效
|
||||||
//按键驱动部分, 为负代表高触发, 否则低触发,
|
//按键驱动部分, 为负代表高触发, 否则低触发,
|
||||||
@@ -65,7 +65,10 @@ const int8_t ReadguyDriver::config_data[22] = {
|
|||||||
READGUY_bl_pin ,//前置光接口引脚IO
|
READGUY_bl_pin ,//前置光接口引脚IO
|
||||||
READGUY_rtc_type ,//使用的RTC型号(待定, 还没用上)
|
READGUY_rtc_type ,//使用的RTC型号(待定, 还没用上)
|
||||||
0 ,//READGUY_sd_ok SD卡已经成功初始化
|
0 ,//READGUY_sd_ok SD卡已经成功初始化
|
||||||
0 //READGUY_buttons 按钮个数, 0-3都有可能
|
0 ,//READGUY_buttons 按钮个数, 0-3都有可能
|
||||||
|
-1, //用户自定义变量 同时用于esp32s3使用SDIO卡数据的DAT1 为-1代表不使用SDIO
|
||||||
|
-1, //用户自定义变量 同时用于esp32s3使用SDIO卡数据的DAT2
|
||||||
|
-1,-1,-1,-1,-1,-1,-1,-1 //user data 区域, 此功能没啥用就暂时全设定为-1了
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
@@ -414,12 +417,14 @@ void ReadguyDriver::setButtonDriver(){
|
|||||||
btn_rd[1].setLongRepeatMode(0); //双按键 确定按键 设置为不允许连按
|
btn_rd[1].setLongRepeatMode(0); //双按键 确定按键 设置为不允许连按
|
||||||
}
|
}
|
||||||
else if(READGUY_buttons==3){
|
else if(READGUY_buttons==3){
|
||||||
btn_rd[0].long_press_ms = 20; //不识别双击三击, 只有按一下或者长按, 并且开启连按
|
btn_rd[0].long_press_ms = 20; //只有长按, 按一下也是长按,
|
||||||
//btn_rd[0].setLongRepeatMode(1);
|
btn_rd[0].double_press_ms = 20; //不识别双击三击,
|
||||||
|
btn_rd[0].setLongRepeatMode(1); //并且开启连按
|
||||||
btn_rd[1].enScanDT(0); //不识别双击或三击(默认) 2024/2/25更新:需要支持连按适配拨轮
|
btn_rd[1].enScanDT(0); //不识别双击或三击(默认) 2024/2/25更新:需要支持连按适配拨轮
|
||||||
btn_rd[1].setLongRepeatMode(0); //三按键 确定按键 设置为不允许连按
|
btn_rd[1].setLongRepeatMode(0); //三按键 确定按键 设置为不允许连按
|
||||||
btn_rd[2].long_press_ms = 20; //不识别双击三击, 只有按一下或者长按, 并且开启连按
|
btn_rd[2].long_press_ms = 20; //只有长按, 按一下也是长按, 并且开启连按
|
||||||
btn_rd[2].setLongRepeatMode(1);
|
btn_rd[2].double_press_ms = 20; //不识别双击三击,
|
||||||
|
btn_rd[2].setLongRepeatMode(1); //并且开启连按
|
||||||
}
|
}
|
||||||
#ifdef ESP8266 //对于esp8266, 需要注册到ticker. 这是因为没freertos.
|
#ifdef ESP8266 //对于esp8266, 需要注册到ticker. 这是因为没freertos.
|
||||||
btnTask.attach_ms(BTN_LOOPTASK_DELAY,looptask);
|
btnTask.attach_ms(BTN_LOOPTASK_DELAY,looptask);
|
||||||
@@ -588,7 +593,7 @@ void ReadguyDriver::nvs_write(){
|
|||||||
}
|
}
|
||||||
#elif (defined(ESP8266))
|
#elif (defined(ESP8266))
|
||||||
void ReadguyDriver::nvs_init(){
|
void ReadguyDriver::nvs_init(){
|
||||||
EEPROM.begin(32);
|
EEPROM.begin(sizeof(config_data)+8+READGUY_ESP8266_EEPROM_OFFSET);
|
||||||
}
|
}
|
||||||
void ReadguyDriver::nvs_deinit(){
|
void ReadguyDriver::nvs_deinit(){
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
@@ -601,7 +606,7 @@ bool ReadguyDriver::nvs_read(){
|
|||||||
sizeof(config_data)+
|
sizeof(config_data)+
|
||||||
#endif
|
#endif
|
||||||
8;i++){
|
8;i++){
|
||||||
int8_t rd=(int8_t)EEPROM.read(2+i);
|
int8_t rd=(int8_t)EEPROM.read(READGUY_ESP8266_EEPROM_OFFSET+i);
|
||||||
#ifdef DYNAMIC_PIN_SETTINGS
|
#ifdef DYNAMIC_PIN_SETTINGS
|
||||||
if(i>=8) config_data[i-8] = rd;
|
if(i>=8) config_data[i-8] = rd;
|
||||||
else
|
else
|
||||||
@@ -613,7 +618,7 @@ bool ReadguyDriver::nvs_read(){
|
|||||||
}
|
}
|
||||||
void ReadguyDriver::nvs_write(){
|
void ReadguyDriver::nvs_write(){
|
||||||
for(unsigned int i=0;i<sizeof(config_data)+8;i++){
|
for(unsigned int i=0;i<sizeof(config_data)+8;i++){
|
||||||
EEPROM.write(2+i,(uint8_t)(i<8?pgm_read_byte(projname+i):config_data[i-8]));
|
EEPROM.write(READGUY_ESP8266_EEPROM_OFFSET+i,(uint8_t)(i<8?pgm_read_byte(projname+i):config_data[i-8]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -139,10 +139,10 @@
|
|||||||
#define READGUY_epd_rst (config_data[7]) // 目标显示器的 RST 引脚
|
#define READGUY_epd_rst (config_data[7]) // 目标显示器的 RST 引脚
|
||||||
#define READGUY_epd_busy (config_data[8]) // 目标显示器的 BUSY 引脚
|
#define READGUY_epd_busy (config_data[8]) // 目标显示器的 BUSY 引脚
|
||||||
//sd卡驱动部分, 默认使用hspi (sd卡建议用hspi)
|
//sd卡驱动部分, 默认使用hspi (sd卡建议用hspi)
|
||||||
#define READGUY_sd_miso (config_data[9]) // 目标sd卡的 MISO 引脚, sd_share_spi == 1 时无效
|
#define READGUY_sd_miso (config_data[9]) // 目标sd卡的 MISO 引脚, 或esp32s3使用SDIO的 DAT0 引脚, sd_share_spi == 1 时无效
|
||||||
#define READGUY_sd_mosi (config_data[10])// 目标sd卡的 MOSI 引脚, sd_share_spi == 1 时无效
|
#define READGUY_sd_mosi (config_data[10])// 目标sd卡的 MOSI 引脚, 或esp32s3使用SDIO的 CMD 引脚, sd_share_spi == 1 时无效
|
||||||
#define READGUY_sd_sclk (config_data[11])// 目标sd卡的 SCLK 引脚, sd_share_spi == 1 时无效
|
#define READGUY_sd_sclk (config_data[11])// 目标sd卡的 SCLK 引脚, 或esp32s3使用SDIO的 CLK 引脚, sd_share_spi == 1 时无效
|
||||||
#define READGUY_sd_cs (config_data[12])// 目标sd卡的 CS 引脚.
|
#define READGUY_sd_cs (config_data[12])// 目标sd卡的 CS 引脚, 或esp32s3使用SDIO的 DAT3 引脚
|
||||||
#define READGUY_i2c_sda (config_data[13])// 目标i2c总线的SDA引脚, 当且仅当启用i2c总线时才生效
|
#define READGUY_i2c_sda (config_data[13])// 目标i2c总线的SDA引脚, 当且仅当启用i2c总线时才生效
|
||||||
#define READGUY_i2c_scl (config_data[14])// 目标i2c总线的SCL引脚, 当且仅当启用i2c总线时才生效
|
#define READGUY_i2c_scl (config_data[14])// 目标i2c总线的SCL引脚, 当且仅当启用i2c总线时才生效
|
||||||
//按键驱动部分, 为负代表高触发, 否则低触发,
|
//按键驱动部分, 为负代表高触发, 否则低触发,
|
||||||
@@ -154,6 +154,17 @@
|
|||||||
#define READGUY_rtc_type (config_data[19])//使用的RTC型号(待定, 还没用上)
|
#define READGUY_rtc_type (config_data[19])//使用的RTC型号(待定, 还没用上)
|
||||||
#define READGUY_sd_ok (config_data[20]) //SD卡已经成功初始化
|
#define READGUY_sd_ok (config_data[20]) //SD卡已经成功初始化
|
||||||
#define READGUY_buttons (config_data[21]) //按钮个数, 0-3都有可能
|
#define READGUY_buttons (config_data[21]) //按钮个数, 0-3都有可能
|
||||||
|
|
||||||
|
#define READGUY_user1 (config_data[22]) //用户自定义变量 同时用于esp32s3使用SDIO卡数据的DAT1 为-1代表不使用SDIO
|
||||||
|
#define READGUY_user2 (config_data[23]) //用户自定义变量 同时用于esp32s3使用SDIO卡数据的DAT2
|
||||||
|
#define READGUY_user3 (config_data[24]) //用户自定义变量
|
||||||
|
#define READGUY_user4 (config_data[25]) //用户自定义变量
|
||||||
|
#define READGUY_user5 (config_data[26]) //用户自定义变量
|
||||||
|
#define READGUY_user6 (config_data[27]) //用户自定义变量
|
||||||
|
#define READGUY_user7 (config_data[28]) //用户自定义变量
|
||||||
|
#define READGUY_user8 (config_data[29]) //用户自定义变量
|
||||||
|
#define READGUY_user9 (config_data[30]) //用户自定义变量
|
||||||
|
#define READGUY_user10 (config_data[31]) //用户自定义变量
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define READGUY_SLOW 0
|
#define READGUY_SLOW 0
|
||||||
@@ -317,10 +328,10 @@ class ReadguyDriver: public LGFX_Sprite{ // readguy 基础类
|
|||||||
bool nvs_read(); //从持久存储器读取, 返回是否读取成功
|
bool nvs_read(); //从持久存储器读取, 返回是否读取成功
|
||||||
void nvs_write(); //写入到持久存储器
|
void nvs_write(); //写入到持久存储器
|
||||||
#ifdef DYNAMIC_PIN_SETTINGS//数据是否已经校准
|
#ifdef DYNAMIC_PIN_SETTINGS//数据是否已经校准
|
||||||
int8_t config_data[22];
|
int8_t config_data[32];
|
||||||
char randomch[4]; //校验用字符串
|
char randomch[4]; //校验用字符串
|
||||||
#else
|
#else
|
||||||
static const int8_t config_data[22];
|
static const int8_t config_data[32];
|
||||||
int8_t READGUY_sd_ok = 0;
|
int8_t READGUY_sd_ok = 0;
|
||||||
int8_t READGUY_cali = 0;
|
int8_t READGUY_cali = 0;
|
||||||
int8_t READGUY_buttons = 0; //按钮个数, 0-3都有可能
|
int8_t READGUY_buttons = 0; //按钮个数, 0-3都有可能
|
||||||
@@ -428,6 +439,29 @@ class ReadguyDriver: public LGFX_Sprite{ // readguy 基础类
|
|||||||
constexpr int getBlPin () const { return READGUY_bl_pin; } //前置光接口引脚IO
|
constexpr int getBlPin () const { return READGUY_bl_pin; } //前置光接口引脚IO
|
||||||
constexpr int getRtcType () const { return READGUY_rtc_type; } //使用的RTC型号(待定, 还没用上)
|
constexpr int getRtcType () const { return READGUY_rtc_type; } //使用的RTC型号(待定, 还没用上)
|
||||||
constexpr int getButtonsCount() const { return READGUY_buttons; } //按钮个数, 0-3都有可能
|
constexpr int getButtonsCount() const { return READGUY_buttons; } //按钮个数, 0-3都有可能
|
||||||
|
constexpr int getReadguy_user1 () const { return READGUY_user1; } //用户变量
|
||||||
|
constexpr int getReadguy_user2 () const { return READGUY_user2; } //用户变量
|
||||||
|
constexpr int getReadguy_user3 () const { return READGUY_user3; } //用户变量
|
||||||
|
constexpr int getReadguy_user4 () const { return READGUY_user4; } //用户变量
|
||||||
|
constexpr int getReadguy_user5 () const { return READGUY_user5; } //用户变量
|
||||||
|
constexpr int getReadguy_user6 () const { return READGUY_user6; } //用户变量
|
||||||
|
constexpr int getReadguy_user7 () const { return READGUY_user7; } //用户变量
|
||||||
|
constexpr int getReadguy_user8 () const { return READGUY_user8; } //用户变量
|
||||||
|
constexpr int getReadguy_user9 () const { return READGUY_user9; } //用户变量
|
||||||
|
constexpr int getReadguy_user10() const { return READGUY_user10;} //用户变量
|
||||||
|
constexpr int getReadguyUseSdio () { //返回程序调用SD卡时 是否使用了SDIO
|
||||||
|
#ifdef CONFIG_IDF_TARGET_ESP32S3 //仅对ESP32S3可用
|
||||||
|
return (READGUY_user1 != -1) && (READGUY_user2 != -1);
|
||||||
|
#else
|
||||||
|
return 0; //非ESP32S3平台不可用SDIO
|
||||||
|
#endif
|
||||||
|
} //用于esp32s3使用SDIO卡数据的DAT2
|
||||||
|
constexpr int getSdio_dat0 () { return getReadguyUseSdio()?READGUY_sd_miso:-1; } //用于esp32s3使用SDIO卡数据的DAT0
|
||||||
|
constexpr int getSdio_dat1 () { return getReadguyUseSdio()?READGUY_user1:-1; } //用于esp32s3使用SDIO卡数据的DAT1
|
||||||
|
constexpr int getSdio_dat2 () { return getReadguyUseSdio()?READGUY_user2:-1; } //用于esp32s3使用SDIO卡数据的DAT2
|
||||||
|
constexpr int getSdio_dat3 () { return getReadguyUseSdio()?READGUY_sd_cs:-1; } //用于esp32s3使用SDIO卡数据的DAT3
|
||||||
|
constexpr int getSdio_clk () { return getReadguyUseSdio()?READGUY_sd_sclk:-1; } //用于esp32s3使用SDIO卡数据的CLK
|
||||||
|
constexpr int getSdio_cmd () { return getReadguyUseSdio()?READGUY_sd_mosi:-1; } //用于esp32s3使用SDIO卡数据的CMD
|
||||||
//constexpr int memWidth () const { return guy_width ; } //返回显存宽度(不是画幅宽度),不会随着画布旋转改变
|
//constexpr int memWidth () const { return guy_width ; } //返回显存宽度(不是画幅宽度),不会随着画布旋转改变
|
||||||
//constexpr int memHeight () const { return guy_height ; } //返回显存高度(不是画幅高度),不会随着画布旋转改变
|
//constexpr int memHeight () const { return guy_height ; } //返回显存高度(不是画幅高度),不会随着画布旋转改变
|
||||||
int drvWidth () const { return READGUY_cali==127?guy_dev->drv_width():0; } //返回显示屏硬件宽度(不是画幅宽度)
|
int drvWidth () const { return READGUY_cali==127?guy_dev->drv_width():0; } //返回显示屏硬件宽度(不是画幅宽度)
|
||||||
|
|||||||
Reference in New Issue
Block a user