Skip to content

Commit fcbc159

Browse files
Merge pull request #131 from wangxiangwangeuse/master
Added Wireless_Paper_V1.1
2 parents d2836f5 + d45cb8e commit fcbc159

38 files changed

+434
-139
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/* Heltec Automation Wireless_Paper_V1.0 Sensors test example
2+
*
3+
* Function:
4+
* Refresh e-paper through BLE, WIFI, and LORAWAN (currently unavailable)
5+
*
6+
* HelTec AutoMation, Chengdu, China
7+
* www.heltec.org
8+
* Operation instance:
9+
*
10+
* this project also realess in GitHub:
11+
* https://github.com/HelTecAutomation/Heltec_ESP32
12+
*/
13+
14+
#include "ESPAsyncWebSrv.h"
15+
#include "HT_QYEG0213RWS800_BWR.h"
16+
#include "images.h"
17+
#include "html.h"
18+
QYEG0213RWS800_BWR display(6, 5, 4, 7, 3, 2, -1, 6000000); //rst,dc,cs,busy,sck,mosi,miso,frequency
19+
20+
21+
uint8_t width, height;
22+
String HTTP_Payload ;
23+
24+
AsyncWebServer server(80); // Create WebServer object with port number 80
25+
// By using port number 80, you can directly enter the IP address for access, while using other ports requires entering the IP: port number for access
26+
27+
const char *ssid = "Heltec-RD";
28+
const char *password = "hunter_3120";
29+
30+
// Distribute processing callback function
31+
void Config_Callback(AsyncWebServerRequest *request)
32+
{
33+
if (request->hasParam("value")) // If there is a value, it will be delivered
34+
{
35+
String Payload;
36+
const char* buff;
37+
38+
Payload = request->getParam("value")->value(); // Obtain the data delivered
39+
buff = Payload.c_str();
40+
41+
delay(100);
42+
int i = 0;
43+
char *token;
44+
token = strtok((char*)buff, ",");
45+
while (token != NULL ) {
46+
47+
int num = atoi(token );
48+
WiFi_Logo_bits[i] = num;
49+
token = strtok(NULL, ",");
50+
// Serial.println(num);
51+
i++;
52+
}
53+
54+
drawImageDemo();
55+
56+
}
57+
request->send(200, "text/plain", "OK");
58+
}
59+
void setup()
60+
{
61+
62+
Serial.begin(115200);
63+
Serial.println();
64+
//disableCore0WDT();
65+
VextON();
66+
delay(100);
67+
display.init();
68+
69+
WiFi.mode(WIFI_STA);
70+
WiFi.setSleep(false);
71+
WiFi.begin(ssid, password);
72+
while (WiFi.status() != WL_CONNECTED)
73+
{
74+
delay(500);
75+
Serial.print(".");
76+
}
77+
Serial.println("Connected");
78+
Serial.print("IP Address:");
79+
Serial.println(WiFi.localIP());
80+
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request)
81+
{
82+
request->send_P(200, "text/html", index_html);
83+
});
84+
85+
server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function
86+
server.begin();
87+
88+
89+
// drawImageDemo();
90+
91+
}
92+
void drawImageDemo() {
93+
// see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
94+
// on how to create xbm files
95+
display.clear();
96+
display.update(BLACK_BUFFER);
97+
98+
display.clear();
99+
int x = width / 2 - WiFi_Logo_width / 2;
100+
int y = height / 2 - WiFi_Logo_height / 2;
101+
display.drawXbm(0 , 0 , WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
102+
display.update(BLACK_BUFFER);
103+
display.display();
104+
}
105+
void VextON(void)
106+
{
107+
pinMode(45, OUTPUT);
108+
digitalWrite(45, LOW);
109+
}
110+
111+
void VextOFF(void) //Vext default OFF
112+
{
113+
pinMode(45, OUTPUT);
114+
digitalWrite(45, HIGH);
115+
}
116+
void loop() {
117+
118+
vTaskDelay(10000);
119+
120+
}
Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
2-
#include "ESPAsyncWebSrv.h"
3-
#include "HT_QYEG0213RWS800_BWR.h"
4-
#include "images.h"
5-
6-
QYEG0213RWS800_BWR display(6, 5, 4, 7, 3, 2, -1, 6000000); //rst,dc,cs,busy,sck,mosi,miso,frequency
7-
8-
9-
int width, height;
10-
String HTTP_Payload ;
11-
//using namespace base64;
12-
//epaper_class epaper;
13-
AsyncWebServer server(80); // 创建WebServer对象, 端口号80
14-
// 使用端口号80可以直接输入IP访问,使用其它端口需要输入IP:端口号访问
15-
// 一个储存网页的数组
16-
const char *ssid = "Heltec-RD";
17-
const char *password = "hunter_3120";
1+
//An array for storing web pages
182
const char index_html[] PROGMEM = R"rawliteral(
193
<!DOCTYPE HTML>
204
<html>
@@ -43,20 +27,20 @@ const char index_html[] PROGMEM = R"rawliteral(
4327
// document.getElementById("inputFileAgent").value = document.getElementById("avatar").value;
4428
var filePath = file.value;
4529
if (filePath) {
46-
var filePic = file.files[0]; //选择的文件内容--图片
47-
var fileType = filePath.slice(filePath.indexOf(".")); //选择文件的格式
48-
var fileSize = file.files[0].size; //选择文件的大
30+
var filePic = file.files[0]; //Selected file content - images
31+
var fileType = filePath.slice(filePath.indexOf(".")); //Choose the format of the file
32+
var fileSize = file.files[0].size; //选Choose the size of the file
4933
var reader = new FileReader();
5034
reader.readAsDataURL(filePic);
5135
reader.onload = function (e) {
5236
var data = e.target.result;
53-
//加载图片获取图片真实宽度和高度
37+
//Load image to obtain the true width and height of the image
5438
var image = new Image();
5539
image.onload = function () {
5640
var width = image.width;
5741
var height = image.height;
58-
if (width == 255 || height == 122) { //判断文件像素
59-
//上传图片
42+
if (width == 255 || height == 122) { //Determine file pixels
43+
//upload pictures
6044
document.getElementById("inputFileAgent").value = document.getElementById("avatar").value;
6145
bmpToXbm(255);
6246
} else {
@@ -160,107 +144,9 @@ const char index_html[] PROGMEM = R"rawliteral(
160144
document.getElementById("dht").innerHTML = this.responseText;
161145
}
162146
};
163-
// 使用GET的方式请求 /dht
147+
// Request using GET /dht
164148
xhttp.open("GET", "/dht", true);
165149
xhttp.send();
166150
}, 1000)
167151
</script>)rawliteral";
168152

169-
170-
// 下发处理回调函数
171-
void Config_Callback(AsyncWebServerRequest *request)
172-
{
173-
if (request->hasParam("value")) // If there is a value, it will be delivered
174-
{
175-
String Payload;
176-
const char* buff;
177-
178-
Payload = request->getParam("value")->value(); // Obtain the data delivered
179-
buff = Payload.c_str();
180-
181-
delay(100);
182-
int i = 0;
183-
char *token;
184-
token = strtok((char*)buff, ",");
185-
/* 继续获取其他的子字符串 */
186-
// token = strtok(NULL, ";");
187-
//WiFi_Logo_width=atoi(token );
188-
// token = strtok(NULL, "=");
189-
// token = strtok(NULL, ";");
190-
// WiFi_Logo_height=atoi(token );
191-
while (token != NULL ) {
192-
193-
int num = atoi(token );
194-
WiFi_Logo_bits[i] = num;
195-
token = strtok(NULL, ",");
196-
// Serial.println(num);
197-
i++;
198-
}
199-
200-
drawImageDemo();
201-
202-
}
203-
request->send(200, "text/plain", "OK");
204-
}
205-
void setup()
206-
{
207-
208-
Serial.begin(115200);
209-
Serial.println();
210-
//disableCore0WDT();
211-
VextON();
212-
delay(100);
213-
display.init();
214-
215-
WiFi.mode(WIFI_STA);
216-
WiFi.setSleep(false);
217-
WiFi.begin(ssid, password);
218-
while (WiFi.status() != WL_CONNECTED)
219-
{
220-
delay(500);
221-
Serial.print(".");
222-
}
223-
Serial.println("Connected");
224-
Serial.print("IP Address:");
225-
Serial.println(WiFi.localIP());
226-
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request)
227-
{
228-
request->send_P(200, "text/html", index_html);
229-
});
230-
231-
server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function
232-
server.begin();
233-
234-
235-
// drawImageDemo();
236-
237-
}
238-
void drawImageDemo() {
239-
// see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
240-
// on how to create xbm files
241-
display.clear();
242-
display.update(BLACK_BUFFER);
243-
244-
display.clear();
245-
int x = width / 2 - WiFi_Logo_width / 2;
246-
int y = height / 2 - WiFi_Logo_height / 2;
247-
display.drawXbm(0 , 0 , WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
248-
display.update(BLACK_BUFFER);
249-
display.display();
250-
}
251-
void VextON(void)
252-
{
253-
pinMode(45, OUTPUT);
254-
digitalWrite(45, LOW);
255-
}
256-
257-
void VextOFF(void) //Vext default OFF
258-
{
259-
pinMode(45, OUTPUT);
260-
digitalWrite(45, HIGH);
261-
}
262-
void loop() {
263-
// server.handleClient(); //Handle requests from clients
264-
vTaskDelay(10000);
265-
266-
}

0 commit comments

Comments
 (0)