First release commit

This commit is contained in:
fsender
2023-09-21 21:55:16 +08:00
parent 43ab8190bd
commit 5f91e9a9a5
58 changed files with 6195 additions and 2 deletions

BIN
extra/artset/favicon-2.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
extra/artset/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

View File

@@ -0,0 +1,18 @@
/**
* @file main.cpp
* @author ex01_helloWorld
* @brief 基础的实例. 同时注入了少许功能性驱动代码.
* http://www.lilygo.cn/prod_view.aspx?TypeId=50036&Id=1318
* 项目基于 TTGO T-block Ep-bk (带有背光功能的ESP32电子墨水屏模块)
*
* 注意屏幕所用的 EPD_RESET 其实是接在 GPIO38 上面, 手册写的 GPIO34 是错误的
* GPIO38 为 SENSOR_CAPN 引脚(可能是供内部使用),
* 在标准的 ESP32-WROOM 和 WROVER 模组上未引出此 GPIO.
* 可能影响一部分功能的正常使用. 不过无伤大雅
*
* @version 0.1
* @date 2022-11-23
*
* @copyright Copyright (c) 2022
*
*/

View File

@@ -0,0 +1,143 @@
/******************** F r i e n d s h i p E n d e r ********************
* 本程序隶属于 Readguy 开源项目, 请尊重开源开发者, 也就是我FriendshipEnder.
* 如果有条件请到 extra/artset/reward 中扫描打赏,否则请在 Bilibili 上支持我.
* 项目交流QQ群: 926824162 (萌新可以进来问问题的哟)
* 郑重声明: 未经授权还请不要商用本开源项目编译出的程序.
*
* @file oldDemo/main.cpp
* @author FriendshipEnder (f_ender@163.com), Bilibili: FriendshipEnder
* @version 1.0
* @date 2023-09-19
* @brief 旧版的功能演示.
* 将根目录下的data文件夹 上传到LittleFS之后运行效果更佳
* 或者可以准备一张SD卡,并准备在卡的根目录下放置data文件夹内的文件.
* 用于演示BMP格式图片灰度显示.
*
* @attention
* Copyright (c) 2022-2023 FriendshipEnder
*
* Apache License, Version 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <Arduino.h>
#include "guy_driver.h"
const char HelloArduino[] = "Hello Arduino!";
const char HelloEpaper[] = "Hello E-Paper!";
readguy_driver guy;
void helloWorld(int i,int j)
{
bool full=1;
if(i>=1000){
i-=1000;
full=0;
}
Serial.printf("[%lu] helloWorld: %d, %d\n",millis(),i,j);
guy.setFont(&FreeMonoBold9pt7b);
guy.setTextColor(0,1);
//display.fillScreen(GxEPD_WHITE);
guy.setCursor(i,j);
guy.print("Hello");
if(!full) guy.print("Full");
//guy.g().drawString(HelloWorld,i,j);
guy.display(full); // full update
Serial.printf("[%lu] helloWorld done\n",millis());
}
//TaskHandle_t press2reset_h=nullptr;
void press2reset_f(void *pv){
pinMode(36,INPUT_PULLUP);
for(;;){
if(!digitalRead(36)) ESP.restart();
delay(10);
}
}
void setup()
{
Serial.begin(115200);
Serial.println("setup");
//xTaskCreate(press2reset_f,"press2reset",1024,nullptr,1,&press2reset_h);
guy.init();
//pinMode(32,INPUT);
delay(100);
// first update should be full refresh
helloWorld(10,10);
helloWorld(10,30);
LGFX_Sprite sp(&guy);
sp.createFromBmpFile(guy.guyFS(),"/test.bmp");
Serial.printf("sp.w: %d, h: %d, res: %d.\n",sp.width(),sp.height(),ESP.getFreeHeap());
guy.drawImage(sp,30,10);
Serial.printf("drawn dithering bmp.\n");
delay(2500);
guy.draw16grey(sp,30,10);
Serial.printf("drawn.\n");
delay(5000);
guy.fillScreen(1);
helloWorld(1010,50);
helloWorld(10,70);
guy.fillScreen(1);
helloWorld(10,90);
guy.fillScreen(1);
helloWorld(10,140);
guy.fillScreen(1);
guy.drawChar(10,40,'a',true,false,2);
helloWorld(10,160);
helloWorld(1010,10);
helloWorld(1040,30);
guy.sleepEPD();
delay(2000);
helloWorld(1010,50);
helloWorld(20,70);
helloWorld(30,90);
guy.fillScreen(1);
helloWorld(40,110);
guy.setDepth(10); //设置颜色深度
helloWorld(38,126);
guy.setDepth(6);
helloWorld(36,142);
guy.setDepth(2);
helloWorld(38,158);
guy.setDepth(0); //恢复正常颜色深度
guy.fillScreen(1);
guy.display(0); //慢刷清屏
guy.setFont(&fonts::Font0);
for(int i=1;i<16;i++){
guy.setDepth(i); //灰度测试
guy.fillRect(10,i*10,20,10,0);
guy.setCursor(32,i*10);
guy.printf("Grey%d",i);
guy.display();
}
delay(3000);
guy.fillScreen(0);
guy.display();
guy.drawLine(0,0,guy.width(),guy.height(),1);
guy.display();
Serial.println("Reading touch sensor...");
//guy.ap_setup();
//guy.server_setup();
}
int bright=128;
void loop(){
//guy.server_loop();
delay(10);
if(bright%7==0){
Serial.printf("getBtn: %d\n",guy.getBtn());
}
if(bright==511) bright=0;
else bright++;
guy.setBright(bright>=256?511-bright:bright);
}

View File

@@ -0,0 +1,118 @@
/******************** F r i e n d s h i p E n d e r ********************
* 本程序隶属于 Readguy 开源项目, 请尊重开源开发者, 也就是我FriendshipEnder.
* 如果有条件请到 extra/artset/reward 中扫描打赏,否则请在 Bilibili 上支持我.
* 项目交流QQ群: 926824162 (萌新可以进来问问题的哟)
* 郑重声明: 未经授权还请不要商用本开源项目编译出的程序.
*
* @file stringConverter.cpp
* @author FriendshipEnder (f_ender@163.com), Bilibili: FriendshipEnder
* @version 1.0
* @date 2023-09-18
* @brief 可以将文本文件转换为字符串格式, 方便在程序中调用.
*
* @attention
* Copyright (c) 2022-2023 FriendshipEnder
*
* Apache License, Version 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void split_filename(const string &t, string &t1, string &t2, string &t3){
string::size_type iPos=(t.find_last_of('\\')+1)==0?t.find_last_of('/')+1:t.find_last_of('\\')+1;
if(iPos != string::npos){
t1 = t .substr(iPos, t .length() - iPos);//获取带后缀的文件名
t2 = t1.substr(0, t1.rfind("."));//获取不带后缀的文件名
//t3 = t1.substr(t1.rfind("."),t1.length());//获取后缀名
t3 = string("./") + t1 + (".txt");
}
}
int main(int argc,char *argv[]) {
int i=0;
fstream rec_file;
fstream out_file;
string ImgName;
string ImgNameNoTag;
string ImgNameOutput;
if(argc>=2){
rec_file.open(argv[1],ios_base::in | ios_base::binary);
split_filename(string(argv[1]),ImgName,ImgNameNoTag,ImgNameOutput);
}
else{
string in_file_name;
cout << "Text file to C-styled string." << endl << "Input File path: (UTF-8 encoded)" << endl;
cin >> in_file_name;
rec_file.open(in_file_name,ios_base::in | ios_base::binary);
split_filename(in_file_name,ImgName,ImgNameNoTag,ImgNameOutput);
}
if(!rec_file.is_open()) return 1;
rec_file.seekg(0,ios::end);
size_t rec_file_sz = rec_file.tellg();
rec_file.seekg(0,ios::beg);
out_file.open(ImgNameOutput,ios_base::out);
out_file << "const uint8_t "<< ImgNameNoTag <<"[" << rec_file_sz+1 << "] =" << endl << '\"';
//out_file.setf(ios_base::hex,ios_base::basefield);
cout << "File size: " << rec_file_sz << endl;
int oneLine = 0;
int unicode_status = 0;
for(i=0;rec_file.good();i++){
int got = rec_file.get();
if(rec_file.eof()) {
cout << "EOF found!!! " << i << endl;
break;
}
if(oneLine>=80 && (!unicode_status)) {
out_file << '\"' << endl << '\"';
oneLine=0;
}
else oneLine++;
if(got == '\\' || got == '\'' || got == '\"' || got == '?'){
out_file << '\\';
}
else if(got >= 0x80 && got <0xc0 && unicode_status){
unicode_status --;
}
else if(got >= 0xc0 && got <0xe0){
unicode_status =1;
}
else if(got >= 0xe0 && got <0xf0){
unicode_status =2;
}
else if(got >= 0xf0 && got <0xf8){
unicode_status =3;
}
else if(got >= 0xf8 && got <0xff){
unicode_status =4;
}
else if(got <0x80){
unicode_status =0;
}
if(got != '\n' && got != '\r' && got != '\t'){
out_file << (char)got;
}
else{ //是\n \r \t
if(got == '\n') out_file << "\\n";
if(got == '\r') out_file << "\\r";
if(got == '\t') out_file << "\\t";
}
}
out_file << "\";" << endl;
out_file.close();
rec_file.close();
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>欢迎使用 readguy</title>
</head>
<body>
<h1>readguy 欢迎页面</h1>
<p>您已完成了初始化工作.现在可以配置WiFi和聚合密钥相关内容.<br />
</p>返回<a href="/pinsetup">设置页面</a><br />前往<a href="/edit">SD卡文件管理器页面</a>
<br />SD card size: 2967040KB, used size: 28224KB.<br />
当前WiFi模式: AP配网模式, IP地址: (IP unset)<br />
芯片型号: ESP-12E or 12F, 芯片闪存ID: 0x00000000<br />
闪存容量: 4096KB, MAC地址: 48:3F:DA:76:24:46<br />
<b>引脚定义:</b><br />EpdMOSI:-1EpdSCLK:-1Epd_CS:15Epd_DC:5Epd_RST:-1
EpdBusy:0SD_MISO:-1SD_MOSI:-1SD_SCLK:-1SD_CS:0<br />按键定义:btn1:5btn2:12btn3:2<br />
<form action="/wifi" method="POST">WiFi 名称<input type='text' name='ssid' maxlength="31" /><br />WiFi 密码<input
type='text' name='psk' maxlength="31" /><br />天气所在地<input type='text' name='ssid'
maxlength="31" /><br />聚合数据API密钥<input type='text' name='psk' maxlength="63" /><br /></form><br />
<p>ReadGuy for device ESP8266<br />Copyright © FriendshipEnder <a href="https://github.com/fsender/readguy">GitHub</a>
<a href="https://space.bilibili.com/180327370/">Bilibili</a><br />版本: 1.0.0 ,编译日期: Sep 20 202318:17:07</p>
</body>
</html>

View File

@@ -0,0 +1,12 @@
const uint8_t final[837] =
"<!DOCTYPE html><html lang=\"zh-cn\">\n<head><meta charset=\"utf-8\"><title>欢迎使"
"用 readguy</title></head>\n<body><h1>readguy 欢迎页面</h1>\n<p>您已完成了"
"初始化工作.现在可以配置WiFi和聚合密钥相关内容.<br/></p>\n返回"
"<a href=\"/pinsetup\">设置页面</a><br/>\n前往<a href=\"/edit\">SD卡文件管理器页面"
"</a><br/>\n\n<form action=\"/wifi\" method=\"POST\">\nWiFi 名称<input type=\'text\' n"
"ame=\'ssid\' maxlength=\"31\"/><br/>\nWiFi 密码<input type=\'text\' name=\'psk\' maxlen"
"gth=\"31\"/><br/>\n天气所在地<input type=\'text\' name=\'ssid\' maxlength=\"31\"/><b"
"r/>\n聚合数据API密钥<input type=\'text\' name=\'psk\' maxlength=\"63\"/><br/>\n</"
"form>\n<br/><p>Copyright (C) FriendshipEnder <a href=\"https://github.com/fsender/"
"readguy\">GitHub</a>\n <a href=\"https://space.bilibili.com/180327370/\">Bilibili</"
"a></p>\n</body></html>";

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>readguy 设置</title>
</head>
<body>
<h1>readguy 设置页面</h1>
<p>感谢您使用ReadGuy. 现在将引脚配置输入到框内, 即可成功点亮屏幕.<br />点击<a href="/wifi">配置WiFi</a><br />点击<a href="/api">配置聚合数据API密钥</a><br /></p>
<form name="input" action="/verify" method="POST">
<h2>引脚定义设定</h2><input type="checkbox" name="share" value="1">墨水屏和SD卡共享SPI<br />E-paper 型号<select name="epdtype">
<option value="0" selected>1.54寸标准</option>
<option value="1">1.54寸Lilygo</option>
<option value="2">2.13寸汉朔价签</option>
<option value="3">2.66寸Vusion价签</option>
<option value="4">2.13寸三色</option>
<option value="5">2.9寸A01</option>
<option value="6">2.9寸T94背光</option>
<option value="7">4.2寸WF丝印</option>
<option value="8">4.2寸HINK黑白价签</option>
<option value="9">3.7寸高DPI墨水屏</option>
<option value="10">测试用LCD屏 请勿选此项</option>
<option value="11">2.7寸佳显触摸墨水屏</option>
</select><br />Epd_CS<input type="number" name="Epd_CS" min="-1" max="100" step="1" value="15" /><br />
Epd_DC<input type="number" name="Epd_DC" min="-1" max="100" step="1" value="5" /><br />
Epd_RST<input type="number" name="Epd_RST" min="-1" max="100" step="1" value="-1" /><br />
EpdBusy<input type="number" name="EpdBusy" min="-1" max="100" step="1" value="4" /><br />
SD_CS<input type="number" name="SD_CS" min="-1" max="100" step="1" value="0" /><br />
几个按键?<br /><input type="number" name="btn_cnt" min="1" max="3" step="1" value="3" /><br />
按键 1 引脚<input type="number" name="btn1" min="-1" max="100" step="1" value="5" /><br />
<input type="checkbox" name="btn1c" value="1">高电平触发<br />
按键 2 引脚<input type="number" name="btn2" min="-1" max="100" step="1" value="12" /><br />
<input type="checkbox" name="btn2c" value="1">高电平触发<br />
按键 3 引脚<input type="number" name="btn3" min="-1" max="100" step="1" value="2" /><br />
<input type="checkbox" name="btn3c" value="1">高电平触发<br />
背光 PWM 引脚<input type="number" name="bklight" min="-1" max="100" step="1" value="-1" /><br />
<input type='submit' value='确定!' /><br />
</form><br />
<p>ReadGuy on device ESP8266<br />Copyright © FriendshipEnder <a href="https://github.com/fsender/readguy">GitHub</a>
<a href="https://space.bilibili.com/180327370/">Bilibili</a><br />版本: 1.0.0 ,编译日期: Sep 20 202318:17:07</p>
</body>
</html>

View File

@@ -0,0 +1,34 @@
const uint8_t index_cn[2661] =
"<!DOCTYPE html><html lang=\"zh-cn\">\r\n<head><meta charset=\"utf-8\"><title>readguy 设"
"置</title></head>\r\n<body><h1>readguy 设置页面</h1>\r\n<p>点击<a href=\"/wifi\""
">配置WiFi</a><br/>\r\n点击<a href=\"/api\">配置聚合数据API密钥</a><br/></"
"p>\r\n<p>系统信息<br/>芯片:flash id:flash 大小:</p>\r\n<form name=\"input\" act"
"ion=\"/verify\" method=\"POST\">\r\nWiFi 名称<input type=\'text\' name=\'ssid\' maxlength"
"=\"31\"/><br/>\r\nWiFi 密码<input type=\'text\' name=\'psk\' maxlength=\"31\"/><br/>\r\n<h2"
">引脚定义设定</h2>\r\n<input type=\"checkbox\" name=\"share\" value=\"1\">墨水屏"
"和SD卡共享SPI<br/>\r\nE-paper 型号\r\n<select name=\"epdtype\" value=\"1\"><option value=\"0\">"
"EPD2_154</option>\r\n<option value=\"1\">EPD2_154_D67</option>\r\n<option value=\"2\""
">EPD2_213</option>\r\n<option value=\"3\">EPD2_290</option></select><br/>\r\nE-pape"
"r MOSI<input type=\"number\" name=\"epd_mosi\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\""
"/><br/>\r\nE-paper SCLK<input type=\"number\" name=\"epd_sclk\" min=\"-1\" max=\"100\" step"
"=\"1\" value=\"-1\"/><br/>\r\nE-paper CS<input type=\"number\" name=\"epd_cs\" min=\"-1\" max"
"=\"100\" step=\"1\" value=\"-1\"/><br/>\r\nE-paper DC<input type=\"number\" name=\"epd_dc\" m"
"in=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\nE-paper RST<input type=\"number\" nam"
"e=\"epd_rst\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\nE-paper BUSY<input typ"
"e=\"number\" name=\"epd_busy\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\nSD card"
" MISO<input type=\"number\" name=\"sd_miso\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/>"
"<br/>\r\nSD card MOSI<input type=\"number\" name=\"sd_mosi\" min=\"-1\" max=\"100\" step=\"1"
"\" value=\"-1\"/><br/>\r\nSD card SCLK<input type=\"number\" name=\"sd_sclk\" min=\"-1\" max"
"=\"100\" step=\"1\" value=\"-1\"/><br/>\r\nSD card CS<input type=\"number\" name=\"sd_cs\" mi"
"n=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\n几个按键\?<br/><input type=\"numbe"
"r\" name=\"btn_count\" min=\"1\" max=\"3\" step=\"1\" value=\"1\"/><br/>\r\n按键 1 引脚<in"
"put type=\"number\" name=\"btn1\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\n<inp"
"ut type=\"checkbox\" name=\"btn1c\" value=\"1\">高电平触发<br/>\r\n按键 2 引脚<i"
"nput type=\"number\" name=\"btn2\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\n<in"
"put type=\"checkbox\" name=\"btn2c\" value=\"1\">高电平触发<br/>\r\n按键 3 引脚<"
"input type=\"number\" name=\"btn3\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\n<i"
"nput type=\"checkbox\" name=\"btn3c\" value=\"1\">高电平触发<br/>\r\n背光 PWM 引脚"
"<input type=\"number\" name=\"bl\" min=\"-1\" max=\"100\" step=\"1\" value=\"-1\"/><br/>\r\n<in"
"put type=\'submit\' value=\'确定!\'/><br/>\r\n</form>\r\n<br/><p>Copyright (C) Friendsh"
"ipEnder <a href=\"https://github.com/fsender/readguy\">GitHub</a>\r\n <a href=\"https"
"://space.bilibili.com/180327370/\">Bilibili</a></p>\r\n</body></html>";

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>readguy 初始化</title>
</head>
<body>
<h1>readguy 验证页面,马上就好</h1>
<p>屏幕即将显示.如果屏幕或者按键无响应请返回到<a href="/">设置页面</a>
<br />三个按键, 操作非常流畅.<br />按键1: 上一个/向上翻页<br />按键2点按:
确定/选择<br />按键2长按: 返回/切换输入法<br />按键3: 下一个/向下翻页<br />
<br />完成上述4个操作之后屏幕上将会展现出验证码,输入验证码即可完成硬件配置.<br /></p>
<form action="/final" method="POST"><input type='text' name='t_verify' maxlength="6" />
<br /><input type='submit' value='确定!' /><br /></form><br />
<p>ReadGuy for device ESP8266<br />Copyright © FriendshipEnder
<a href="https://github.com/fsender/readguy">GitHub</a>
<a href="https://space.bilibili.com/180327370/">Bilibili</a>
<br />版本: 1.0.0 ,编译日期: Sep 20 202318:17:07</p>
</body>
</html>

View File

@@ -0,0 +1,11 @@
const uint8_t verify[809] =
"<!DOCTYPE html><html lang=\"zh-cn\">\n<head><meta charset=\"utf-8\"><title>readguy 初"
"始化</title></head>\n<body><h1>readguy 验证页面,马上就好</h1>\n<p>屏幕"
"即将显示.<br/>\n请在显示完成后依次按下所有按键进行测试,确"
"保按键可正常工作<br/>\n按键按下时, 屏幕将会在对应地方显示"
"为黑色, 松开为白色<br/>\n请输入屏幕上显示的内容<br/>\n如果屏"
"幕或者按键无响应请返回到<a href=\"/\">设置页面</a><br/></p>\n<form "
"action=\"/final\" method=\"POST\">\n<input type=\'text\' name=\'t_verify\' maxlength=\"6\"/"
"><br/>\n<input type=\'submit\' value=\'确定!\'/><br/>\n</form>\n<br/><p>Copyright ("
"C) FriendshipEnder <a href=\"https://github.com/fsender/readguy\">GitHub</a>\n <a "
"href=\"https://space.bilibili.com/180327370/\">Bilibili</a></p>\n</body></html>";