|
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 |
18 | 2 | const char index_html[] PROGMEM = R"rawliteral( |
19 | 3 | <!DOCTYPE HTML> |
20 | 4 | <html> |
@@ -43,20 +27,20 @@ const char index_html[] PROGMEM = R"rawliteral( |
43 | 27 | // document.getElementById("inputFileAgent").value = document.getElementById("avatar").value; |
44 | 28 | var filePath = file.value; |
45 | 29 | 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 |
49 | 33 | var reader = new FileReader(); |
50 | 34 | reader.readAsDataURL(filePic); |
51 | 35 | reader.onload = function (e) { |
52 | 36 | var data = e.target.result; |
53 | | - //加载图片获取图片真实宽度和高度 |
| 37 | + //Load image to obtain the true width and height of the image |
54 | 38 | var image = new Image(); |
55 | 39 | image.onload = function () { |
56 | 40 | var width = image.width; |
57 | 41 | var height = image.height; |
58 | | - if (width == 255 || height == 122) { //判断文件像素 |
59 | | - //上传图片 |
| 42 | + if (width == 255 || height == 122) { //Determine file pixels |
| 43 | + //upload pictures |
60 | 44 | document.getElementById("inputFileAgent").value = document.getElementById("avatar").value; |
61 | 45 | bmpToXbm(255); |
62 | 46 | } else { |
@@ -160,107 +144,9 @@ const char index_html[] PROGMEM = R"rawliteral( |
160 | 144 | document.getElementById("dht").innerHTML = this.responseText; |
161 | 145 | } |
162 | 146 | }; |
163 | | - // 使用GET的方式请求 /dht |
| 147 | + // Request using GET /dht |
164 | 148 | xhttp.open("GET", "/dht", true); |
165 | 149 | xhttp.send(); |
166 | 150 | }, 1000) |
167 | 151 | </script>)rawliteral"; |
168 | 152 |
|
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