fix bwr display

This commit is contained in:
Shuanglei Tao
2024-11-16 00:04:23 +08:00
parent 32eb020b62
commit 107f639b0b
4 changed files with 5 additions and 19 deletions

View File

@@ -92,7 +92,7 @@ function canvas2bytes(canvas, type='bw') {
if (type !== 'bwr') {
buffer.push(imageData.data[index] > 0 && imageData.data[index+1] > 0 && imageData.data[index+2] > 0 ? 1 : 0);
} else {
buffer.push(imageData.data[index] > 0 && imageData.data[index+1] === 0 && imageData.data[index+2] === 0 ? 1 : 0);
buffer.push(imageData.data[index] > 0 && imageData.data[index+1] === 0 && imageData.data[index+2] === 0 ? 0 : 1);
}
if (buffer.length === 8) {

View File

@@ -76,6 +76,7 @@ async function sendIMGArray(imgArray, type = 'bw'){
async function sendimg(cmdIMG) {
startTime = new Date().getTime();
let epdDriver = document.getElementById("epddriver").value;
let imgArray = cmdIMG.replace(/(?:\r\n|\r|\n|,|0x| )/g, '');
const bwArrLen = (canvas.width/8) * canvas.height * 2;
@@ -86,7 +87,7 @@ async function sendimg(cmdIMG) {
await sendcmd("0313");
await sendIMGArray(imgArray.slice(bwArrLen), 'bwr');
} else {
await sendcmd("0313");
await sendcmd(epdDriver === "03" ? "0310" : "0313");
await sendIMGArray(imgArray);
}
await sendcmd("05");