提交 dcd8899a 编写于 作者: qsbye's avatar qsbye

更新README.md

上级 7cf2f59f
无法预览此类型文件
# 甜心·嵌入式esp32项目
## 固件说明
固件,使用Rust开发,esp32s,
* 编译方式:
```shell
......
/*
Copyright (c) 2023 qsbye
This file is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
说明:
构建脚本,在宿主机构建时运行,有std库
预处理数据并写入mydata.rs
......
/*
Copyright (c) 2023 qsbye
This file is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
备注:
- 使用no-std,没有常规的main函数
- 串口波特率115200
......
/*
Copyright (c) 2023 qsbye
This file is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
/* start 导入库 */
use crate::DEBUG_LEVEL_0;
use crate::UART0_RX_BUFFER;
......
/*
Copyright (c) 2023 qsbye
This file is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
pub static webpage_test : &[u8] = b"HTTP/1.0 200 OK\r\n\r\n<!DOCTYPE html>\n<html lang='en'>\n<head>\n <meta charset='UTF-8'>\n <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n <title>POST Data Example</title>\n</head>\n<body>\n <button id='myButton1' style='width: 100vw; height: 20vh;'>Click Me</button>\n <button id='myButton2' style='width: 100vw; height: 20vh;'>POST OK</button>\n <button id='myButton3' style='width: 100vw; height: 20vh;'>GET DATA</button>\n <span id=\"dashboardData\">\xE4\xBB\xAA\xE8\xA1\xA8\xE7\x9B\x98\xE6\x95\xB0\xE6\x8D\xAE</span>\n\n <script>\n document.getElementById('myButton1').addEventListener('click', function() {\n // \xE4\xBD\xBF\xE7\x94\xA8 Fetch API \xE5\x8F\x91\xE9\x80\x81 POST \xE8\xAF\xB7\xE6\xB1\x82\n fetch('/post_gcode', {\n method: 'POST',\n headers: {\n 'Content-Type': 'text/plain'\n },\n body: '/post_gcode M0'\n })\n .then(response => {\n // \xE6\xA3\x80\xE6\x9F\xA5\xE5\x93\x8D\xE5\xBA\x94\xE7\x8A\xB6\xE6\x80\x81\xEF\xBC\x8C\xE5\xA6\x82\xE6\x9E\x9C\xE6\x98\xAF 200-299 \xE4\xB9\x8B\xE9\x97\xB4\xE7\x9A\x84\xE7\x8A\xB6\xE6\x80\x81\xE7\xA0\x81\xEF\xBC\x8C\xE8\xAF\xB4\xE6\x98\x8E\xE8\xAF\xB7\xE6\xB1\x82\xE6\x88\x90\xE5\x8A\x9F\n if (response.ok) {\n console.log('Data posted successfully!');\n } else {\n console.error('Error posting data:', response.statusText);\n }\n })\n .catch(error => {\n console.error('An error occurred:', error);\n });\n });\n document.getElementById('myButton2').addEventListener('click', function() {\n // \xE4\xBD\xBF\xE7\x94\xA8 Fetch API \xE5\x8F\x91\xE9\x80\x81 POST \xE8\xAF\xB7\xE6\xB1\x82\n fetch('/post_ok', {\n method: 'POST',\n headers: {\n 'Content-Type': 'text/plain'\n },\n body: '/post_ok x'\n })\n .then(response => {\n // \xE6\xA3\x80\xE6\x9F\xA5\xE5\x93\x8D\xE5\xBA\x94\xE7\x8A\xB6\xE6\x80\x81\xEF\xBC\x8C\xE5\xA6\x82\xE6\x9E\x9C\xE6\x98\xAF 200-299 \xE4\xB9\x8B\xE9\x97\xB4\xE7\x9A\x84\xE7\x8A\xB6\xE6\x80\x81\xE7\xA0\x81\xEF\xBC\x8C\xE8\xAF\xB4\xE6\x98\x8E\xE8\xAF\xB7\xE6\xB1\x82\xE6\x88\x90\xE5\x8A\x9F\n if (response.ok) {\n console.log('Data posted successfully!');\n console.log(response);\n document.getElementById('myButton2').style.backgroundColor = 'red';\n // \xE6\x89\x93\xE5\x8D\xB0\xE5\x93\x8D\xE5\xBA\x94\xE7\x9A\x84body\xE5\x86\x85\xE5\xAE\xB9\xE5\xB9\xB6\xE5\x88\xA4\xE6\x96\xAD\xE6\x98\xAF\xE5\x90\xA6\xE5\x8C\x85\xE5\x90\xAB\"ok\"\xE6\x96\x87\xE6\x9C\xAC\n response.text().then(bodyText => {\n console.log('Response body:', bodyText);\n if (bodyText.includes('ok')) {\n console.log('Body contains \"ok\" text!');\n document.getElementById('myButton2').style.backgroundColor = 'green';\n } else {\n console.log('Body does not contain \"ok\" text.');\n }\n });\n } else {\n console.error('Error posting data:', response.statusText);\n console.log(response);\n document.getElementById('myButton2').style.backgroundColor = 'blue';\n }\n })\n .catch(error => {\n console.error('An error occurred:', error);\n document.getElementById('myButton2').style.backgroundColor = 'yellow';\n });\n });\n document.getElementById('myButton3').addEventListener('click', function() {\n // \xE4\xBD\xBF\xE7\x94\xA8 Fetch API \xE5\x8F\x91\xE9\x80\x81 POST \xE8\xAF\xB7\xE6\xB1\x82\n fetch('/get_data', {\n method: 'POST',\n headers: {\n 'Content-Type': 'text/plain'\n },\n body: '/get_data x'\n })\n .then(response => {\n // \xE6\xA3\x80\xE6\x9F\xA5\xE5\x93\x8D\xE5\xBA\x94\xE7\x8A\xB6\xE6\x80\x81\xEF\xBC\x8C\xE5\xA6\x82\xE6\x9E\x9C\xE6\x98\xAF 200-299 \xE4\xB9\x8B\xE9\x97\xB4\xE7\x9A\x84\xE7\x8A\xB6\xE6\x80\x81\xE7\xA0\x81\xEF\xBC\x8C\xE8\xAF\xB4\xE6\x98\x8E\xE8\xAF\xB7\xE6\xB1\x82\xE6\x88\x90\xE5\x8A\x9F\n if (response.ok) {\n console.log('Data posted successfully!');\n console.log(response);\n document.getElementById('myButton3').style.backgroundColor = 'red';\n // \xE6\x89\x93\xE5\x8D\xB0\xE5\x93\x8D\xE5\xBA\x94\xE7\x9A\x84body\xE5\x86\x85\xE5\xAE\xB9\xE5\xB9\xB6\xE5\x88\xA4\xE6\x96\xAD\xE6\x98\xAF\xE5\x90\xA6\xE5\x8C\x85\xE5\x90\xAB\"ok\"\xE6\x96\x87\xE6\x9C\xAC\n response.text().then(bodyText => {\n console.log('Response body:', bodyText);\n console.log('Body contains \"ok\" text!');\n document.getElementById('myButton3').style.backgroundColor = 'green';\n // \xE6\x9B\xB4\xE6\x96\xB0\xE6\x95\xB0\xE6\x8D\xAE\n updataDashboard(bodyText);\n \n });\n } else {\n console.error('Error posting data:', response.statusText);\n console.log(response);\n document.getElementById('myButton3').style.backgroundColor = 'blue';\n }\n })\n .catch(error => {\n console.error('An error occurred:', error);\n document.getElementById('myButton3').style.backgroundColor = 'yellow';\n });\n });\n\n /*\n \xE6\x9B\xB4\xE6\x96\xB0\xE9\xA1\xB5\xE9\x9D\xA2\xE4\xBB\xAA\xE8\xA1\xA8\xE7\x9B\x98\xE6\x95\xB0\xE6\x8D\xAE\n \xE8\xBE\x93\xE5\x85\xA5:http\xE7\x9A\x84body\xE6\x95\xB0\xE6\x8D\xAE\n \xE8\xBE\x93\xE5\x87\xBA:\xE6\x97\xA0\n */\n function updataDashboard(http_body_data){\n let mapping = {\n 1: \"heatedbed\",\n 2: \"jet\",\n 3: \"hot_jet\",\n 4: \"hot_heatedbed\",\n 5: \"jet_on\"\n };\n var dashboardDataElement = document.getElementById('dashboardData');\n // \xE5\x88\x86\xE5\x89\xB2\xE6\x95\xB0\xE6\x8D\xAE\xE5\xAD\x97\xE7\xAC\xA6\xE4\xB8\xB2\n var pairs = http_body_data.split(';');\n \n // \xE9\x81\x8D\xE5\x8E\x86\xE6\x95\xB0\xE6\x8D\xAE\xE5\xAF\xB9\xEF\xBC\x8C\xE8\xA7\xA3\xE6\x9E\x90\xE5\xB9\xB6\xE6\x98\xBE\xE7\xA4\xBA\xE6\x95\xB0\xE6\x8D\xAE\n var output = '';\n pairs.forEach(function(pair) {\n if (pair !== '') {\n var keyValue = pair.split('=');\n var key = keyValue[0];\n var value = keyValue[1];\n output += mapping[key] + ': ' + value + '<br>';\n }\n });\n \n // \xE5\xB0\x86\xE8\xA7\xA3\xE6\x9E\x90\xE5\x90\x8E\xE7\x9A\x84\xE6\x95\xB0\xE6\x8D\xAE\xE6\x98\xBE\xE7\xA4\xBA\xE5\x88\xB0\xE9\xA1\xB5\xE9\x9D\xA2\xE4\xB8\x8A\n dashboardDataElement.innerHTML = output;\n }\n </script>\n</body>\n</html>\r\n";
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册