diff --git a/EPD/EPD_Test.h b/EPD/EPD_Test.h
deleted file mode 100644
index dd37fdb..0000000
--- a/EPD/EPD_Test.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "DEV_Config.h"
-
-void EPD_4in2_test(void);
diff --git a/html/index.html b/html/index.html
index 856b5f8..b9590d3 100644
--- a/html/index.html
+++ b/html/index.html
@@ -62,6 +62,8 @@
+
+
@@ -107,6 +109,7 @@
- 驱动选择:黑白屏可尝试 EPD_4in2 / EPD_4in2_V2, 三色屏选择 EPD_4in2b_V2 (选错驱动可能会导致任何未知的异常,重启即可恢复)
- 引脚配置:格式为十六进制,顺序:MOSI/SCLK/CS/DC/ST/BUSY/BS,必须按此顺序包含完整的 7 个引脚配置(没有用到的引脚可配置为
FF)
+ - 确认间隔: 这个间隔指的是数据包数量间隔,即发送此数量的不确认响应的数据包后才发送一次需确认响应的数据包。加大此值可优化传图速度,但是丢包风险也更大(你可能会发现图片有部分位置显示不正常,此时需调小这个值)。
-
指令列表(指令和参数全部要使用十六进制):
diff --git a/html/js/main.js b/html/js/main.js
index bb5c3ab..886aec7 100644
--- a/html/js/main.js
+++ b/html/js/main.js
@@ -45,7 +45,7 @@ async function handleError(error) {
}
}
-async function write(cmd, data) {
+async function write(cmd, data, withResponse=true) {
if (!epdCharacteristic) {
addLog("服务不可用,请检查蓝牙连接");
return;
@@ -60,13 +60,18 @@ async function write(cmd, data) {
throw new Error("BLE packet too large!");
}
addLog(`⇑ ${bytes2hex(payload)}`);
- await epdCharacteristic.writeValue(Uint8Array.from(payload));
+ if (withResponse)
+ await epdCharacteristic.writeValueWithResponse(Uint8Array.from(payload));
+ else
+ await epdCharacteristic.writeValueWithoutResponse(Uint8Array.from(payload));
}
async function epdWrite(cmd, data) {
const chunkSize = MAX_PACKET_SIZE - 1;
const count = Math.round(data.length / chunkSize);
+ const interleavedCount = document.getElementById('interleavedcount').value;
let chunkIdx = 0;
+ let noReplyCount = interleavedCount;
if (typeof data == 'string') data = hex2bytes(data);
@@ -74,7 +79,13 @@ async function epdWrite(cmd, data) {
for (let i = 0; i < data.length; i += chunkSize) {
let currentTime = (new Date().getTime() - startTime) / 1000.0;
setStatus(`命令:0x${cmd.toString(16)}, 数据块: ${chunkIdx+1}/${count+1}, 总用时: ${currentTime}s`);
- await write(EpdCmd.SEND_DATA, data.slice(i, i + chunkSize));
+ if (noReplyCount > 0) {
+ await write(EpdCmd.SEND_DATA, data.slice(i, i + chunkSize), false);
+ noReplyCount--;
+ } else {
+ await write(EpdCmd.SEND_DATA, data.slice(i, i + chunkSize), true);
+ noReplyCount = interleavedCount;
+ }
chunkIdx++;
}
}