main
Norman Köhring 11 months ago
commit e6e0d5e633

@ -0,0 +1,13 @@
# Info Display
This Deno application transforms (resizes and dithers) and image and sends the image to Waveshare's E-Paper ESP32 driver board. For it to work, you need the original wifi example code to be loaded on the board. The code is derived from the wifi example web app, but specialized for the Waveshare 7.5 V2 monochrome display.
## Usage
```sh
# just send the image to the display
deno --allow-read --allow-net main.ts /path/to/original/image
# store dithered image on disk, before sending
deno --allow-read --allow-write --allow-net main.ts /path/to/original/image /path/to/output.image
```

@ -0,0 +1,5 @@
{
"tasks": {
"dev": "deno run --watch main.ts"
}
}

@ -0,0 +1,583 @@
{
"version": "2",
"remote": {
"https://deno.land/std@0.176.0/fmt/colors.ts": "938c5d44d889fb82eff6c358bea8baa7e85950a16c9f6dae3ec3a7a729164471",
"https://deno.land/std@0.176.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea",
"https://deno.land/std@0.176.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7",
"https://deno.land/std@0.176.0/testing/asserts.ts": "984ab0bfb3faeed92ffaa3a6b06536c66811185328c5dd146257c702c41b01ab"
},
"npm": {
"specifiers": {
"jimp@0.22.8": "jimp@0.22.8_@jimp+custom@0.22.8"
},
"packages": {
"@jimp/bmp@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-JEMKgM1AEvvWfn9ZCHn62nK+QCE3Pb/ZhPdL3NF0ZgKNww6pqOmo6KqXzqY18JLB7c0epuTp4GPDPDhOh/ou1g==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"bmp-js": "bmp-js@0.1.0"
}
},
"@jimp/core@0.22.8": {
"integrity": "sha512-vkN28aFikzQieA6bGxN+qe20pseCAemCyUI0YmRkJIArlb6OujtAwWAKyokv2lylV56bq8EQGIz+Y30OXUnRqg==",
"dependencies": {
"@jimp/utils": "@jimp/utils@0.22.8",
"any-base": "any-base@1.1.0",
"buffer": "buffer@5.7.1",
"exif-parser": "exif-parser@0.1.12",
"file-type": "file-type@16.5.4",
"isomorphic-fetch": "isomorphic-fetch@3.0.0",
"mkdirp": "mkdirp@2.1.6",
"pixelmatch": "pixelmatch@4.0.2",
"tinycolor2": "tinycolor2@1.6.0"
}
},
"@jimp/custom@0.22.8": {
"integrity": "sha512-u6lP9x/HNeGHB0Oojv4c2mhuDvn7G0ikzYbK4IKLsH4HzHxt62faMjBzQMcFhKJhR6UiiKE/jiHrhGvBT/fMkw==",
"dependencies": {
"@jimp/core": "@jimp/core@0.22.8"
}
},
"@jimp/gif@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-I0l6koS67IPU40RPxCJTD1NvePEd8vUIHTejx1ly0jrjGnumbqdarAlBUkDrKfPPc+Fnqp84hBbSN1w5hNPT6w==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"gifwrap": "gifwrap@0.9.4",
"omggif": "omggif@1.0.10"
}
},
"@jimp/jpeg@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-hLXrQ7/0QiUhAVAF10dfGCSq3hvyqjKltlpu/87b3wqMDKe9KdvhX1AJHiUUrAbJv1fAcnOmQGTyXGuySa1D6A==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"jpeg-js": "jpeg-js@0.4.4"
}
},
"@jimp/plugin-blit@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-rQ19txVCKIwo74HtgFodFt4//0ATPCJK+f24riqzb+nx+1JaOo1xRvpJqg4moirHwKR2fhwdDxmY7KX20kCeYA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-blur@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-GWbNK3YW6k2EKiGJdpAFEr0jezPBtiVxj2wG/lCPuWJz7KmzSSN99hQjIy73xQxoBCRdALfJlkhe3leFNRueSQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-circle@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-qPCw8XFW8opT89ciFDuvs+eB3EB1mZIJWVajD2qAlprHiE7YGr34TkM7N5MNr3qZ1pJgkYdW6+HbBrJwBaonqw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-color@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-ogkbg6rpDVH/mMLgAQKg17z3oZE0VN7ZWxNoH12fUHchqKz1I57zpa65fxZe2I8T5Xz97HR3x+7V7oI8qQGdSA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"tinycolor2": "tinycolor2@1.6.0"
}
},
"@jimp/plugin-contain@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8": {
"integrity": "sha512-oiaPLdJt9Dk+XEEhM/OU3lFemM51mA9NgMCAdburSCjDzKacJYBGFSHjTOhXzcxOie/ZDpOYN/UzFGKy8Dgl9A==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-blit": "@jimp/plugin-blit@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-scale": "@jimp/plugin-scale@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-cover@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8": {
"integrity": "sha512-mO68w1m/LhfuHU8LKHY05a4/hhWnY4t+T+8JCw9t+5yfzA4+LofBZZKtFtWgwf/QGe1y3X2rtUU/avAzDUKyyA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-crop": "@jimp/plugin-crop@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-scale": "@jimp/plugin-scale@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-crop@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-ns4oH0h0gezYsbuH8RThcMLY5uTLk/vnqOVjWCehMHEzxi0DHMWCmpcb6bC//vJ+XFNhtVGn1ALN7+ROmPrj+A==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-displace@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-Cj8nHYgsdFynOIx3dbbiVwRuZn3xO+RVfwkTRy0JBye+K2AU8SQJS+hSFNMQFTZt5djivh6kh0TzvR/6LkOd1w==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-dither@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-oE0Us/6bEgrgEg56plU3jSBzvB9iGhweKUHmxYMWnQbFCHP4mNCtPAs8+Fmq6c+m98ZgBgRcrJTnC7lphHkGyw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-fisheye@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-bWvYY/nfMcKclWEaRyAir+YsT6C5St823HUQAsewZowTrJmme+w4U2a6InsryTHUL01BBcV5BLH0aDHuV3StvA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-flip@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-rotate@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-blit@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-crop@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-0NFTNzjsdmOQkaIkNjZqO3/yU4SQb9nnWQXsLS1fFo+9QrIL5v8vVkXpk/rhiND6PyTj2mMTNjOa76GuZcC+iQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-rotate": "@jimp/plugin-rotate@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-gaussian@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-E/f14aLzCS50QAM7K+InI9V61KVy/Zx52vy7Jjfo1h7qKhQHss3PYaydaH0N6qlXRNeXgh+4/32P9JfieLMcdw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-invert@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-UauP39FF2cwbA5VU+Tz9VlNa9rtULPSHZb0Huwcjqjm9/G/xVN69VJ8+RKiFC4zM1/kYAUp/6IRwPa6qdKJpSw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-mask@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-bhg5+3i8x1CmYj6cjvPBQZLwZEI3iK3gJWF25ZHF+12d3cqDuJngtr8oRQOQLlAgvKmrj9FXIiEPDczUI9cnWQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-normalize@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-Yg5nreAR1JYuSObu3ExlgaLxVeW6VvjVL5qFwiPFxSNlG8JIwL1Ir3K3ChSnnvymyZvJMHb6YKTYNfXKw5Da6g==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-print@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-86O5ejCDi543IYl0TykSmNWErzAjEYhiAxNQb2F7rFRT38WJYNVsvJ6QhxhDQHKxSmF5iwmqbk0jYk5Wp2Z1kw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-blit": "@jimp/plugin-blit@0.22.8_@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"load-bmfont": "load-bmfont@1.4.1"
}
},
"@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-kg8ArQRPqv/iU3DWNXCa8kcVIhoq64Ze0aGCAeFLKlAq/59f5pzAci6m6vV4L/uOVdYmUa9/kYwIFY6RWKpfzQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-rotate@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-9a+VPZWMN/Cks76wf8LjM5RVA3ntP9+NAdsS1SZhhXel7U3Re/dWMouIEbo3QTt6K+igRo4txUCdZiw4ZucvkQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-blit": "@jimp/plugin-blit@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-crop": "@jimp/plugin-crop@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-scale@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-dQS4pG6DX6endu8zUpvBBOEtGC+ljDDDNw0scSXY71TxyQdNo5Ro0apfsppjmuAr8rNotRkfyxbITKkXQDRUDQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-shadow@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blur@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-HyAhr7OblTQh+BoKHQg4qbS9MweNlH77yfpBqUEyDtfyjI5r06+5chf1ZdLRIPEWv/BdCfdI/g81Wv69muCMwA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-blur": "@jimp/plugin-blur@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugin-threshold@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-color@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-ZmkfH0PtjvF1UcKsjw0H7V6r+LC0yKzEfg76Jhs2nIqIgsxsSOVfHwS7z0/1IWnyXxSw36m+NjCAotNHRILGmA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-color": "@jimp/plugin-color@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8"
}
},
"@jimp/plugins@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-rotate@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-blit@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-crop@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-blur@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-color@0.22.8__@jimp+custom@0.22.8": {
"integrity": "sha512-ieI2+kCpmIfjwVlT7B67ULCzxMizfj7LspJh9HnIZCDXQB9GBOZ9KImLYc75Krae0dP/3FR7FglLiSI7fkOHbw==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugin-blit": "@jimp/plugin-blit@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-blur": "@jimp/plugin-blur@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-circle": "@jimp/plugin-circle@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-color": "@jimp/plugin-color@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-contain": "@jimp/plugin-contain@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8",
"@jimp/plugin-cover": "@jimp/plugin-cover@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8",
"@jimp/plugin-crop": "@jimp/plugin-crop@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-displace": "@jimp/plugin-displace@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-dither": "@jimp/plugin-dither@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-fisheye": "@jimp/plugin-fisheye@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-flip": "@jimp/plugin-flip@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-rotate@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-blit@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-crop@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/plugin-gaussian": "@jimp/plugin-gaussian@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-invert": "@jimp/plugin-invert@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-mask": "@jimp/plugin-mask@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-normalize": "@jimp/plugin-normalize@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-print": "@jimp/plugin-print@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8",
"@jimp/plugin-resize": "@jimp/plugin-resize@0.22.8_@jimp+custom@0.22.8",
"@jimp/plugin-rotate": "@jimp/plugin-rotate@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/plugin-scale": "@jimp/plugin-scale@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/plugin-shadow": "@jimp/plugin-shadow@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blur@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"@jimp/plugin-threshold": "@jimp/plugin-threshold@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-color@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8",
"timm": "timm@1.7.1"
}
},
"@jimp/png@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-XOj11kcCr8zKg24QSwlRfH9k4hbV6rkMGUVxMS3puRzzB0FBSQy42NBYEfYf2XlY2QJSAByPl4AYerOtKb805w==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/utils": "@jimp/utils@0.22.8",
"pngjs": "pngjs@6.0.0"
}
},
"@jimp/tiff@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-K0hYUVW5MLgwq3jiHVHa6LvP05J1rXOlRCC+5dMTUnAXVwi45+MKsqA/8lzzwhHYJ65CNhZwy6D3+ZNzM9SIBQ==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"utif2": "utif2@4.1.0"
}
},
"@jimp/types@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-9+xc+mzuYwu0i+6dsnhXiUgfcS+Ktqn5q2jczoKyyBT0cOKgsk+57EIeFLgpTfVGRKRR0y/UIdHByeCzGguF3A==",
"dependencies": {
"@jimp/bmp": "@jimp/bmp@0.22.8_@jimp+custom@0.22.8",
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/gif": "@jimp/gif@0.22.8_@jimp+custom@0.22.8",
"@jimp/jpeg": "@jimp/jpeg@0.22.8_@jimp+custom@0.22.8",
"@jimp/png": "@jimp/png@0.22.8_@jimp+custom@0.22.8",
"@jimp/tiff": "@jimp/tiff@0.22.8_@jimp+custom@0.22.8",
"timm": "timm@1.7.1"
}
},
"@jimp/utils@0.22.8": {
"integrity": "sha512-AaqjfqDeLzSFzrbGRKHMXg/ntiWKvoG9tpVgWzgOx5/gPWj/IyGfztojLTTvY8HqZCr25z8z91u2lAQD2v46Jw==",
"dependencies": {
"regenerator-runtime": "regenerator-runtime@0.13.11"
}
},
"@tokenizer/token@0.3.0": {
"integrity": "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==",
"dependencies": {}
},
"@types/node@16.9.1": {
"integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
"dependencies": {}
},
"any-base@1.1.0": {
"integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==",
"dependencies": {}
},
"base64-js@1.5.1": {
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"dependencies": {}
},
"bmp-js@0.1.0": {
"integrity": "sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==",
"dependencies": {}
},
"buffer-equal@0.0.1": {
"integrity": "sha512-RgSV6InVQ9ODPdLWJ5UAqBqJBOg370Nz6ZQtRzpt6nUjc8v0St97uJ4PYC6NztqIScrAXafKM3mZPMygSe1ggA==",
"dependencies": {}
},
"buffer@5.7.1": {
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"dependencies": {
"base64-js": "base64-js@1.5.1",
"ieee754": "ieee754@1.2.1"
}
},
"dom-walk@0.1.2": {
"integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==",
"dependencies": {}
},
"exif-parser@0.1.12": {
"integrity": "sha512-c2bQfLNbMzLPmzQuOr8fy0csy84WmwnER81W88DzTp9CYNPJ6yzOj2EZAh9pywYpqHnshVLHQJ8WzldAyfY+Iw==",
"dependencies": {}
},
"file-type@16.5.4": {
"integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==",
"dependencies": {
"readable-web-to-node-stream": "readable-web-to-node-stream@3.0.2",
"strtok3": "strtok3@6.3.0",
"token-types": "token-types@4.2.1"
}
},
"gifwrap@0.9.4": {
"integrity": "sha512-MDMwbhASQuVeD4JKd1fKgNgCRL3fGqMM4WaqpNhWO0JiMOAjbQdumbs4BbBZEy9/M00EHEjKN3HieVhCUlwjeQ==",
"dependencies": {
"image-q": "image-q@4.0.0",
"omggif": "omggif@1.0.10"
}
},
"global@4.4.0": {
"integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==",
"dependencies": {
"min-document": "min-document@2.19.0",
"process": "process@0.11.10"
}
},
"ieee754@1.2.1": {
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"dependencies": {}
},
"image-q@4.0.0": {
"integrity": "sha512-PfJGVgIfKQJuq3s0tTDOKtztksibuUEbJQIYT3by6wctQo+Rdlh7ef4evJ5NCdxY4CfMbvFkocEwbl4BF8RlJw==",
"dependencies": {
"@types/node": "@types/node@16.9.1"
}
},
"inherits@2.0.4": {
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dependencies": {}
},
"is-function@1.0.2": {
"integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==",
"dependencies": {}
},
"isomorphic-fetch@3.0.0": {
"integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==",
"dependencies": {
"node-fetch": "node-fetch@2.6.11",
"whatwg-fetch": "whatwg-fetch@3.6.2"
}
},
"jimp@0.22.8_@jimp+custom@0.22.8": {
"integrity": "sha512-pBbrooJMX7795sDcxx1XpwNZC8B/ITyDV+JK2/1qNbQl/1UWqWeh5Dq7qQpMZl5jLdcFDv5IVTM+OhpafSqSFA==",
"dependencies": {
"@jimp/custom": "@jimp/custom@0.22.8",
"@jimp/plugins": "@jimp/plugins@0.22.8_@jimp+custom@0.22.8_@jimp+plugin-blit@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-resize@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-scale@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-crop@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-rotate@0.22.8__@jimp+custom@0.22.8__@jimp+plugin-blit@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-crop@0.22.8___@jimp+custom@0.22.8__@jimp+plugin-resize@0.22.8___@jimp+custom@0.22.8_@jimp+plugin-blur@0.22.8__@jimp+custom@0.22.8_@jimp+plugin-color@0.22.8__@jimp+custom@0.22.8",
"@jimp/types": "@jimp/types@0.22.8_@jimp+custom@0.22.8",
"regenerator-runtime": "regenerator-runtime@0.13.11"
}
},
"jpeg-js@0.4.4": {
"integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==",
"dependencies": {}
},
"load-bmfont@1.4.1": {
"integrity": "sha512-8UyQoYmdRDy81Brz6aLAUhfZLwr5zV0L3taTQ4hju7m6biuwiWiJXjPhBJxbUQJA8PrkvJ/7Enqmwk2sM14soA==",
"dependencies": {
"buffer-equal": "buffer-equal@0.0.1",
"mime": "mime@1.6.0",
"parse-bmfont-ascii": "parse-bmfont-ascii@1.0.6",
"parse-bmfont-binary": "parse-bmfont-binary@1.0.6",
"parse-bmfont-xml": "parse-bmfont-xml@1.1.4",
"phin": "phin@2.9.3",
"xhr": "xhr@2.6.0",
"xtend": "xtend@4.0.2"
}
},
"mime@1.6.0": {
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dependencies": {}
},
"min-document@2.19.0": {
"integrity": "sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==",
"dependencies": {
"dom-walk": "dom-walk@0.1.2"
}
},
"mkdirp@2.1.6": {
"integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==",
"dependencies": {}
},
"node-fetch@2.6.11": {
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dependencies": {
"whatwg-url": "whatwg-url@5.0.0"
}
},
"omggif@1.0.10": {
"integrity": "sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==",
"dependencies": {}
},
"pako@1.0.11": {
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
"dependencies": {}
},
"parse-bmfont-ascii@1.0.6": {
"integrity": "sha512-U4RrVsUFCleIOBsIGYOMKjn9PavsGOXxbvYGtMOEfnId0SVNsgehXh1DxUdVPLoxd5mvcEtvmKs2Mmf0Mpa1ZA==",
"dependencies": {}
},
"parse-bmfont-binary@1.0.6": {
"integrity": "sha512-GxmsRea0wdGdYthjuUeWTMWPqm2+FAd4GI8vCvhgJsFnoGhTrLhXDDupwTo7rXVAgaLIGoVHDZS9p/5XbSqeWA==",
"dependencies": {}
},
"parse-bmfont-xml@1.1.4": {
"integrity": "sha512-bjnliEOmGv3y1aMEfREMBJ9tfL3WR0i0CKPj61DnSLaoxWR3nLrsQrEbCId/8rF4NyRF0cCqisSVXyQYWM+mCQ==",
"dependencies": {
"xml-parse-from-string": "xml-parse-from-string@1.0.1",
"xml2js": "xml2js@0.4.23"
}
},
"parse-headers@2.0.5": {
"integrity": "sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA==",
"dependencies": {}
},
"peek-readable@4.1.0": {
"integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==",
"dependencies": {}
},
"phin@2.9.3": {
"integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==",
"dependencies": {}
},
"pixelmatch@4.0.2": {
"integrity": "sha512-J8B6xqiO37sU/gkcMglv6h5Jbd9xNER7aHzpfRdNmV4IbQBzBpe4l9XmbG+xPF/znacgu2jfEw+wHffaq/YkXA==",
"dependencies": {
"pngjs": "pngjs@3.4.0"
}
},
"pngjs@3.4.0": {
"integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==",
"dependencies": {}
},
"pngjs@6.0.0": {
"integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==",
"dependencies": {}
},
"process@0.11.10": {
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
"dependencies": {}
},
"readable-stream@3.6.2": {
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
"dependencies": {
"inherits": "inherits@2.0.4",
"string_decoder": "string_decoder@1.3.0",
"util-deprecate": "util-deprecate@1.0.2"
}
},
"readable-web-to-node-stream@3.0.2": {
"integrity": "sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw==",
"dependencies": {
"readable-stream": "readable-stream@3.6.2"
}
},
"regenerator-runtime@0.13.11": {
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
"dependencies": {}
},
"safe-buffer@5.2.1": {
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"dependencies": {}
},
"sax@1.2.4": {
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
"dependencies": {}
},
"string_decoder@1.3.0": {
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"dependencies": {
"safe-buffer": "safe-buffer@5.2.1"
}
},
"strtok3@6.3.0": {
"integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==",
"dependencies": {
"@tokenizer/token": "@tokenizer/token@0.3.0",
"peek-readable": "peek-readable@4.1.0"
}
},
"timm@1.7.1": {
"integrity": "sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==",
"dependencies": {}
},
"tinycolor2@1.6.0": {
"integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==",
"dependencies": {}
},
"token-types@4.2.1": {
"integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==",
"dependencies": {
"@tokenizer/token": "@tokenizer/token@0.3.0",
"ieee754": "ieee754@1.2.1"
}
},
"tr46@0.0.3": {
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"dependencies": {}
},
"utif2@4.1.0": {
"integrity": "sha512-+oknB9FHrJ7oW7A2WZYajOcv4FcDR4CfoGB0dPNfxbi4GO05RRnFmt5oa23+9w32EanrYcSJWspUiJkLMs+37w==",
"dependencies": {
"pako": "pako@1.0.11"
}
},
"util-deprecate@1.0.2": {
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"dependencies": {}
},
"webidl-conversions@3.0.1": {
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"dependencies": {}
},
"whatwg-fetch@3.6.2": {
"integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==",
"dependencies": {}
},
"whatwg-url@5.0.0": {
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "tr46@0.0.3",
"webidl-conversions": "webidl-conversions@3.0.1"
}
},
"xhr@2.6.0": {
"integrity": "sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA==",
"dependencies": {
"global": "global@4.4.0",
"is-function": "is-function@1.0.2",
"parse-headers": "parse-headers@2.0.5",
"xtend": "xtend@4.0.2"
}
},
"xml-parse-from-string@1.0.1": {
"integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==",
"dependencies": {}
},
"xml2js@0.4.23": {
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
"dependencies": {
"sax": "sax@1.2.4",
"xmlbuilder": "xmlbuilder@11.0.1"
}
},
"xmlbuilder@11.0.1": {
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"dependencies": {}
},
"xtend@4.0.2": {
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"dependencies": {}
}
}
}
}

@ -0,0 +1,70 @@
import Jimp from 'npm:jimp@0.22.8'
function floydSteinberg (data: Buffer, w: number, h: number) {
const errorMultiplier = .6 // 1 is normal, 0.5 is "reduced color bleeding"
const filter = [
[0, 0, 0, 7 / 48, 5 / 48],
[3 / 48, 5 / 48, 7 / 48, 5 / 48, 3 / 48],
[1 / 48, 3 / 48, 5 / 48, 3 / 48, 1 / 48]
]
const error = Array(h)
let r: number
let g: number
let b: number
for (let y = 0; y < h; y++) error[y] = new Float32Array(w)
for (let y = 0; y < h; y++) {
for (let x = 0; x < w; x++) {
const id = ((y * w) + x) * 4
r = data[id]
g = data[id + 1]
b = data[id + 2]
let avg = (r + g + b) / 3
avg -= error[y][x] * errorMultiplier
let e = 0
if (avg < 128) {
e = -avg
avg = 0
} else {
e = 255 - avg
avg = 255
}
data[id] = data[id + 1] = data[id + 2] = avg
data[id + 3] = 255
for (let yy = 0; yy < 3; yy++) {
for (let xx = -2; xx <= 2; xx++) {
if (y + yy < 0 || h <= y + yy || x + xx < 0 || w <= x + xx) continue
error[y + yy][x + xx] += e * filter[yy][xx + 2]
}
}
}
}
return data
}
export default async function process (source: string, destinationWidth?: number, destinationHeight?: number, storeAs?: string): Uint8ClampedArray | null {
try {
const image = await Jimp.read(source)
const width = destinationWidth ?? image.bitmap.width
const height = destinationHeight ?? image.bitmap.height
image.grayscale().cover(width, height)
const data = floydSteinberg(image.bitmap.data, width, height)
if (storeAs) {
new Jimp({data, width, height }, (err, image) => image.write(storeAs))
}
return new Uint8ClampedArray(data)
} catch (error) {
console.error('failed to process image', error)
return null
}
}

@ -0,0 +1,20 @@
import dither from './dither.ts'
import initTransmitter from './transmit.ts'
const ADDRESS = '192.168.178.200'
const DISPLAY_SIZE = [800, 480]
const imgSrcPath = Deno.args[0]
const imgDstPath = Deno.args[1]
// Learn more at https://deno.land/manual/examples/module_metadata#concepts
if (import.meta.main) {
if (!imgSrcPath) {
console.error('Usage: deno main.ts <input-path> [output-path]')
} else {
const [w, h] = DISPLAY_SIZE
const transmit = initTransmitter(ADDRESS)
const imageData = await dither(imgSrcPath, w, h, imgDstPath)
transmit(imageData, w, h)
}
}

@ -0,0 +1,61 @@
import { assertEquals } from "https://deno.land/std@0.176.0/testing/asserts.ts";
import { byteToStr, wordToStr, DisplayCode, getPixelValue } from './transmit.ts'
function orig_byteToStr(v: number) {
return String.fromCharCode((v & 0xF) + 97, ((v >> 4) & 0xF) + 97);
}
function orig_wordToStr(v: number) {
return byteToStr(v & 0xFF) + byteToStr((v >> 8) & 0xFF);
}
function orig_displayCode(epdInd = 22) {
return "EPD" + String.fromCharCode(epdInd + 97) + "_"
}
function orig_getVal(p: { data: Uint8ClampedArray }, i: number) {
if ((p.data[i]==0x00) && (p.data[i+1]==0x00)) return 0
if ((p.data[i]==0xFF) && (p.data[i+1]==0xFF)) return 1
if ((p.data[i]==0x7F) && (p.data[i+1]==0x7F)) return 2
return 3
}
Deno.test(function test_byteToStr() {
const testValues = [0,1,2,23,42,255]
const results = testValues.map(v => byteToStr(v))
const expected = testValues.map(v => orig_byteToStr(v))
assertEquals(results, expected)
})
Deno.test(function test_wordToStr() {
const testValues = [0,1,2,23,42,384]
const results = testValues.map(v => wordToStr(v))
const expected = testValues.map(v => orig_wordToStr(v))
assertEquals(results, expected)
})
Deno.test(function test_displayCode() {
assertEquals(orig_displayCode(), DisplayCode)
})
Deno.test(function test_getPixelValue() {
// 4 pixels: white, black, black, white
const data = new Uint8ClampedArray([
255, 255, 255, 255,
0, 0, 0, 255,
0, 0, 0, 255,
255, 255, 255, 255,
])
const results = [
getPixelValue(data, 0 << 2),
getPixelValue(data, 1 << 2),
getPixelValue(data, 2 << 2),
getPixelValue(data, 3 << 2),
]
const expected = [
orig_getVal({ data }, 0 << 2),
orig_getVal({ data }, 1 << 2),
orig_getVal({ data }, 2 << 2),
orig_getVal({ data }, 3 << 2),
]
assertEquals(results, expected)
})

@ -0,0 +1,39 @@
/**
******************************************************************************
@file Loader.h
@author Waveshare Team
@version V2.0.0
@date 10-August-2018
@brief The main file.
This file provides firmware functions:
+ Initialization of Serial Port, SPI pins and server
+ Main loop
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "srvr.h" // Server functions
/* Entry point ----------------------------------------------------------------*/
void setup()
{
// Serial port initialization
Serial.begin(115200);
delay(10);
// Bluetooth initialization
Srvr__btSetup();
// SPI initialization
EPD_initSPI();
// Initialization is complete
Serial.print("\r\nOk!\r\n");
}
/* The main loop -------------------------------------------------------------*/
void loop()
{
Srvr__loop();
}

@ -0,0 +1,56 @@
/**
******************************************************************************
* @file buff.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief ESP8266 WiFi server.
* This file provides firmware functions:
* + Sending web page of the tool to a client's browser
* + Uploading images from client part by part
*
******************************************************************************
*/
/* Size, current position index and byte array of the buffer -----------------*/
#define Buff__SIZE 2050
int Buff__bufInd;
char Buff__bufArr[Buff__SIZE];
/* Reads a word from the buffer at specified position ------------------------*/
int Buff__getByte(int index)
{
return Buff__bufArr[index];
}
/* Reads a byte from the buffer at specified position ------------------------*/
int Buff__getWord(int index)
{
if (index + 1 >= Buff__SIZE) return -1;
return Buff__bufArr[index] + (Buff__bufArr[index + 1] << 8);
}
/* Reads a byte from the buffer at specified position ------------------------*/
int Buff__getN3(int index)
{
return (index + 3 > Buff__SIZE) ? 0 :
(Buff__bufArr[index ] ) +
(Buff__bufArr[index + 1] << 8) +
(Buff__bufArr[index + 2] << 16);
}
/* Checks if the buffer's data ends with specified string --------------------*/
int Buff__signature(int index, char*str)
{
// characters of the string to the end of the string
while (*str != 0)
{
// If the correspondent character in the buffer isn't equal
// to the string's character, return false
if (Buff__bufArr[index++] != *str) return false;
str++;
}
// Otherwise return true
return true;
}

@ -0,0 +1,597 @@
/**
******************************************************************************
* @file epd.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file provides e-Paper driver functions
* void EPD_SendCommand(byte command);
* void EPD_SendData(byte data);
* void EPD_WaitUntilIdle();
* void EPD_Send_1(byte c, byte v1);
* void EPD_Send_2(byte c, byte v1, byte v2);
* void EPD_Send_3(byte c, byte v1, byte v2, byte v3);
* void EPD_Send_4(byte c, byte v1, byte v2, byte v3, byte v4);
* void EPD_Send_5(byte c, byte v1, byte v2, byte v3, byte v4, byte v5);
* void EPD_Reset();
* void EPD_dispInit();
*
* varualbes:
* EPD_dispLoad; - pointer on current loading function
* EPD_dispIndex; - index of current e-Paper
* EPD_dispInfo EPD_dispMass[]; - array of e-Paper properties
*
******************************************************************************
*/
/* SPI pin definition --------------------------------------------------------*/
#define PIN_SPI_SCK 13
#define PIN_SPI_DIN 14
#define PIN_SPI_CS 15
#define PIN_SPI_BUSY 25//19
#define PIN_SPI_RST 26//21
#define PIN_SPI_DC 27//22
/* Pin level definition ------------------------------------------------------*/
#define LOW 0
#define HIGH 1
#define GPIO_PIN_SET 1
#define GPIO_PIN_RESET 0
#define UBYTE uint8_t
#define UWORD uint16_t
#define UDOUBLE uint32_t
void EPD_initSPI()
{
//Serial.println(SPI._spi_num);
//Serial.println(SPI.get);
pinMode(PIN_SPI_BUSY, INPUT);
pinMode(PIN_SPI_RST , OUTPUT);
pinMode(PIN_SPI_DC , OUTPUT);
pinMode(PIN_SPI_SCK, OUTPUT);
pinMode(PIN_SPI_DIN, OUTPUT);
pinMode(PIN_SPI_CS , OUTPUT);
digitalWrite(PIN_SPI_CS , HIGH);
digitalWrite(PIN_SPI_SCK, LOW);
//SPI.begin();
}
/* Lut mono ------------------------------------------------------------------*/
byte lut_full_mono[] =
{
0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22,
0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88,
0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51,
0x35, 0x51, 0x51, 0x19, 0x01, 0x00
};
byte lut_partial_mono[] =
{
0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* The procedure of sending a byte to e-Paper by SPI -------------------------*/
void EpdSpiTransferCallback(byte data)
{
//SPI.beginTransaction(spi_settings);
digitalWrite(PIN_SPI_CS, GPIO_PIN_RESET);
for (int i = 0; i < 8; i++)
{
if ((data & 0x80) == 0) digitalWrite(PIN_SPI_DIN, GPIO_PIN_RESET);
else digitalWrite(PIN_SPI_DIN, GPIO_PIN_SET);
data <<= 1;
digitalWrite(PIN_SPI_SCK, GPIO_PIN_SET);
digitalWrite(PIN_SPI_SCK, GPIO_PIN_RESET);
}
//SPI.transfer(data);
digitalWrite(PIN_SPI_CS, GPIO_PIN_SET);
//SPI.endTransaction();
}
byte lut_vcom0[] = { 15, 0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A, 0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00 };
byte lut_w [] = { 15, 0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04 };
byte lut_b [] = { 15, 0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04 };
byte lut_g1 [] = { 15, 0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04 };
byte lut_g2 [] = { 15, 0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04 };
byte lut_vcom1[] = { 15, 0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte lut_red0 [] = { 15, 0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte lut_red1 [] = { 15, 0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* Sending a byte as a command -----------------------------------------------*/
void EPD_SendCommand(byte command)
{
digitalWrite(PIN_SPI_DC, LOW);
EpdSpiTransferCallback(command);
}
/* Sending a byte as a data --------------------------------------------------*/
void EPD_SendData(byte data)
{
digitalWrite(PIN_SPI_DC, HIGH);
EpdSpiTransferCallback(data);
}
/* Waiting the e-Paper is ready for further instructions ---------------------*/
void EPD_WaitUntilIdle()
{
//0: busy, 1: idle
while(digitalRead(PIN_SPI_BUSY) == 0) delay(100);
}
/* Waiting the e-Paper is ready for further instructions ---------------------*/
void EPD_WaitUntilIdle_high()
{
//1: busy, 0: idle
while(digitalRead(PIN_SPI_BUSY) == 1) delay(100);
}
/* Send a one-argument command -----------------------------------------------*/
void EPD_Send_1(byte c, byte v1)
{
EPD_SendCommand(c);
EPD_SendData(v1);
}
/* Send a two-arguments command ----------------------------------------------*/
void EPD_Send_2(byte c, byte v1, byte v2)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
}
/* Send a three-arguments command --------------------------------------------*/
void EPD_Send_3(byte c, byte v1, byte v2, byte v3)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
}
/* Send a four-arguments command ---------------------------------------------*/
void EPD_Send_4(byte c, byte v1, byte v2, byte v3, byte v4)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
EPD_SendData(v4);
}
/* Send a five-arguments command ---------------------------------------------*/
void EPD_Send_5(byte c, byte v1, byte v2, byte v3, byte v4, byte v5)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
EPD_SendData(v4);
EPD_SendData(v5);
}
/* Writting lut-data into the e-Paper ----------------------------------------*/
void EPD_lut(byte c, byte l, byte*p)
{
// lut-data writting initialization
EPD_SendCommand(c);
// lut-data writting doing
for (int i = 0; i < l; i++, p++) EPD_SendData(*p);
}
/* Writting lut-data of the black-white channel ------------------------------*/
void EPD_SetLutBw(byte*c20, byte*c21, byte*c22, byte*c23, byte*c24)
{
EPD_lut(0x20, *c20, c20 + 1);//g vcom
EPD_lut(0x21, *c21, c21 + 1);//g ww --
EPD_lut(0x22, *c22, c22 + 1);//g bw r
EPD_lut(0x23, *c23, c23 + 1);//g wb w
EPD_lut(0x24, *c24, c24 + 1);//g bb b
}
/* Writting lut-data of the red channel --------------------------------------*/
void EPD_SetLutRed(byte*c25, byte*c26, byte*c27)
{
EPD_lut(0x25, *c25, c25 + 1);
EPD_lut(0x26, *c26, c26 + 1);
EPD_lut(0x27, *c27, c27 + 1);
}
/* This function is used to 'wake up" the e-Paper from the deep sleep mode ---*/
void EPD_Reset()
{
digitalWrite(PIN_SPI_RST, HIGH);
delay(200);
digitalWrite(PIN_SPI_RST, LOW);
delay(200);
digitalWrite(PIN_SPI_RST, HIGH);
delay(200);
}
/* e-Paper initialization functions ------------------------------------------*/
#include "epd1in54.h"
#include "epd2in13.h"
#include "epd2in9.h"
#include "epd2in7.h"
#include "epd2in66.h"
#include "epd3in7.h"
#include "epd3in52.h"
#include "epd4in01f.h"
#include "epd4in2.h"
#include "epd5in83.h"
#include "epd5in65f.h"
#include "epd7in5.h"
#include "epd7in5_HD.h"
bool EPD_invert; // If true, then image data bits must be inverted
int EPD_dispIndex; // The index of the e-Paper's type
int EPD_dispX, EPD_dispY; // Current pixel's coordinates (for 2.13 only)
void(*EPD_dispLoad)(); // Pointer on a image data writting function
/* Image data loading function for a-type e-Paper ----------------------------*/
void EPD_loadA()
{
// Get the index of the image data begin
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte
int value = Buff__getByte(pos);
// Invert byte's bits in case of '2.7' e-Paper
if (EPD_invert) value = ~value;
// Write the byte into e-Paper's memory
EPD_SendData((byte)value);
// Increment the current byte index on 2 characters
pos++;
}
}
void EPD_loadAFilp()
{
// Get the index of the image data begin
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte
int value = Buff__getByte(pos);
// Invert byte's bits in case of '2.7' e-Paper
if (EPD_invert) value = ~value;
// Write the byte into e-Paper's memory
EPD_SendData(~(byte)value);
// Increment the current byte index on 2 characters
pos++;
}
}
/* Image data loading function for b-type e-Paper ----------------------------*/
void EPD_loadB()
{
// Get the index of the image data begin
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current word from obtained image data
int valueA = (int)Buff__getWord(pos);
// Clean current word of processed image data
int valueB = 0;
// Enumerate next 8 pixels
for (int p = 0; p < 8; p++)
{
// Current obtained pixel data
int pixInd = valueA & 3;
// Remove the obtained pixel data from 'valueA' word
valueA = valueA >> 2;
// Processing of 8 2-bit pixels to 8 2-bit pixels:
// black(value 0) to bits 00, white(value 1) to bits 11, gray(otherwise) to bits 10
valueB = (valueB << 2) + (pixInd == 1 ? 3 : (pixInd == 0 ? 0 : 2));
}
// Write the word into e-Paper's memory
EPD_SendData((byte)(valueB >> 8));
EPD_SendData((byte)valueB);
// Increment the current byte index on 2 characters
pos += 2;
}
}
/* Image data loading function for 2.13 e-Paper ------------------------------*/
void EPD_loadC()
{
// Get the index of the image data begin
int pos = 6;
EPD_Send_2(0x44, 0, 15); //SET_RAM_X_ADDRESS_START_END_POSITION LO(x >> 3), LO((w - 1) >> 3)
EPD_Send_4(0x45, 0, 0, 249, 0); //SET_RAM_Y_ADDRESS_START_END_POSITION LO(y), HI(y), LO(h - 1), HI(h - 1)
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Before write a line of image data
// 2.13 e-Paper requires to set the address counter
// Every line has 15*8-6 pixels + 6 empty bits, totally 15*8 bits
if (EPD_dispX == 0)
{
EPD_Send_1(0x4E, 0 );//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3)
EPD_Send_2(0x4F, EPD_dispY, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y)
EPD_SendCommand(0x24);//WRITE_RAM
}
// Write the byte into e-Paper's memory
EPD_SendData((byte)Buff__getByte(pos));
// Increment the current byte index on 2 characters
pos++;
// EPD_dispX and EPD_dispY increments
if (++EPD_dispX > 15)
{
EPD_dispX = 0;
// If the client's browser sends more bits, than it needs, then exit the function
if (++EPD_dispY > 250) return;
}
}
}
/* Image data loading function for 7.5 e-Paper -------------------------------*/
void EPD_loadD()
{
// Get the index of the image data begin
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int valueA = Buff__getByte(pos);
// Processing of 4 1-bit pixels to 4 4-bit pixels:
// black(value 0) to bits 0000, white(value 1) to bits 0011
EPD_SendData((byte)((valueA & 0x80) ? 0x30 : 0x00) + ((valueA & 0x40) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x20) ? 0x30 : 0x00) + ((valueA & 0x10) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x08) ? 0x30 : 0x00) + ((valueA & 0x04) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x02) ? 0x30 : 0x00) + ((valueA & 0x01) ? 0x03 : 0x00));
// Increment the current byte index on 2 characters
pos++;
}
}
/* Image data loading function for 7.5b e-Paper ------------------------------*/
void EPD_loadE()
{
// Get the index of the image data begin
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int value = Buff__getByte(pos);
// Processing of 4 1-bit pixels to 4 4-bit pixels:
// red(value 1) to bits 0011, white(value 3) to bits 0100
int A = (value ) & 3;if (A == 3) A = 4;if (A == 1) A = 3;
int B = (value >> 2) & 3;if (B == 3) B = 4;if (B == 1) B = 3;
int C = (value >> 4) & 3;if (C == 3) C = 4;if (C == 1) C = 3;
int D = (value >> 6) & 3;if (D == 3) D = 4;if (D == 1) D = 3;
// Write the word into e-Paper's memory
EPD_SendData((A << 4) + B);
EPD_SendData((C << 4) + D);
// Increment the current byte index on 2 characters
pos++;
}
}
/* Image data loading function for 5.65f e-Paper -----------------------------*/
void EPD_loadG()
{
// Come back to the image data end
int pos = 6;
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int value = Buff__getByte(pos);
// Switch the positions of the two 4-bits pixels
// Black:0b000;White:0b001;Green:0b010;Blue:0b011;Red:0b100;Yellow:0b101;Orange:0b110;
int A = (value ) & 0x07;
int B = (value >> 4) & 0x07;
// Write the data into e-Paper's memory
EPD_SendData((byte)(A << 4) + B);
// Increment the current byte index on 2 characters
pos ++;
}
}
/* Show image and turn to deep sleep mode (a-type, 4.2 and 2.7 e-Paper) ------*/
void EPD_showA()
{
// Refresh
EPD_Send_1(0x22, 0xC4);//DISPLAY_UPDATE_CONTROL_2
EPD_SendCommand(0x20);//MASTER_ACTIVATION
EPD_SendCommand(0xFF);//TERMINATE_FRAME_READ_WRITE
EPD_WaitUntilIdle();
// Sleep
EPD_SendCommand(0x10);//DEEP_SLEEP_MODE
EPD_WaitUntilIdle();
}
/* Show image and turn to deep sleep mode (b-type, e-Paper) ------------------*/
void EPD_showB()
{
// Refresh
EPD_SendCommand(0x12);//DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
// Sleep
EPD_Send_1(0x50, 0x17);//VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x82, 0x00);//VCM_DC_SETTING_REGISTER, to solve Vcom drop
EPD_Send_4(0x01, 0x02, 0x00, 0x00, 0x00);//POWER_SETTING
EPD_WaitUntilIdle();
EPD_SendCommand(0x02);//POWER_OFF
}
/* Show image and turn to deep sleep mode (7.5 and 7.5b e-Paper) -------------*/
void EPD_showC()
{
// Refresh
EPD_SendCommand(0x12);//DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
// Sleep
EPD_SendCommand(0x02);// POWER_OFF
EPD_WaitUntilIdle();
EPD_Send_1(0x07, 0xA5);// DEEP_SLEEP
}
/* Show image and turn to deep sleep mode (2.13 e-Paper) ---------------------*/
void EPD_showD()
{
// VCOM AND DATA INTERVAL SETTING
// WBmode:VBDF 17, D7 VBDW 97, VBDB 57
// WBRmode:VBDF F7, VBDW 77, VBDB 37, VBDR B7
EPD_Send_1(0x50, 0x97);
EPD_SendCommand(0x20);
for(int count=0; count<44; count++) EPD_SendData(lut_vcomDC_2in13d[count]);
EPD_SendCommand(0x21);
for(int count=0; count<42; count++) EPD_SendData(lut_ww_2in13d[count]);
EPD_SendCommand(0x22);
for(int count=0; count<42; count++) EPD_SendData(lut_bw_2in13d[count]);
EPD_SendCommand(0x23);
for(int count=0; count<42; count++) EPD_SendData(lut_wb_2in13d[count]);
EPD_SendCommand(0x24);
for(int count=0; count<42; count++) EPD_SendData(lut_bb_2in13d[count]);
delay(10);
EPD_SendCommand(0x12);//DISPLAY REFRESH
delay(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_WaitUntilIdle();
EPD_Send_1(0x50, 0xf7);
EPD_SendCommand( 0x02);//POWER_OFF
EPD_Send_1(0x07, 0xA5);//DEEP_SLEEP
}
/* The set of pointers on 'init', 'load' and 'show' functions, title and code */
struct EPD_dispInfo
{
int(*init)(); // Initialization
void(*chBk)();// Black channel loading
int next; // Change channel code
void(*chRd)();// Red channel loading
void(*show)();// Show and sleep
char*title; // Title of an e-Paper
};
/* Array of sets describing the usage of e-Papers ----------------------------*/
EPD_dispInfo EPD_dispMass[] =
{
{ EPD_Init_1in54 , EPD_loadA, -1 , 0, EPD_showA, "1.54 inch" },// a 0
{ EPD_Init_1in54b, EPD_loadB, 0x13, EPD_loadA, EPD_showB, "1.54 inch b" },// b 1
{ EPD_Init_1in54c, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "1.54 inch c" },// c 2
{ EPD_Init_2in13 , EPD_loadC, -1 , 0, EPD_showA, "2.13 inch" },// d 3
{ EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch b" },// e 4
{ EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch c" },// f 5
{ EPD_Init_2in13d, EPD_loadA, -1 , 0, EPD_showD, "2.13 inch d" },// g 6
{ EPD_Init_2in7 , EPD_loadA, -1 , 0, EPD_showB, "2.7 inch" },// h 7
{ EPD_Init_2in7b , EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.7 inch b" },// i 8
{ EPD_Init_2in9 , EPD_loadA, -1 , 0, EPD_showA, "2.9 inch" },// j 9
{ EPD_Init_2in9b , EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch b" },// k 10
{ EPD_Init_2in9b , EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch c" },// l 11
{ EPD_Init_2in9d , EPD_loadA, -1 , 0, EPD_2IN9D_Show, "2.9 inch d" },// M 12
{ EPD_Init_4in2 , EPD_loadA, -1 , 0, EPD_showB, "4.2 inch" },// m 12
{ EPD_Init_4in2b , EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch b" },// n 13
{ EPD_Init_4in2b , EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch c" },// o 14
{ EPD_Init_5in83 , EPD_loadD, -1 , 0, EPD_showC, "5.83 inch" },// p 15
{ EPD_Init_5in83b, EPD_loadE, -1 , 0, EPD_showC, "5.83 inch b" },// q 16
{ EPD_Init_5in83b, EPD_loadE, -1 , 0, EPD_showC, "5.83 inch c" },// r 17
{ EPD_Init_7in5 , EPD_loadD, -1 , 0, EPD_showC, "7.5 inch" },// s 18
{ EPD_Init_7in5 , EPD_loadE, -1 , 0, EPD_showC, "7.5 inch b" },// t 19
{ EPD_Init_7in5 , EPD_loadE, -1 , 0, EPD_showC, "7.5 inch c" }, // u 20
{ EPD_7in5_V2_init , EPD_loadAFilp, -1 , 0, EPD_7IN5_V2_Show, "7.5 inch V2" },// w 22
{ EPD_7in5B_V2_Init , EPD_loadA, 0x13 , EPD_loadAFilp, EPD_7IN5_V2_Show, "7.5 inch B V2 "},// x 23
{ EPD_7IN5B_HD_init , EPD_loadA, 0x26 , EPD_loadAFilp, EPD_7IN5B_HD_Show, "7.5 inch B HD "},// x 24
{ EPD_5IN65F_init, EPD_loadG, -1 , 0, EPD_5IN65F_Show, "5.65 inch F " },// z 25
{ EPD_7IN5_HD_init, EPD_loadA, -1, 0, EPD_7IN5_HD_Show, "7.5 inch HD" },// 26
{ EPD_3IN7_1Gray_Init, EPD_loadA, -1 , 0, EPD_3IN7_1Gray_Show,"3.7 inch" },// 27
{ EPD_2IN66_Init, EPD_loadA, -1 , 0, EPD_2IN66_Show, "2.66 inch" },// 28
{ EPD_5in83b_V2_init, EPD_loadA, 0x13, EPD_loadAFilp, EPD_showC, "5.83 inch B V2"},// 29
{ EPD_Init_2in9b_V3, EPD_loadA, 0x13, EPD_loadA, EPD_showC, "2.9 inch B V3" },// 30
{ EPD_1IN54B_V2_Init, EPD_loadA, 0x26, EPD_loadAFilp, EPD_1IN54B_V2_Show, "1.54 inch B V2"},// 31
{ EPD_2IN13B_V3_Init, EPD_loadA, 0x13, EPD_loadA, EPD_2IN13B_V3_Show, "2.13 inch B V3"},// 32
{ EPD_Init_2in9_V2, EPD_loadA, -1, 0, EPD_2IN9_V2_Show, "2.9 inch V2" },// 33
{ EPD_Init_4in2b_V2, EPD_loadA, 0x13, EPD_loadA, EPD_4IN2B_V2_Show, "4.2 inch B V2" },// 34
{ EPD_2IN66B_Init, EPD_loadA, 0x26, EPD_loadAFilp, EPD_2IN66_Show, "2.66 inch B" },// 35
{ EPD_Init_5in83_V2, EPD_loadAFilp, -1, 0, EPD_showC, "5.83 inch V2" },// 36
{ EPD_4IN01F_init, EPD_loadG, -1, 0, EPD_4IN01F_Show, "4.01 inch F" },// 37
{ EPD_Init_2in7b_V2, EPD_loadA, 0x26, EPD_loadAFilp, EPD_2in7b_V2_Show, "2.7 inch B V2" },// 38
{ EPD_Init_2in13_V3, EPD_loadC, -1, 0, EPD_2IN13_V3_Show, "2.13 inch V3" },// 39
{ EPD_2IN13B_V4_Init, EPD_loadA, 0x26, EPD_loadA, EPD_2IN13B_V4_Show, "2.13 inch B V4"},// 40
{ EPD_3IN52_Init, EPD_loadA, -1, 0, EPD_3IN52_Show, "3.52 inch" },// 41
{ EPD_2IN7_V2_Init, EPD_loadA, -1 , 0, EPD_2IN7_V2_Show, "2.7 inch V2" },// 42
};
/* Initialization of an e-Paper ----------------------------------------------*/
void EPD_dispInit()
{
// Call initialization function
EPD_dispMass[EPD_dispIndex].init();
// Set loading function for black channel
EPD_dispLoad = EPD_dispMass[EPD_dispIndex].chBk;
// Set initial coordinates
EPD_dispX = 0;
EPD_dispY = 0;
// The inversion of image data bits isn't needed by default
EPD_invert = false;
}

@ -0,0 +1,168 @@
/**
******************************************************************************
* @file edp1in54.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 1.54 and 1.54b e-Papers
*
******************************************************************************
*/
int EPD_Init_1in54()
{
int EPD1in54 = 2;
if(EPD1in54 == 1) {
Serial.print("\r\nEPD1in54 V1");
EPD_Reset();
EPD_Send_3(0x01, 199, 0, 00);//DRIVER_OUTPUT_CONTROL: LO(EPD_HEIGHT-1), HI(EPD_HEIGHT-1). GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER: VCOM 7C
EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_lut(0x32, 30, &lut_full_mono[0]);
EPD_Send_2(0x44, 0, 24);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), LO((w-1) >> 3)
EPD_Send_4(0x45, 0, 0, 200, 0);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1), HI(h - 1)
EPD_Send_1(0x4E, 0);//LO(x >> 3)
EPD_Send_2(0x4F, 0, 0);//LO(y), HI(y >> 8)
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
} else {
Serial.print("\r\nEPD1in54 V2");
EPD_Reset();
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x12); //SWRESET
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x01); //Driver output control
EPD_SendData(0xC7);
EPD_SendData(0x00);
EPD_SendData(0x01);
EPD_SendCommand(0x11); //data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44); //set Ram-X address start/end position
EPD_SendData(0x00);
EPD_SendData(0x18); //0x0C-->(18+1)*8=200
EPD_SendCommand(0x45); //set Ram-Y address start/end position
EPD_SendData(0xC7); //0xC7-->(199+1)=200
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x3C); //BorderWavefrom
EPD_SendData(0x01);
EPD_SendCommand(0x18);
EPD_SendData(0x80);
EPD_SendCommand(0x22); // //Load Temperature and waveform setting.
EPD_SendData(0XB1);
EPD_SendCommand(0x20);
EPD_SendCommand(0x4E); // set RAM x address count to 0;
EPD_SendData(0x00);
EPD_SendCommand(0x4F); // set RAM y address count to 0X199;
EPD_SendData(0xC7);
EPD_SendData(0x00);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
Serial.print("\r\n init over");
EPD_SendCommand(0x24);//DATA_START_TRANSMISSION_1
}
return 0;
}
int EPD_Init_1in54b()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x07, 0x07, 0x07);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xCF);//PANEL_SETTING
EPD_Send_1(0x50, 0x37);//VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0xC8, 0x00, 0xC8);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x0E);//VCM_DC_SETTING_REGISTER
EPD_SetLutBw (&lut_vcom0[0], &lut_w[0], &lut_b[0], &lut_g1[0], &lut_g2[0]);
EPD_SetLutRed(&lut_vcom1[0], &lut_red0[0], &lut_red1[0]);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_1IN54B_V2_Init(void)
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0xc7, 0x00, 0x01); //Driver output control
EPD_Send_1(0x11, 0x01); //data entry mode
EPD_Send_2(0x44, 0x00, 0x18); //set Ram-X address start/end position
EPD_Send_4(0x45, 0xc7, 0x00, 0x00, 0x00); //set Ram-Y address start/end position
EPD_Send_1(0x3C, 0x05); //BorderWavefrom
EPD_Send_1(0x18, 0x80); //Read built-in temperature sensor
EPD_Send_1(0x4E, 0x00); // set RAM x address count to 0;
EPD_Send_2(0x4F, 0xc7, 0x00); // set RAM y address count to 0X199;
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);
delay(2);
return 0;
}
void EPD_1IN54B_V2_Show(void)
{
//refresh
EPD_Send_1(0x22, 0xf7); //Display Update Control
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
//sleep
EPD_Send_1(0x10, 0x01); //enter deep sleep
delay(2);
}
int EPD_Init_1in54c()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
//EPD_Send_2(0x00, 0x0F, 0x0D);//PANEL_SETTING
EPD_Send_1(0x50, 0xF7);//VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0x98, 0x00, 0x98);//TCON_RESOLUTION
EPD_Send_1(0x82, 0xF7);//VCM_DC_SETTING_REGISTER
EPD_SetLutBw (&lut_vcom0[0], &lut_w[0], &lut_b[0], &lut_g1[0], &lut_g2[0]);
EPD_SetLutRed(&lut_vcom1[0], &lut_red0[0], &lut_red1[0]);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}

@ -0,0 +1,315 @@
/**
******************************************************************************
* @file edp2in13.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of e-Papers:
* 2.13,
* 2.13b and 2.13c,
* 2.13d.
*
******************************************************************************
*/
unsigned char lut_full_2in13[] = {
0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_full_2in3v2[] = {
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
0x15,0x41,0xA8,0x32,0x30,0x0A,
};
const unsigned char WS_20_30_2IN13_V3[159] ={
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF, 0x0, 0x0, 0xF, 0x0, 0x0, 0x2,
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22, 0x17, 0x41, 0x0, 0x32, 0x36
};
const unsigned char lut_vcomDC_2in13d[] = {
0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00,
0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char lut_ww_2in13d[] = {
0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14,
0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_bw_2in13d[] = {
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_wb_2in13d[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14,
0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_bb_2in13d[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14,
0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int EPD_Init_2in13()
{
int EPD2in13V = 2;
if(EPD2in13V == 1) {
Serial.print("\r\nEPD_Init_2in13 V1");
EPD_Reset();
EPD_Send_3(0x01, 249, 0, 0); // DRIVER_OUTPUT_CONTROL: LO(h-1), HI(h-1), GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);// BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8); // WRITE_VCOM_REGISTER: VCOM 7C
EPD_Send_1(0x3A, 0x1A); // SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08); // SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03); // DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_lut(0x32, 30, &lut_full_2in13[0]);
return 0;
} else if(EPD2in13V == 2){
Serial.print("\r\nEPD_Init_2in13 V2");
EPD_Reset();
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x12);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_Send_1(0x74, 0x54);
EPD_Send_1(0x7e, 0x3B);
EPD_Send_3(0x01, 0XF9, 0X00, 0X00);
EPD_Send_1(0X11, 0X01);
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0xF9, 0x00, 0x00, 0x00);
EPD_Send_1(0X3C, 0X03);
EPD_Send_1(0X2C, 0X55);
EPD_Send_1(0x03, lut_full_2in3v2[70]);
EPD_Send_3(0x04, lut_full_2in3v2[71], lut_full_2in3v2[72], lut_full_2in3v2[73]);
EPD_Send_1(0x3A, lut_full_2in3v2[74]);
EPD_Send_1(0x3B, lut_full_2in3v2[75]);
int count;
EPD_SendCommand(0x32);
for(count = 0; count < 70; count++)
EPD_SendData(lut_full_2in3v2[count]);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0xF9, 0x00);
int Width, Height;
Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1);
Height = 250;
EPD_SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
EPD_SendData(0XFF);
}
}
EPD_SendCommand(0x22);
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
return 0;
}
}
int EPD_Init_2in13_V3()
{
Serial.print("\r\nEPD_Init_2in13 V3");
EPD_Reset();
delay(100);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
EPD_SendCommand(0x12);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
EPD_Send_3(0x01, 0XF9, 0X00, 0X00);
EPD_Send_1(0X11, 0X03);
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0x00, 0x00, 0x00, 0xF9);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0X00, 0X00);
EPD_Send_1(0x3C, 0x05);
EPD_Send_2(0x21, 0x00, 0x80);
EPD_Send_1(0x18, 0x80);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
int count;
EPD_SendCommand(0x32);
for(count = 0; count < 153; count++)
EPD_SendData(WS_20_30_2IN13_V3[count]);
EPD_Send_1(0x3f, WS_20_30_2IN13_V3[153]);
EPD_Send_1(0x03, WS_20_30_2IN13_V3[154]);
EPD_Send_3(0x04, WS_20_30_2IN13_V3[155], WS_20_30_2IN13_V3[156], WS_20_30_2IN13_V3[157]);
EPD_Send_1(0x2C, WS_20_30_2IN13_V3[158]);
int Width, Height;
Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1);
Height = 250;
EPD_SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
EPD_SendData(0XFF);
}
}
EPD_SendCommand(0x22);
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
return 0;
}
/* Show image and turn to deep sleep mode ------*/
void EPD_2IN13_V3_Show()
{
Serial.print("\r\n EPD_2IN13_V3_Show");
// Refresh
EPD_Send_1(0x22, 0xC7); //DISPLAY_UPDATE_CONTROL_2
EPD_SendCommand(0x20); //MASTER_ACTIVATION
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
// Sleep
EPD_Send_1(0x10, 0x01); //DEEP_SLEEP_MODE
EPD_WaitUntilIdle();
}
int EPD_Init_2in13b()
{
EPD_Reset();
EPD_Send_3(0x06, 0x17, 0x17, 0x17);// BOOSTER_SOFT_START
EPD_SendCommand(0x04); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x8F); // PANEL_SETTING
EPD_Send_1(0x50, 0x37); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_3(0x61, 0x68, 0, 0xD4); // TCON_RESOLUTION
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_2IN13B_V3_Init(void)
{
EPD_Reset();
delay(10);
EPD_SendCommand(0x04);
EPD_WaitUntilIdle();//waiting for the electronic paper IC to release the idle signal
EPD_Send_2(0x00, 0x0f, 0x89);//panel setting
EPD_Send_3(0x61, 0x68, 0x00, 0xd4);//resolution setting
EPD_Send_1(0X50, 0x77);//VCOM AND DATA INTERVAL SETTING
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_2IN13B_V3_Show()
{
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(2);
EPD_WaitUntilIdle();
EPD_Send_1(0X50, 0xf7);
EPD_SendCommand(0X02); //power off
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X07, 0xa5); //deep sleep
}
int EPD_2IN13B_V4_Init(void)
{
EPD_Reset();
delay(10);
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0xf9, 0x00, 0x00); //Driver output control
EPD_Send_1(0x11, 0x03); //data entry mode
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0x00, 0x00, 0x00, 0xF9);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0X00, 0X00);
EPD_Send_1(0x3C, 0x05); //BorderWavefrom
EPD_Send_1(0x18, 0x80); //Read built-in temperature sensor
EPD_Send_2(0x21, 0x80, 0x80); // Display update control
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);
return 0;
}
void EPD_2IN13B_V4_Show()
{
EPD_SendCommand(0x20); //DISPLAY REFRESH
delay(2);
EPD_WaitUntilIdle_high();
EPD_Send_1(0X10, 0x01);
}
int EPD_Init_2in13d()
{
EPD_Reset();
EPD_Send_5(0x01, 0x03, 0x00, 0x2b, 0x2b, 0x03);//POWER SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17); //BOOSTER_SOFT_START
EPD_SendCommand(0x04); //POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0xbf, 0x0d); //PANEL_SETTINGS: LUT from OTP£¬128x296
EPD_Send_1(0x30, 0x3a); //PLL_SETTINGS: 3a 100HZ, 29 150Hz, 39 200HZ, 31 171HZ, 3c 50hz
EPD_Send_3(0x61, 0x68, 0x00, 0xD4); //TCON_RESOLUTION
EPD_Send_1(0x82, 0x28); //VCOM_DC_SETTINGS
EPD_SendCommand(0x10);
for (int j = 0; j < 212; j++) for (int i = 0; i < 13; i++) EPD_SendData(0);
delay(10);
EPD_SendCommand(0x13);
return 0;
}

@ -0,0 +1,135 @@
/*****************************************************************************
* | File : EPD_2in66.c
* | Author : Waveshare team
* | Function : 2.66inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-08-10
* | Info :
* -----------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
// Display resolution
#define EPD_2IN66_WIDTH 152
#define EPD_2IN66_HEIGHT 296
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
static void EPD_2IN66_ReadBusy(void)
{
Serial.print("e-Paper busy\r\n");
delay(100);
while(digitalRead(PIN_SPI_BUSY) == 1) { //LOW: idle, HIGH: busy
delay(100);
}
delay(100);
Serial.print("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN66_Show(void)
{
EPD_SendCommand(0x20);
EPD_2IN66_ReadBusy();
Serial.print("EPD_2IN66_Show END\r\n");
EPD_SendCommand(0x10);//sleep
EPD_SendData(0x01);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_2IN66_Init(void)
{
EPD_Reset();
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
/* Y increment, X increment */
EPD_SendCommand(0x11);
EPD_SendData(0x03);
/* Set RamX-address Start/End position */
EPD_SendCommand(0x44);
EPD_SendData(0x01);
EPD_SendData((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1) );
/* Set RamY-address Start/End position */
EPD_SendCommand(0x45);
EPD_SendData(0);
EPD_SendData(0);
EPD_SendData((EPD_2IN66_HEIGHT&0xff));
EPD_SendData((EPD_2IN66_HEIGHT&0x100)>>8);
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x24);//show
return 0;
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_2IN66B_Init(void)
{
EPD_Reset();
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x11); //data entry mode
EPD_SendData(0x03);
EPD_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_SendData((0>>3) & 0x1F);
EPD_SendData(((EPD_2IN66_WIDTH-1)>>3) & 0x1F);
EPD_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_SendData(0 & 0xFF);
EPD_SendData((0 >> 8) & 0x01);
EPD_SendData((EPD_2IN66_HEIGHT-1) & 0xFF);
EPD_SendData(((EPD_2IN66_HEIGHT-1) >> 8) & 0x01);
EPD_SendCommand(0x21); // Display update control
EPD_SendData(0x00);
EPD_SendData(0x80);
EPD_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_SendData(0 & 0x1F);
EPD_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_SendData(0 & 0xFF);
EPD_SendData((0 >> 8) & 0x01);
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x24);//show
return 0;
}

@ -0,0 +1,240 @@
/**
******************************************************************************
* @file edp2in7.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 2.7 and 2.7b e-Papers
*
******************************************************************************
*/
unsigned char lut_dc_2in7[] =
{
0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32,
0x00, 0x00, 0x02, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_2in7[] =
{
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_2in7[] =
{
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_2in7[] =
{
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_2in7[] =
{
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_2in7()
{
EPD_Reset();
EPD_SendCommand(0x01);//POWER_SETTING
EPD_SendData(0x03); // VDS_EN, VDG_EN
EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
EPD_SendData(0x2b); // VDH
EPD_SendData(0x2b); // VDL
EPD_SendData(0x09); // VDHR
EPD_Send_3(0x06, 0x07, 0x07, 0x17);//BOOSTER_SOFT_START
// Power optimization
EPD_Send_2(0xF8, 0x60, 0xA5);
EPD_Send_2(0xF8, 0x89, 0xA5);
EPD_Send_2(0xF8, 0x90, 0x00);
EPD_Send_2(0xF8, 0x93, 0x2A);
EPD_Send_2(0xF8, 0xA0, 0xA5);
EPD_Send_2(0xF8, 0xA1, 0x00);
EPD_Send_2(0xF8, 0x73, 0x41);
EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xAF);//PANEL_SETTING: KW-BF, KWR-AF, BWROTP 0f
EPD_Send_1(0x30, 0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_1(0x82, 0x12);//VCM_DC_SETTING_REGISTER
delay(2);
EPD_lut(0x20,44,&lut_dc_2in7[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_2in7[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_2in7[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_2in7[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_2in7[0]);// LUT_BLACK_TO_BLACK
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
for(int i = 0; i < 176*264; i++)EPD_SendData(0xFF);//Red channel
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
int EPD_2IN7_V2_Init(void)
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x45); //set Ram-Y address start/end position
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x07); //0x0107-->(263+1)=264
EPD_SendData(0x01);
EPD_SendCommand(0x4F); // set RAM y address count to 0;
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x11); // data entry mode
EPD_SendData(0x03);
EPD_SendCommand(0x24);
delay(2);
return 0;
}
void EPD_2IN7_V2_Show(void)
{
EPD_SendCommand(0x22); //Display Update Control
EPD_SendData(0XF7);
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
delay(2);
Serial.print("EPD_2IN7_V2_Show END\r\n");
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
unsigned char lut_dc_2in7b[] =
{
0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A,
0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A,
0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00,
0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R21H
unsigned char lut_ww_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R22H r
unsigned char lut_bw_2in7b[] =
{
0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0xB0, 0x04, 0x10, 0x00,
0x00, 0x05, 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R23H w
unsigned char lut_bb_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R24H b
unsigned char lut_wb_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
int EPD_Init_2in7b()
{
EPD_Reset();
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xAF);//PANEL_SETTING
EPD_Send_1(0x30,0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_5(0x01,0x03,0x00,0x2B,0x2B,0x09);//POWER_SETTING
EPD_Send_3(0x06,0x07,0x07,0x17);//BOOSTER_SOFT_START
// Power optimization
EPD_Send_2(0xF8,0x60,0xA5);
EPD_Send_2(0xF8,0x89,0xA5);
EPD_Send_2(0xF8,0x90,0x00);
EPD_Send_2(0xF8,0x93,0x2A);
EPD_Send_2(0xF8,0x73,0x41);
EPD_Send_1(0x82,0x12);// VCM_DC_SETTING_REGISTER
EPD_Send_1(0x50,0x87);// VCOM_AND_DATA_INTERVAL_SETTING
EPD_lut(0x20,44,&lut_dc_2in7b[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_2in7b[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_2in7b[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_2in7b[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_2in7b[0]);// LUT_BLACK_TO_BLACK
EPD_Send_4(0x61, 0, 176, 1, 8);// TCON_RESOLUTION: HI(W), LO(W), HI(H), LO(H)
EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_2in7b_V2()
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12);
EPD_WaitUntilIdle_high();
EPD_Send_3(0x00, 0x27, 0x01, 0x00);
EPD_Send_1(0x11, 0x03);
EPD_Send_2(0x44, 0x00, 0x15); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_Send_4(0x45, 0x00, 0x00, 0x07, 0x01); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_Send_1(0x4E, 0x00); // SET_RAM_X_ADDRESS_COUNTER
EPD_Send_2(0x4F, 0x00, 0x00); // SET_RAM_Y_ADDRESS_COUNTER
EPD_SendCommand(0x24);
return 0;
}
void EPD_2in7b_V2_Show()
{
EPD_SendCommand(0x20);
EPD_WaitUntilIdle_high();
EPD_Send_1(0x10, 0x01);
}

@ -0,0 +1,177 @@
/**
******************************************************************************
* @file edp2in9.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 2.9 and 2.9b e-Papers
*
******************************************************************************
*/
int EPD_Init_2in9()
{
EPD_Reset();
EPD_Send_3(0x01, 39, 1, 0);//DRIVER_OUTPUT_CONTROL:LO(EPD_HEIGHT-1),HI(EPD_HEIGHT-1), GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER:VCOM 7C
EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_Send_2(0x44, 0, 15);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), HI ((w-1) >> 3)
EPD_Send_4(0x45, 0, 0, 45, 1);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1),HI(h - 1)
EPD_Send_1(0x4E, 0);//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3)
EPD_Send_2(0x4F, 0, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y)
EPD_lut(0x32, 30, &lut_full_mono[0]);
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
return 0;
}
int EPD_Init_2in9_V2()
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0x27, 0x01, 0x00);//Driver output control
EPD_Send_1(0x11, 0x03);//data entry mode
EPD_Send_2(0x21, 0x00, 0x80);// Display update control
EPD_Send_2(0x44, 0x00, 0x0f);// SET_RAM_X_ADDRESS_START_END_POSITION
EPD_Send_4(0x45, 0x00, 0x00, 0x27, 0x01);// SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_Send_1(0x4e, 0x00);// // SET_RAM_X_ADDRESS_COUNTER
EPD_Send_2(0x4f, 0x00, 0x00);// SET_RAM_Y_ADDRESS_COUNTER
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
return 0;
}
void EPD_2IN9_V2_Show(void)
{
Serial.printf("EPD_2IN9_V2_Show \r\n");
EPD_Send_1(0x22, 0xF7); //Display Update Control
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
}
int EPD_Init_2in9b()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x8F);//PANEL_SETTING
EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING;
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x0A);//VCM_DC_SETTING_REGISTER
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
Serial.printf("EPD_SendCommand b\r\n");
return 0;
}
int EPD_Init_2in9b_V3()
{
EPD_Reset();
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0x0F, 0x89);//PANEL_SETTING
EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION
EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING;
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
/************************************************************************************/
#define EPD_2IN9D_WIDTH 128
#define EPD_2IN9D_HEIGHT 296
void EPD_2IN9D_ReadBusy(void)
{
Serial.print("\r\ne-Paper busy");
UBYTE busy;
do {
EPD_SendCommand(0x71);
busy = digitalRead(PIN_SPI_BUSY);
busy = !(busy & 0x01);
delay(20);
} while(busy);
delay(20);
Serial.print("\r\ne-Paper busy free");
}
void EPD_2IN9D_Show(void)
{
Serial.print("\r\nEPD_2IN9D_Show");
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(10); //!!!The delay here is necessary, 200uS at least!!!
EPD_2IN9D_ReadBusy();
delay(200);
// Sleep
EPD_SendCommand(0X50);
EPD_SendData(0xf7);
EPD_SendCommand(0X02); //power off
EPD_2IN9D_ReadBusy();
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
void EPD_2IN9D_Clear(void)
{
UWORD Width, Height;
Width = (EPD_2IN9D_WIDTH % 8 == 0)? (EPD_2IN9D_WIDTH / 8 ): (EPD_2IN9D_WIDTH / 8 + 1);
Height = EPD_2IN9D_HEIGHT;
EPD_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_SendData(0x00);
}
}
EPD_SendCommand(0x13);
}
int EPD_Init_2in9d()
{
EPD_Reset();
EPD_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_SendCommand(0x00); //panel setting
EPD_SendData(0x1f); //LUT from OTP128x296
EPD_SendCommand(0x61); //resolution setting
EPD_SendData(EPD_2IN9D_WIDTH);
EPD_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_SendCommand(0x50); //vcom_DC setting
EPD_SendData(0x97);
delay(2);
EPD_2IN9D_Clear();
return 0;
}

@ -0,0 +1,246 @@
/*****************************************************************************
* | File : EPD_3IN52.h
* | Author : Waveshare team
* | Function : 3.52inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-11-02
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
//GC 0.9S
static const UBYTE EPD_3IN52_lut_R20_GC[] =
{
0x01,0x0f,0x0f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R21_GC[] =
{
0x01,0x4f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R22_GC[] =
{
0x01,0x0f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R23_GC[] =
{
0x01,0x4f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R24_GC[] =
{
0x01,0x0f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
UBYTE EPD_3IN52_Flag;
/******************************************************************************
function : Read Busy
parameter:
******************************************************************************/
void EPD_3IN52_ReadBusy(void)
{
Serial.print("e-Paper busy\r\n");
UBYTE busy;
do {
busy = digitalRead(PIN_SPI_BUSY);
} while(!busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/**
* @brief
*
*/
void EPD_3IN52_refresh(void)
{
EPD_SendCommand(0x17);
EPD_SendData(0xA5);
EPD_3IN52_ReadBusy();
delay(200);
}
// LUT download
void EPD_3IN52_lut_GC(void)
{
UBYTE count;
EPD_SendCommand(0x20); // vcom
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R20_GC[count]);
}
EPD_SendCommand(0x21); // red not use
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R21_GC[count]);
}
EPD_SendCommand(0x24); // bb b
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R24_GC[count]);
}
if(EPD_3IN52_Flag == 0)
{
EPD_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_3IN52_Flag = 1;
}
else
{
EPD_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_3IN52_Flag = 0;
}
}
void EPD_3IN52_Clear(void)
{
EPD_SendCommand(0x13);
for(int i=0; i<10800; i++)
EPD_SendData(0xFF);
EPD_3IN52_lut_GC();
EPD_3IN52_refresh();
EPD_SendCommand(0x50);
EPD_SendData(0x17);
delay(500);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_3IN52_Init(void)
{
EPD_3IN52_Flag = 0;
EPD_Reset();
EPD_SendCommand(0x00); // panel setting PSR
EPD_SendData(0xFF); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N
EPD_SendData(0x01); // x x x VCMZ TS_AUTO TIGE NORG VC_LUTZ
EPD_SendCommand(0x01); // POWER SETTING PWR
EPD_SendData(0x03); // x x x x x x VDS_EN VDG_EN
EPD_SendData(0x10); // x x x VCOM_SLWE VGH[3:0] VGH=20V, VGL=-20V
EPD_SendData(0x3F); // x x VSH[5:0] VSH = 15V
EPD_SendData(0x3F); // x x VSL[5:0] VSL=-15V
EPD_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
// T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
EPD_SendCommand(0x06); // booster soft start BTST
EPD_SendData(0x37); // BT_PHA[7:0]
EPD_SendData(0x3D); // BT_PHB[7:0]
EPD_SendData(0x3D); // x x BT_PHC[5:0]
EPD_SendCommand(0x60); // TCON setting TCON
EPD_SendData(0x22); // S2G[3:0] G2S[3:0] non-overlap = 12
EPD_SendCommand(0x82); // VCOM_DC setting VDCS
EPD_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
EPD_SendCommand(0x30);
EPD_SendData(0x09);
EPD_SendCommand(0xe3); // power saving PWS
EPD_SendData(0x88); // VCOM_W[3:0] SD_W[3:0]
EPD_SendCommand(0x61); // resoultion setting
EPD_SendData(0xf0); // HRES[7:3] 0 0 0
EPD_SendData(0x01); // x x x x x x x VRES[8]
EPD_SendData(0x68); // VRES[7:0]
EPD_SendCommand(0x50);
EPD_SendData(0xB7);
EPD_3IN52_Clear();
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_3IN52_Show(void)
{
EPD_3IN52_lut_GC();
EPD_3IN52_refresh();
delay(2);
Serial.print("EPD_3IN52_Show END\r\n");
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}

@ -0,0 +1,190 @@
/*****************************************************************************
* | File : EPD_3IN7.c
* | Author : Waveshare team
* | Function : 3.7inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-08-10
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
static const UBYTE lut_1Gray_GC[] =
{
0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
0x22,0x22,0x22,0x22,0x22
};
static void EPD_3IN7_ReadBusy_HIGH(void)
{
Serial.print("e-Paper busy\r\n");
UBYTE busy;
do {
busy = digitalRead(PIN_SPI_BUSY);
} while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/******************************************************************************
function : set the look-up tables
parameter:
******************************************************************************/
static void EPD_3IN7_Load_LUT(void)
{
UWORD i;
EPD_SendCommand(0x32);
for (i = 0; i < 105; i++)
{
EPD_SendData(lut_1Gray_GC[i]);
}
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_3IN7_1Gray_Init()
{
EPD_Reset();
EPD_SendCommand(0x12);
delay(300);
EPD_SendCommand(0x46);
EPD_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_SendCommand(0x47);
EPD_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_SendCommand(0x01); // setting gaet number
EPD_SendData(0xDF);
EPD_SendData(0x01);
EPD_SendData(0x00);
EPD_SendCommand(0x03); // set gate voltage
EPD_SendData(0x00);
EPD_SendCommand(0x04); // set source voltage
EPD_SendData(0x41);
EPD_SendData(0xA8);
EPD_SendData(0x32);
EPD_SendCommand(0x11); // set data entry sequence
EPD_SendData(0x03);
EPD_SendCommand(0x3C); // set border
EPD_SendData(0x00);
EPD_SendCommand(0x0C); // set booster strength
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0xC0);
EPD_SendCommand(0x18); // set internal sensor on
EPD_SendData(0x80);
EPD_SendCommand(0x2C); // set vcom value
EPD_SendData(0x44);
EPD_SendCommand(0x37); // set display option, these setting turn on previous function
EPD_SendData(0x00); //can switch 1 gray or 4 gray
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0x4F);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendCommand(0x44); // setting X direction start/end position of RAM
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x17);
EPD_SendData(0x01);
EPD_SendCommand(0x45); // setting Y direction start/end position of RAM
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0xDF);
EPD_SendData(0x01);
EPD_SendCommand(0x22); // Display Update Control 2
EPD_SendData(0xCF);
// EPD_SendCommand(0x4E);//clear
// EPD_SendData(0x00);
// EPD_SendData(0x00);
// EPD_SendCommand(0x4F);
// EPD_SendData(0x00);
// EPD_SendData(0x00);
// EPD_SendCommand(0x24);
// for (int i = 0; i < 16800; i++) {
// EPD_SendData(0xff);
// }
// EPD_3IN7_Load_LUT();
// EPD_SendCommand(0x20);
// EPD_3IN7_ReadBusy_HIGH();
EPD_SendCommand(0x4E);//Set Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x24);//begin write data to e-Paper
return 0;
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
static void EPD_3IN7_1Gray_Show(void)
{
EPD_3IN7_Load_LUT();
EPD_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
Serial.print("EPD_3IN7_Show END\r\n");
EPD_SendCommand(0X10); //deep sleep
EPD_SendData(0x03);
}

@ -0,0 +1,83 @@
/**
******************************************************************************
* @file edp4in01f.h
* @author Waveshare Team
* @version V1.0.0
* @date 29-Dec-2020
* @brief This file describes initialisation of 4.01f e-Papers
*
******************************************************************************
*/
/*****************************************************************************
EPD_4IN01F
******************************************************************************/
static void EPD_4IN01F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(digitalRead(PIN_SPI_BUSY)));
}
static void EPD_4IN01F_BusyLow(void)// If BUSYN=1 then waiting
{
while(digitalRead(PIN_SPI_BUSY));
}
static void EPD_4IN01F_Show(void)
{
EPD_SendCommand(0x04);//0x04
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x12);//0x12
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x02);//0x02
EPD_4IN01F_BusyLow();
delay(200);
Serial.print("EPD_4IN01F_Show END\r\n");
delay(100);
EPD_SendCommand(0x07);//sleep
EPD_SendData(0xA5);
delay(100);
}
int EPD_4IN01F_init()
{
EPD_Reset();
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x00);
EPD_SendData(0x2f);
EPD_SendData(0x00);
EPD_SendCommand(0x01);
EPD_SendData(0x37);
EPD_SendData(0x00);
EPD_SendData(0x05);
EPD_SendData(0x05);
EPD_SendCommand(0x03);
EPD_SendData(0x00);
EPD_SendCommand(0x06);
EPD_SendData(0xC7);
EPD_SendData(0xC7);
EPD_SendData(0x1D);
EPD_SendCommand(0x41);
EPD_SendData(0x00);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x60);
EPD_SendData(0x22);
EPD_SendCommand(0x61);
EPD_SendData(0x02);
EPD_SendData(0x80);
EPD_SendData(0x01);
EPD_SendData(0x90);
EPD_SendCommand(0xE3);
EPD_SendData(0xAA);
EPD_SendCommand(0x61);//Set Resolution setting
EPD_SendData(0x02);
EPD_SendData(0x80);
EPD_SendData(0x01);
EPD_SendData(0x90);
EPD_SendCommand(0x10);//begin write data to e-Paper
return 0;
}

@ -0,0 +1,168 @@
/**
******************************************************************************
* @file edp4in2.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 4.2 and 4.2b e-Papers
*
******************************************************************************
*/
unsigned char lut_dc_4in2[] =
{
0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00,
0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_4in2[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_4in2[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_4in2[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_4in2[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_4in2()
{
EPD_Reset();
EPD_SendCommand(0x01);//POWER_SETTING
EPD_SendData(0x03); // VDS_EN, VDG_EN
EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
EPD_SendData(0x2F); // VDH
EPD_SendData(0x2F); // VDL
EPD_SendData(0xFF); // VDHR
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0xBF, 0x0B);//PANEL_SETTING: // KW-BF KWR-AF BWROTP 0f
EPD_Send_1(0x30, 0x3C);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_4(0x61, 1, 144, 1, 44);// RESOLUTION_SETTING: HI(W), LO(W), HI(H), LO(H)
EPD_Send_1(0x82, 0x12);// VCM_DC_SETTING
EPD_Send_1(0x50, 0x97);// VCOM_AND_DATA_INTERVAL_SETTING: VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_lut(0x20,44,&lut_dc_4in2[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_4in2[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_4in2[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_4in2[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_4in2[0]);// LUT_BLACK_TO_BLACK
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
for(int i = 0; i < 400*300; i++)EPD_SendData(0xFF);//Red channel
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
unsigned char lut_dc_4in2b[] =
{
0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00,
0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_4in2b[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_4in2b[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_4in2b[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_4in2b[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_4in2b()
{
EPD_Reset();
EPD_Send_3(0x06,0x17,0x17,0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x0F);//PANEL_SETTING
EPD_Send_1(0x50,0xF7);// VCOM_AND_DATA_INTERVAL_SETTING
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_4in2b_V2()
{
EPD_Reset();
EPD_SendCommand(0x04);
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x0F);//PANEL_SETTING
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_4IN2B_V2_Show(void)
{
EPD_SendCommand(0x12); // DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
EPD_Send_1(0X50, 0xf7);
EPD_SendCommand(0X02); //power off
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X07, 0xf7); //deep sleep
}

@ -0,0 +1,90 @@
/**
******************************************************************************
* @file edp5in65.h
* @author Waveshare Team
* @version V1.0.0
* @date 05-August-2020
* @brief This file describes initialisation of 5.65f e-Papers
*
******************************************************************************
*/
/*****************************************************************************
EPD_5IN65F
******************************************************************************/
static void EPD_5IN65F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(digitalRead(PIN_SPI_BUSY)));
}
static void EPD_5IN65F_BusyLow(void)// If BUSYN=1 then waiting
{
while(digitalRead(PIN_SPI_BUSY));
}
static void EPD_5IN65F_Show(void)
{
EPD_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x02);//0x02
EPD_5IN65F_BusyLow();
delay(200);
Serial.print("EPD_5IN65F_Show END\r\n");
delay(100);
EPD_SendCommand(0x07);//sleep
EPD_SendData(0xA5);
delay(100);
}
int EPD_5IN65F_init()
{
EPD_Reset();
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x00);
EPD_SendData(0xEF);
EPD_SendData(0x08);
EPD_SendCommand(0x01);
EPD_SendData(0x37);
EPD_SendData(0x00);
EPD_SendData(0x23);
EPD_SendData(0x23);
EPD_SendCommand(0x03);
EPD_SendData(0x00);
EPD_SendCommand(0x06);
EPD_SendData(0xC7);
EPD_SendData(0xC7);
EPD_SendData(0x1D);
EPD_SendCommand(0x30);
EPD_SendData(0x3C);
EPD_SendCommand(0x41);
EPD_SendData(0x00);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x60);
EPD_SendData(0x22);
EPD_SendCommand(0x61);
EPD_SendData(0x02);
EPD_SendData(0x58);
EPD_SendData(0x01);
EPD_SendData(0xC0);
EPD_SendCommand(0xE3);
EPD_SendData(0xAA);
delay(100);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x61);//Set Resolution setting
EPD_SendData(0x02);
EPD_SendData(0x58);
EPD_SendData(0x01);
EPD_SendData(0xC0);
EPD_SendCommand(0x10);//begin write data to e-Paper
return 0;
}

@ -0,0 +1,92 @@
/**
******************************************************************************
* @file edp5in83.h
* @author Waveshare Team
* @version V1.0.0
* @date 8-September-2018
* @brief This file describes initialisation of 5.83, 5.83b, 5.83c e-Papers
*
******************************************************************************
*/
int EPD_Init_5in83()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START
EPD_SendCommand(0x4); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3C); // PLL_CONTROL
EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); // TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION
EPD_Send_1(0x82, 0x1E); // VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); // FLASH MODE
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_5in83_V2()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x07, 0x3f, 0x3f); // POWER_SETTING
EPD_SendCommand(0x04); // POWER_ON
delay(100);
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x1F); // PANEL_SETTING
EPD_Send_4(0x61, 0x02, 0x88, 0x01, 0xE0);// TCON_RESOLUTION
EPD_Send_1(0X15, 0x00);
EPD_Send_2(0X50, 0x10, 0x07);
EPD_Send_1(0X60, 0x22);
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
for(UDOUBLE i=0; i<38800; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13); // DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
int EPD_Init_5in83b()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START
EPD_SendCommand(0x4); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3A); // PLL_CONTROL
EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); // TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION
EPD_Send_1(0x82, 0x20); // VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); // FLASH MODE
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_5in83b_V2_init()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x07, 0x3f, 0x3f); //POWER SETTING
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X00, 0x0F); //PANNEL SETTING
EPD_Send_4(0x61, 0x02, 0x88, 0x01, 0xe0); //tres
EPD_Send_1(0X15, 0x00);
EPD_Send_2(0X50, 0x11, 0x07); //VCOM AND DATA INTERVAL SETTING
EPD_Send_1(0X60, 0x22); //TCON SETTING
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}

@ -0,0 +1,263 @@
/**
******************************************************************************
* @file edp7in5.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 7.5 and 7.5b e-Papers
*
******************************************************************************
*/
int EPD_Init_7in5()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); //POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); //PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); //BOOSTER_SOFT_START
EPD_SendCommand(0x4); //POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3C); //PLL_CONTROL
EPD_Send_1(0x41, 0x00); //TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); //VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); //TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x80, 0x01, 0x80);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x1E); //VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); //FLASH MODE
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
/*****************************************************************************
EPD_7in5_V2
******************************************************************************/
UBYTE Voltage_Frame_7IN5_V2[]={
0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
};
UBYTE LUT_VCOM_7IN5_V2[]={
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0xF, 0x1, 0xF, 0x1, 0x2,
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_WW_7IN5_V2[]={
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_BW_7IN5_V2[]={
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_WB_7IN5_V2[]={
0x80, 0xF, 0xF, 0x0, 0x0, 0x3,
0x84, 0xF, 0x1, 0xF, 0x1, 0x4,
0x40, 0xF, 0xF, 0x0, 0x0, 0x3,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_BB_7IN5_V2[]={
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
static void EPD_7in5_V2_Readbusy(void)
{
Serial.print("\r\ne-Paper busy\r\n");
unsigned char busy;
do{
EPD_SendCommand(0x71);
busy = digitalRead(PIN_SPI_BUSY);
busy =!(busy & 0x01);
}while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
static void EPD_7IN5_V2_Show(void)
{
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_7in5_V2_Readbusy();
//Enter sleep mode
EPD_SendCommand(0X02); //power off
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
static void EPD_7IN5_V2_LUT(UBYTE* lut_vcom, UBYTE* lut_ww, UBYTE* lut_bw, UBYTE* lut_wb, UBYTE* lut_bb)
{
UBYTE count;
EPD_SendCommand(0x20); //VCOM
for(count=0; count<60; count++)
EPD_SendData(lut_vcom[count]);
EPD_SendCommand(0x21); //LUTBW
for(count=0; count<60; count++)
EPD_SendData(lut_ww[count]);
EPD_SendCommand(0x22); //LUTBW
for(count=0; count<60; count++)
EPD_SendData(lut_bw[count]);
EPD_SendCommand(0x23); //LUTWB
for(count=0; count<60; count++)
EPD_SendData(lut_wb[count]);
EPD_SendCommand(0x24); //LUTBB
for(count=0; count<60; count++)
EPD_SendData(lut_bb[count]);
}
int EPD_7in5_V2_init()
{
EPD_Reset();
// EPD_SendCommand(0x01); //POWER SETTING
// EPD_SendData(0x07);
// EPD_SendData(0x07); //VGH=20V,VGL=-20V
// EPD_SendData(0x3f); //VDH=15V
// EPD_SendData(0x3f); //VDL=-15V
EPD_SendCommand(0x01); // power setting
EPD_SendData(0x17); // 1-0=11: internal power
EPD_SendData(*(Voltage_Frame_7IN5_V2+6)); // VGH&VGL
EPD_SendData(*(Voltage_Frame_7IN5_V2+1)); // VSH
EPD_SendData(*(Voltage_Frame_7IN5_V2+2)); // VSL
EPD_SendData(*(Voltage_Frame_7IN5_V2+3)); // VSHR
EPD_SendCommand(0x82); // VCOM DC Setting
EPD_SendData(*(Voltage_Frame_7IN5_V2+4)); // VCOM
EPD_SendCommand(0x06); // Booster Setting
EPD_SendData(0x27);
EPD_SendData(0x27);
EPD_SendData(0x2F);
EPD_SendData(0x17);
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X00); //PANNEL SETTING
EPD_SendData(0x3F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_SendCommand(0x61); //tres
EPD_SendData(0x03); //source 800
EPD_SendData(0x20);
EPD_SendData(0x01); //gate 480
EPD_SendData(0xE0);
EPD_SendCommand(0X15);
EPD_SendData(0x00);
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_SendData(0x10);
EPD_SendData(0x00);
EPD_SendCommand(0X60); //TCON SETTING
EPD_SendData(0x22);
EPD_SendCommand(0x65); // Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);//800*480
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_7IN5_V2_LUT(LUT_VCOM_7IN5_V2, LUT_WW_7IN5_V2, LUT_BW_7IN5_V2, LUT_WB_7IN5_V2, LUT_BB_7IN5_V2);
EPD_SendCommand(0x10);
for(UWORD i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13);
return 0;
}
/*****************************************************************************
EPD_7in5B_V2
******************************************************************************/
int EPD_7in5B_V2_Init(void)
{
EPD_Reset();
EPD_SendCommand(0x01); //POWER SETTING
EPD_SendData(0x07);
EPD_SendData(0x07); //VGH=20V,VGL=-20V
EPD_SendData(0x3f); //VDH=15V
EPD_SendData(0x3f); //VDL=-15V
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X00); //PANNEL SETTING
EPD_SendData(0x0F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_SendCommand(0x61); //tres
EPD_SendData(0x03); //source 800
EPD_SendData(0x20);
EPD_SendData(0x01); //gate 480
EPD_SendData(0xE0);
EPD_SendCommand(0X15);
EPD_SendData(0x00);
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_SendData(0x11);
EPD_SendData(0x07);
EPD_SendCommand(0X60); //TCON SETTING
EPD_SendData(0x22);
EPD_SendCommand(0x65); // Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);//800*480
EPD_SendData(0x00);
EPD_SendData(0x00);
UWORD i;
EPD_SendCommand(0x10);
for(i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13);
for(i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x10);
return 0;
}

@ -0,0 +1,188 @@
/**
******************************************************************************
* @file edp7in5_HD.h
* @author Waveshare Team
* @version V1.0.0
* @date 05-August-2020
* @brief This file describes initialisation of 7.5 HD and 7.5b HD e-Papers
*
******************************************************************************
*/
void EPD_7IN5_HD_Readbusy(void)
{
Serial.print("\r\ne-Paper busy\r\n");
delay(200);
unsigned char busy;
do{
busy = digitalRead(PIN_SPI_BUSY);
}while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/*****************************************************************************
EPD_7IN5_HD
******************************************************************************/
static void EPD_7IN5_HD_Show(void)
{
unsigned int i;
EPD_SendCommand(0x26);
for(i=0; i<880*528/8; i++) {
EPD_SendData(0xff);
}
EPD_SendCommand(0x22);
EPD_SendData(0xF7);
EPD_SendCommand(0x20);
delay(200);
EPD_7IN5_HD_Readbusy();
Serial.print("EPD_7IN5_HD_Show END\r\n");
}
int EPD_7IN5_HD_init()
{
EPD_Reset();
EPD_SendCommand(0x12); //SWRESET
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x46); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x47); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x0C); // Soft start setting
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0x40);
EPD_SendCommand(0x01); // Set MUX as 527
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendData(0x01);
EPD_SendCommand(0x11); // Data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44);
EPD_SendData(0x00); // RAM x address start at 0
EPD_SendData(0x00);
EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879
EPD_SendData(0x03);
EPD_SendCommand(0x45);
EPD_SendData(0xAF); // RAM y address start at 20Fh;
EPD_SendData(0x02);
EPD_SendData(0x00); // RAM y address end at 00h;
EPD_SendData(0x00);
EPD_SendCommand(0x3C); // VBD
EPD_SendData(0x01); // LUT1, for white
EPD_SendCommand(0x18);
EPD_SendData(0X80);
EPD_SendCommand(0x22);
EPD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_SendCommand(0x20);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x4E);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x24);//BLOCK
return 0;
}
/*****************************************************************************
EPD_7IN5B_HD
******************************************************************************/
static void EPD_7IN5B_HD_Show(void)
{
EPD_SendCommand(0x22);
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
delay(200);
EPD_7IN5_HD_Readbusy();
Serial.print("EPD_7IN5B_HD_Show END\r\n");
}
int EPD_7IN5B_HD_init()
{
EPD_Reset();
EPD_SendCommand(0x12); //SWRESET
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x46); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x47); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x0C); // Soft start setting
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0x40);
EPD_SendCommand(0x01); // Set MUX as 527
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendData(0x01);
EPD_SendCommand(0x11); // Data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44);
EPD_SendData(0x00); // RAM x address start at 0
EPD_SendData(0x00);
EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879
EPD_SendData(0x03);
EPD_SendCommand(0x45);
EPD_SendData(0xAF); // RAM y address start at 20Fh;
EPD_SendData(0x02);
EPD_SendData(0x00); // RAM y address end at 00h;
EPD_SendData(0x00);
EPD_SendCommand(0x3C); // VBD
EPD_SendData(0x01); // LUT1, for white
EPD_SendCommand(0x18);
EPD_SendData(0X80);
EPD_SendCommand(0x22);
EPD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_SendCommand(0x20);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x4E);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendCommand(0x4F);
EPD_SendData(0xAf);
EPD_SendData(0x02);
EPD_SendCommand(0x24);//BLOCK
return 0;
}

@ -0,0 +1,208 @@
/**
******************************************************************************
* @file srvr.h
* @author Waveshare Team
* @version V2.0.0
* @date 10-August-2018
* @brief ESP8266 WiFi server.
* This file provides firmware functions:
* + Sending web page of the tool to a client's browser
* + Uploading images from client part by part
*
******************************************************************************
*/
/* Library includes ----------------------------------------------------------*/
#include <BluetoothSerial.h>
bool Srvr__btIsOn;// It's true when bluetooth is on
bool Srvr__btConn;// It's true when bluetooth has connected client
int Srvr__msgPos;// Position in buffer from where data is expected
int Srvr__length;// Length of loaded data
/* Client ---------------------------------------------------------------------*/
BluetoothSerial Srvr__btClient; // Bluetooth client
/* Avaialble bytes in a stream ------------------------------------------------*/
int Srvr__available()
{
return Srvr__btIsOn ? Srvr__btClient.available() : false;
}
void Srvr__write(const char*value)
{
// Write data to bluetooth
if (Srvr__btIsOn) Srvr__btClient.write((const uint8_t*)value, strlen(value));
}
int Srvr__read()
{
return Srvr__btIsOn ? Srvr__btClient.read() : -1;
}
void Srvr__flush()
{
// Clear Bluetooth's stream
if (Srvr__btIsOn) Srvr__btClient.flush();
}
/* Project includes ----------------------------------------------------------*/
#include "buff.h" // POST request data accumulator
#include "epd.h" // e-Paper driver
bool Srvr__btSetup()
{
// Name shown in bluetooth device list of App part (PC or smartphone)
String devName("esp32");
// Turning on
Srvr__btIsOn = Srvr__btClient.begin(devName);
// Show the connection result
if (Srvr__btIsOn) Serial.println("Bluetooth is on");
else Serial.println("Bluetooth is off");
// There is no connection yet
Srvr__btConn = false;
// Return the connection result
return Srvr__btIsOn;
}
/* The server state observation loop -------------------------------------------*/
bool Srvr__loop()
{
// Bluetooh connection checking
if (!Srvr__btIsOn) return false;
// Show and update the state if it was changed
if (Srvr__btConn != Srvr__btClient.hasClient())
{
Serial.print("Bluetooth status:");
Srvr__btConn = !Srvr__btConn;
if(Srvr__btConn)
Serial.println("connected");
else
Serial.println("disconnected");
}
// Exit if there is no bluetooth connection
if (!Srvr__btConn) return false;
// Waiting the client is ready to send data
while(!Srvr__btClient.available())
{
delay(1);
}
// Set buffer's index to zero
// It means the buffer is empty initially
Buff__bufInd = 0;
// While the stream of 'client' has some data do...
while (Srvr__available())
{
// Read a character from 'client'
int q = Srvr__read();
// Save it in the buffer and increment its index
Buff__bufArr[Buff__bufInd++] = (byte)q;
}
Serial.println();
// Initialization
if (Buff__bufArr[0] == 'I')
{
Srvr__length = 0;
// Getting of e-Paper's type
EPD_dispIndex = Buff__bufArr[1];
// Print log message: initialization of e-Paper (e-Paper's type)
Serial.printf("<<<EPD %s", EPD_dispMass[EPD_dispIndex].title);
// Initialization
EPD_dispInit();
Buff__bufInd = 0;
Srvr__flush();
}
// Loading of pixels' data
else if (Buff__bufArr[0] == 'L')
{
// Print log message: image loading
Serial.print("<<<LOAD");
int dataSize = Buff__getWord(1);
Srvr__length += dataSize;
if ((Buff__bufInd < dataSize) || Srvr__length != Buff__getN3(3))
{
Buff__bufInd = 0;
Srvr__flush();
Serial.print(" - failed!>>>");
Srvr__write("Error!");
return true;
}
// Load data into the e-Paper
// if there is loading function for current channel (black or red)
if (EPD_dispLoad != 0) EPD_dispLoad();
Buff__bufInd = 0;
Srvr__flush();
}
// Initialize next channel
else if (Buff__bufArr[0] == 'N')
{
// Print log message: next data channel
Serial.print("<<<NEXT");
// Instruction code for for writting data into
// e-Paper's memory
int code = EPD_dispMass[EPD_dispIndex].next;
// e-Paper '2.7' (index 8) needs inverting of image data bits
EPD_invert = (EPD_dispIndex == 8);
// If the instruction code isn't '-1', then...
if (code != -1)
{
// Print log message: instruction code
Serial.printf(" %d", code);
// Do the selection of the next data channel
EPD_SendCommand(code);
delay(2);
}
// Setup the function for loading choosen channel's data
EPD_dispLoad = EPD_dispMass[EPD_dispIndex].chRd;
Buff__bufInd = 0;
Srvr__flush();
}
// Show loaded picture
else if (Buff__bufArr[0] == 'S')
{
EPD_dispMass[EPD_dispIndex].show();
Buff__bufInd = 0;
Srvr__flush();
//Print log message: show
Serial.print("<<<SHOW");
}
// Send message "Ok!" to continue
Srvr__write("Ok!");
delay(1);
// Print log message: the end of request processing
Serial.print(">>>");
return true;
}

@ -0,0 +1,40 @@
/**
******************************************************************************
* @file Loader.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief The main file.
* This file provides firmware functions:
* + Initialization of Serial Port, SPI pins and server
* + Main loop
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "srvr.h" // Server functions
/* Entry point ----------------------------------------------------------------*/
void setup()
{
// Serial port initialization
Serial.begin(115200);
delay(10);
// Server initialization
Srvr__setup();
// SPI initialization
EPD_initSPI();
// Initialization is complete
Serial.print("\r\nOk!\r\n");
}
/* The main loop -------------------------------------------------------------*/
void loop()
{
// The server state observation
Srvr__loop();
}

@ -0,0 +1,66 @@
/**
******************************************************************************
* @file buff.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief ESP8266 WiFi server.
* This file provides firmware functions:
* + Sending web page of the tool to a client's browser
* + Uploading images from client part by part
*
******************************************************************************
*/
/* Size, current position index and byte array of the buffer -----------------*/
#define Buff__SIZE 2050
int Buff__bufInd;
char Buff__bufArr[Buff__SIZE];
/* Reads a word from the buffer at specified position ------------------------*/
int Buff__getByte(int index)
{
// The first and second characters of the byte stored in the buffer
// are supposed to be in range ['a'; 'p'], otherwise it isn't a image data's byte
if ((Buff__bufArr[index ] < 'a') || (Buff__bufArr[index ] > 'p')) return -1;
if ((Buff__bufArr[index + 1] < 'a') || (Buff__bufArr[index + 1] > 'p')) return -1;
// The character 'a' means 0, the character 'p' means 15 consequently,
// The 1st character describes 4 low bits if the byte and the 2nd one - 4 high bits
return ((int)Buff__bufArr[index] - 'a') + (((int)Buff__bufArr[index + 1] - 'a') << 4);
}
/* Reads a byte from the buffer at specified position ------------------------*/
int Buff__getWord(int index)
{
// Read low byte of the word
int a = Buff__getByte(index);
// If it is not a image data byte, then exit
if (a == -1) return -1;
// Read high byte of the word
int b = Buff__getByte(index + 2);
// If it is not a image data byte, then exit
if (b == -1) return -1;
// Return the word's value
return a + (b << 8);
}
/* Checks if the buffer's data ends with specified string --------------------*/
int Buff__signature(int index, char*str)
{
// characters of the string to the end of the string
while (*str != 0)
{
// If the correspondent character in the buffer isn't equal
// to the string's character, return false
if (Buff__bufArr[index++] != *str) return false;
str++;
}
// Otherwise return true
return true;
}

@ -0,0 +1,145 @@
/**
******************************************************************************
* @file css.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes the sending of Cascade Style Sheet to a client
*
******************************************************************************
*/
void sendCSS(WiFiClient client)
{
client.println(
".menu_button {\r\n"
"width: 100%;\r\n"
"height: 50px;\r\n"
"border-radius: 4px;\r\n"
"text-align: center;\r\n"
"cursor: pointer;\r\n"
"display: block;\r\n"
"margin-bottom:5px;\r\n"
"font: 14px/50px Tahoma;\r\n"
"transition: all 0.18s ease-in-out;\r\n"
"border: 1px solid #4FD666;\r\n"
"background: linear-gradient(to top right, #3EC97A, #69EA49 20%, rgba(255, 255, 255, 0) 80%, rgba(255, 255, 255, 0)) top right/500% 500%;\r\n"
"color: green;\r\n"
"}\r\n"
".menu_button:hover {\r\n"
"color: white;\r\n"
"background-position: bottom left;\r\n"
"}\r\n"
".hidden_input {\r\n"
"width: 0.1px;\r\n"
"height: 0.1px;\r\n"
"opacity: 0;\r\n"
"overflow: hidden;\r\n"
"position: absolute;\r\n"
"z-index: -1;\r\n"
"}\r\n"
".imgBox\r\n"
"{\r\n"
"border: 2px dashed green;\r\n"
"border-radius: 8px;\r\n"
"background: lightyellow;\r\n"
"background-repeat: no-repeat;\r\n"
"text-align: center;\r\n"
"margin-top:10px;\r\n"
"}\r\n"
".mesBox {\r\n"
"margin: 100px 70px;\r\n"
"color: green;\r\n"
"font-size: 25px;\r\n"
"font-family: Verdana, Arial, sans-serif;\r\n"
"}\r\n"
".header_back\r\n"
"{\r\n"
"width:100%;\r\n"
"height:100px;\r\n"
"background:#EEEEEE;\r\n"
"}\r\n"
".content_back\r\n"
"{\r\n"
"width:100%;\r\n"
"background:#EEEEEE;\r\n"
"}\r\n"
".footer_back\r\n"
"{\r\n"
"width:100%;\r\n"
"height:100px;\r\n"
"background:#EEEEEE;\r\n"
"}\r\n"
".header_face\r\n"
"{\r\n"
"width:1024px;\r\n"
"height:100px;\r\n"
"margin:0 auto;\r\n"
"background:#CCFFCC;\r\n"
"}\r\n"
".content_face\r\n"
"{\r\n"
"width:1024px;\r\n"
"height:100%;\r\n"
"margin:0 auto;\r\n"
"background:#FFFFFF;\r\n"
"}\r\n"
".footer_face\r\n"
"{\r\n"
"width:1024px;\r\n"
"height:100%;\r\n"
"margin:0 auto;\r\n"
"background:#CCFFCC;\r\n"
"}\r\n"
".menu_bar\r\n"
"{\r\n"
"border-right:1px solid #4FD666;\r\n"
"background:#EEFFEE;\r\n"
"vertical-align:top;\r\n"
"padding:15px;\r\n"
"width:200px;\r\n"
"height:100%\r\n"
"}\r\n"
".content_body\r\n"
"{\r\n"
"vertical-align:top;\r\n"
"text-align:center;\r\n"
"height:100%;\r\n"
"padding:30px;\r\n"
"padding-left:15px;\r\n"
"}\r\n"
".title\r\n"
"{\r\n"
"color:green;\r\n"
"font-size:32px;\r\n"
"font-family: arial;\r\n"
"}\r\n"
".comment\r\n"
"{\r\n"
"width:100%;\r\n"
"color:green;\r\n"
"font-size:16px;\r\n"
"font-style:italic;\r\n"
"font-family: arial;\r\n"
"text-align:center;\r\n"
"}\r\n"
".nud\r\n"
"{\r\n"
"width:70px;\r\n"
"}\r\n");
}

@ -0,0 +1,638 @@
/**
******************************************************************************
* @file epd.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file provides e-Paper driver functions
* void EPD_SendCommand(byte command);
* void EPD_SendData(byte data);
* void EPD_WaitUntilIdle();
* void EPD_Send_1(byte c, byte v1);
* void EPD_Send_2(byte c, byte v1, byte v2);
* void EPD_Send_3(byte c, byte v1, byte v2, byte v3);
* void EPD_Send_4(byte c, byte v1, byte v2, byte v3, byte v4);
* void EPD_Send_5(byte c, byte v1, byte v2, byte v3, byte v4, byte v5);
* void EPD_Reset();
* void EPD_dispInit();
*
* varualbes:
* EPD_dispLoad; - pointer on current loading function
* EPD_dispIndex; - index of current e-Paper
* EPD_dispInfo EPD_dispMass[]; - array of e-Paper properties
*
******************************************************************************
*/
/* SPI pin definition --------------------------------------------------------*/
//#include "epd7in5_HD.h"
#define PIN_SPI_SCK 13
#define PIN_SPI_DIN 14
#define PIN_SPI_CS 15
#define PIN_SPI_BUSY 25//19
#define PIN_SPI_RST 26//21
#define PIN_SPI_DC 27//22
/* Pin level definition ------------------------------------------------------*/
#define LOW 0
#define HIGH 1
#define GPIO_PIN_SET 1
#define GPIO_PIN_RESET 0
void EPD_initSPI()
{
pinMode(PIN_SPI_BUSY, INPUT);
pinMode(PIN_SPI_RST , OUTPUT);
pinMode(PIN_SPI_DC , OUTPUT);
pinMode(PIN_SPI_SCK, OUTPUT);
pinMode(PIN_SPI_DIN, OUTPUT);
pinMode(PIN_SPI_CS , OUTPUT);
digitalWrite(PIN_SPI_CS , HIGH);
digitalWrite(PIN_SPI_SCK, LOW);
}
/* Lut mono ------------------------------------------------------------------*/
byte lut_full_mono[] =
{
0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22,
0x66, 0x69, 0x69, 0x59, 0x58, 0x99, 0x99, 0x88,
0x00, 0x00, 0x00, 0x00, 0xF8, 0xB4, 0x13, 0x51,
0x35, 0x51, 0x51, 0x19, 0x01, 0x00
};
byte lut_partial_mono[] =
{
0x10, 0x18, 0x18, 0x08, 0x18, 0x18, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x13, 0x14, 0x44, 0x12,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* The procedure of sending a byte to e-Paper by SPI -------------------------*/
void EpdSpiTransferCallback(byte data)
{
//SPI.beginTransaction(spi_settings);
digitalWrite(PIN_SPI_CS, GPIO_PIN_RESET);
for (int i = 0; i < 8; i++)
{
if ((data & 0x80) == 0) digitalWrite(PIN_SPI_DIN, GPIO_PIN_RESET);
else digitalWrite(PIN_SPI_DIN, GPIO_PIN_SET);
data <<= 1;
digitalWrite(PIN_SPI_SCK, GPIO_PIN_SET);
digitalWrite(PIN_SPI_SCK, GPIO_PIN_RESET);
}
//SPI.transfer(data);
digitalWrite(PIN_SPI_CS, GPIO_PIN_SET);
//SPI.endTransaction();
}
byte lut_vcom0[] = { 15, 0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A, 0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00 };
byte lut_w [] = { 15, 0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04 };
byte lut_b [] = { 15, 0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04 };
byte lut_g1 [] = { 15, 0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04 };
byte lut_g2 [] = { 15, 0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A, 0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04 };
byte lut_vcom1[] = { 15, 0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte lut_red0 [] = { 15, 0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte lut_red1 [] = { 15, 0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* Sending a byte as a command -----------------------------------------------*/
void EPD_SendCommand(byte command)
{
digitalWrite(PIN_SPI_DC, LOW);
EpdSpiTransferCallback(command);
}
/* Sending a byte as a data --------------------------------------------------*/
void EPD_SendData(byte data)
{
digitalWrite(PIN_SPI_DC, HIGH);
EpdSpiTransferCallback(data);
}
/* Waiting the e-Paper is ready for further instructions ---------------------*/
void EPD_WaitUntilIdle()
{
//0: busy, 1: idle
while(digitalRead(PIN_SPI_BUSY) == 0) delay(100);
}
/* Waiting the e-Paper is ready for further instructions ---------------------*/
void EPD_WaitUntilIdle_high()
{
//1: busy, 0: idle
while(digitalRead(PIN_SPI_BUSY) == 1) delay(100);
}
/* Send a one-argument command -----------------------------------------------*/
void EPD_Send_1(byte c, byte v1)
{
EPD_SendCommand(c);
EPD_SendData(v1);
}
/* Send a two-arguments command ----------------------------------------------*/
void EPD_Send_2(byte c, byte v1, byte v2)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
}
/* Send a three-arguments command --------------------------------------------*/
void EPD_Send_3(byte c, byte v1, byte v2, byte v3)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
}
/* Send a four-arguments command ---------------------------------------------*/
void EPD_Send_4(byte c, byte v1, byte v2, byte v3, byte v4)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
EPD_SendData(v4);
}
/* Send a five-arguments command ---------------------------------------------*/
void EPD_Send_5(byte c, byte v1, byte v2, byte v3, byte v4, byte v5)
{
EPD_SendCommand(c);
EPD_SendData(v1);
EPD_SendData(v2);
EPD_SendData(v3);
EPD_SendData(v4);
EPD_SendData(v5);
}
/* Writting lut-data into the e-Paper ----------------------------------------*/
void EPD_lut(byte c, byte l, byte*p)
{
// lut-data writting initialization
EPD_SendCommand(c);
// lut-data writting doing
for (int i = 0; i < l; i++, p++) EPD_SendData(*p);
}
/* Writting lut-data of the black-white channel ------------------------------*/
void EPD_SetLutBw(byte*c20, byte*c21, byte*c22, byte*c23, byte*c24)
{
EPD_lut(0x20, *c20, c20 + 1);//g vcom
EPD_lut(0x21, *c21, c21 + 1);//g ww --
EPD_lut(0x22, *c22, c22 + 1);//g bw r
EPD_lut(0x23, *c23, c23 + 1);//g wb w
EPD_lut(0x24, *c24, c24 + 1);//g bb b
}
/* Writting lut-data of the red channel --------------------------------------*/
void EPD_SetLutRed(byte*c25, byte*c26, byte*c27)
{
EPD_lut(0x25, *c25, c25 + 1);
EPD_lut(0x26, *c26, c26 + 1);
EPD_lut(0x27, *c27, c27 + 1);
}
/* This function is used to 'wake up" the e-Paper from the deep sleep mode ---*/
void EPD_Reset()
{
digitalWrite(PIN_SPI_RST, HIGH);
delay(200);
digitalWrite(PIN_SPI_RST, LOW);
delay(5);
digitalWrite(PIN_SPI_RST, HIGH);
delay(200);
}
/* e-Paper initialization functions ------------------------------------------*/
#include "epd1in54.h"
#include "epd2in13.h"
#include "epd2in9.h"
#include "epd2in7.h"
#include "epd2in66.h"
#include "epd3in7.h"
#include "epd3in52.h"
#include "epd4in01f.h"
#include "epd4in2.h"
#include "epd5in65f.h"
#include "epd5in83.h"
#include "epd7in5.h"
#include "epd7in5_HD.h"
bool EPD_invert; // If true, then image data bits must be inverted
int EPD_dispIndex; // The index of the e-Paper's type
int EPD_dispX, EPD_dispY; // Current pixel's coordinates (for 2.13 only)
void(*EPD_dispLoad)(); // Pointer on a image data writting function
/* Image data loading function for a-type e-Paper ----------------------------*/
void EPD_loadA()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte
int value = Buff__getByte(pos);
// Serial.printf("address:%d, data:%x ",pos, value);
// if(pos % 8 == 0)
// Serial.printf("\r\n");
// Invert byte's bits in case of '2.7' e-Paper
if (EPD_invert) value = ~value;
// Write the byte into e-Paper's memory
EPD_SendData((byte)value);
// Increment the current byte index on 2 characters
pos += 2;
}
}
void EPD_loadAFilp()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte
int value = Buff__getByte(pos);
// Invert byte's bits in case of '2.7' e-Paper
if (EPD_invert) value = ~value;
// Write the byte into e-Paper's memory
EPD_SendData(~(byte)value);
// Increment the current byte index on 2 characters
pos += 2;
}
}
/* Image data loading function for b-type e-Paper ----------------------------*/
void EPD_loadB()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current word from obtained image data
int valueA = (int)Buff__getByte(pos) + ((int)Buff__getByte(pos + 2) << 8);
// Clean current word of processed image data
int valueB = 0;
// Enumerate next 8 pixels
for (int p = 0; p < 8; p++)
{
// Current obtained pixel data
int pixInd = valueA & 3;
// Remove the obtained pixel data from 'valueA' word
valueA = valueA >> 2;
// Processing of 8 2-bit pixels to 8 2-bit pixels:
// black(value 0) to bits 00, white(value 1) to bits 11, gray(otherwise) to bits 10
valueB = (valueB << 2) + (pixInd == 1 ? 3 : (pixInd == 0 ? 0 : 2));
}
// Write the word into e-Paper's memory
EPD_SendData((byte)(valueB >> 8));
EPD_SendData((byte)valueB);
// Increment the current byte index on 2 characters
pos += 4;
}
}
/* Image data loading function for 2.13 e-Paper ------------------------------*/
void EPD_loadC()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
EPD_Send_2(0x44, 0, 15); //SET_RAM_X_ADDRESS_START_END_POSITION LO(x >> 3), LO((w - 1) >> 3)
EPD_Send_4(0x45, 0, 0, 249, 0); //SET_RAM_Y_ADDRESS_START_END_POSITION LO(y), HI(y), LO(h - 1), HI(h - 1)
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Before write a line of image data
// 2.13 e-Paper requires to set the address counter
// Every line has 15*8-6 pixels + 6 empty bits, totally 15*8 bits
if (EPD_dispX == 0)
{
EPD_Send_1(0x4E, 0 );//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3)
EPD_Send_2(0x4F, EPD_dispY, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y)
EPD_SendCommand(0x24);//WRITE_RAM
}
// Write the byte into e-Paper's memory
EPD_SendData((byte)Buff__getByte(pos));
// Increment the current byte index on 2 characters
pos += 2;
// EPD_dispX and EPD_dispY increments
if (++EPD_dispX > 15)
{
EPD_dispX = 0;
// If the client's browser sends more bits, than it needs, then exit the function
if (++EPD_dispY > 250) return;
}
}
}
/* Image data loading function for 7.5 e-Paper -------------------------------*/
void EPD_loadD()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int valueA = Buff__getByte(pos);
// Processing of 4 1-bit pixels to 4 4-bit pixels:
// black(value 0) to bits 0000, white(value 1) to bits 0011
EPD_SendData((byte)((valueA & 0x80) ? 0x30 : 0x00) + ((valueA & 0x40) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x20) ? 0x30 : 0x00) + ((valueA & 0x10) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x08) ? 0x30 : 0x00) + ((valueA & 0x04) ? 0x03 : 0x00));
EPD_SendData((byte)((valueA & 0x02) ? 0x30 : 0x00) + ((valueA & 0x01) ? 0x03 : 0x00));
// Increment the current byte index on 2 characters
pos += 2;
}
}
/* Image data loading function for 7.5b e-Paper ------------------------------*/
void EPD_loadE()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int value = Buff__getByte(pos);
// Processing of 4 1-bit pixels to 4 4-bit pixels:
// red(value 1) to bits 0011, white(value 3) to bits 0100
int A = (value ) & 3;if (A == 3) A = 4;if (A == 1) A = 3;
int B = (value >> 2) & 3;if (B == 3) B = 4;if (B == 1) B = 3;
int C = (value >> 4) & 3;if (C == 3) C = 4;if (C == 1) C = 3;
int D = (value >> 6) & 3;if (D == 3) D = 4;if (D == 1) D = 3;
// Write the word into e-Paper's memory
EPD_SendData((A << 4) + B);
EPD_SendData((C << 4) + D);
// Increment the current byte index on 2 characters
pos += 2;
}
}
/* Image data loading function for 5.83b e-Paper -----------------------------*/
void EPD_loadF()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int value = Buff__getByte(pos);
int value1 = Buff__getByte(pos+2);
// Processing of 4 1-bit pixels to 4 4-bit pixels:
// white(value 1) to bits 0011, red(value 2) to bits 0100
int A = (value ) & 3;if (A == 2) A = 4;
int B = (value >> 8) & 3;if (B == 2) B = 4;
int C = (value1 >> 4) & 3;if (C == 2) C = 4;
int D = (value1 >> 6) & 3;if (D == 2) D = 4;
// Write the word into e-Paper's memory
EPD_SendData((A << 4) + B);
EPD_SendData((C << 4) + D);
// Increment the current byte index on 2 characters
pos += 4;
}
}
/* Image data loading function for 5.65f e-Paper -----------------------------*/
void EPD_loadG()
{
// Come back to the image data end
Buff__bufInd -= 8;
// Get the index of the image data begin
int pos = Buff__bufInd - Buff__getWord(Buff__bufInd);
// Enumerate all of image data bytes
while (pos < Buff__bufInd)
{
// Get current byte from obtained image data
int value = Buff__getByte(pos);
// Switch the positions of the two 4-bits pixels
// Black:0b000;White:0b001;Green:0b010;Blue:0b011;Red:0b100;Yellow:0b101;Orange:0b110;
int A = (value ) & 0x07;
int B = (value >> 4) & 0x07;
// Write the data into e-Paper's memory
EPD_SendData((byte)(A << 4) + B);
// Increment the current byte index on 2 characters
pos += 2;
}
}
/* Show image and turn to deep sleep mode (a-type, 4.2 and 2.7 e-Paper) ------*/
void EPD_showA()
{
// Refresh
EPD_Send_1(0x22, 0xC4);// DISPLAY_UPDATE_CONTROL_2
EPD_SendCommand( 0x20);// MASTER_ACTIVATION
EPD_SendCommand( 0xFF);// TERMINATE_FRAME_READ_WRITE
EPD_WaitUntilIdle();
// Sleep
EPD_SendCommand(0x10);// DEEP_SLEEP_MODE
EPD_WaitUntilIdle();
}
/* Show image and turn to deep sleep mode (b-type, e-Paper) ------------------*/
void EPD_showB()
{
// Refresh
EPD_SendCommand(0x12);// DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
// Sleep
EPD_Send_1(0x50, 0x17);// VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x82, 0x00);// VCM_DC_SETTING_REGISTER, to solve Vcom drop
EPD_Send_4(0x01, 0x02, 0x00, 0x00, 0x00);// POWER_SETTING
EPD_WaitUntilIdle();
EPD_SendCommand(0x02);// POWER_OFF
}
/* Show image and turn to deep sleep mode (7.5 and 7.5b e-Paper) -------------*/
void EPD_showC()
{
// Refresh
EPD_SendCommand(0x12);// DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
// Sleep
EPD_SendCommand(0x02);// POWER_OFF
EPD_WaitUntilIdle();
EPD_Send_1(0x07, 0xA5);// DEEP_SLEEP
}
void EPD_showD()
{
// VCOM AND DATA INTERVAL SETTING
// WBmode:VBDF 17, D7 VBDW 97, VBDB 57
// WBRmode:VBDF F7, VBDW 77, VBDB 37, VBDR B7
EPD_Send_1(0x50, 0x97);
EPD_SendCommand(0x20);
for(int count=0; count<44; count++) EPD_SendData(lut_vcomDC_2in13d[count]);
EPD_SendCommand(0x21);
for(int count=0; count<42; count++) EPD_SendData(lut_ww_2in13d[count]);
EPD_SendCommand(0x22);
for(int count=0; count<42; count++) EPD_SendData(lut_bw_2in13d[count]);
EPD_SendCommand(0x23);
for(int count=0; count<42; count++) EPD_SendData(lut_wb_2in13d[count]);
EPD_SendCommand(0x24);
for(int count=0; count<42; count++) EPD_SendData(lut_bb_2in13d[count]);
delay(10);
EPD_SendCommand(0x12);//DISPLAY REFRESH
delay(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_WaitUntilIdle();
EPD_Send_1(0x50, 0xf7);
EPD_SendCommand( 0x02);//POWER_OFF
EPD_Send_1(0x07, 0xA5);//DEEP_SLEEP
}
/* The set of pointers on 'init', 'load' and 'show' functions, title and code */
struct EPD_dispInfo
{
int(*init)(); // Initialization
void(*chBk)();// Black channel loading
int next; // Change channel code
void(*chRd)();// Red channel loading
void(*show)();// Show and sleep
char*title; // Title of an e-Paper
};
/* Array of sets describing the usage of e-Papers ----------------------------*/
EPD_dispInfo EPD_dispMass[] =
{
{ EPD_Init_1in54, EPD_loadA, -1 , 0, EPD_1IN54_Show, "1.54 inch" },// a 0
{ EPD_Init_1in54b, EPD_loadB, 0x13, EPD_loadA, EPD_showB, "1.54 inch b" },// b 1
{ EPD_Init_1in54c, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "1.54 inch c" },// c 2
{ EPD_Init_2in13, EPD_loadC, -1 , 0, EPD_showA, "2.13 inch" },// d 3
{ EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch b" },// e 4
{ EPD_Init_2in13b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.13 inch c" },// f 5
{ EPD_Init_2in13d, EPD_loadA, -1 , 0, EPD_showD, "2.13 inch d" },// g 6
{ EPD_Init_2in7, EPD_loadA, 1 , 0, EPD_showB, "2.7 inch" },// h 7
{ EPD_Init_2in7b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.7 inch b" },// i 8
{ EPD_Init_2in9, EPD_loadA, -1 , 0, EPD_showA, "2.9 inch" },// j 9
{ EPD_Init_2in9b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch b" },// k 10
{ EPD_Init_2in9b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "2.9 inch c" },// l 11
{ EPD_Init_2in9d, EPD_loadA, -1 , 0, EPD_2IN9D_Show, "2.9 inch d" },// M 12
{ EPD_Init_4in2, EPD_loadA, -1 , 0, EPD_showB, "4.2 inch" },// N 13
{ EPD_Init_4in2b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch b" },// O 14
{ EPD_Init_4in2b, EPD_loadA, 0x13, EPD_loadA, EPD_showB, "4.2 inch c" },// P 15
{ EPD_5in83__init, EPD_loadD, -1 , 0, EPD_showC, "5.83 inch" },// Q 16
{ EPD_5in83b__init, EPD_loadE, -1 , 0, EPD_showC, "5.83 inch b" },// R 17
{ EPD_5in83b__init, EPD_loadE, -1 , 0, EPD_showC, "5.83 inch c" },// S 18
{ EPD_7in5__init, EPD_loadD, -1 , 0, EPD_showC, "7.5 inch" },// T 19
{ EPD_7in5__init, EPD_loadE, -1 , 0, EPD_showC, "7.5 inch b" },// u 20
{ EPD_7in5__init, EPD_loadE, -1 , 0, EPD_showC, "7.5 inch c" },// v 21
{ EPD_7in5_V2_init, EPD_loadAFilp, -1 , 0, EPD_7IN5_V2_Show, "7.5 inch V2" },// w 22
{ EPD_7in5B_V2_Init, EPD_loadA, 0x13, EPD_loadAFilp, EPD_7IN5_V2_Show, "7.5 inch B V2" },// x 23
{ EPD_7IN5B_HD_init, EPD_loadA, 0x26, EPD_loadAFilp, EPD_7IN5B_HD_Show, "7.5 inch B HD" },// y 24
{ EPD_5IN65F_init, EPD_loadG, -1 , 0, EPD_5IN65F_Show, "5.65 inch F " },// z 25
{ EPD_7IN5_HD_init, EPD_loadA, -1 , 0, EPD_7IN5_HD_Show, "7.5 inch HD" },// A 26
{ EPD_3IN7_1Gray_Init, EPD_loadA, -1 , 0, EPD_3IN7_1Gray_Show,"3.7 inch" },// 27
{ EPD_2IN66_Init, EPD_loadA, -1 , 0, EPD_2IN66_Show, "2.66 inch" },// 28
{ EPD_5in83b_V2_init, EPD_loadA, 0x13, EPD_loadAFilp, EPD_showC, "5.83 inch B V2"},// 29
{ EPD_Init_2in9b_V3, EPD_loadA, 0x13, EPD_loadA, EPD_showC, "2.9 inch B V3" },// 30
{ EPD_1IN54B_V2_Init, EPD_loadA, 0x26, EPD_loadAFilp, EPD_1IN54B_V2_Show, "1.54 inch B V2"},// 31
{ EPD_2IN13B_V3_Init, EPD_loadA, 0x13, EPD_loadA, EPD_2IN13B_V3_Show, "2.13 inch B V3"},// 32
{ EPD_Init_2in9_V2, EPD_loadA, -1, 0, EPD_2IN9_V2_Show, "2.9 inch V2" },// 33
{ EPD_Init_4in2b_V2, EPD_loadA, 0x13, EPD_loadA, EPD_4IN2B_V2_Show, "4.2 inch b V2" },// 34
{ EPD_2IN66B_Init, EPD_loadA, 0x26, EPD_loadAFilp, EPD_2IN66_Show, "2.66 inch b" },// 35
{ EPD_Init_5in83_V2, EPD_loadAFilp, -1, 0, EPD_showC, "5.83 inch V2" },// 36
{ EPD_4IN01F_init, EPD_loadG, -1, 0, EPD_4IN01F_Show, "4.01 inch f" },// 37
{ EPD_Init_2in7b_V2, EPD_loadA, 0x26, EPD_loadAFilp, EPD_Show_2in7b_V2, "2.7 inch B V2" },// 38
{ EPD_Init_2in13_V3, EPD_loadC, -1, 0, EPD_2IN13_V3_Show, "2.13 inch V3" },// 39
{ EPD_2IN13B_V4_Init, EPD_loadA, 0x26, EPD_loadA, EPD_2IN13B_V4_Show, "2.13 inch B V4"},// 40
{ EPD_3IN52_Init, EPD_loadA, -1, 0, EPD_3IN52_Show, "3.52 inch" },// 41
{ EPD_2IN7_V2_Init, EPD_loadA, -1 , 0, EPD_2IN7_V2_Show, "2.7 inch V2" },// 42
};
/* Initialization of an e-Paper ----------------------------------------------*/
void EPD_dispInit()
{
// Call initialization function
EPD_dispMass[EPD_dispIndex].init();
// Set loading function for black channel
EPD_dispLoad = EPD_dispMass[EPD_dispIndex].chBk;
// Set initial coordinates
EPD_dispX = 0;
EPD_dispY = 0;
// The inversion of image data bits isn't needed by default
EPD_invert = false;
}

@ -0,0 +1,193 @@
/**
******************************************************************************
* @file edp1in54.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 1.54 and 1.54b e-Papers
*
******************************************************************************
*/
int EPD_Init_1in54()
{
int EPD1in54 = 2;
if(EPD1in54 == 1) {
Serial.print("\r\nEPD1in54 V1");
EPD_Reset();
EPD_Send_3(0x01, 199, 0, 00);//DRIVER_OUTPUT_CONTROL: LO(EPD_HEIGHT-1), HI(EPD_HEIGHT-1). GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER: VCOM 7C
EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_lut(0x32, 30, &lut_full_mono[0]);
EPD_Send_2(0x44, 0, 24);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), LO((w-1) >> 3)
EPD_Send_4(0x45, 0, 0, 200, 0);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1), HI(h - 1)
EPD_Send_1(0x4E, 0);//LO(x >> 3)
EPD_Send_2(0x4F, 0, 0);//LO(y), HI(y >> 8)
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
} else {
Serial.print("\r\nEPD1in54 V2");
EPD_Reset();
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x12); //SWRESET
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x01); //Driver output control
EPD_SendData(0xC7);
EPD_SendData(0x00);
EPD_SendData(0x01);
EPD_SendCommand(0x11); //data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44); //set Ram-X address start/end position
EPD_SendData(0x00);
EPD_SendData(0x18); //0x0C-->(18+1)*8=200
EPD_SendCommand(0x45); //set Ram-Y address start/end position
EPD_SendData(0xC7); //0xC7-->(199+1)=200
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x3C); //BorderWavefrom
EPD_SendData(0x01);
EPD_SendCommand(0x18);
EPD_SendData(0x80);
EPD_SendCommand(0x22); // //Load Temperature and waveform setting.
EPD_SendData(0XB1);
EPD_SendCommand(0x20);
EPD_SendCommand(0x4E); // set RAM x address count to 0;
EPD_SendData(0x00);
EPD_SendCommand(0x4F); // set RAM y address count to 0X199;
EPD_SendData(0xC7);
EPD_SendData(0x00);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
Serial.print("\r\n init over");
EPD_SendCommand(0x24);//DATA_START_TRANSMISSION_1
}
return 0;
}
void EPD_1IN54_Show(void)
{
int EPD1in54 = 2;
if(EPD1in54 == 1) {
Serial.print("\r\n EPD_1IN54_Show");
// Refresh
EPD_Send_1(0x22, 0xC4);// DISPLAY_UPDATE_CONTROL_2
EPD_SendCommand( 0x20);// MASTER_ACTIVATION
EPD_SendCommand( 0xFF);// TERMINATE_FRAME_READ_WRITE
EPD_WaitUntilIdle();
// Sleep
EPD_SendCommand(0x10);// DEEP_SLEEP_MODE
EPD_WaitUntilIdle();
}
else {
Serial.print("\r\n EPD_1IN54_V2_Show");
EPD_Send_1(0x22, 0xc7); //Display Update Control
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle();
EPD_Send_1(0x10, 0x01);
}
}
int EPD_Init_1in54b()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x07, 0x07, 0x07);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xCF);//PANEL_SETTING
EPD_Send_1(0x50, 0x37);//VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0xC8, 0x00, 0xC8);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x0E);//VCM_DC_SETTING_REGISTER
EPD_SetLutBw (&lut_vcom0[0], &lut_w[0], &lut_b[0], &lut_g1[0], &lut_g2[0]);
EPD_SetLutRed(&lut_vcom1[0], &lut_red0[0], &lut_red1[0]);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_1IN54B_V2_Init(void)
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0xc7, 0x00, 0x01); //Driver output control
EPD_Send_1(0x11, 0x01); //data entry mode
EPD_Send_2(0x44, 0x00, 0x18); //set Ram-X address start/end position
EPD_Send_4(0x45, 0xc7, 0x00, 0x00, 0x00); //set Ram-Y address start/end position
EPD_Send_1(0x3C, 0x05); //BorderWavefrom
EPD_Send_1(0x18, 0x80); //Read built-in temperature sensor
EPD_Send_1(0x4E, 0x00); // set RAM x address count to 0;
EPD_Send_2(0x4F, 0xc7, 0x00); // set RAM y address count to 0X199;
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);
delay(2);
return 0;
}
void EPD_1IN54B_V2_Show(void)
{
//refresh
EPD_Send_1(0x22, 0xf7); //Display Update Control
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
//sleep
EPD_Send_1(0x10, 0x01); //enter deep sleep
delay(2);
}
int EPD_Init_1in54c()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
//EPD_Send_2(0x00, 0x0F, 0x0D);//PANEL_SETTING
EPD_Send_1(0x50, 0xF7);//VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0x98, 0x00, 0x98);//TCON_RESOLUTION
EPD_Send_1(0x82, 0xF7);//VCM_DC_SETTING_REGISTER
EPD_SetLutBw (&lut_vcom0[0], &lut_w[0], &lut_b[0], &lut_g1[0], &lut_g2[0]);
EPD_SetLutRed(&lut_vcom1[0], &lut_red0[0], &lut_red1[0]);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}

@ -0,0 +1,316 @@
/**
******************************************************************************
* @file edp2in13.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of e-Papers:
* 2.13,
* 2.13b and 2.13c,
* 2.13d.
*
******************************************************************************
*/
unsigned char lut_full_2in13[] = {
0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_full_2in3v2[] = {
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
0x15,0x41,0xA8,0x32,0x30,0x0A,
};
const unsigned char WS_20_30_2IN13_V3[159] ={
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x80, 0x4A, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x40, 0x4A, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xF, 0x0, 0x0, 0xF, 0x0, 0x0, 0x2,
0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x0, 0x0, 0x0,
0x22, 0x17, 0x41, 0x0, 0x32, 0x36
};
const unsigned char lut_vcomDC_2in13d[] = {
0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00,
0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char lut_ww_2in13d[] = {
0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14,
0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_bw_2in13d[] = {
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_wb_2in13d[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14,
0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char lut_bb_2in13d[] = {
0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14,
0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int EPD_Init_2in13()
{
int EPD2in13V = 2;
if(EPD2in13V == 1) {
Serial.print("\r\nEPD_Init_2in13 V1");
EPD_Reset();
EPD_Send_3(0x01, 249, 0, 0); // DRIVER_OUTPUT_CONTROL: LO(h-1), HI(h-1), GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);// BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8); // WRITE_VCOM_REGISTER: VCOM 7C
EPD_Send_1(0x3A, 0x1A); // SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08); // SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03); // DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_lut(0x32, 30, &lut_full_2in13[0]);
return 0;
} else {
Serial.print("\r\nEPD_Init_2in13 V2");
EPD_Reset();
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_SendCommand(0x12);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
EPD_Send_1(0x74, 0x54);
EPD_Send_1(0x7e, 0x3B);
EPD_Send_3(0x01, 0XF9, 0X00, 0X00);
EPD_Send_1(0X11, 0X01);
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0xF9, 0x00, 0x00, 0x00);
EPD_Send_1(0X3C, 0X03);
EPD_Send_1(0X2C, 0X55);
EPD_Send_1(0x03, lut_full_2in3v2[70]);
EPD_Send_3(0x04, lut_full_2in3v2[71], lut_full_2in3v2[72], lut_full_2in3v2[73]);
EPD_Send_1(0x3A, lut_full_2in3v2[74]);
EPD_Send_1(0x3B, lut_full_2in3v2[75]);
int count;
EPD_SendCommand(0x32);
for(count = 0; count < 70; count++)
EPD_SendData(lut_full_2in3v2[count]);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0xF9, 0x00);
int Width, Height;
Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1);
Height = 250;
EPD_SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
EPD_SendData(0XFF);
}
}
EPD_SendCommand(0x22);
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
return 0;
}
}
int EPD_Init_2in13_V3()
{
Serial.print("\r\nEPD_Init_2in13 V3");
EPD_Reset();
delay(100);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
EPD_SendCommand(0x12);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
EPD_Send_3(0x01, 0XF9, 0X00, 0X00);
EPD_Send_1(0X11, 0X03);
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0x00, 0x00, 0x00, 0xF9);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0X00, 0X00);
EPD_Send_1(0x3C, 0x05);
EPD_Send_2(0x21, 0x00, 0x80);
EPD_Send_1(0x18, 0x80);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(100);
int count;
EPD_SendCommand(0x32);
for(count = 0; count < 153; count++)
EPD_SendData(WS_20_30_2IN13_V3[count]);
EPD_Send_1(0x3f, WS_20_30_2IN13_V3[153]);
EPD_Send_1(0x03, WS_20_30_2IN13_V3[154]);
EPD_Send_3(0x04, WS_20_30_2IN13_V3[155], WS_20_30_2IN13_V3[156], WS_20_30_2IN13_V3[157]);
EPD_Send_1(0x2C, WS_20_30_2IN13_V3[158]);
int Width, Height;
Width = (122 % 8 == 0)? (122 / 8 ): (122 / 8 + 1);
Height = 250;
EPD_SendCommand(0x24);
for (int j = 0; j < Height; j++) {
for (int i = 0; i < Width; i++) {
EPD_SendData(0XFF);
}
}
EPD_SendCommand(0x22);
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
return 0;
}
/* Show image and turn to deep sleep mode ------*/
void EPD_2IN13_V3_Show()
{
Serial.print("\r\n EPD_2IN13_V3_Show");
// Refresh
EPD_Send_1(0x22, 0xC7); //DISPLAY_UPDATE_CONTROL_2
EPD_SendCommand(0x20); //MASTER_ACTIVATION
while (digitalRead(PIN_SPI_BUSY) == 1) delay(10);
// Sleep
EPD_Send_1(0x10, 0x01); //DEEP_SLEEP_MODE
EPD_WaitUntilIdle();
}
int EPD_Init_2in13b()
{
EPD_Reset();
EPD_Send_3(0x06, 0x17, 0x17, 0x17);// BOOSTER_SOFT_START
EPD_SendCommand(0x04); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x8F); // PANEL_SETTING
EPD_Send_1(0x50, 0x37); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_3(0x61, 0x68, 0, 0xD4); // TCON_RESOLUTION
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_2IN13B_V3_Init(void)
{
EPD_Reset();
delay(10);
EPD_SendCommand(0x04);
EPD_WaitUntilIdle();//waiting for the electronic paper IC to release the idle signal
EPD_Send_2(0x00, 0x0f, 0x89);//panel setting
EPD_Send_3(0x61, 0x68, 0x00, 0xd4);//resolution setting
EPD_Send_1(0X50, 0x77);//VCOM AND DATA INTERVAL SETTING
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_2IN13B_V3_Show()
{
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(2);
EPD_WaitUntilIdle();
EPD_Send_1(0X50, 0xf7);
EPD_SendCommand(0X02); //power off
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X07, 0xa5); //deep sleep
}
int EPD_2IN13B_V4_Init(void)
{
EPD_Reset();
delay(10);
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0xf9, 0x00, 0x00); //Driver output control
EPD_Send_1(0x11, 0x03); //data entry mode
EPD_Send_2(0X44, 0X00, 0X0F);
EPD_Send_4(0x45, 0x00, 0x00, 0x00, 0xF9);
EPD_Send_1(0x4E, 0x00);
EPD_Send_2(0x4F, 0X00, 0X00);
EPD_Send_1(0x3C, 0x05); //BorderWavefrom
EPD_Send_1(0x18, 0x80); //Read built-in temperature sensor
EPD_Send_2(0x21, 0x80, 0x80); // Display update control
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);
return 0;
}
void EPD_2IN13B_V4_Show()
{
EPD_SendCommand(0x20); //DISPLAY REFRESH
delay(2);
EPD_WaitUntilIdle_high();
EPD_Send_1(0X10, 0x01);
}
int EPD_Init_2in13d()
{
EPD_Reset();
EPD_Send_5(0x01, 0x03, 0x00, 0x2b, 0x2b, 0x03);//POWER SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17); //BOOSTER_SOFT_START
EPD_SendCommand(0x04); //POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0xbf, 0x0d); //PANEL_SETTINGS: LUT from OTP£¬128x296
EPD_Send_1(0x30, 0x3a); //PLL_SETTINGS: 3a 100HZ, 29 150Hz, 39 200HZ, 31 171HZ, 3c 50hz
EPD_Send_3(0x61, 0x68, 0x00, 0xD4); //TCON_RESOLUTION
EPD_Send_1(0x82, 0x28); //VCOM_DC_SETTINGS
EPD_SendCommand(0x10);
for (int j = 0; j < 212; j++) for (int i = 0; i < 13; i++) EPD_SendData(0);
delay(10);
EPD_SendCommand(0x13);
return 0;
}

@ -0,0 +1,135 @@
/*****************************************************************************
* | File : EPD_2in66.c
* | Author : Waveshare team
* | Function : 2.66inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-08-10
* | Info :
* -----------------------------------------------------------------------------
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
// Display resolution
#define EPD_2IN66_WIDTH 152
#define EPD_2IN66_HEIGHT 296
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
static void EPD_2IN66_ReadBusy(void)
{
Serial.print("e-Paper busy\r\n");
delay(100);
while(digitalRead(PIN_SPI_BUSY) == 1) { //LOW: idle, HIGH: busy
delay(100);
}
delay(100);
Serial.print("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN66_Show(void)
{
EPD_SendCommand(0x20);
EPD_2IN66_ReadBusy();
Serial.print("EPD_2IN66_Show END\r\n");
EPD_SendCommand(0x10);//sleep
EPD_SendData(0x01);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_2IN66_Init(void)
{
EPD_Reset();
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
/* Y increment, X increment */
EPD_SendCommand(0x11);
EPD_SendData(0x03);
/* Set RamX-address Start/End position */
EPD_SendCommand(0x44);
EPD_SendData(0x01);
EPD_SendData((EPD_2IN66_WIDTH % 8 == 0)? (EPD_2IN66_WIDTH / 8 ): (EPD_2IN66_WIDTH / 8 + 1) );
/* Set RamY-address Start/End position */
EPD_SendCommand(0x45);
EPD_SendData(0);
EPD_SendData(0);
EPD_SendData((EPD_2IN66_HEIGHT&0xff));
EPD_SendData((EPD_2IN66_HEIGHT&0x100)>>8);
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x24);//show
return 0;
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_2IN66B_Init(void)
{
EPD_Reset();
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x12);//soft reset
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x11); //data entry mode
EPD_SendData(0x03);
EPD_SendCommand(0x44); // SET_RAM_X_ADDRESS_START_END_POSITION
EPD_SendData((0>>3) & 0x1F);
EPD_SendData(((EPD_2IN66_WIDTH-1)>>3) & 0x1F);
EPD_SendCommand(0x45); // SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_SendData(0 & 0xFF);
EPD_SendData((0 >> 8) & 0x01);
EPD_SendData((EPD_2IN66_HEIGHT-1) & 0xFF);
EPD_SendData(((EPD_2IN66_HEIGHT-1) >> 8) & 0x01);
EPD_SendCommand(0x21); // Display update control
EPD_SendData(0x00);
EPD_SendData(0x80);
EPD_SendCommand(0x4E); // SET_RAM_X_ADDRESS_COUNTER
EPD_SendData(0 & 0x1F);
EPD_SendCommand(0x4F); // SET_RAM_Y_ADDRESS_COUNTER
EPD_SendData(0 & 0xFF);
EPD_SendData((0 >> 8) & 0x01);
EPD_2IN66_ReadBusy();
EPD_SendCommand(0x24);//show
return 0;
}

@ -0,0 +1,247 @@
/**
******************************************************************************
* @file edp2in7.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 2.7 and 2.7b e-Papers
*
******************************************************************************
*/
unsigned char lut_dc_2in7[] =
{
0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x32, 0x32,
0x00, 0x00, 0x02, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_2in7[] =
{
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_2in7[] =
{
0x50, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0xA0, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_2in7[] =
{
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_2in7[] =
{
0xA0, 0x0F, 0x0F, 0x00, 0x00, 0x05, 0x60, 0x32, 0x32, 0x00, 0x00, 0x02, 0x50, 0x0F,
0x0F, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_2in7()
{
EPD_Reset();
EPD_SendCommand(0x01);//POWER_SETTING
EPD_SendData(0x03); // VDS_EN, VDG_EN
EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
EPD_SendData(0x2b); // VDH
EPD_SendData(0x2b); // VDL
EPD_SendData(0x09); // VDHR
EPD_Send_3(0x06, 0x07, 0x07, 0x17);//BOOSTER_SOFT_START
// Power optimization
EPD_Send_2(0xF8, 0x60, 0xA5);
EPD_Send_2(0xF8, 0x89, 0xA5);
EPD_Send_2(0xF8, 0x90, 0x00);
EPD_Send_2(0xF8, 0x93, 0x2A);
EPD_Send_2(0xF8, 0xA0, 0xA5);
EPD_Send_2(0xF8, 0xA1, 0x00);
EPD_Send_2(0xF8, 0x73, 0x41);
EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xAF);//PANEL_SETTING: KW-BF, KWR-AF, BWROTP 0f
EPD_Send_1(0x30, 0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_1(0x82, 0x12);//VCM_DC_SETTING_REGISTER
delay(2);
EPD_lut(0x20,44,&lut_dc_2in7[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_2in7[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_2in7[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_2in7[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_2in7[0]);// LUT_BLACK_TO_BLACK
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
for(int i = 0; i < 176*264; i++)EPD_SendData(0xFF);//Red channel
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
int EPD_2IN7_V2_Init(void)
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x45); //set Ram-Y address start/end position
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x07); //0x0107-->(263+1)=264
EPD_SendData(0x01);
EPD_SendCommand(0x4F); // set RAM y address count to 0;
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x11); // data entry mode
EPD_SendData(0x03);
EPD_SendCommand(0x24);
delay(2);
return 0;
}
void EPD_2IN7_V2_Show(void)
{
EPD_SendCommand(0x22); //Display Update Control
EPD_SendData(0XF7);
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
delay(2);
Serial.print("EPD_2IN7_V2_Show END\r\n");
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
unsigned char lut_dc_2in7b[] =
{
0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A,
0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A,
0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00,
0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R21H
unsigned char lut_ww_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R22H r
unsigned char lut_bw_2in7b[] =
{
0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0xB0, 0x04, 0x10, 0x00,
0x00, 0x05, 0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R23H w
unsigned char lut_bb_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
//R24H b
unsigned char lut_wb_2in7b[] =
{
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x84, 0x0E,
0x01, 0x0E, 0x01, 0x10, 0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00,
0x00, 0x05, 0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01
};
int EPD_Init_2in7b()
{
EPD_Reset();
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0xAF);//PANEL_SETTING
EPD_Send_1(0x30,0x3A);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_5(0x01,0x03,0x00,0x2B,0x2B,0x09);//POWER_SETTING
EPD_Send_3(0x06,0x07,0x07,0x17);//BOOSTER_SOFT_START
// Power optimization
EPD_Send_2(0xF8,0x60,0xA5);
EPD_Send_2(0xF8,0x89,0xA5);
EPD_Send_2(0xF8,0x90,0x00);
EPD_Send_2(0xF8,0x93,0x2A);
EPD_Send_2(0xF8,0x73,0x41);
EPD_Send_1(0x82,0x2E);// VCM_DC_SETTING_REGISTER
EPD_Send_1(0x50,0xA7);// VCOM_AND_DATA_INTERVAL_SETTING
EPD_lut(0x20,44,&lut_dc_2in7b[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_2in7b[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_2in7b[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_2in7b[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_2in7b[0]);// LUT_BLACK_TO_BLACK
EPD_Send_4(0x61, 0, 176, 1, 8);// TCON_RESOLUTION: HI(W), LO(W), HI(H), LO(H)
EPD_Send_1(0x16, 0x00);//PARTIAL_DISPLAY_REFRESH);
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_2in7b_V2(void)
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12);
EPD_WaitUntilIdle_high();
EPD_Send_3(0x00, 0x27, 0x01, 0x00);
EPD_Send_1(0x11, 0x03);
EPD_Send_2(0x44, 0x00, 0x15);
EPD_Send_4(0x45, 0x00, 0x00, 0x7, 0x1);
EPD_Send_1(0x4e, 0x00);
EPD_Send_2(0x4f, 0x00, 0x00);
EPD_SendCommand(0x24);
return 0;
}
void EPD_Show_2in7b_V2(void)
{
EPD_SendCommand(0x20);
EPD_WaitUntilIdle_high();
delay(200);
EPD_Send_1(0x10, 0x01);
}

@ -0,0 +1,179 @@
/**
******************************************************************************
* @file edp2in9.h
* @author Waveshare Team
* @version V1.1
* @date 23-Oct-2020
* @brief This file describes initialisation of 2.9 and 2.9b e-Papers
*
******************************************************************************
*/
int EPD_Init_2in9()
{
EPD_Reset();
EPD_Send_3(0x01, 39, 1, 0);//DRIVER_OUTPUT_CONTROL:LO(EPD_HEIGHT-1),HI(EPD_HEIGHT-1), GD = 0; SM = 0; TB = 0;
EPD_Send_3(0x0C, 0xD7, 0xD6, 0x9D);//BOOSTER_SOFT_START_CONTROL
EPD_Send_1(0x2C, 0xA8);//WRITE_VCOM_REGISTER:VCOM 7C
EPD_Send_1(0x3A, 0x1A);//SET_DUMMY_LINE_PERIOD: 4 dummy lines per gate
EPD_Send_1(0x3B, 0x08);//SET_GATE_TIME: 2us per line
EPD_Send_1(0x11, 0x03);//DATA_ENTRY_MODE_SETTING: X increment; Y increment
EPD_Send_2(0x44, 0, 15);//SET_RAM_X_ADDRESS_START_END_POSITION: LO(x >> 3), HI ((w-1) >> 3)
EPD_Send_4(0x45, 0, 0, 45, 1);//SET_RAM_Y_ADDRESS_START_END_POSITION: LO(y), HI(y), LO(h - 1),HI(h - 1)
EPD_Send_1(0x4E, 0);//SET_RAM_X_ADDRESS_COUNTER: LO(x >> 3)
EPD_Send_2(0x4F, 0, 0);//SET_RAM_Y_ADDRESS_COUNTER: LO(y), HI(y)
EPD_lut(0x32, 30, &lut_full_mono[0]);
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
return 0;
}
int EPD_Init_2in9_V2()
{
EPD_Reset();
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x12); //SWRESET
EPD_WaitUntilIdle_high();
EPD_Send_3(0x01, 0x27, 0x01, 0x00);//Driver output control
EPD_Send_1(0x11, 0x03);//data entry mode
EPD_Send_2(0x21, 0x00, 0x80);// Display update control
EPD_Send_2(0x44, 0x00, 0x0f);// SET_RAM_X_ADDRESS_START_END_POSITION
EPD_Send_4(0x45, 0x00, 0x00, 0x27, 0x01);// SET_RAM_Y_ADDRESS_START_END_POSITION
EPD_Send_1(0x4e, 0x00);// // SET_RAM_X_ADDRESS_COUNTER
EPD_Send_2(0x4f, 0x00, 0x00);// SET_RAM_Y_ADDRESS_COUNTER
EPD_WaitUntilIdle_high();
EPD_SendCommand(0x24);//WRITE_RAM
delay(2);
return 0;
}
void EPD_2IN9_V2_Show(void)
{
Serial.print("\r\n EPD_2IN9_V2_Show");
EPD_Send_1(0x22, 0xF7); //Display Update Control
EPD_SendCommand(0x20); //Activate Display Update Sequence
EPD_WaitUntilIdle_high();
}
int EPD_Init_2in9b()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x00, 0x08, 0x00);//POWER_SETTING
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x8F);//PANEL_SETTING
EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING;
EPD_Send_1(0x30, 0x39);//PLL_CONTROL
EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x0A);//VCM_DC_SETTING_REGISTER
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_2in9b_V3()
{
EPD_Reset();
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0x0F, 0x89);//PANEL_SETTING
EPD_Send_3(0x61, 0x80, 0x01, 0x28);//TCON_RESOLUTION
EPD_Send_1(0x50, 0x77);//VCOM_AND_DATA_INTERVAL_SETTING;
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
/************************************************************************************/
#define UBYTE uint8_t
#define UWORD uint16_t
#define UDOUBLE uint32_t
#define EPD_2IN9D_WIDTH 128
#define EPD_2IN9D_HEIGHT 296
void EPD_2IN9D_ReadBusy(void)
{
Serial.print("\r\ne-Paper busy");
UBYTE busy;
do {
EPD_SendCommand(0x71);
busy = digitalRead(PIN_SPI_BUSY);
busy = !(busy & 0x01);
delay(20);
} while(busy);
delay(20);
Serial.print("\r\ne-Paper busy free");
}
void EPD_2IN9D_Show(void)
{
Serial.print("\r\nEPD_2IN9D_Show");
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(10); //!!!The delay here is necessary, 200uS at least!!!
EPD_2IN9D_ReadBusy();
delay(200);
// Sleep
EPD_SendCommand(0X50);
EPD_SendData(0xf7);
EPD_SendCommand(0X02); //power off
EPD_2IN9D_ReadBusy();
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
void EPD_2IN9D_Clear(void)
{
UWORD Width, Height;
Width = (EPD_2IN9D_WIDTH % 8 == 0)? (EPD_2IN9D_WIDTH / 8 ): (EPD_2IN9D_WIDTH / 8 + 1);
Height = EPD_2IN9D_HEIGHT;
EPD_SendCommand(0x10);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_SendData(0x00);
}
}
EPD_SendCommand(0x13);
}
int EPD_Init_2in9d()
{
EPD_Reset();
EPD_SendCommand(0x04);
EPD_2IN9D_ReadBusy();
EPD_SendCommand(0x00); //panel setting
EPD_SendData(0x1f); //LUT from OTP128x296
EPD_SendCommand(0x61); //resolution setting
EPD_SendData(EPD_2IN9D_WIDTH);
EPD_SendData((EPD_2IN9D_HEIGHT >> 8) & 0xff);
EPD_SendData(EPD_2IN9D_HEIGHT & 0xff);
EPD_SendCommand(0x50); //vcom_DC setting
EPD_SendData(0x97);
delay(2);
EPD_2IN9D_Clear();
return 0;
}

@ -0,0 +1,246 @@
/*****************************************************************************
* | File : EPD_3IN52.h
* | Author : Waveshare team
* | Function : 3.52inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2022-11-02
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
//GC 0.9S
static const UBYTE EPD_3IN52_lut_R20_GC[] =
{
0x01,0x0f,0x0f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R21_GC[] =
{
0x01,0x4f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R22_GC[] =
{
0x01,0x0f,0x8f,0x0f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R23_GC[] =
{
0x01,0x4f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const UBYTE EPD_3IN52_lut_R24_GC[] =
{
0x01,0x0f,0x8f,0x4f,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
UBYTE EPD_3IN52_Flag;
/******************************************************************************
function : Read Busy
parameter:
******************************************************************************/
void EPD_3IN52_ReadBusy(void)
{
Serial.print("e-Paper busy\r\n");
UBYTE busy;
do {
busy = digitalRead(PIN_SPI_BUSY);
} while(!busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/**
* @brief
*
*/
void EPD_3IN52_refresh(void)
{
EPD_SendCommand(0x17);
EPD_SendData(0xA5);
EPD_3IN52_ReadBusy();
delay(200);
}
// LUT download
void EPD_3IN52_lut_GC(void)
{
UBYTE count;
EPD_SendCommand(0x20); // vcom
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R20_GC[count]);
}
EPD_SendCommand(0x21); // red not use
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R21_GC[count]);
}
EPD_SendCommand(0x24); // bb b
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R24_GC[count]);
}
if(EPD_3IN52_Flag == 0)
{
EPD_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_3IN52_Flag = 1;
}
else
{
EPD_SendCommand(0x22); // bw r
for(count = 0; count < 56 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R23_GC[count]);
}
EPD_SendCommand(0x23); // wb w
for(count = 0; count < 42 ; count++)
{
EPD_SendData(EPD_3IN52_lut_R22_GC[count]);
}
EPD_3IN52_Flag = 0;
}
}
void EPD_3IN52_Clear(void)
{
EPD_SendCommand(0x13);
for(int i=0; i<10800; i++)
EPD_SendData(0xFF);
EPD_3IN52_lut_GC();
EPD_3IN52_refresh();
EPD_SendCommand(0x50);
EPD_SendData(0x17);
delay(500);
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_3IN52_Init(void)
{
EPD_3IN52_Flag = 0;
EPD_Reset();
EPD_SendCommand(0x00); // panel setting PSR
EPD_SendData(0xFF); // RES1 RES0 REG KW/R UD SHL SHD_N RST_N
EPD_SendData(0x01); // x x x VCMZ TS_AUTO TIGE NORG VC_LUTZ
EPD_SendCommand(0x01); // POWER SETTING PWR
EPD_SendData(0x03); // x x x x x x VDS_EN VDG_EN
EPD_SendData(0x10); // x x x VCOM_SLWE VGH[3:0] VGH=20V, VGL=-20V
EPD_SendData(0x3F); // x x VSH[5:0] VSH = 15V
EPD_SendData(0x3F); // x x VSL[5:0] VSL=-15V
EPD_SendData(0x03); // OPTEN VDHR[6:0] VHDR=6.4V
// T_VDS_OFF[1:0] 00=1 frame; 01=2 frame; 10=3 frame; 11=4 frame
EPD_SendCommand(0x06); // booster soft start BTST
EPD_SendData(0x37); // BT_PHA[7:0]
EPD_SendData(0x3D); // BT_PHB[7:0]
EPD_SendData(0x3D); // x x BT_PHC[5:0]
EPD_SendCommand(0x60); // TCON setting TCON
EPD_SendData(0x22); // S2G[3:0] G2S[3:0] non-overlap = 12
EPD_SendCommand(0x82); // VCOM_DC setting VDCS
EPD_SendData(0x07); // x VDCS[6:0] VCOM_DC value= -1.9v 00~3f,0x12=-1.9v
EPD_SendCommand(0x30);
EPD_SendData(0x09);
EPD_SendCommand(0xe3); // power saving PWS
EPD_SendData(0x88); // VCOM_W[3:0] SD_W[3:0]
EPD_SendCommand(0x61); // resoultion setting
EPD_SendData(0xf0); // HRES[7:3] 0 0 0
EPD_SendData(0x01); // x x x x x x x VRES[8]
EPD_SendData(0x68); // VRES[7:0]
EPD_SendCommand(0x50);
EPD_SendData(0xB7);
EPD_3IN52_Clear();
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_3IN52_Show(void)
{
EPD_3IN52_lut_GC();
EPD_3IN52_refresh();
delay(2);
Serial.print("EPD_3IN52_Show END\r\n");
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}

@ -0,0 +1,174 @@
/*****************************************************************************
* | File : EPD_3IN7.c
* | Author : Waveshare team
* | Function : 3.7inch e-paper
* | Info :
*----------------
* | This version: V1.0
* | Date : 2020-08-10
* | Info :
* -----------------------------------------------------------------------------
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
static const UBYTE lut_1Gray_GC[] =
{
0x2A,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//1
0x05,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//2
0x2A,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//3
0x05,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//4
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//5
0x00,0x02,0x03,0x0A,0x00,0x02,0x06,0x0A,0x05,0x00,//6
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//8
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10
0x22,0x22,0x22,0x22,0x22
};
static void EPD_3IN7_ReadBusy_HIGH(void)
{
Serial.print("e-Paper busy\r\n");
UBYTE busy;
do {
busy = digitalRead(PIN_SPI_BUSY);
} while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/******************************************************************************
function : set the look-up tables
parameter:
******************************************************************************/
static void EPD_3IN7_Load_LUT(void)
{
UWORD i;
EPD_SendCommand(0x32);
for (i = 0; i < 105; i++)
{
EPD_SendData(lut_1Gray_GC[i]);
}
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
int EPD_3IN7_1Gray_Init()
{
EPD_Reset();
EPD_SendCommand(0x12);
delay(300);
EPD_SendCommand(0x46);
EPD_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_SendCommand(0x47);
EPD_SendData(0xF7);
EPD_3IN7_ReadBusy_HIGH();
EPD_SendCommand(0x01); // setting gaet number
EPD_SendData(0xDF);
EPD_SendData(0x01);
EPD_SendData(0x00);
EPD_SendCommand(0x03); // set gate voltage
EPD_SendData(0x00);
EPD_SendCommand(0x04); // set source voltage
EPD_SendData(0x41);
EPD_SendData(0xA8);
EPD_SendData(0x32);
EPD_SendCommand(0x11); // set data entry sequence
EPD_SendData(0x03);
EPD_SendCommand(0x3C); // set border
EPD_SendData(0x00);
EPD_SendCommand(0x0C); // set booster strength
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0xC0);
EPD_SendCommand(0x18); // set internal sensor on
EPD_SendData(0x80);
EPD_SendCommand(0x2C); // set vcom value
EPD_SendData(0x44);
EPD_SendCommand(0x37); // set display option, these setting turn on previous function
EPD_SendData(0x00); //can switch 1 gray or 4 gray
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0x4F);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendData(0xFF);
EPD_SendCommand(0x44); // setting X direction start/end position of RAM
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0x17);
EPD_SendData(0x01);
EPD_SendCommand(0x45); // setting Y direction start/end position of RAM
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendData(0xDF);
EPD_SendData(0x01);
EPD_SendCommand(0x22); // Display Update Control 2
EPD_SendData(0xCF);
EPD_SendCommand(0x4E);//Set Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x24);//begin write data to e-Paper
return 0;
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
static void EPD_3IN7_1Gray_Show(void)
{
EPD_3IN7_Load_LUT();
EPD_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
Serial.print("EPD_3IN7_Show END\r\n");
EPD_SendCommand(0X10); //deep sleep
EPD_SendData(0x03);
}

@ -0,0 +1,83 @@
/**
******************************************************************************
* @file edp4in01f.h
* @author Waveshare Team
* @version V1.0.0
* @date 29-Dec-2020
* @brief This file describes initialisation of 4.01f e-Papers
*
******************************************************************************
*/
/*****************************************************************************
EPD_4IN01F
******************************************************************************/
static void EPD_4IN01F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(digitalRead(PIN_SPI_BUSY)));
}
static void EPD_4IN01F_BusyLow(void)// If BUSYN=1 then waiting
{
while(digitalRead(PIN_SPI_BUSY));
}
static void EPD_4IN01F_Show(void)
{
EPD_SendCommand(0x04);//0x04
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x12);//0x12
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x02);//0x02
EPD_4IN01F_BusyLow();
delay(200);
Serial.print("EPD_4IN01F_Show END\r\n");
delay(100);
EPD_SendCommand(0x07);//sleep
EPD_SendData(0xA5);
delay(100);
}
int EPD_4IN01F_init()
{
EPD_Reset();
EPD_4IN01F_BusyHigh();
EPD_SendCommand(0x00);
EPD_SendData(0x2f);
EPD_SendData(0x00);
EPD_SendCommand(0x01);
EPD_SendData(0x37);
EPD_SendData(0x00);
EPD_SendData(0x05);
EPD_SendData(0x05);
EPD_SendCommand(0x03);
EPD_SendData(0x00);
EPD_SendCommand(0x06);
EPD_SendData(0xC7);
EPD_SendData(0xC7);
EPD_SendData(0x1D);
EPD_SendCommand(0x41);
EPD_SendData(0x00);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x60);
EPD_SendData(0x22);
EPD_SendCommand(0x61);
EPD_SendData(0x02);
EPD_SendData(0x80);
EPD_SendData(0x01);
EPD_SendData(0x90);
EPD_SendCommand(0xE3);
EPD_SendData(0xAA);
EPD_SendCommand(0x61);//Set Resolution setting
EPD_SendData(0x02);
EPD_SendData(0x80);
EPD_SendData(0x01);
EPD_SendData(0x90);
EPD_SendCommand(0x10);//begin write data to e-Paper
return 0;
}

@ -0,0 +1,169 @@
/**
******************************************************************************
* @file edp4in2.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 4.2 and 4.2b e-Papers
*
******************************************************************************
*/
unsigned char lut_dc_4in2[] =
{
0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00,
0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_4in2[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_4in2[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_4in2[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_4in2[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_4in2()
{
EPD_Reset();
EPD_SendCommand(0x01);//POWER_SETTING
EPD_SendData(0x03); // VDS_EN, VDG_EN
EPD_SendData(0x00); // VCOM_HV, VGHL_LV[1], VGHL_LV[0]
EPD_SendData(0x2F); // VDH
EPD_SendData(0x2F); // VDL
EPD_SendData(0xFF); // VDHR
EPD_Send_3(0x06, 0x17, 0x17, 0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_2(0x00, 0xBF, 0x0B);//PANEL_SETTING: // KW-BF KWR-AF BWROTP 0f
EPD_Send_1(0x30, 0x3C);//PLL_CONTROL: 3A 100HZ, 29 150Hz, 39 200HZ, 31 171HZ
EPD_Send_4(0x61, 1, 144, 1, 44);// RESOLUTION_SETTING: HI(W), LO(W), HI(H), LO(H)
EPD_Send_1(0x82, 0x12);// VCM_DC_SETTING
EPD_Send_1(0x50, 0x97);// VCOM_AND_DATA_INTERVAL_SETTING: VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7
EPD_lut(0x20,44,&lut_dc_4in2[0]);// LUT_FOR_VCOM
EPD_lut(0x21,42,&lut_ww_4in2[0]);// LUT_WHITE_TO_WHITE
EPD_lut(0x22,42,&lut_bw_4in2[0]);// LUT_BLACK_TO_WHITE
EPD_lut(0x23,42,&lut_wb_4in2[0]);// LUT_WHITE_TO_BLACK
EPD_lut(0x24,42,&lut_bb_4in2[0]);// LUT_BLACK_TO_BLACK
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
for(int i = 0; i < 400*300; i++)EPD_SendData(0xFF);//Red channel
EPD_SendCommand(0x13);//DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
unsigned char lut_dc_4in2b[] =
{
0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00,
0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R21H
unsigned char lut_ww_4in2b[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R22H r
unsigned char lut_bw_4in2b[] =
{
0x40, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x40, 0x0A,
0x01, 0x00, 0x00, 0x01, 0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R24H b
unsigned char lut_bb_4in2b[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//R23H w
unsigned char lut_wb_4in2b[] =
{
0x80, 0x17, 0x00, 0x00, 0x00, 0x02, 0x90, 0x17, 0x17, 0x00, 0x00, 0x02, 0x80, 0x0A,
0x01, 0x00, 0x00, 0x01, 0x50, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
int EPD_Init_4in2b()
{
EPD_Reset();
EPD_Send_3(0x06,0x17,0x17,0x17);//BOOSTER_SOFT_START
EPD_SendCommand(0x04);//POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x0F);//PANEL_SETTING
EPD_Send_1(0x50,0xF7);// VCOM_AND_DATA_INTERVAL_SETTING
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_4in2b_V2()
{
EPD_Reset();
EPD_SendCommand(0x04);
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x0F);//PANEL_SETTING
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
void EPD_4IN2B_V2_Show(void)
{
EPD_SendCommand(0x12); // DISPLAY_REFRESH
delay(100);
EPD_WaitUntilIdle();
EPD_Send_1(0X50, 0xf7);
EPD_SendCommand(0X02); //power off
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X07, 0xf7); //deep sleep
}

@ -0,0 +1,90 @@
/**
******************************************************************************
* @file edp5in65.h
* @author Waveshare Team
* @version V1.0.0
* @date 27-July-2020
* @brief This file describes initialisation of 5.65f e-Papers
*
******************************************************************************
*/
/*****************************************************************************
EPD_5IN65F
******************************************************************************/
static void EPD_5IN65F_BusyHigh(void)// If BUSYN=0 then waiting
{
while(!(digitalRead(PIN_SPI_BUSY)));
}
static void EPD_5IN65F_BusyLow(void)// If BUSYN=1 then waiting
{
while(digitalRead(PIN_SPI_BUSY));
}
static void EPD_5IN65F_Show(void)
{
EPD_SendCommand(0x04);//0x04
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x12);//0x12
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x02);//0x02
EPD_5IN65F_BusyLow();
delay(200);
Serial.print("EPD_5IN65F_Show END\r\n");
delay(100);
EPD_SendCommand(0x07);//sleep
EPD_SendData(0xA5);
delay(100);
}
int EPD_5IN65F_init()
{
EPD_Reset();
EPD_5IN65F_BusyHigh();
EPD_SendCommand(0x00);
EPD_SendData(0xEF);
EPD_SendData(0x08);
EPD_SendCommand(0x01);
EPD_SendData(0x37);
EPD_SendData(0x00);
EPD_SendData(0x23);
EPD_SendData(0x23);
EPD_SendCommand(0x03);
EPD_SendData(0x00);
EPD_SendCommand(0x06);
EPD_SendData(0xC7);
EPD_SendData(0xC7);
EPD_SendData(0x1D);
EPD_SendCommand(0x30);
EPD_SendData(0x3C);
EPD_SendCommand(0x41);
EPD_SendData(0x00);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x60);
EPD_SendData(0x22);
EPD_SendCommand(0x61);
EPD_SendData(0x02);
EPD_SendData(0x58);
EPD_SendData(0x01);
EPD_SendData(0xC0);
EPD_SendCommand(0xE3);
EPD_SendData(0xAA);
delay(100);
EPD_SendCommand(0x50);
EPD_SendData(0x37);
EPD_SendCommand(0x61);//Set Resolution setting
EPD_SendData(0x02);
EPD_SendData(0x58);
EPD_SendData(0x01);
EPD_SendData(0xC0);
EPD_SendCommand(0x10);//begin write data to e-Paper
return 0;
}

@ -0,0 +1,92 @@
/**
******************************************************************************
* @file edp5in83.h
* @author Waveshare Team
* @version V1.1
* @date 15-Dec-2020
* @brief This file describes initialisation of 5.83, 5.83b, 5.83c e-Papers
*
******************************************************************************
*/
int EPD_5in83__init()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START
EPD_SendCommand(0x4); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3C); // PLL_CONTROL
EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); // TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION
EPD_Send_1(0x82, 0x1E); // VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); // FLASH MODE
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_Init_5in83_V2()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x07, 0x3f, 0x3f); // POWER_SETTING
EPD_SendCommand(0x04); // POWER_ON
delay(100);
EPD_WaitUntilIdle();
EPD_Send_1(0x00, 0x1F); // PANEL_SETTING
EPD_Send_4(0x61, 0x02, 0x88, 0x01, 0xE0);// TCON_RESOLUTION
EPD_Send_1(0X15, 0x00);
EPD_Send_2(0X50, 0x10, 0x07);
EPD_Send_1(0X60, 0x22);
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
for(UWORD i=0; i<38880; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13); // DATA_START_TRANSMISSION_2
delay(2);
return 0;
}
int EPD_5in83b__init()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); // POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); // PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); // BOOSTER_SOFT_START
EPD_SendCommand(0x4); // POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3A); // PLL_CONTROL
EPD_Send_1(0x41, 0x00); // TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); // VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); // TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x58, 0x01, 0xC0);// TCON_RESOLUTION
EPD_Send_1(0x82, 0x20); // VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); // FLASH MODE
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
int EPD_5in83b_V2_init()
{
EPD_Reset();
EPD_Send_4(0x01, 0x07, 0x07, 0x3f, 0x3f); //POWER SETTING
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_WaitUntilIdle(); //waiting for the electronic paper IC to release the idle signal
EPD_Send_1(0X00, 0x0F); //PANNEL SETTING
EPD_Send_4(0x61, 0x02, 0x88, 0x01, 0xe0); //tres
EPD_Send_1(0X15, 0x00);
EPD_Send_2(0X50, 0x11, 0x07); //VCOM AND DATA INTERVAL SETTING
EPD_Send_1(0X60, 0x22); //TCON SETTING
EPD_SendCommand(0x10); // DATA_START_TRANSMISSION_1
delay(2);
return 0;
}

@ -0,0 +1,264 @@
/**
******************************************************************************
* @file edp7in5.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 7.5 and 7.5b e-Papers
*
******************************************************************************
*/
UBYTE Voltage_Frame_7IN5_V2[]={
0x6, 0x3F, 0x3F, 0x11, 0x24, 0x7, 0x17,
};
UBYTE LUT_VCOM_7IN5_V2[]={
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0xF, 0x1, 0xF, 0x1, 0x2,
0x0, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_WW_7IN5_V2[]={
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_BW_7IN5_V2[]={
0x10, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x20, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_WB_7IN5_V2[]={
0x80, 0xF, 0xF, 0x0, 0x0, 0x3,
0x84, 0xF, 0x1, 0xF, 0x1, 0x4,
0x40, 0xF, 0xF, 0x0, 0x0, 0x3,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
UBYTE LUT_BB_7IN5_V2[]={
0x80, 0xF, 0xF, 0x0, 0x0, 0x1,
0x84, 0xF, 0x1, 0xF, 0x1, 0x2,
0x40, 0xF, 0xF, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
int EPD_7in5__init()
{
EPD_Reset();
EPD_Send_2(0x01, 0x37, 0x00); //POWER_SETTING
EPD_Send_2(0x00, 0xCF, 0x08); //PANEL_SETTING
EPD_Send_3(0x06, 0xC7, 0xCC, 0x28); //BOOSTER_SOFT_START
EPD_SendCommand(0x4); //POWER_ON
EPD_WaitUntilIdle();
EPD_Send_1(0x30, 0x3C); //PLL_CONTROL
EPD_Send_1(0x41, 0x00); //TEMPERATURE_CALIBRATION
EPD_Send_1(0x50, 0x77); //VCOM_AND_DATA_INTERVAL_SETTING
EPD_Send_1(0x60, 0x22); //TCON_SETTING
EPD_Send_4(0x61, 0x02, 0x80, 0x01, 0x80);//TCON_RESOLUTION
EPD_Send_1(0x82, 0x1E); //VCM_DC_SETTING: decide by LUT file
EPD_Send_1(0xE5, 0x03); //FLASH MODE
EPD_SendCommand(0x10);//DATA_START_TRANSMISSION_1
delay(2);
return 0;
}
/*****************************************************************************
EPD_7in5_V2
******************************************************************************/
static void EPD_7in5_V2_Readbusy(void)
{
Serial.print("\r\ne-Paper busy\r\n");
unsigned char busy;
do{
EPD_SendCommand(0x71);
busy = digitalRead(PIN_SPI_BUSY);
busy =!(busy & 0x01);
}while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
static void EPD_7IN5_V2_Show(void)
{
EPD_SendCommand(0x12); //DISPLAY REFRESH
delay(100); //!!!The delay here is necessary, 200uS at least!!!
EPD_7in5_V2_Readbusy();
//Enter sleep mode
EPD_SendCommand(0X02); //power off
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X07); //deep sleep
EPD_SendData(0xA5);
}
static void EPD_7IN5_V2_LUT(UBYTE* lut_vcom, UBYTE* lut_ww, UBYTE* lut_bw, UBYTE* lut_wb, UBYTE* lut_bb)
{
UBYTE count;
EPD_SendCommand(0x20); //VCOM
for(count=0; count<60; count++)
EPD_SendData(lut_vcom[count]);
EPD_SendCommand(0x21); //LUTBW
for(count=0; count<60; count++)
EPD_SendData(lut_ww[count]);
EPD_SendCommand(0x22); //LUTBW
for(count=0; count<60; count++)
EPD_SendData(lut_bw[count]);
EPD_SendCommand(0x23); //LUTWB
for(count=0; count<60; count++)
EPD_SendData(lut_wb[count]);
EPD_SendCommand(0x24); //LUTBB
for(count=0; count<60; count++)
EPD_SendData(lut_bb[count]);
}
int EPD_7in5_V2_init()
{
EPD_Reset();
// EPD_SendCommand(0x01); //POWER SETTING
// EPD_SendData(0x07);
// EPD_SendData(0x07); //VGH=20V,VGL=-20V
// EPD_SendData(0x3f); //VDH=15V
// EPD_SendData(0x3f); //VDL=-15V
EPD_SendCommand(0x01); // power setting
EPD_SendData(0x17); // 1-0=11: internal power
EPD_SendData(*(Voltage_Frame_7IN5_V2+6)); // VGH&VGL
EPD_SendData(*(Voltage_Frame_7IN5_V2+1)); // VSH
EPD_SendData(*(Voltage_Frame_7IN5_V2+2)); // VSL
EPD_SendData(*(Voltage_Frame_7IN5_V2+3)); // VSHR
EPD_SendCommand(0x82); // VCOM DC Setting
EPD_SendData(*(Voltage_Frame_7IN5_V2+4)); // VCOM
EPD_SendCommand(0x06); // Booster Setting
EPD_SendData(0x27);
EPD_SendData(0x27);
EPD_SendData(0x2F);
EPD_SendData(0x17);
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X00); //PANNEL SETTING
EPD_SendData(0x3F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_SendCommand(0x61); //tres
EPD_SendData(0x03); //source 800
EPD_SendData(0x20);
EPD_SendData(0x01); //gate 480
EPD_SendData(0xE0);
EPD_SendCommand(0X15);
EPD_SendData(0x00);
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_SendData(0x10);
EPD_SendData(0x00);
EPD_SendCommand(0X60); //TCON SETTING
EPD_SendData(0x22);
EPD_SendCommand(0x65); // Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);//800*480
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_7IN5_V2_LUT(LUT_VCOM_7IN5_V2, LUT_WW_7IN5_V2, LUT_BW_7IN5_V2, LUT_WB_7IN5_V2, LUT_BB_7IN5_V2);
EPD_SendCommand(0x10);
for(UWORD i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13);
return 0;
}
/*****************************************************************************
EPD_7in5B_V2
******************************************************************************/
int EPD_7in5B_V2_Init(void)
{
EPD_Reset();
EPD_SendCommand(0x01); //POWER SETTING
EPD_SendData(0x07);
EPD_SendData(0x07); //VGH=20V,VGL=-20V
EPD_SendData(0x3f); //VDH=15V
EPD_SendData(0x3f); //VDL=-15V
EPD_SendCommand(0x04); //POWER ON
delay(100);
EPD_7in5_V2_Readbusy();
EPD_SendCommand(0X00); //PANNEL SETTING
EPD_SendData(0x0F); //KW-3f KWR-2F BWROTP 0f BWOTP 1f
EPD_SendCommand(0x61); //tres
EPD_SendData(0x03); //source 800
EPD_SendData(0x20);
EPD_SendData(0x01); //gate 480
EPD_SendData(0xE0);
EPD_SendCommand(0X15);
EPD_SendData(0x00);
EPD_SendCommand(0X50); //VCOM AND DATA INTERVAL SETTING
EPD_SendData(0x11);
EPD_SendData(0x07);
EPD_SendCommand(0X60); //TCON SETTING
EPD_SendData(0x22);
EPD_SendCommand(0x65); // Resolution setting
EPD_SendData(0x00);
EPD_SendData(0x00);//800*480
EPD_SendData(0x00);
EPD_SendData(0x00);
UWORD i;
EPD_SendCommand(0x10);
for(i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x13);
for(i=0; i<800 / 8 *480; i++) {
EPD_SendData(0x00);
}
EPD_SendCommand(0x10);
return 0;
}

@ -0,0 +1,196 @@
/**
******************************************************************************
* @file edp7in5_HD.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes initialisation of 7.5 HD and 7.5b HD e-Papers
*
******************************************************************************
*/
void EPD_7IN5_HD_Readbusy(void)
{
Serial.print("\r\ne-Paper busy\r\n");
delay(200);
unsigned char busy;
do{
busy = digitalRead(PIN_SPI_BUSY);
}while(busy);
delay(200);
Serial.print("e-Paper busy release\r\n");
}
/*****************************************************************************
EPD_7IN5_HD
******************************************************************************/
static void EPD_7IN5_HD_Show(void)
{
unsigned int i;
EPD_SendCommand(0x26);
for(i=0; i<880*528/8; i++) {
EPD_SendData(0xff);
}
EPD_SendCommand(0x22);//show
EPD_SendData(0xF7);
EPD_SendCommand(0x20);
delay(200);
EPD_7IN5_HD_Readbusy();
EPD_SendCommand(0x10);//sleep
EPD_SendData(0x01);
Serial.print("EPD_7IN5_HD_Show END\r\n");
}
int EPD_7IN5_HD_init()
{
EPD_Reset();
EPD_SendCommand(0x12); //SWRESET
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x46); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x47); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x0C); // Soft start setting
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0x40);
EPD_SendCommand(0x01); // Set MUX as 527
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendData(0x01);
EPD_SendCommand(0x11); // Data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44);
EPD_SendData(0x00); // RAM x address start at 0
EPD_SendData(0x00);
EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879
EPD_SendData(0x03);
EPD_SendCommand(0x45);
EPD_SendData(0xAF); // RAM y address start at 20Fh;
EPD_SendData(0x02);
EPD_SendData(0x00); // RAM y address end at 00h;
EPD_SendData(0x00);
EPD_SendCommand(0x3C); // VBD
EPD_SendData(0x01); // LUT1, for white
EPD_SendCommand(0x18);
EPD_SendData(0X80);
EPD_SendCommand(0x22);
EPD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_SendCommand(0x20);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x4E);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x24);//BLOCK
return 0;
}
/*****************************************************************************
EPD_7IN5B_HD
******************************************************************************/
static void EPD_7IN5B_HD_Show(void)
{
EPD_SendCommand(0x22);//show
EPD_SendData(0xC7);
EPD_SendCommand(0x20);
delay(200);
EPD_7IN5_HD_Readbusy();
EPD_SendCommand(0x10);//sleep
EPD_SendData(0x01);
Serial.print("EPD_7IN5B_HD_Show END\r\n");
}
int EPD_7IN5B_HD_init()
{
EPD_Reset();
EPD_SendCommand(0x12); //SWRESET
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x46); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x47); // Auto Write RAM
EPD_SendData(0xF7);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x0C); // Soft start setting
EPD_SendData(0xAE);
EPD_SendData(0xC7);
EPD_SendData(0xC3);
EPD_SendData(0xC0);
EPD_SendData(0x40);
EPD_SendCommand(0x01); // Set MUX as 527
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendData(0x01);
EPD_SendCommand(0x11); // Data entry mode
EPD_SendData(0x01);
EPD_SendCommand(0x44);
EPD_SendData(0x00); // RAM x address start at 0
EPD_SendData(0x00);
EPD_SendData(0x6F); // RAM x address end at 36Fh -> 879
EPD_SendData(0x03);
EPD_SendCommand(0x45);
EPD_SendData(0xAF); // RAM y address start at 20Fh;
EPD_SendData(0x02);
EPD_SendData(0x00); // RAM y address end at 00h;
EPD_SendData(0x00);
EPD_SendCommand(0x3C); // VBD
EPD_SendData(0x01); // LUT1, for white
EPD_SendCommand(0x18);
EPD_SendData(0X80);
EPD_SendCommand(0x22);
EPD_SendData(0XB1); //Load Temperature and waveform setting.
EPD_SendCommand(0x20);
EPD_7IN5_HD_Readbusy(); //waiting for the electronic paper IC to release the idle signal
EPD_SendCommand(0x4E);
EPD_SendData(0x00);
EPD_SendData(0x00);
EPD_SendCommand(0x4F);
EPD_SendData(0xAF);
EPD_SendData(0x02);
EPD_SendCommand(0x4F);
EPD_SendData(0xAf);
EPD_SendData(0x02);
EPD_SendCommand(0x24);//BLOCK
return 0;
}

@ -0,0 +1,74 @@
/**
******************************************************************************
* @file html.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes the sending of HTML-page to a client
*
******************************************************************************
*/
void sendHtml(WiFiClient client,IPAddress myIP)
{
client.print(
"<!DOCTYPE html>\r\n"
"<html>\r\n"
"<head>\r\n"
"<meta charset='utf-8'>\r\n"
"<title>PriceTag</title>\r\n"
"<link rel='icon' href='data:;base64,='>\r\n"
"<link rel='stylesheet' href='styles.css'>\r\n"
"<script src='scriptA.js'></script>\r\n"
"<script src='scriptB.js'></script>\r\n"
"<script src='scriptC.js'></script>\r\n"
"<script src='scriptD.js'></script>\r\n"
"</head>\r\n"
"<body>\r\n"
"<div class='header_back'>\r\n"
"<div class='header_face'></div>\r\n"
"</div>\r\n"
"<div class='content_back'>\r\n"
"<div class='content_face'>\r\n"
"<table style='width:100%; height:100%' border='0' cellspacing='0'>\r\n"
"<tr>\r\n"
"<td class='menu_bar' rowspan='2'>\r\n"
"<div id='BT'></div>\r\n"
"<table>\r\n"
"<tr>\r\n"
"<td class='comment' colspan='4'><br>Device IP:</td>\r\n"
"</tr>\r\n"
"<tr>\r\n"
"<td colspan=\"4\"><input id=\"ip_addr\" style=\"width:100%;text-align:center\" type=\"text\" value=\"\r\n"
+ String(myIP[0],DEC)+'.'+String(myIP[1],DEC)+'.'+String(myIP[2],DEC)+'.'+String(myIP[3],DEC)+"\"></td>\r\n"
"</tr>\r\n"
"<tr><td class='comment' colspan='4'><br>Bounds:</td></tr>\r\n"
"<tr id='XY'></tr>\r\n"
"<tr id='WH'></tr>\r\n"
"</table>\r\n"
"<div id='RB'></div>\r\n"
"</td>\r\n"
"<td class='content_body'>\r\n"
"<span class='title'>Original image</span><br>\r\n"
"<canvas id='source' class='hidden_input'></canvas>\r\n"
"<div id='srcBox'>\r\n"
"<div class='imgBox'>\r\n"
"<div class='mesBox'>Drop image here...</div>\r\n"
"</div>\r\n"
"</div>\r\n"
"</td>\r\n"
"</tr>\r\n"
"<tr>\r\n"
"<td id='dstBox' class='content_body'>\r\n"
"</td>\r\n"
"</tr>\r\n"
"</table>\r\n"
"</div>\r\n"
"</div>\r\n"
"<div class='footer_back'>\r\n"
"<div class='footer_face' id='logTag'>\r\n"
"</div>\r\n"
"</div>\r\n"
"</body>\r\n"
"</html>\r\n");
}

@ -0,0 +1,509 @@
/**
******************************************************************************
* @file scripts.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief This file describes the sending of JavaScript codes to a client
*
******************************************************************************
*/
void sendJS_A(WiFiClient client)
{
client.println(
"var srcBox,srcImg,dstImg;\r\n"
"var epdArr,epdInd,palArr;\r\n"
"var curPal;\r\n"
"function getElm(n){return document.getElementById(n);}\r\n"
"function setInn(n,i){ document.getElementById(n).innerHTML=i;}\r\n"
"function processFiles(files){\r\n"
"var file=files[0];\r\n"
"var reader=new FileReader();\r\n"
"srcImg=new Image();\r\n"
"reader.onload=function(e){\r\n"
"setInn('srcBox','<img id=\"imgView\" class=\"sourceImage\">');\r\n"
"var img=getElm('imgView');\r\n"
"img.src=e.target.result;\r\n"
"srcImg.src=e.target.result;\r\n"
"};\r\n"
"reader.readAsDataURL(file);\r\n"
"}\r\n"
//-------------------------------------------
"function drop(e){\r\n"
"e.stopPropagation();\r\n"
"e.preventDefault();\r\n"
"var files=e.dataTransfer.files;\r\n"
"processFiles(files);\r\n"
"}\r\n"
//-------------------------------------------
"function ignoreDrag(e){\r\n"
"e.stopPropagation();\r\n"
"e.preventDefault();\r\n"
"}\r\n"
//-------------------------------------------
"function getNud(nm,vl){\r\n"
"return '<td class=\"comment\">'+nm+':</td>'+\r\n"
"'<td><input id=\"nud_'+nm+'\" class=\"nud\"type=\"number\" value=\"'+vl+'\"/></td>';\r\n"
"}\r\n"
//-------------------------------------------
"function Btn(nm,tx,fn){\r\n"
"return '<div><label class=\"menu_button\" for=\"_'+nm+'\">'+tx+'</label>'+\r\n"
"'<input class=\"hidden_input\" id=\"_'+nm+'\" type=\"'+\r\n"
"(nm==0?'file\" onchange=\"':'button\" onclick=\"')+fn+'\"/></div>';\r\n"
"}\r\n"
//-------------------------------------------
"function RB(vl,tx){\r\n"
"return '<input type=\"radio\" name=\"kind\" value=\"m'+vl+\r\n"
"'\" onclick=\"rbClick('+vl+');\"'+(vl==0?'checked=\"true\"':'')+'/>'+tx;\r\n"
"}\r\n"
//-------------------------------------------
"window.onload = function(){\r\n"
"srcBox = getElm('srcBox');\r\n"
"srcBox.ondragenter=ignoreDrag;\r\n"
"srcBox.ondragover=ignoreDrag;\r\n"
"srcBox.ondrop=drop;\r\n"
"srcImg=0;\r\n"
"epdInd=0;\r\n"
"palArr=[[[0,0,0],[255,255,255]],\r\n"
"[[0,0,0],[255,255,255],[127,0,0]],\r\n"
"[[0,0,0],[255,255,255],[127,127,127]],\r\n"
"[[0,0,0],[255,255,255],[127,127,127],[127,0,0]],\r\n"
"[[0,0,0],[255,255,255]],\r\n"
"[[0,0,0],[255,255,255],[220,180,0]],\r\n"
"[[0,0,0]],\r\n"
"[[0,0,0],[255,255,255],[0,255,0],[0,0,255],[255,0,0],[255,255,0],[255,128,0]]];\r\n"//5.65f 7-color E-Paper
"epdArr=[[200,200,0],[200,200,3],[152,152,5],\r\n"
"[122,250,0],[104,212,1],[104,212,5],[104,212,0],\r\n"
"[176,264,0],[176,264,1],\r\n"
"[128,296,0],[128,296,1],[128,296,5],[128,296,0],\r\n"
"[400,300,0],[400,300,1],[400,300,5],\r\n"
"[600,448,0],[600,448,1],[600,448,5],\r\n"
"[640,384,0],[640,384,1],[640,384,5],\r\n"
"[800,480,0],[800,480,1],[880,528,1],\r\n"
"[600,448,7],[880,528,0],[280,480,0],\r\n"
"[152,296,0],[648,480,1],[128,296,1],\r\n"
"[200,200,1],[104,214,1],[128,296,0],\r\n"
"[400,300,1],[152,296,1],[648,480,0],\r\n"
"[640,400,7],[176,264,1],[122,250,0],\r\n"
"[122,250,1],[240,360,0],[176,264,0]];\r\n"
"setInn('BT',\r\n"
"Btn(0,'Select image file','processFiles(this.files);')+\r\n"
"Btn(1,'Level: mono','procImg(true,false);')+\r\n"
"Btn(2,'Level: color','procImg(true,true);')+\r\n"
"Btn(3,'Dithering: mono','procImg(false,false);')+\r\n"
"Btn(4,'Dithering: color','procImg(false,true);')+\r\n"
"Btn(5,'Upload image','uploadImage();'));\r\n"
"setInn('XY',getNud('x','0')+getNud('y','0'));\r\n"
"setInn('WH',getNud('w','200')+getNud('h','200'));\r\n"
"setInn('RB',RB(0,'1.54&ensp;')+RB(1,'1.54b')+RB(2,'1.54c&ensp;<br>')+\r\n"
"RB(3,'2.13&ensp;')+RB(4,'2.13b')+RB(5,'2.13c<br>')+\r\n"
"RB(6,'2.13d')+RB(7,'2.7&ensp;&ensp;')+RB(8,'2.7b&ensp;<br>')+\r\n"
"RB(9,'2.9&ensp;&ensp;')+RB(10,'2.9b&ensp;')+RB(11,'2.9c&ensp;<br>')+\r\n"
"RB(12,'2.9d&ensp;')+RB(13,'4.2&ensp;&ensp;')+RB(14,'4.2b&ensp;<br>')+\r\n"
"RB(15,'4.2c&ensp;')+RB(16,'5.83&ensp;')+RB(17,'5.83b<br>')+\r\n"
"RB(18,'5.83c&ensp;')+RB(19,'7.5&ensp;&ensp;')+RB(20,'7.5b&ensp;<br>')+\r\n"
"RB(21,'7.5c')+RB(22,'7.5 V2')+RB(23,'7.5b V2<br>')+\r\n"
"RB(24,'7.5b HD&ensp;')+RB(25,'5.65f<br>')+\r\n"
"RB(26,'7.5 HD&ensp;')+RB(27,'3.7&ensp;')+RB(28,'2.66<br>')+\r\n"
"RB(29,'5.83b V2&ensp;')+RB(30,'2.9b V3<br>')+\r\n"
"RB(31,'1.54b V2&ensp;')+RB(32,'2.13b V3<br>')+\r\n"
"RB(33,'2.9 V2&ensp;')+RB(34,'4.2b V2<br>')+\r\n"
"RB(35,'2.66b&ensp;')+RB(36,'5.83 V2<br>')+\r\n"
"RB(37,'4.01 f&ensp;')+RB(38,'2.7b V2<br>')+\r\n"
"RB(39,'2.13 V3&ensp;')+RB(40,'2.13 B V4<br>')+\r\n"
"RB(41,'3.52&ensp;')+RB(42,'2.7 V2'));\r\n"
"}\r\n"
//-------------------------------------------
"function rbClick(index){\r\n"
"getElm('nud_w').value=""+epdArr[index][0];\r\n"
"getElm('nud_h').value=""+epdArr[index][1];\r\n"
"epdInd=index;\r\n"
"}\r\n");
}
void sendJS_B(WiFiClient client)
{
client.println(
"var source;\r\n"
"var dX, dY, dW, dH, sW, sH;\r\n"
//-------------------------------------------
"function getVal(p, i){\r\n"
"if((p.data[i]==0x00) && (p.data[i+1]==0x00))return 0;\r\n"
"if((p.data[i]==0xFF) && (p.data[i+1]==0xFF))return 1;\r\n"
"if((p.data[i]==0x7F) && (p.data[i+1]==0x7F))return 2;\r\n"
"return 3;\r\n"
"}\r\n"
//-------------------------------------------
"function getVal_7color(p, i) {\r\n"//for 5.65f E-Paper
"if((p.data[i]==0x00) && (p.data[i+1]==0x00) && (p.data[i+2]==0x00))return 0;\r\n"
"if((p.data[i]==0xFF) && (p.data[i+1]==0xFF) && (p.data[i+2]==0xFF))return 1;\r\n"
"if((p.data[i]==0x00) && (p.data[i+1]==0xFF) && (p.data[i+2]==0x00))return 2;\r\n"
"if((p.data[i]==0x00) && (p.data[i+1]==0x00) && (p.data[i+2]==0xFF))return 3;\r\n"
"if((p.data[i]==0xFF) && (p.data[i+1]==0x00) && (p.data[i+2]==0x00))return 4;\r\n"
"if((p.data[i]==0xFF) && (p.data[i+1]==0xFF) && (p.data[i+2]==0x00))return 5;\r\n"
"if((p.data[i]==0xFF) && (p.data[i+1]==0x80) && (p.data[i+2]==0x00))return 6;\r\n"
"return 7;\r\n"
"}\r\n"
//-------------------------------------------
"function setVal(p,i,c){\r\n"
"p.data[i]=curPal[c][0];\r\n"
"p.data[i+1]=curPal[c][1];\r\n"
"p.data[i+2]=curPal[c][2];\r\n"
"p.data[i+3]=255;\r\n"
"}\r\n"
//-------------------------------------------
"function addVal(c,r,g,b,k){\r\n"
"return[c[0]+(r*k)/32,c[1]+(g*k)/32,c[2]+(b*k)/32];\r\n"
"}\r\n"
//-------------------------------------------
"function getErr(r,g,b,stdCol){\r\n"
"r-=stdCol[0];\r\n"
"g-=stdCol[1];\r\n"
"b-=stdCol[2];\r\n"
"return r*r + g*g + b*b;\r\n"
"}\r\n"
//-------------------------------------------
"function getNear(r,g,b){\r\n"
"var ind=0;\r\n"
"var err=getErr(r,g,b,curPal[0]);\r\n"
"for (var i=1;i<curPal.length;i++)\r\n"
"{\r\n"
"var cur=getErr(r,g,b,curPal[i]);\r\n"
"if (cur<err){err=cur;ind=i;}\r\n"
"}\r\n"
"return ind;\r\n"
"}\r\n");
}
void sendJS_C(WiFiClient client)
{
client.println(
"function procImg(isLvl,isRed){\r\n"
"if (document.getElementsByClassName('sourceImage').length == 0){\r\n"
"alert('First select image');\r\n"
"return;\r\n"
"}\r\n"
"var palInd=epdArr[epdInd][2];\r\n"
"if (isRed&&((palInd&1)==0)){\r\n"
"alert('This white-black display');\r\n"
"return;\r\n"
"}\r\n"
"if (!isRed)palInd=palInd&0xFE;\r\n"
"curPal=palArr[palInd];\r\n"
"getElm('dstBox').innerHTML=\r\n"
"'<span class=\"title\">Processed image</span><br><canvas id=\"canvas\"></canvas>';\r\n"
"var canvas=getElm('canvas');\r\n"
"sW=srcImg.width;\r\n"
"sH=srcImg.height;\r\n"
"source=getElm('source');\r\n"
"source.width=sW;\r\n"
"source.height=sH;\r\n"
"source.getContext('2d').drawImage(srcImg,0,0,sW,sH);\r\n"
"dX=parseInt(getElm('nud_x').value);\r\n"
"dY=parseInt(getElm('nud_y').value);\r\n"
"dW=parseInt(getElm('nud_w').value);\r\n"
"dH=parseInt(getElm('nud_h').value);\r\n"
"if((dW<3)||(dH<3)){\r\n"
"alert('Image is too small');\r\n"
"return;\r\n"
"}\r\n"
"canvas.width=dW;\r\n"
"canvas.height=dH;\r\n"
"var index=0;\r\n"
"var pSrc=source.getContext('2d').getImageData(0,0,sW,sH);\r\n"
"var pDst=canvas.getContext('2d').getImageData(0,0,dW,dH);\r\n"
"if(isLvl){\r\n"
"for (var j=0;j<dH;j++){\r\n"
"var y=dY+j;\r\n"
"if ((y<0)||(y>=sH)){\r\n"
"for (var i=0;i<dW;i++,index+=4) setVal(pDst,index,(i+j)%2==0?1:0);\r\n"
"continue;\r\n"
"}\r\n"
"for (var i=0;i<dW;i++){\r\n"
"var x=dX+i;\r\n"
"if ((x<0)||(x>=sW)){\r\n"
"setVal(pDst,index,(i+j)%2==0?1:0);\r\n"
"index+=4;\r\n"
"continue;\r\n"
"}\r\n"
"var pos=(y*sW+x)*4;\r\n"
"setVal(pDst,index,getNear(pSrc.data[pos],pSrc.data[pos+1],pSrc.data[pos+2]));\r\n"
"index+=4;\r\n"
"}\r\n"
"}\r\n"
"}else{\r\n"
"var aInd=0;\r\n"
"var bInd=1;\r\n"
"var errArr=new Array(2);\r\n"
"errArr[0]=new Array(dW);\r\n"
"errArr[1]=new Array(dW);\r\n"
"for (var i=0;i<dW;i++)\r\n"
"errArr[bInd][i]=[0,0,0];\r\n"
"for (var j=0;j<dH;j++){\r\n"
"var y=dY+j;\r\n"
"if ((y<0)||(y>=sH)){\r\n"
"for (var i=0;i<dW;i++,index+=4)setVal(pDst,index,(i+j)%2==0?1:0);\r\n"
"continue;\r\n"
"}\r\n"
"aInd=((bInd=aInd)+1)&1;\r\n"
"for (var i=0;i<dW;i++)errArr[bInd][i]=[0,0,0];\r\n"
"for (var i=0;i<dW;i++){\r\n"
"var x=dX+i;\r\n"
"if ((x<0)||(x>=sW)){\r\n"
"setVal(pDst,index,(i+j)%2==0?1:0);\r\n"
"index+=4;\r\n"
"continue;\r\n"
"}\r\n"
"var pos=(y*sW+x)*4;\r\n"
"var old=errArr[aInd][i];\r\n"
"var r=pSrc.data[pos ]+old[0];\r\n"
"var g=pSrc.data[pos+1]+old[1];\r\n"
"var b=pSrc.data[pos+2]+old[2];\r\n"
"var colVal = curPal[getNear(r,g,b)];\r\n"
"pDst.data[index++]=colVal[0];\r\n"
"pDst.data[index++]=colVal[1];\r\n"
"pDst.data[index++]=colVal[2];\r\n"
"pDst.data[index++]=255;\r\n"
"r=(r-colVal[0]);\r\n"
"g=(g-colVal[1]);\r\n"
"b=(b-colVal[2]);\r\n"
"if (i==0){\r\n"
"errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,7.0);\r\n"
"errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,2.0);\r\n"
"errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n"
"}else if (i==dW-1){\r\n"
"errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,7.0);\r\n"
"errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,9.0);\r\n"
"}else{\r\n"
"errArr[bInd][i-1]=addVal(errArr[bInd][i-1],r,g,b,3.0);\r\n"
"errArr[bInd][i ]=addVal(errArr[bInd][i ],r,g,b,5.0);\r\n"
"errArr[bInd][i+1]=addVal(errArr[bInd][i+1],r,g,b,1.0);\r\n"
"errArr[aInd][i+1]=addVal(errArr[aInd][i+1],r,g,b,7.0);\r\n"
"}\r\n"
"}\r\n"
"}\r\n"
"}\r\n"
"canvas.getContext('2d').putImageData(pDst,0,0);\r\n"
"}\r\n");
}
void sendJS_D(WiFiClient client)
{
client.println(
"var pxInd,stInd;\r\n"
"var dispW,dispH;\r\n"
"var xhReq,dispX;\r\n"
"var rqPrf,rqMsg;\r\n"
"function byteToStr(v){return String.fromCharCode((v & 0xF) + 97, ((v >> 4) & 0xF) + 97);}\r\n"
"function wordToStr(v){return byteToStr(v&0xFF) + byteToStr((v>>8)&0xFF);}\r\n"
"function u_send(cmd,next)\r\n"
"{\r\n"
"xhReq.open('POST',rqPrf+cmd, true);\r\n"
"xhReq.send('');\r\n"
"if(next)stInd++;\r\n"
"return 0;\r\n"
"}\r\n"
"function u_next()\r\n"
"{\r\n"
"lnInd=0;\r\n"
"pxInd=0;\r\n"
"u_send('NEXT_',true);\r\n"
"}\r\n"
"function u_done()\r\n"
"{\r\n"
"setInn('logTag','Complete!');\r\n"
"return u_send('SHOW_',true);\r\n"
"}\r\n"
"function u_show(a,k1,k2)"
"{"
"var x=''+(k1+k2*pxInd/a.length);"
"if(x.length>5)x=x.substring(0,5);"
"setInn('logTag','Progress: '+x+'%');"
"return u_send(rqMsg+wordToStr(rqMsg.length)+'LOAD_',pxInd>=a.length);"
"}\r\n"
"function u_data(a,c,k1,k2)\r\n"
"{\r\n"
"rqMsg='';\r\n"
"if(c==-1)\r\n"
"{\r\n"
"while((pxInd<a.length)&&(rqMsg.length<1000))\r\n"
"{\r\n"
"var v=0;\r\n"
"for (var i=0;i<16;i+=2)if(pxInd<a.length)v|=(a[pxInd++]<<i);\r\n"
"rqMsg += wordToStr(v);\r\n"
"}\r\n"
"}\r\n"
"else if(c==-2)\r\n"
"{\r\n"
"while((pxInd<a.length)&&(rqMsg.length<1000))\r\n"
"{\r\n"
"var v=0;\r\n"
"for (var i=0;i<16;i+=4)if(pxInd<a.length)v|=(a[pxInd++]<<i);\r\n"
"rqMsg += wordToStr(v);\r\n"
"}\r\n"
"}\r\n"
"else\r\n"
"{\r\n"
"while((pxInd<a.length)&&(rqMsg.length<1000))\r\n"
"{\r\n"
"var v=0;\r\n"
"for (var i=0;i<8;i++) if((pxInd<a.length)&&(a[pxInd++]!=c))v|=(128>>i);\r\n"
"rqMsg += byteToStr(v);\r\n"
"}\r\n"
"}\r\n"
"return u_show(a,k1,k2);"
"}\r\n"
"function u_line(a,c,k1,k2)\r\n"
"{\r\n"
"var x;\r\n"
"rqMsg='';\r\n"
"while(rqMsg.length<1000)\r\n"
"{\r\n"
"x=0;\r\n"
"while(x<122)\r\n"
"{\r\n"
"var v=0;\r\n"
"for (var i=0;(i<8)&&(x<122);i++,x++) if(a[pxInd++]!=c)v|=(128>>i);\r\n"
"rqMsg += byteToStr(v);\r\n"
"}\r\n"
"}\r\n"
"return u_show(a,k1,k2);"
"}\r\n"
"function uploadImage()\r\n"
"{\r\n"
"var c=getElm('canvas');\r\n"
"var w=dispW=c.width;\r\n"
"var h=dispH=c.height;\r\n"
"var p=c.getContext('2d').getImageData(0,0,w,h);\r\n"
"var a=new Array(w*h);\r\n"
"var i=0;\r\n"
"for(var y=0;y<h;y++)for(var x=0;x<w;x++,i++) {\r\n"
"if(epdInd==25 || epdInd==37)\r\n"
"a[i]=getVal_7color(p,i<<2);\r\n"
"else\r\n"
"a[i]=getVal(p,i<<2);\r\n"
"}\r\n"
"dispX=0;\r\n"
"pxInd=0;\r\n"
"stInd=0;\r\n"
"xhReq=new XMLHttpRequest();\r\n"
"rqPrf='http://'+getElm('ip_addr').value+'/';\r\n"
"if ((epdInd==3) || (epdInd==39))\r\n" //2.13
"{\r\n"
"xhReq.onload=xhReq.onerror = function()\r\n"
"{\r\n"
"if(stInd==0)return u_line(a,0,0,100);\r\n"
"if(stInd==1)return u_done();\r\n"
"};\r\n"
"if(epdInd>25)\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+-26+65)+'_',false);\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"if ((epdInd==40))\r\n" //2.13 B V4
"{\r\n"
"xhReq.onload=xhReq.onerror = function()\r\n"
"{\r\n"
"if(stInd==0)return u_line(a,0,0,50);\r\n"
"if(stInd==1)return u_next();\r\n"
"if(stInd==2)return u_line(a,3,50,50);\r\n"
"if(stInd==3)return u_done();\r\n"
"};\r\n"
"if(epdInd>25)\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+-26+65)+'_',false);\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"if ((epdInd==0)||(epdInd==3)||(epdInd==6)||(epdInd==7)||(epdInd==9)||(epdInd==12)||\
(epdInd==16)||(epdInd==19)||(epdInd==22)||(epdInd==26)||(epdInd==27)||(epdInd==28))\r\n"
"{\r\n"
"xhReq.onload=xhReq.onerror=function()\r\n"
"{\r\n"
"if(stInd==0)return u_data(a,0,0,100);\r\n"
"if(stInd==1)return u_done();\r\n"
"};\r\n"
"if(epdInd>25)\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+-26+65)+'_',false);\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"if (epdInd>15 && epdInd < 22)\r\n"
"{\r\n"
"xhReq.onload=xhReq.onerror=function()\r\n"
"{\r\n"
"if(stInd==0)return u_data(a,-1,0,100);\r\n"
"if(stInd==1)return u_done();\r\n"
"};\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"if (epdInd == 25 || epdInd == 37)\r\n" // 7 colors
"{\r\n"
"xhReq.onload=xhReq.onerror=function()\r\n"
"{\r\n"
"if(stInd==0)return u_data(a,-2,0,100);\r\n"
"if(stInd==1)return u_done();\r\n"
"};\r\n"
"if(epdInd>25)\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+-26+65)+'_',false);\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"else\r\n"
"{\r\n"
"xhReq.onload=xhReq.onerror=function()\r\n"
"{\r\n"
"console.log('*************');\r\n"
"console.log(stInd);\r\n"
"console.log('*************');\r\n"
"if(stInd==0&&epdInd==23)return u_data(a,0,0,100);\r\n"
"if(stInd==0)return u_data(a,((epdInd==1)||(epdInd==12))?-1:0,0,50);\r\n"
"if(stInd==1)return u_next();\r\n"
"if(stInd==2)return u_data(a,3,50,50);\r\n"
"if(stInd==3)return u_done();\r\n"
"};\r\n"
"if(epdInd>25)\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+-26+65)+'_',false);\r\n"
"return u_send('EPD'+String.fromCharCode(epdInd+97)+'_',false);\r\n"
"}\r\n"
"}\r\n\r\n");
}

@ -0,0 +1,279 @@
/**
******************************************************************************
* @file srvr.h
* @author Waveshare Team
* @version V1.0.0
* @date 23-January-2018
* @brief ESP8266 WiFi server.
* This file provides firmware functions:
* + Sending web page of the tool to a client's browser
* + Uploading images from client part by part
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
//#include <ESP8266WiFi.h>// ESP8266 and WiFi classes
#include <WiFi.h>
#include "buff.h" // POST request data accumulator
#include "epd.h" // e-Paper driver
#include "scripts.h" // JavaScript code
#include "css.h" // Cascading Style Sheets
#include "html.h" // HTML page of the tool
/* SSID and password of your WiFi net ----------------------------------------*/
const char *ssid = "Team:Chaos"; //"your ssid";
const char *password = "professional!lasertag!victory"; //"your password";
/* Static IP address Settings ------------------------------------------------*/
IPAddress staticIP(192, 168, 178, 200);
IPAddress gateway(192, 168, 178, 255);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 178, 1);
/* Server and IP address ------------------------------------------------------*/
WiFiServer server(80); // Wifi server exemplar using port 80
IPAddress myIP; // IP address in your local wifi net
/* The 'index' page flag ------------------------------------------------------*/
bool isIndexPage = true; // true : GET request, client needs 'index' page;
// false: POST request, server sends empty page.
/* Server initialization -------------------------------------------------------*/
void Srvr__setup()
{
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
if (WiFi.config(staticIP, gateway, subnet, dns, dns) == false) {
Serial.println("Configuration failed.");
}
// Applying SSID and password
WiFi.begin(ssid, password);
// Waiting the connection to a router
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Connection is complete
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Show obtained IP address in local Wifi net
Serial.println(myIP = WiFi.localIP());
}
/* Sending a script to the client's browser ------------------------------------*/
bool Srvr__file(WiFiClient client, int fileIndex, char *fileName)
{
// Print log message: sending of script file
Serial.print(fileName);
// Sent to the 'client' the header describing the type of data.
client.print(fileIndex == 0
? "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\n\r\n"
: "HTTP/1.1 200 OK\r\nContent-Type: text/javascript\r\n\r\n");
// Choose the index of script
// (ESP8266 can't to send all of code by one file
// and needs split it on a few parts)
switch (fileIndex) {
case 0:
sendCSS(client);
break;
case 1:
sendJS_A(client);
break;
case 2:
sendJS_B(client);
break;
case 3:
sendJS_C(client);
break;
case 4:
sendJS_D(client);
break;
}
client.print("\r\n");
delay(1);
// Print log message: the end of request processing
Serial.println(">>>");
return true;
}
/* The server state observation loop -------------------------------------------*/
bool Srvr__loop()
{
// Looking for a client trying to connect to the server
WiFiClient client = server.available();
int16_t label = 0;
int16_t fale = 1000;
// Exit if there is no any clients
if (!client)
return false;
// Print log message: the start of request processing
Serial.print("<<<");
// Waiting the client is ready to send data
while (!client.available())
{
delay(1);
label++;
if(label > fale)
{
label = fale + 1;
if(!server.available())
return false;
}
}
// Set buffer's index to zero
// It means the buffer is empty initially
Buff__bufInd = 0;
// While the stream of 'client' has some data do...
while (client.available()) {
// Read a character from 'client'
int q = client.read();
// Save it in the buffer and increment its index
Buff__bufArr[Buff__bufInd++] = (byte)q;
// If the carachter means the end of line, then...
if ((q == 10) || (q == 13)) {
// Clean the buffer
Buff__bufInd = 0;
continue;
}
// Requests of files
if (Buff__bufInd >= 11) {
if (Buff__signature(Buff__bufInd - 11, "/styles.css"))
return Srvr__file(client, 0, "styles.css");
if (Buff__signature(Buff__bufInd - 11, "/scriptA.js"))
return Srvr__file(client, 1, "scriptA.js");
if (Buff__signature(Buff__bufInd - 11, "/scriptB.js"))
return Srvr__file(client, 2, "scriptB.js");
if (Buff__signature(Buff__bufInd - 11, "/scriptC.js"))
return Srvr__file(client, 3, "scriptC.js");
if (Buff__signature(Buff__bufInd - 11, "/scriptD.js"))
return Srvr__file(client, 4, "scriptD.js");
}
// If the buffer's length is larger, than 4 (length of command's name), then...
if (Buff__bufInd > 4) {
// It is probably POST request, no need to send the 'index' page
isIndexPage = false;
// e-Paper driver initialization
if (Buff__signature(Buff__bufInd - 4, "EPD")) {
Serial.print("\r\nEPD\r\n");
// Getting of e-Paper's type
EPD_dispIndex = (int)Buff__bufArr[Buff__bufInd - 1] - (int)'a';
if(EPD_dispIndex < 0)
EPD_dispIndex = (int)Buff__bufArr[Buff__bufInd - 1] - (int)'A' + 26;
// Print log message: initialization of e-Paper (e-Paper's type)
Serial.printf("EPD %s", EPD_dispMass[EPD_dispIndex].title);
// Initialization
EPD_dispInit();
//client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
break;
}
// Image loading
if (Buff__signature(Buff__bufInd - 4, "LOAD")) {
// Print log message: image loading
Serial.print("LOAD");
// Load data into the e-Paper
// if there is loading function for current channel (black or red)
if (EPD_dispLoad != 0)
EPD_dispLoad();
//client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
break;
}
// Select the next data channel
if (Buff__signature(Buff__bufInd - 4, "NEXT")) {
// Print log message: next data channel
Serial.print("NEXT");
// Instruction code for for writting data into
// e-Paper's memory
int code = EPD_dispMass[EPD_dispIndex].next;
// If the instruction code isn't '-1', then...
if (code != -1) {
// Print log message: instruction code
Serial.printf(" %d", code);
// Do the selection of the next data channel
EPD_SendCommand(code);
delay(2);
}
// Setup the function for loading choosen channel's data
EPD_dispLoad = EPD_dispMass[EPD_dispIndex].chRd;
//client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
break;
}
// If the loading is complete, then...
if (Buff__signature(Buff__bufInd - 4, "SHOW")) {
// Show results and Sleep
EPD_dispMass[EPD_dispIndex].show();
//Print log message: show
Serial.print("\r\nSHOW");
//client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
break;
}
// If the routine reaches this code,
// it means the there is no known commands,
// the server has to send the 'index' page
isIndexPage = true;
}
}
// Clear data stream of the 'client'
client.flush();
// Sent to the 'client' the header describing the type of data.
// In this case 'Content-Type' is 'text/html'
client.print("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
// Send the 'index' page if it's needed
if (isIndexPage)
sendHtml(client, myIP);
else
client.print("Ok!");
client.print("\r\n");
delay(1);
// Print log message: the end of request processing
Serial.println(">>>");
return true;
}

@ -0,0 +1,23 @@
2020-08-05: 新添加5.65inch F e-paper 例程
2020-08-05新添加7.5inch HD e-Paper 例程
2020-08-12新添加3.7inch e-Paper 例程
2020-08-12新添加2.66inch e-Paper 例程
2020-09-03新添加5.83inch B V2 e-Paper例程
2020-09-03新添加2.9inch B V2 e-Paper例程
2020-09-04新添加1.54inch B V2 e-Paper例程
2020-09-04新添加2.13inch B V3 e-Paper例程
2020-11-23更新1.54inch V2 e-Paper例程
2020-11-27补充4.2inch B V2 e-Paper例程
2020-12-01更新7.5inch B V2 e-Paper例程
2020-12-03新添加2.66inch B V2 e-Paper例程
2002-12-032.9inch B V2 e-Paper 改名为 2.9inch B V3 e-Paper
2020-12-11新添加2.9inch V2 e-Paper例程
2020-12-16新添加5.83inch V2 e-Paper例程
2020-12-29新添加4.01inch F e-Paper例程
2021-03-19新添加2.7inch B V2 e-Paper例程
2021-07-29更新7.5inch V2 e-Paper例程
2021-10-28实现 1.54V2 新老版本的兼容
2021-11-03添加新程序2.13inch V3 e-Paper例程。
2022-04-26添加新程序2.13inch B V4 e-Paper例程。
2022-11-05添加新程序2.7inch V2 e-Paper例程。
2022-11-05添加新程序3.52inch e-Paper例程。

@ -0,0 +1,23 @@
2020-08-05: New 5.65inch F e-paper routine added
2020-08-05: New 7.5inch HD e-Paper routine added
2020-08-12: New 3.7inch e-Paper routine added
2020-08-12: New 2.66inch e-Paper routine added
2020-09-03: New 5.83inch B V2 e-Paper routine added
2020-09-03: New 2.9inch B V2 e-Paper routine added
2020-09-04: New 1.54inch B V2 e-Paper routine added
2020-09-04: New 2.13inch B V3 e-Paper routine added
2020-11-23: Updata 1.54inch V2 e-Paper routine.
2020-11-27: Added 4.2inch B V2 e-paper routine.
2020-12-01: Updata 7.5inch B V2 e-Paper routine.
2020-12-03: New 2.66inch B e-Paper routine.
2020-12-03: 2.9inch B V2 e-Paper was renamed 2.9inch B V3 e-Paper.
2020-12-11: New 2.9inch V2 e-Paper routine added.
2020-12-16: New 5.83inch V2 e-Paper routine added.
2020-12-29: New 4.01inch F e-Paper routine added.
2021-03-19: New 2.7inch B V2 e-Paper routine added.
2021-07-29: Updata 7.5inch V2 e-Paper routine added.
2021-10-28: Realize the compatibility of old and new versions of 1.54V2
2021-11-03: Added new program 2.13-inch V3 e-paper routine.
2022-04-26: Added new program 2.13-inch B V4 e-paper routine.
2022-11-05: Added new program 2.7-inch V2 e-paper routine.
2022-11-05: Added new program 3.52-inch e-paper routine.

@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,122 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" withSubpackages="false" static="false" />
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
<package name="io.ktor" withSubpackages="true" static="false" />
</value>
</option>
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/app_start_activity.xml" value="0.5411458333333333" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/displays_activity.xml" value="0.33" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/displays_list_item.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/open_file_activity.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/palettes_activity.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/scanning_activity.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/scanning_list_item.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/scanning_ring.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/test_activity.xml" value="0.30052083333333335" />
<entry key="..\:/android/ePape_Esp32_Loader_APP/app/src/main/res/layout/upload_activity.xml" value="0.30052083333333335" />
<entry key="..\:/project/E-Paper_ESP32_Driver_Board_Code/ePape_Esp32_Loader_APP/app/src/main/res/layout/displays_activity.xml" value="0.38333333333333336" />
<entry key="..\:/project/E-Paper_ESP32_Driver_Board_Code/ePape_Esp32_Loader_APP/app/src/main/res/layout/open_file_activity.xml" value="0.38333333333333336" />
<entry key="..\:/project/E-Paper_ESP32_Driver_Board_Code/ePape_Esp32_Loader_APP/app/src/main/res/layout/palettes_activity.xml" value="0.38333333333333336" />
<entry key="..\:/project/E-Paper_ESP32_Driver_Board_Code/ePape_Esp32_Loader_APP/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.34375" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/ePape_Esp32_Loader_APP.iml" filepath="$PROJECT_DIR$/ePape_Esp32_Loader_APP.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.iml" filepath="$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.androidTest.iml" filepath="$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.androidTest.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.main.iml" filepath="$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.unitTest.iml" filepath="$PROJECT_DIR$/.idea/modules/app/ePape_Esp32_Loader_APP.app.unitTest.iml" />
</modules>
</component>
</project>

@ -0,0 +1,48 @@
apply plugin: 'com.android.application'
// support-annotations
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}
android {
signingConfigs {
/* config {
keyAlias 'waveshare'
keyPassword 'waveshare0755'
storeFile file('C:/Users/chenruiwen/Desktop/ePaperEsp32Loader/e-Paper.jks')
storePassword 'waveshare0755'
}
*/
}
compileSdkVersion 26
defaultConfig {
applicationId "com.waveshare.epaperesp32loader"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.waveshare.epaperesp32loader",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
]
}

@ -0,0 +1,26 @@
package com.waveshare.epaperesp32loader;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.waveshare.epaperesp32loader", appContext.getPackageName());
}
}

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.waveshare.epaperesp32loader">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".AppStartActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ScanningActivity" android:screenOrientation="portrait"/>
<activity android:name=".OpenFileActivity" android:screenOrientation="portrait"/>
<activity android:name=".DisplaysActivity" android:screenOrientation="portrait"/>
<activity android:name=".FilteringActivity" android:screenOrientation="portrait"/>
<activity android:name=".UploadActivity" android:screenOrientation="portrait"/>
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"/>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.STATUS_BAR" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
</manifest>

@ -0,0 +1,326 @@
package com.waveshare.epaperesp32loader;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
//import android.icu.text.StringPrepParseException;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.theartofdev.edmodo.cropper.CropImage;
import com.theartofdev.edmodo.cropper.CropImageView;
import com.waveshare.epaperesp32loader.communication.PermissionHelper;
import com.waveshare.epaperesp32loader.image_processing.EPaperDisplay;
/*
* <h1>Main activity</h1>
* The main activity. It leads the steps of e-Paper image uploading:
* 1. Open Wi-fi or Bluetooth adapter
* 2. Select the image file
* 3. Select the type of the display
* 4. Select the method of pixel format converting
* 5. Start uploading
*
* @author Waveshare team
* @version 1.0
* @since 8/16/2018
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class AppStartActivity extends AppCompatActivity
{
// Request codes
//-----------------------------
public static final int REQ_BLUETOOTH_CONNECTION = 2;
public static final int REQ_OPEN_FILE = 3;
public static final int REQ_DISPLAY_SELECTION = 4;
public static final int REQ_PALETTE_SELECTION = 5;
public static final int REQ_UPLOADING = 6;
// Image file name and path
//-----------------------------
public static String fileName;
public static String filePath;
// Views
//-----------------------------
public TextView textBlue;
public TextView textLoad;
public TextView textDisp;
public TextView textFilt;
public TextView textSend;
// public TextView textAddr;
public Button button_file;
public ImageView pictFile; // View of loaded image
public ImageView pictFilt; // View of filtered image
Log log ;
// Data
//-----------------------------
public static Bitmap originalImage; // Loaded image with original pixel format
public static Bitmap indTableImage; // Filtered image with indexed colors
// Device
//-----------------------------
public static BluetoothDevice btDevice;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.app_start_activity);
// Image file name (null by default)
//-----------------------------------------------------
fileName = null;
// Image file path (external storage root by default)
//-----------------------------------------------------
filePath = Environment.getExternalStorageDirectory().getAbsolutePath();
// Views
//-----------------------------------------------------
textBlue = findViewById(R.id.text_blue);
textLoad = findViewById(R.id.text_file);
textDisp = findViewById(R.id.text_disp);
textFilt = findViewById(R.id.text_filt);
textSend = findViewById(R.id.text_send);
pictFile = findViewById(R.id.pict_file);
pictFilt = findViewById(R.id.pict_filt);
button_file = findViewById(R.id.Button_file);
// Data
//-----------------------------
originalImage = null;
indTableImage = null;
button_file.setEnabled(false);
}
public void onScan(View view)
{
// Open bluetooth devices scanning activity
//-----------------------------------------------------
startActivityForResult(
new Intent(this, ScanningActivity.class),
REQ_BLUETOOTH_CONNECTION);
}
public void onLoad(View view)
{
// Opening file browser in recently opened folder
//-----------------------------------------------------
/*
startActivityForResult(
new Intent(this, OpenFileActivity.class),
REQ_OPEN_FILE);
*/
CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setFixAspectRatio(true)
.setAspectRatio(EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].width, EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].height)
.start(this);
}
public void onDisplay(View view)
{
// Open display selection activity
//-----------------------------------------------------
startActivityForResult(
new Intent(this, DisplaysActivity.class),
REQ_DISPLAY_SELECTION);
}
public void onFilter(View view)
{
// Check if any image is loaded
//-----------------------------------------------------
if (originalImage == null) PermissionHelper.note(this, R.string.no_pict);
// Check if any display is selected
//-----------------------------------------------------
else if (EPaperDisplay.epdInd == -1) PermissionHelper.note(this, R.string.no_disp);
// Open palette selection activity
//-----------------------------------------------------
else startActivityForResult(
new Intent(this, FilteringActivity.class),
REQ_PALETTE_SELECTION);
}
public void onUpload(View view)
{
// Check if any devices is found
//-----------------------------------------------------
if (btDevice == null) PermissionHelper.note(this, R.string.no_blue);
// Check if any palette is selected
//-----------------------------------------------------
else if (indTableImage == null) PermissionHelper.note(this, R.string.no_filt);
// Open uploading activity
//-----------------------------------------------------
else startActivityForResult(
new Intent(this, UploadActivity.class),
REQ_UPLOADING);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
//-----------------------------------------------------
// Messages form ScanningActivity
//-----------------------------------------------------
if (requestCode == REQ_BLUETOOTH_CONNECTION)
{
// Bluetooth device was found and selected
//-------------------------------------------------
if (resultCode == RESULT_OK)
{
// Get selected bluetooth device
//---------------------------------------------
btDevice = data.getParcelableExtra("DEVICE");
// Show name and address of the device
//---------------------------------------------
textBlue.setText(btDevice.getName() + " (" + btDevice.getAddress() + ")");
}
}
//-----------------------------------------------------
// Message form open file activity
//-----------------------------------------------------
else if (requestCode == REQ_OPEN_FILE)
{
if (resultCode == RESULT_OK)
{
// Getting file name and file path
//---------------------------------------------
textLoad.setText(fileName);
try
{
// Loading of the selected file
//---------------------------------------------
InputStream is = new FileInputStream(filePath + "/" + fileName);
originalImage = (new BitmapDrawable(is)).getBitmap();
int pictSize = textLoad.getWidth();
pictFile.setMaxHeight(pictSize);
pictFile.setMinimumHeight(pictSize / 2);
pictFile.setImageBitmap(originalImage);
}
catch(Exception e)
{
textFilt.setText(R.string.failed_file);
}
}
}
//-----------------------------------------------------
// Message form display selection activity
//-----------------------------------------------------
else if (requestCode == REQ_DISPLAY_SELECTION)
{
if (resultCode == RESULT_OK) {
textDisp.setText(EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].title);
button_file.setEnabled(true);
}
}
//-----------------------------------------------------
// Message form palette selection activity
//-----------------------------------------------------
else if (requestCode == REQ_PALETTE_SELECTION)
{
if (resultCode == RESULT_OK)
{
textFilt.setText(data.getStringExtra("NAME"));
try
{
int size = textLoad.getWidth();
pictFilt.setMaxHeight(size);
pictFilt.setMinimumHeight(size / 2);
pictFilt.setImageBitmap(indTableImage);
}
catch(Exception e)
{
textFilt.setText(R.string.failed_filt);
}
}
}else if(requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE){
CropImage.ActivityResult result = CropImage.getActivityResult(data);
File temp = new File(Environment.getExternalStorageDirectory() .getAbsolutePath()+ "/Android/data/" + getPackageName()
+ "/" + System.currentTimeMillis() + ".png");
String lastBipmapName;
lastBipmapName=temp.getName();
//log.e(" "," " +lastBipmapName);
if (resultCode == RESULT_OK) {
Uri contentURI = result.getUri();
log.e(" ", " "+contentURI);
try {
bmp_raw = MediaStore.Images.Media.getBitmap(this.getContentResolver(), contentURI);
FileOutputStream fos = new FileOutputStream(temp);
bmp_raw.compress(Bitmap.CompressFormat.PNG, 30, fos);
fos.flush();
fos.close();
log.e("getHeight "," "+ bmp_raw.getHeight());
log.e("getWidth "," "+ bmp_raw.getWidth());
log.e("getHeight 1"," "+ EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].width);
log.e("getWidth 1"," "+ EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].height);
Matrix matrix = new Matrix();
bmp_raw = Bitmap.createScaledBitmap(bmp_raw, EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].width, EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].height, false);
originalImage = bmp_raw;
textLoad.setText(lastBipmapName);
int pictSize = bmp_raw.getWidth();
pictFile.setMaxHeight(pictSize);
pictFile.setMinimumHeight(pictSize / 2);
pictFile.setImageBitmap(bmp_raw);
} catch (IOException e) {
e.printStackTrace();
}
}
else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
//SetOrGetInfo.getInstance().setLastPicName(this,"lastBipmapName",lastBipmapName);
}
}
public Bitmap bmp_raw;
}

@ -0,0 +1,89 @@
package com.waveshare.epaperesp32loader;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.waveshare.epaperesp32loader.image_processing.EPaperDisplay;
/**
* <h1>Display activity</h1>
* The activity contains a list of available displays.
* User must select one of them.
*
* @author Waveshare team
* @version 1.0
* @since 8/16/2018
*/
public class DisplaysActivity extends AppCompatActivity implements AdapterView.OnItemClickListener
{
// View of displays list
//---------------------------------------------------------
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.displays_activity);
getSupportActionBar().setTitle(R.string.disp);
// ListView, its adapter and listener
//--------------------------------------
listView = findViewById(R.id.displays_list);
listView.setAdapter(new DisplayListAdapter(this, EPaperDisplay.getDisplays()));
listView.setOnItemClickListener(this);
}
public void onCancel(View view)
{
onBackPressed();
}
@Override
public void onBackPressed()
{
setResult(RESULT_CANCELED, new Intent());
finish();
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
{
EPaperDisplay.epdInd = i;
setResult(RESULT_OK, new Intent());
finish();
}
//---------------------------------------------------------
// File list adapter
//---------------------------------------------------------
private class DisplayListAdapter extends ArrayAdapter<EPaperDisplay>
{
public DisplayListAdapter(Context context, EPaperDisplay[] array)
{
// Standard one-line item layout
//-------------------------------------------------
super(context, android.R.layout.simple_list_item_1, array);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
TextView view = (TextView) super.getView(position, convertView, parent);
if(view != null) view.setText(EPaperDisplay.getDisplays()[position].title);
return view;
}
}
}

@ -0,0 +1,142 @@
package com.waveshare.epaperesp32loader;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.waveshare.epaperesp32loader.image_processing.EPaperDisplay;
import com.waveshare.epaperesp32loader.image_processing.EPaperPicture;
/**
* <h1>Filtering activity</h1>
* The activity offers to select one of available image filters,
* which converts the loaded image for better pixel format
* converting required for selected display.
*
* @author Waveshare team
* @version 1.0
* @since 8/18/2018
*/
public class FilteringActivity extends AppCompatActivity
{
// View
//------------------------------------------
private Button button;
private TextView textView;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.palettes_activity);
getSupportActionBar().setTitle(R.string.filt);
// View
//------------------------------------------
textView = findViewById(R.id.txt_indexed);
imageView = findViewById(R.id.img_indexed);
// Disable unavailable palettes
//------------------------------------------
boolean redIsEnabled = (EPaperDisplay.getDisplays()[EPaperDisplay.epdInd].index & 1) != 0;
findViewById(R.id.btn_wbrl).setEnabled(redIsEnabled);
findViewById(R.id.btn_wbrd).setEnabled(redIsEnabled);
// Disable unavailable palettes just for 5.65f e-Paper
//------------------------------------------
if(EPaperDisplay.epdInd == 25 || EPaperDisplay.epdInd == 37)
{
redIsEnabled = false;
findViewById(R.id.btn_wb_l).setEnabled(redIsEnabled);
findViewById(R.id.btn_wb_d).setEnabled(redIsEnabled);
}
}
// Accept the selected
public void onOk(View view)
{
// If palette is not selected, then exit
//-----------------------------------------------------
if (button == null) return;
// Close palette activity and return palette's name
//-----------------------------------------------------
Intent intent = new Intent();
intent.putExtra("NAME", button.getText().toString());
setResult(RESULT_OK, intent);
finish();
}
public void onCancel(View view)
{
onBackPressed();
}
@Override
public void onBackPressed()
{
setResult(RESULT_CANCELED);
finish();
}
public void onWhiteAndBlackLevelClick(View view)
{
// Save pushed button and run image processing
//-----------------------------------------------------
button = (Button)view;
run(true, false);
}
public void onWhiteBlackRedLevelClick(View view)
{
// Save pushed button and run image processing
//-----------------------------------------------------
button = (Button)view;
run(true, true);
}
public void onWhiteAndBlackDitheringClick(View view)
{
// Save pushed button and run image processing
//-----------------------------------------------------
button = (Button)view;
run(false, false);
}
public void onWhiteBlackRedDitheringClick(View view)
{
// Save pushed button and run image processing
//-----------------------------------------------------
button = (Button)view;
run(false, true);
}
public void run(boolean isLvl, boolean isRed)
{
// Image processing
//-----------------------------------------------------
AppStartActivity.indTableImage = EPaperPicture.createIndexedImage(isLvl, isRed);
// Image view size calculation
//-----------------------------------------------------
int size = textView.getWidth();
imageView.setMaxHeight(size);
imageView.setMinimumHeight(size / 2);
imageView.setImageBitmap(AppStartActivity.indTableImage);
// Show selected image filter
//-----------------------------------------------------
textView.setText(button.getText());
}
}

@ -0,0 +1,231 @@
package com.waveshare.epaperesp32loader;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.waveshare.epaperesp32loader.communication.PermissionHelper;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
/**
* <h1>Open file activity</h1>
* The activity if a simple file browser.
* It provides the file choosing within the external storage.
*
* @author Waveshare team
* @version 1.0
* @since 8/17/2018
*/
public class OpenFileActivity extends AppCompatActivity implements AdapterView.OnItemClickListener
{
// Permission
//--------------------------------------
private PermissionHelper permissionHelper;
private ReadPermissionResponse permissionResponse;
// Views
//--------------------------------------
public TextView textView;
public ListView listView;
// Files
//--------------------------------------
public File thisFolder;
public String externalStorage;
// File list
//--------------------------------------
public ArrayList<File> fileArrayList;
public FileListAdapter fileListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.open_file_activity);
getSupportActionBar().setTitle(R.string.file);
// Permission (READ_EXTERNAL_STORAGE)
//--------------------------------------
permissionHelper = new PermissionHelper(this);
permissionResponse = new ReadPermissionResponse();
permissionHelper.setResponse(PermissionHelper.REQ_READ, permissionResponse);
// Views
//--------------------------------------
textView = findViewById(R.id.open_file_text);
listView = findViewById(R.id.open_file_list);
// File list adapter
//--------------------------------------
fileArrayList = new ArrayList<>();
fileListAdapter = new FileListAdapter(this, fileArrayList);
listView.setAdapter(fileListAdapter);
listView.setOnItemClickListener(this);
// Set current folder
//--------------------------------------
externalStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
String fileName = AppStartActivity.filePath;
thisFolder = (fileName == null) || !fileName.startsWith(externalStorage)
? Environment.getExternalStorageDirectory()
: new File(fileName);
select(thisFolder);
}
public void select(File folder)
{
// Set folder's file into the permission's response
//-----------------------------------------------------
permissionResponse.file = folder;
// Check permission and run response if it's granted
//-----------------------------------------------------
if (permissionHelper.sendRequestPermission(PermissionHelper.REQ_READ))
permissionResponse.invoke();
}
// On coming to parent folder event handler
//---------------------------------------------------------
public void onBack(View view)
{
// Exit if the external storage root is current folder
//-----------------------------------------------------
if (thisFolder.getAbsolutePath().equals(
Environment.getExternalStorageDirectory().getAbsolutePath())) return;
// Setup parent folder
//-----------------------------------------------------
thisFolder = thisFolder.getParentFile();
textView.setText(thisFolder.getPath());
// Update list of files
//-----------------------------------------------------
fileArrayList.clear();
fileArrayList.addAll(Arrays.asList(thisFolder.listFiles()));
fileListAdapter.notifyDataSetChanged();
}
public void onCancel(View view)
{
onBackPressed();
}
@Override
public void onBackPressed()
{
setResult(RESULT_CANCELED, new Intent());
finish();
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
{
select(fileListAdapter.getItem(i));
}
//---------------------------------------------------------
// File list adapter
//---------------------------------------------------------
private class FileListAdapter extends ArrayAdapter<File>
{
public FileListAdapter(Context context, ArrayList<File> files)
{
super(context, android.R.layout.simple_list_item_1, files);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// Get list item view and its file
//-------------------------------------------------
TextView view = (TextView) super.getView(position, convertView, parent);
File file = getItem(position);
// Put the name of the file into its view
//-------------------------------------------------
if(view != null) view.setText(file.getName());
return view;
}
}
//------------------------------------------
// Result of permission request
//------------------------------------------
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
permissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
//---------------------------------------------------------
// Permission responses
//---------------------------------------------------------
class ReadPermissionResponse implements PermissionHelper.PermissionResponse
{
public File file;
@Override
public void invoke()
{
// Check if the file is located in external storage
//-------------------------------------------------
if ((file == null) || !file.getAbsolutePath().startsWith(externalStorage))
file = Environment.getExternalStorageDirectory();
// Case of file: return its name and path
//-------------------------------------------------
if (file.isFile())
{
AppStartActivity.fileName = file.getName();
AppStartActivity.filePath = thisFolder.getAbsolutePath();
setResult(RESULT_OK, new Intent());
finish();
}
// Case of folder: return its name and path
//-------------------------------------------------
else
{
String message = "Current location: ";
message += file.getAbsolutePath().substring(externalStorage.length());
textView.setText(message);
// Get items of the folder
//---------------------------------------------
File[] files = file.listFiles();
if (files == null) return;
// Mark the folder as current one
//---------------------------------------------
thisFolder = file;
// Update file list view
//---------------------------------------------
fileArrayList.clear();
fileArrayList.addAll(Arrays.asList(files));
fileListAdapter.notifyDataSetChanged();
}
}
}
}

@ -0,0 +1,358 @@
package com.waveshare.epaperesp32loader;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.waveshare.epaperesp32loader.communication.BluetoothHelper;
import com.waveshare.epaperesp32loader.communication.BluetoothScanner;
import com.waveshare.epaperesp32loader.communication.PermissionHelper;
import java.util.ArrayList;
/**
* <h1>Scanning activity</h1>
* The activity offers to select one of available bluetooth devices.
*
* @author Waveshare team
* @version 1.0
* @since 8/11/2018
*/
public class ScanningActivity extends AppCompatActivity implements BluetoothScanner.ScanningHandler
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.scanning_activity);
getSupportActionBar().setTitle(R.string.scan);
// Device list
//-------------------------
deviceList = findViewById(R.id.device_list);
deviceList.setAdapter(btListAdapter = new ListAdapter());
deviceList.setOnItemClickListener(new OnDevListItemClick());
// Bluetooth scanner
//-------------------------
if (!BluetoothScanner.initialize(this))
{
Intent intent = new Intent();
intent.putExtra("COMMENT", "Bluetooth is not supported on this device");
setResult(RESULT_CANCELED);
finish();
}
}
@Override
protected void onResume()
{
super.onResume();
BluetoothScanner.stopScanning(this, false);
}
@Override
protected void onPause()
{
BluetoothScanner.stopScanning(this, false);
super.onPause();
}
@Override
protected void onDestroy()
{
BluetoothScanner.stopScanning(this, true);
super.onDestroy();
}
@Override
public void onBackPressed()
{
super.onBackPressed();
BluetoothScanner.stopScanning(this, true);
}
//------------------------------------------
// Result of permission request
//------------------------------------------
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
BluetoothScanner.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
//---------------------------------------------------------
// Main menu
//---------------------------------------------------------
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.scanning_menu, menu);
if (BluetoothScanner.isScanning())
{
menu.findItem(R.id.menu_item_ring).setActionView(R.layout.scanning_ring);
menu.findItem(R.id.menu_item_scan).setVisible(false);
menu.findItem(R.id.menu_item_stop).setVisible(true);
}
else
{
menu.findItem(R.id.menu_item_ring).setActionView(null);
menu.findItem(R.id.menu_item_scan).setVisible(true);
menu.findItem(R.id.menu_item_stop).setVisible(false);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
int id = item.getItemId();
switch (id)
{
// Start scanning
//-------------------------------------------------
case R.id.menu_item_scan:
// If scanning is started
//---------------------------------------------
if (BluetoothScanner.startScanning())
// Just update option menu's view
//-----------------------------------------
invalidateOptionsMenu();
// ... otherwise send request permission
//---------------------------------------------
else BluetoothScanner.sendRequestPermission();
break;
// Stop scanning and update menu
//-------------------------------------------------
case R.id.menu_item_stop:
BluetoothScanner.stopScanning(this, false);
invalidateOptionsMenu();
break;
}
return super.onOptionsItemSelected(item);
}
//---------------------------------------------------------
// Device list
//---------------------------------------------------------
private ListView deviceList;
private ListAdapter btListAdapter;
static class ViewHolder
{
public TextView text;
public TextView addr;
}
private class ListAdapter extends BaseAdapter
{
private ArrayList<BluetoothDevice> btDevices;
public ListAdapter()
{
super();
btDevices = new ArrayList<>();
}
public void addDevice(BluetoothDevice device)
{
btDevices.add(device);
}
public BluetoothDevice getDevice(int position)
{
return btDevices.get(position);
}
public void clear()
{
btDevices.clear();
}
public boolean contains(BluetoothDevice device)
{
// The device is already in the list
//-------------------------------------------------
if (btDevices.contains(device))
return true;
// Every device must have unique MAC address
//-------------------------------------------------
for (int i = 0; i < btDevices.size(); i++)
if (btDevices.get(i).getAddress().equals(device.getAddress()))
return true;
return false;
}
@Override
public int getCount()
{
return btDevices.size();
}
@Override
public Object getItem(int i)
{
return btDevices.get(i);
}
@Override
public long getItemId(int i)
{
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup)
{
ViewHolder viewHolder;
if (view == null)
{
view = ScanningActivity.this.getLayoutInflater().inflate(R.layout.scanning_list_item, null);
viewHolder = new ViewHolder();
viewHolder.text = view.findViewById(R.id.bt_dev_name);
viewHolder.addr = view.findViewById(R.id.bt_dev_addr);
view.setTag(viewHolder);
}
else viewHolder = (ScanningActivity.ViewHolder) view.getTag();
BluetoothDevice device = btDevices.get(i);
String name = device.getName();
if (device.getBondState() == BluetoothDevice.BOND_BONDED) name += " (BONDED)";
viewHolder.text.setText((name != null) && (name.length() > 0) ? name : "unknown");
viewHolder.addr.setText(device.getAddress());
return view;
}
}
private class OnDevListItemClick implements AdapterView.OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
// Stop scanning and broadcast receiving
//-------------------------------------------------
BluetoothScanner.stopScanning(ScanningActivity.this, true);
// Return name and address of the selected device
//-------------------------------------------------
Intent intent = new Intent();
intent.putExtra("DEVICE", btListAdapter.getDevice(position));
setResult(RESULT_OK, intent);
finish();
}
}
//---------------------------------------------------------
// Scanning message handler
//---------------------------------------------------------
public void handleMessage(int cmd, Intent data)
{
runOnUiThread(new ScanHandler(cmd, data));
}
private class ScanHandler implements Runnable
{
public int cmd;
public Intent data;
public ScanHandler(int cmd, Intent data)
{
this.cmd = cmd;
this.data = data;
}
@Override
public void run()
{
BluetoothDevice device;
int state;
switch (cmd)
{
case BluetoothScanner.BT_DEVICE_FOUND:
// Found bluetooth device
//-----------------------------------------
device = data.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Check if the device is unique
//-----------------------------------------
if (btListAdapter.contains(device)) break;
// Add the device into devices list
//-----------------------------------------
btListAdapter.addDevice(device);
// Update devices list's view
//-----------------------------------------
btListAdapter.notifyDataSetChanged();
break;
case BluetoothScanner.BT_SCANNING_ON:
// Update the options menu's view
//-----------------------------------------
invalidateOptionsMenu();
// Clear devices list
//-----------------------------------------
btListAdapter.clear();
// Update devices list's view
//-----------------------------------------
btListAdapter.notifyDataSetChanged();
break;
case BluetoothScanner.BT_SCANNING_OFF:
// Just update the options menu's view
//-----------------------------------------
invalidateOptionsMenu();
break;
case BluetoothScanner.BT_IS_CHANGED:
// Current state of the bluetooth adapter
//-----------------------------------------
state = data.getIntExtra(
BluetoothAdapter.EXTRA_STATE,
BluetoothAdapter.ERROR);
// Update the options menu's view
// if the adapter is turned off
//-----------------------------------------
if (state == BluetoothAdapter.STATE_OFF)
invalidateOptionsMenu();
break;
default:
break;
}
}
}
}

@ -0,0 +1,458 @@
package com.waveshare.epaperesp32loader;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import com.waveshare.epaperesp32loader.communication.BluetoothHelper;
import com.waveshare.epaperesp32loader.image_processing.EPaperDisplay;
/**
* <h1>Upload activity</h1>
* The activity shows the progress of image uploading into display
* of the selected bluetooth device.
*
* @author Waveshare team
* @version 1.0
* @since 8/20/2018
*/
public class UploadActivity extends AppCompatActivity
{
private TextView textView;
private SocketHandler handler;
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.upload_activity);
getSupportActionBar().setTitle(R.string.dlg_send);
// View
//--------------------------------------
textView = findViewById(R.id.upload_text);
textView.setText("Uploading: 0%");
// Bluetooth helper and its handler
//--------------------------------------
BluetoothHelper.initialize(AppStartActivity.btDevice, handler = new SocketHandler());
}
@Override
protected void onResume()
{
super.onResume();
// Bluetooth socket connection
//--------------------------------------
if (!BluetoothHelper.connect() || !handler.init(AppStartActivity.indTableImage))
{
setResult(RESULT_CANCELED);
finish();
}
else textView.setText("Uploading 0 %");
}
@Override
protected void onPause()
{
BluetoothHelper.close();
super.onPause();
}
@Override
protected void onDestroy()
{
BluetoothHelper.close();
super.onDestroy();
}
@Override
public void onBackPressed()
{
BluetoothHelper.close();
setResult(RESULT_OK);
finish();
}
public void onCancel(View view)
{
onBackPressed();
}
// Uploaded data buffer
//---------------------------------------------------------
private static final int BUFF_SIZE = 256;
private static byte[] buffArr = new byte[BUFF_SIZE];
private static int buffInd;
private static int xLine;
//---------------------------------------------------------
// Socket Handler
//---------------------------------------------------------
class SocketHandler extends Handler
{
private int pxInd; // Pixel index in picture
private int stInd; // Stage index of uploading
private int dSize; // Size of uploaded data by LOAD command
private int[] array; // Values of picture pixels
public SocketHandler()
{
super();
}
// Converts picture pixels into selected pixel format
// and sends EPDx command
//-----------------------------------------------------
private boolean init(Bitmap bmp)
{
int w = bmp.getWidth(); // Picture with
int h = bmp.getHeight();// Picture height
int epdInd = EPaperDisplay.epdInd;
array = new int[w*h]; // Array of pixels
int i = 0; // Index of pixel in the array of pixels
// Loading pixels into array
//-------------------------------------------------
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++, i++)
if(epdInd == 25 || epdInd ==37)
array[i] = getVal_7color(bmp.getPixel(x, y));
else
array[i] = getVal(bmp.getPixel(x, y));
pxInd = 0;
xLine = 0; //2.13inch
stInd = 0;
dSize = 0;
buffInd = 2; // Size of command in bytes
buffArr[0] = (byte)'I'; // Name of command (Initialize)
buffArr[1] = (byte)EPaperDisplay.epdInd; // Index of display
return u_send(false);
}
// The function is executed after every "Ok!" response
// obtained from esp32, which means a previous command
// is complete and esp32 is ready to get the new one.
//-----------------------------------------------------
private boolean handleUploadingStage()
{
int epdInd = EPaperDisplay.epdInd;
// 2.13 e-Paper display
if ((epdInd == 3) || (epdInd == 39))
{
if(stInd == 0) return u_line(0, 0, 100);
//-------------------------------------------------
if(stInd == 1) return u_show();
}
// 2.13 b V4
else if ((epdInd == 40))
{
if(stInd == 0) return u_line(0, 0, 50);
if(stInd == 1) return u_next();
if(stInd == 2) return u_line(3, 50, 50);
if(stInd == 3) return u_show();
}
// White-black e-Paper displays
//-------------------------------------------------
else if ((epdInd==0)||(epdInd==6)||(epdInd==7)||(epdInd==9)||(epdInd==12)||
(epdInd==16)||(epdInd==19)||(epdInd==22)||(epdInd==26)||(epdInd==27)||(epdInd==28))
{
if(stInd == 0) return u_data(0,0,100);
if(stInd == 1) return u_show();
}
// 7.5 colored e-Paper displays
//-------------------------------------------------
else if (epdInd>15 && epdInd < 22)
{
if(stInd == 0) return u_data(-1,0,100);
if(stInd == 1) return u_show();
}
// 5.65f colored e-Paper displays
//-------------------------------------------------
else if (epdInd == 25 || epdInd == 37)
{
if(stInd == 0) return u_data(-2,0,100);
if(stInd == 1) return u_show();
}
// Other colored e-Paper displays
//-------------------------------------------------
else
{
// if(stInd==0 && epdInd==23)return u_data(0,0,100);
if(stInd == 0)return u_data((epdInd == 1)? -1 : 0,0,50);
if(stInd == 1)return u_next();
if(stInd == 2)return u_data(3,50,50);
if(stInd == 3)return u_show();
}
return true;
}
// Returns the index of color in palette
//-----------------------------------------------------
public int getVal(int color)
{
int r = Color.red(color);
int b = Color.blue(color);
if((r == 0xFF) && (b == 0xFF)) return 1;
if((r == 0x7F) && (b == 0x7F)) return 2;
if((r == 0xFF) && (b == 0x00)) return 3;
return 0;
}
// Returns the index of color in palette just for 5.65f e-Paper
//-----------------------------------------------------
public int getVal_7color(int color)
{
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
if((r == 0x00) && (g == 0x00) && (b == 0x00)) return 0;
if((r == 0xFF) && (g == 0xFF) && (b == 0xFF)) return 1;
if((r == 0x00) && (g == 0xFF) && (b == 0x00)) return 2;
if((r == 0x00) && (g == 0x00) && (b == 0xFF)) return 3;
if((r == 0xFF) && (g == 0x00) && (b == 0x00)) return 4;
if((r == 0xFF) && (g == 0xFF) && (b == 0x00)) return 5;
if((r == 0xFF) && (g == 0x80) && (b == 0x00)) return 6;
return 7;
}
// Sends command cmd
//-----------------------------------------------------
private boolean u_send(boolean next)
{
if (!BluetoothHelper.btThread.write(buffArr, buffInd))
return false; // Command sending is failed
if(next) stInd++; // Go to next stage if it is needed
return true; // Command is sent successful
}
// Next stage command
//-----------------------------------------------------
private boolean u_next()
{
buffInd = 1; // Size of command in bytes
buffArr[0] = (byte)'N';// Name of command (Next)
pxInd = 0;
return u_send(true);
}
// The finishing command
//-----------------------------------------------------
private boolean u_show()
{
buffInd = 1; // Size of command in bytes
buffArr[0] = (byte)'S';// Name of command (Show picture)
// Return false if the SHOW command is not sent
//-------------------------------------------------
if (!u_send(true)) return false;
// Otherwise exit the uploading activity.
//-------------------------------------------------
return true;
}
// Sends pixels of picture and shows uploading progress
//-----------------------------------------------------
private boolean u_load(int k1, int k2)
{
// Uploading progress message
//-------------------------------------------------
String x = "" + (k1 + k2*pxInd/array.length);
if (x.length() > 5) x = x.substring(0, 5);
handleUserInterfaceMessage(x);
// Size of uploaded data
//-------------------------------------------------
dSize += buffInd;
// Request message contains:
// data (maximum BUFF_SIZE bytes),
// size of uploaded data (4 bytes),
// length of data
// command name "LOAD"
//-------------------------------------------------
buffArr[0] = (byte)'L';
// Size of packet
//-------------------------------------------------
buffArr[1] = (byte)(buffInd );
buffArr[2] = (byte)(buffInd >> 8);
// Data size
//-------------------------------------------------
buffArr[3] = (byte)(dSize );
buffArr[4] = (byte)(dSize >> 8);
buffArr[5] = (byte)(dSize >> 16);
return u_send(pxInd >= array.length);
}
// Pixel format converting
//-----------------------------------------------------
private boolean u_data(int c, int k1, int k2)
{
buffInd = 6; // pixels' data offset
if(c == -1)
{
while ((pxInd < array.length) && (buffInd + 1 < BUFF_SIZE))
{
int v = 0;
for(int i = 0; i < 16; i += 2)
{
if (pxInd < array.length) v |= (array[pxInd] << i);
pxInd++;
}
buffArr[buffInd++] = (byte)(v );
buffArr[buffInd++] = (byte)(v >> 8);
}
}
else if(c == -2)
{
while ((pxInd < array.length) && (buffInd + 1 < BUFF_SIZE))
{
int v = 0;
for(int i = 0; i < 16; i += 4)
{
if (pxInd < array.length) v |= (array[pxInd] << i);
pxInd++;
}
buffArr[buffInd++] = (byte)(v );
buffArr[buffInd++] = (byte)(v >> 8);
}
}
else
{
while ((pxInd < array.length) && (buffInd < BUFF_SIZE))
{
int v = 0;
for (int i = 0; i < 8; i++)
{
if ((pxInd < array.length) && (array[pxInd] != c)) v |= (128 >> i);
pxInd++;
}
buffArr[buffInd++] = (byte)v;
}
}
return u_load(k1, k2);
}
// Pixel format converting (2.13 e-Paper display)
//-----------------------------------------------------
private boolean u_line(int c, int k1, int k2)
{
buffInd = 6; // pixels' data offset
while ((pxInd < array.length) && (buffInd < 246)) // 15*16+6 16*8 = 128
{
int v = 0;
for (int i = 0; (i < 8) && (xLine < 122); i++, xLine++){
if (array[pxInd++] != c) v |= (128 >> i);
}
if(xLine >= 122 )xLine = 0;
buffArr[buffInd++] = (byte)v;
}
return u_load(k1, k2);
}
//-------------------------------------------
// Handles socket message
//-------------------------------------------
public void handleMessage(android.os.Message msg)
{
// "Fatal error" event
//-------------------------------------------------
if (msg.what == BluetoothHelper.BT_FATAL_ERROR)
{
setResult(RESULT_CANCELED);
finish();
}
// "Data is received" event
//-------------------------------------------------
else if (msg.what == BluetoothHelper.BT_RECEIVE_DATA)
{
// Convert data to string
//---------------------------------------------
String line = new String((byte[]) msg.obj, 0, msg.arg1);
// If esp32 is ready for new command
//---------------------------------------------
if (line.contains("Ok!"))
{
// Try to handle received data.
// If it's failed, restart the uploading
//-----------------------------------------
if (handleUploadingStage()) return;
}
// Exit is the message is unknown
//---------------------------------------------
else if (!line.contains("Error!")) return;
// Otherwise restart the uploading
//-----------------------------------------
BluetoothHelper.close();
BluetoothHelper.connect();
handler.init(AppStartActivity.indTableImage);
}
}
}
//---------------------------------------------------------
// User Interface Handler
//---------------------------------------------------------
public void handleUserInterfaceMessage(String msg)
{
runOnUiThread(new UserInterfaceHandler(msg));
}
private class UserInterfaceHandler implements Runnable
{
public String msg;
public UserInterfaceHandler(String msg)
{
this.msg = "Uploading: " + msg + "%";
}
@Override
public void run()
{
textView.setText(msg);
}
}
}

@ -0,0 +1,217 @@
package com.waveshare.epaperesp32loader.communication;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Handler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
/**
* <h1>Bluetooth helper</h1>
* The class provides functions for bluetooth device
* input\output data transfer by BluetoothSocket class
*
* @author Waveshare team
* @version 1.0
* @since 8/18/2018
*/
public class BluetoothHelper
{
// This constant is used for creating bluetooth socket
//---------------------------------------------------------
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
// Bluetooth
//---------------------------------------------------------
private static BluetoothAdapter btAdapter;
private static BluetoothSocket btSocket;
private static BluetoothDevice btDevice;
private static String btAddress;
public static ConnectedThread btThread;
private static Handler btHandler;
// Keys of events
//---------------------------------------------------------
public static final int BT_FATAL_ERROR = 1;
public static final int BT_STATE_IS_OFF = 2;
public static final int BT_RECEIVE_DATA = 3;
// Initialisation/restart the upload activity
//---------------------------------------------------------
public static boolean initialize(BluetoothDevice device, Handler handler)
{
btDevice = device;
btAddress = device.getAddress();
btHandler = handler;
return checkState();
}
// Initialisation bluetooth socket in its listening thread
//---------------------------------------------------------
public static boolean connect()
{
// If it is already connected
//-----------------------------------------------------
if ((btSocket != null) && (btSocket.isConnected())) return true;
// Prepare the bluetooth device for connection
//-----------------------------------------------------
if (!checkState()) return false;
BluetoothDevice device = btAdapter.getRemoteDevice(btAddress);
// Trying to create bluetooth socket
//-----------------------------------------------------
try
{
btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
}
catch (IOException e)
{
btHandler.obtainMessage(BT_FATAL_ERROR);
return false;
}
// Trying to make connection by the bluetooth socket
//-----------------------------------------------------
try
{
btSocket.connect();
}
catch (IOException e)
{
close();
return false;
}
// Create and start a thread listening the socket
//-----------------------------------------------------
btThread = new ConnectedThread(btSocket, btHandler);
btThread.start();
return true;
}
// Trying to close the bluetooth socket
//---------------------------------------------------------
public static boolean close()
{
try
{
btSocket.close();
return true;
}
catch (IOException e2)
{
btHandler.obtainMessage(BT_FATAL_ERROR);
return false;
}
}
// Checks the bluetooth adapter is on
//---------------------------------------------------------
public static boolean checkState()
{
if ((btAdapter = BluetoothAdapter.getDefaultAdapter()) == null)
{
btHandler.obtainMessage(BT_FATAL_ERROR);
return false;
}
if (!btAdapter.isEnabled())
{
btHandler.obtainMessage(BT_STATE_IS_OFF);
return false;
}
return true;
}
// Thread where input\output streams of socket are handled
//---------------------------------------------------------
public static class ConnectedThread extends Thread
{
private final Handler mmHandler;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public static boolean keepConnection = false;
public ConnectedThread(BluetoothSocket socket, Handler handler)
{
mmHandler = handler;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Getting socket's streams
//-------------------------------------------------
try
{
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
tmpOut.flush();
}
catch (IOException e) { }
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
// Reading data from the input stream into a buffer
// and sending it to message handler
//-----------------------------------------------------
public void run()
{
byte[] buffer = new byte[256];
while (true)
{
try
{
mmHandler.obtainMessage(BluetoothHelper.BT_RECEIVE_DATA,
mmInStream.read(buffer), -1, buffer).sendToTarget();
}
catch (IOException e)
{
if (keepConnection)
{
try
{
Thread.sleep(1000);
close();
connect();
}
catch (InterruptedException internetExplorer)
{
}
}
else break;
}
}
}
// Writing of string into the output stream
//-----------------------------------------------------
public boolean write(byte[] mass, int size)
{
try
{
//mmOutStream.flush();
mmOutStream.write(mass, 0, size);
return true;
}
catch (IOException e)
{
return false;
}
}
}
}

@ -0,0 +1,240 @@
package com.waveshare.epaperesp32loader.communication;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.support.annotation.NonNull;
import com.waveshare.epaperesp32loader.ScanningActivity;
/**
* Created by YiWan on 8/19/2018.
*/
/**
* <h1>Bluetooth scanner</h1>
* The class provides functions for receiving bluetooth broadcast messages
* (bluetooth is on\off, discovering is on\off, new device found),
* requesting ACCESS_COARSE_LOCATION permission and devices scanning.
*
* @author Waveshare team
* @version 1.0
* @since 8/19/2018
*/
public class BluetoothScanner
{
// Bluetooth scanning objects
//-----------------------------
private static BluetoothAdapter btAdapter;
private static BluetoothBroadcastReceiver btReceiver;
private static ScanningHandler btHandler;
// Keys of scanning events
//-----------------------------
public static final int BT_SCANNING_ON = 2;
public static final int BT_SCANNING_OFF = 3;
public static final int BT_IS_CHANGED = 4;
public static final int BT_DEVICE_FOUND = 5;
//--------------------------------------
// Permission
//--------------------------------------
private static PermissionHelper permissionHelper;
private static PermissionHelper.PermissionResponse permissionResponse;
//---------------------------------------------------------
// Scanning message handler
//---------------------------------------------------------
public interface ScanningHandler
{
void handleMessage(int cmnd, Intent data);
}
//---------------------------------------------------------
// Broadcast receiver of bluetooth adapter events:
//
// ACTION_STATE_CHANGED - bluetooth on/off
// ACTION_DISCOVERY_STARTED - scanning on
// ACTION_DISCOVERY_FINISHED - scanning off
// ACTION_FOUND - some device is found
//---------------------------------------------------------
private static class BluetoothBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (action.equals(BluetoothDevice.ACTION_FOUND))
btHandler.handleMessage(BT_DEVICE_FOUND, intent);
else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED))
btHandler.handleMessage(BT_IS_CHANGED, intent);
else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_STARTED))
btHandler.handleMessage(BT_SCANNING_ON, null);
else if (action.equals(BluetoothAdapter.ACTION_DISCOVERY_FINISHED))
btHandler.handleMessage(BT_SCANNING_OFF, null);
}
}
//---------------------------------------------------------
// Tries to start scanning process
// Returns true if the starting is successful
// Returns false if the starting needs permission
//---------------------------------------------------------
public static boolean initialize(Activity activity)
{
// Permission required for scanning
//-----------------------------------------------------
permissionHelper = new PermissionHelper(activity);
//-----------------------------------------------------
// Start the scanning if it is granted
//
// This class exemplar is analog of C#'s delegate.
// It wraps invoke function and is stored in the
// permissionHelper, just because function invoke
// can't be stored as a variable in Java.
//-----------------------------------------------------
permissionResponse = new PermissionHelper.PermissionResponse()
{
// It must be executed if the permission is granted
//-------------------------------------------------
@Override
public void invoke()
{
// Start the scanning of bluetooth devices
//---------------------------------------------
btAdapter.startDiscovery();
}
};
// Permission of ACCESS_COARSE_LOCATION
//--------------------------------------
permissionHelper.setResponse(PermissionHelper.REQ_BLUE, permissionResponse);
// Get available bluetooth adapter
//-----------------------------------------------------
btAdapter = BluetoothAdapter.getDefaultAdapter();
// Exit, if the adapter is not available
//-----------------------------------------------------
if (btAdapter == null) return false;
// Message handler
//-----------------------------------------------------
btHandler = (ScanningHandler)activity;
// Broadcast receiver of bluetooth events
//-----------------------------------------------------
btReceiver = new BluetoothBroadcastReceiver();
//-----------------------------------------------------
// Intent filter for bluetooth events:
//
// ACTION_STATE_CHANGED - bluetooth on/off
// ACTION_DISCOVERY_STARTED - scanning on
// ACTION_DISCOVERY_FINISHED - scanning off
// ACTION_FOUND - some device is found
//-----------------------------------------------------
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
activity.registerReceiver(btReceiver, intentFilter);
//-----------------------------------------------------
// Turn bluetooth on if it isn't on yet
//
// In fact, if btAdapter is off then following
// command sends request ACTION_REQUEST_ENABLE
// to turn on btAdapter and the broadcast receiver
// gets STATE_TURNING_ON message, which means
// the adapter started the turning on process.
// The scanning routine is interesting in STATE_ON
// and STATE_OFF messages only and ignores others.
//-----------------------------------------------------
if (!btAdapter.isEnabled()) activity.startActivity(
new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE));
return true;
}
//---------------------------------------------------------
// Checks if the device is scanning now
//---------------------------------------------------------
public static boolean isScanning()
{
return (btAdapter != null) && btAdapter.isDiscovering();
}
//---------------------------------------------------------
// Tries to start scanning process
// Returns true if the starting is successful
// Returns false if the scanning needs permission
//---------------------------------------------------------
public static boolean startScanning()
{
if (btAdapter.isDiscovering())
return true;
else if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ||
permissionHelper.sendRequestPermission(PermissionHelper.REQ_BLUE))
permissionResponse.invoke();
return false;
}
//---------------------------------------------------------
// Stops scanning process and unregisters receiver
//---------------------------------------------------------
public static void stopScanning(Activity activity, boolean unregisterReceiver)
{
try
{
// Stop getting messages from broadcast receiver
//-------------------------------------------------
if (unregisterReceiver)
activity.unregisterReceiver(btReceiver);
// Stop scanning bluetooth devices
//-------------------------------------------------
if ((btAdapter != null) && btAdapter.isDiscovering())
btAdapter.cancelDiscovery();
}
catch (Exception e)
{
}
}
//---------------------------------------------------------
// Sends request of scanning permission
//---------------------------------------------------------
public static void sendRequestPermission()
{
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ||
permissionHelper.sendRequestPermission(PermissionHelper.REQ_BLUE))
permissionResponse.invoke();
}
//---------------------------------------------------------
// Request's result of the scanning permission
//---------------------------------------------------------
public static void onRequestPermissionsResult(
// Expected arguments:
int requestCode, // PermissionHelper.REQ_BLUE
@NonNull String[] permissions, // Manifest.permission.ACCESS_COARSE_LOCATION
@NonNull int[] grantResults) // PackageManager.PERMISSION_GRANTED
{
permissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}

@ -0,0 +1,172 @@
package com.waveshare.epaperesp32loader.communication;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import com.waveshare.epaperesp32loader.R;
/**
* <h1>Permission helper</h1>
* The class provides functions for delayed operations,
* which require permissions and interaction with user.
*
* @author Waveshare team
* @version 1.0
* @since 8/16/2018
*/
public class PermissionHelper implements DialogInterface.OnDismissListener
{
// Permissions used in the application
//---------------------------------------------------------
public static final int REQ_BLUE = 0; // For bluetooth devices scanning
public static final int REQ_READ = 1; // For reading from external storage
// Permissions related messages
//---------------------------------------------------------
private static final String[] messages = new String[]
{
"Please accept the GPS Location permission",
"Please accept the Storage reading permission",
"The GPS Location permission is denied",
"The Storage Reading permission is denied",
};
// Full names of permissions
//---------------------------------------------------------
private static final String[] permissions = new String[]
{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE,
};
// Wrapped names of permissions wrapped (used in requests)
//---------------------------------------------------------
private static final String[][] permissionArrays = new String[][]
{
new String[] { Manifest.permission.ACCESS_COARSE_LOCATION },
new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
};
// Granted permission event handler interface
//---------------------------------------------------------
public interface PermissionResponse
{
void invoke();
}
// Array of granted permission event handlers
//---------------------------------------------------------
private static PermissionResponse[] responses = new PermissionResponse[]
{
null,
null,
};
private Activity context; // Activity which needs a permission
private int reqCode; //
public PermissionHelper(Activity activity)
{
context = activity;
}
public AlertDialog show(int requestCode)
{
reqCode = requestCode;
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(R.string.dlg_note);
dialog.setOnDismissListener(this);
dialog.setPositiveButton(R.string.btn_okey, null);
dialog.setMessage(messages[reqCode]);
return dialog.show();
}
public void onDismiss(DialogInterface dialog)
{
if (reqCode >= permissions.length) return;
ActivityCompat.requestPermissions(context, permissionArrays[reqCode], reqCode);
}
// Interaction with user and sending the request permission
//---------------------------------------------------------
public boolean sendRequestPermission(int requestCode)
{
// Get permission if possible
//-----------------------------------------------------
if (requestCode >= permissions.length) return false;
String permission = permissions[requestCode];
// Return true if it is already granted
//-----------------------------------------------------
if (context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED)
return true;
// Interact with user if it's needed
//-----------------------------------------------------
if (context.shouldShowRequestPermissionRationale(permission))
show(requestCode);
// Request the permission
//-----------------------------------------------------
else context.requestPermissions(permissionArrays[requestCode], requestCode);
return false;
}
// Getting and handling the request permission result
//---------------------------------------------------------
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
{
// Unknown result
//-----------------------------------------------------
if ((requestCode < 0) || (requestCode >= permissions.length))
return;
// Notify that permission is not granted yet
//-----------------------------------------------------
if (context.checkSelfPermission(permissions[requestCode]) != PackageManager.PERMISSION_GRANTED)
{
if (responses[requestCode] != null)
show(requestCode + permissions.length);
}
// Perform granted permission's response function
//-----------------------------------------------------
else if (responses[requestCode] != null)
responses[requestCode].invoke();
// Clear corresponded cell in responses array
//-----------------------------------------------------
responses[requestCode] = null;
}
// Set response on
//---------------------------------------------------------
public void setResponse(int requestCode, PermissionResponse response)
{
if ((requestCode < 0) || (requestCode >= responses.length)) return;
responses[requestCode] = response;
}
// Notification dialog
//---------------------------------------------------------
public static void note(Activity activity, int msg)
{
Resources resources = activity.getResources();
AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
dialog.setTitle(resources.getString(R.string.dlg_note));
dialog.setPositiveButton(resources.getString(R.string.btn_okey), null);
dialog.setMessage(resources.getString(msg));
dialog.show();
}
}

@ -0,0 +1,7 @@
package com.waveshare.epaperesp32loader.image_processing;
import android.graphics.Bitmap;
class AppStartActivity {
public static Bitmap originalImage;
}

@ -0,0 +1,99 @@
package com.waveshare.epaperesp32loader.image_processing;
/**
* Created by YiWan on 8/24/2018.
*/
/**
* <h1>e-Paper display characteristics</h1>
* The class is intended to store width, height and index of palette.
*
* @author Waveshare team
* @version 1.0
* @since 8/14/2018
*/
public class EPaperDisplay
{
public int width;
public int height;
public int index;
public String title;
/**
* Stores display's characteristics.
* @param width of display in pixels
* @param height of display on pixels
* @param index of palette
* @param title of display
*/
public EPaperDisplay(int width, int height, int index, String title)
{
this.width = width;
this.height = height;
this.index = index;
this.title = title;
}
// Index of selected display
//---------------------------------------------------------
public static int epdInd = -1;
// Array of display characteristics
//---------------------------------------------------------
private static EPaperDisplay[] array = null;
public static EPaperDisplay[] getDisplays()
{
if (array == null)
{
array = new EPaperDisplay[]
{
new EPaperDisplay(200,200,0, "1.54 inch e-Paper"), // 0
new EPaperDisplay(200,200,3, "1.54 inch e-Paper (B)"), // 1
new EPaperDisplay(152,152,5, "1.54 inch e-Paper (C)"), // 2
new EPaperDisplay(122,250,0, "2.13 inch e-Paper"), // 3
new EPaperDisplay(104,212,1, "2.13 inch e-Paper (B)"), // 4
new EPaperDisplay(104,212,5, "2.13 inch e-Paper (C)"), // 5
new EPaperDisplay(104,212,0, "2.13 inch e-Paper (D)"), // 6
new EPaperDisplay(176,264,0, "2.7 inch e-Paper"), // 7
new EPaperDisplay(176,264,1, "2.7 inch e-Paper (B)"), // 8
new EPaperDisplay(128,296,0, "2.9 inch e-Paper"), // 9
new EPaperDisplay(128,296,1, "2.9 inch e-Paper (B)"), // 10
new EPaperDisplay(128,296,5, "2.9 inch e-Paper (C)"), // 11
new EPaperDisplay(128,296,0, "2.9 inch e-Paper (D)"), // 12
new EPaperDisplay(400,300,0, "4.2 inch e-Paper"), // 13
new EPaperDisplay(400,300,1, "4.2 inch e-Paper (B)"), // 14
new EPaperDisplay(400,300,5, "4.2 inch e-Paper (C)"), // 15
new EPaperDisplay(600,448,0, "5.83 inch e-Paper"), // 16
new EPaperDisplay(600,448,1, "5.83 inch e-Paper (B)"), // 17
new EPaperDisplay(600,448,5, "5.83 inch e-Paper (C)"), // 18
new EPaperDisplay(640,384,0, "7.5 inch e-Paper"), // 19
new EPaperDisplay(640,384,1, "7.5 inch e-Paper (B)"), // 20
new EPaperDisplay(640,384,5, "7.5 inch e-Paper (C)"), // 21
new EPaperDisplay(800,480,0, "7.5 inch e-Paper V2"), // 22
new EPaperDisplay(800,480,1, "7.5 inch e-Paper (B) V2"), // 23
new EPaperDisplay(880,528,1, "7.5 inch HD e-Paper (B)"), // 24
new EPaperDisplay(600,448,7, "5.65 inch e-Paper (F)"), // 25
new EPaperDisplay(880,528,0, "7.5 inch HD e-Paper"), // 26
new EPaperDisplay(280,480,0, "3.7 inch e-Paper"), // 27
new EPaperDisplay(152,296,0, "2.66 inch e-Paper"), // 28
new EPaperDisplay(648,480,1, "5.83 inch e-Paper (B) V2"), // 29
new EPaperDisplay(128,296,1, "2.9 inch e-Paper (B) V3"), // 30
new EPaperDisplay(200,200,1, "1.54 inch e-Paper (B) V2"), // 31
new EPaperDisplay(104,214,1, "2.13 inch e-Paper (B) V3"), // 32
new EPaperDisplay(128,296,0, "2.9 inch e-Paper V2"), // 33
new EPaperDisplay(400,300,1, "4.2 inch e-Paper (B) V2"), // 34
new EPaperDisplay(152,296,1, "2.66 inch e-Paper (B)"), // 35
new EPaperDisplay(648,480,0, "5.83 inch e-Paper V2"), // 36
new EPaperDisplay(640,400,7, "4.01 inch e-Paper (F)"), // 37
new EPaperDisplay(176,264,1, "2.7 inch e-Paper (B) V2"), // 38
new EPaperDisplay(122,250,0, "2.13 inch e-Paper V3"), // 39
new EPaperDisplay(122,250,1, "2.13 inch e-Paper (B) V4"), // 40
new EPaperDisplay(240,360,0, "3.52 inch e-Paper"), // 41
new EPaperDisplay(176,264,0, "2.7 inch e-Paper V2") // 42
};
}
return array;
}
}

@ -0,0 +1,224 @@
package com.waveshare.epaperesp32loader.image_processing;
import android.graphics.Bitmap;
import android.graphics.Color;
import com.waveshare.epaperesp32loader.AppStartActivity;
import com.waveshare.epaperesp32loader.DisplaysActivity;
/**
* <h1>Image filtering for e-Paper display</h1>
* The class is intended for pixel data converting
* from ARGB format to e-Paper display suitable format.
* The result of the pixel format's converting is an index
* of color in e-Paper dislay's palette
*
* @author Waveshare team
* @version 1.0
* @since 8/14/2018
*/
public class EPaperPicture
{
private static int srcW, srcH; // Width and height of source image
private static int dstW, dstH; // Width and height of destination image
private static Bitmap srcBmp; // Bitmap of source image
private static Bitmap dstBmp; // Bitmap of destination image
private static int[] curPal; // Current palette
private static int[][] palettes = new int[][] // Palettes
{
new int[] { Color.BLACK, Color.WHITE },
new int[] { Color.BLACK, Color.WHITE, Color.RED },
new int[] { Color.BLACK, Color.WHITE, Color.GRAY },
new int[] { Color.BLACK, Color.WHITE, Color.GRAY, Color.RED },
new int[] { Color.BLACK, Color.WHITE },
new int[] { Color.BLACK, Color.WHITE, Color.YELLOW },
new int[] {},
new int[] { 0xff000000, 0xffffffff, 0xff00ff00, 0xff0000ff, 0xffff0000, 0xffffff00,0xffff8000},
};
// Return the square error of {r, g, b},
// that means how far them are from standard color stdCol
//---------------------------------------------------------
private static double getErr(double r, double g, double b, int stdCol)
{
r -= Color.red (stdCol);
g -= Color.green(stdCol);
b -= Color.blue (stdCol);
return r*r + g*g + b*b;
}
// Return the index of current palette color which is
// nearest to the {r, g, b}
//---------------------------------------------------------
private static int getNear(double r, double g, double b)
{
int ind = 0;
double err = getErr(r, g, b, curPal[0]);
for (int i = 1; i < curPal.length; i++)
{
double cur = getErr(r, g, b, curPal[i]);
if (cur < err) { err = cur; ind = i; }
}
return ind;
}
// Return the index of current palette color which is
// nearest to the color clr
//---------------------------------------------------------
private static int getNear(int clr)
{
return getNear(Color.red(clr), Color.green(clr), Color.blue(clr));
}
// Adding of color {r, g, b} into e color array with
// weight k. Here every r, g or b channel takes one cell
// in e color array and can have any integer value.
//---------------------------------------------------------
private static void addVal(double[] e, int i, double r, double g, double b, double k)
{
int index = i * 3;
e[index ] = (r * k) / 16 + e[index ];
e[index + 1] = (g * k) / 16 + e[index + 1];
e[index + 2] = (b * k) / 16 + e[index + 2];
}
// Returns a color from the current palette
// which is nearest to source bitmap pixel at (x, y), or
// returns default color if (x, y) is out of the bitmap
//---------------------------------------------------------
private static int nearColor(int x, int y)
{
if ((x >= srcW) || (y >= srcH)) return curPal[(x + y) % 2 == 0 ? 1 : 0];
return curPal[getNear(srcBmp.getPixel(x, y))];
}
// Returns bitmap of pixels from current palette.
//
// isLvl = true - the method of searching the nearest color
// is based on estimation how less the original pixel
// differs from the palette's pixels.
//
// isLvl = false - the method of searching the nearest color
// is based on estimation how less the original pixel's area
// differs from the palette's pixels (so called dithering).
//---------------------------------------------------------
public static Bitmap createIndexedImage(boolean isLvl, boolean isRed)
{
EPaperDisplay epd = EPaperDisplay.getDisplays()[EPaperDisplay.epdInd];
srcBmp = AppStartActivity.originalImage;
dstBmp = Bitmap.createBitmap(epd.width, epd.height, srcBmp.getConfig());
int palInd = epd.index;
if (!isRed) palInd = palInd & 0xE;
curPal = palettes[palInd];
dstW = dstBmp.getWidth();
dstH = dstBmp.getHeight();
srcW = srcBmp.getWidth();
srcH = srcBmp.getHeight();
int[] srcArr = new int[srcW * srcH];
int[] dstArr = new int[dstW * dstH];
int index = 0;
srcBmp.getPixels(srcArr, 0, srcW, 0, 0, srcW, srcH);
if (isLvl)
{
for (int y = 0; y < dstH; y++)
for (int x = 0; x < dstW; x++)
dstArr[index++] = nearColor(x, y);
}
else
{
int aInd = 0;
int bInd = 1;
double[][] errArr = new double[2][];
errArr[0] = new double[3*dstW];
errArr[1] = new double[3*dstW];
for (int i = 0; i < dstW; i++)
{
errArr[bInd][3*i ] = 0;
errArr[bInd][3*i + 1] = 0;
errArr[bInd][3*i + 2] = 0;
}
for (int j = 0; j < dstH; j++)
{
if (j >= srcH)
{
for (int i = 0; i < dstW; i++, index++)
dstArr[index] = curPal[(i + j) % 2 == 0 ? 1 : 0];
continue;
}
aInd = ((bInd = aInd) + 1) & 1;
for (int i = 0; i < dstW; i++)
{
errArr[bInd][3*i ] = 0;
errArr[bInd][3*i + 1] = 0;
errArr[bInd][3*i + 2] = 0;
}
for (int i = 0; i < dstW; i++)
{
if (i >= srcW)
{
dstArr[index++] = curPal[(i + j) % 2 == 0 ? 1 : 0];
continue;
}
int srcPix = srcArr[j * srcW + i];
double r = Color.red (srcPix) + errArr[aInd][3*i ];
double g = Color.green(srcPix) + errArr[aInd][3*i + 1];
double b = Color.blue (srcPix) + errArr[aInd][3*i + 2];
int colVal = curPal[getNear(r, g, b)];
dstArr[index++] = colVal;
r -= Color.red (colVal);
g -= Color.green(colVal);
b -= Color.blue (colVal);
if (i == 0)
{
addVal(errArr[bInd], (i ), r, g, b, 7.0);
addVal(errArr[bInd], (i + 1), r, g, b, 2.0);
addVal(errArr[aInd], (i + 1), r, g, b, 7.0);
}
else if (i == dstW - 1)
{
addVal(errArr[bInd], (i - 1), r, g, b, 7.0);
addVal(errArr[bInd], (i ), r, g, b, 9.0);
}
else
{
addVal(errArr[bInd], (i - 1), r, g, b, 3.0);
addVal(errArr[bInd], (i ), r, g, b, 5.0);
addVal(errArr[bInd], (i + 1), r, g, b, 1.0);
addVal(errArr[aInd], (i + 1), r, g, b, 7.0);
}
}
}
}
// Put converted pixels into destination image bitmap
//-----------------------------------------------------
dstBmp.setPixels(dstArr, 0, dstW, 0, 0, dstW, dstH);
return dstBmp;
}
}

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
style="@style/mchV">
<Button
style="@style/btn"
android:text="@string/scan"
android:onClick="onScan"/>
<TextView
style="@style/txt"
android:id="@+id/text_blue"
android:textColor="#000000"
android:text="@string/no_blue"/>
<View
style="@style/sepL"/>
<Button
android:id= "@+id/Button_disp"
style="@style/btn"
android:text="@string/disp"
android:onClick="onDisplay"/>
<TextView
style="@style/txt"
android:id="@+id/text_disp"
android:textColor="#000000"
android:text="@string/no_disp"/>
<View
style="@style/sepL"/>
<Button
style="@style/btn"
android:id= "@+id/Button_file"
android:text="@string/file"
android:onClick="onLoad"/>
<TextView
style="@style/txt"
android:id="@+id/text_file"
android:textColor="#000000"
android:text="@string/no_pict"/>
<ImageView
style="@style/txt"
android:id="@+id/pict_file"
android:scaleType="fitCenter"/>
<View
style="@style/sepL"/>
<Button
style="@style/btn"
android:text="@string/filt"
android:onClick="onFilter"/>
<TextView
style="@style/txt"
android:id="@+id/text_filt"
android:textColor="#000000"
android:text="@string/no_filt"/>
<ImageView
style="@style/txt"
android:id="@+id/pict_filt" android:scaleType="fitCenter"/>
<View
style="@style/sepL"/>
<Button
style="@style/btn"
android:text="@string/upld"
android:onClick="onUpload"/>
<TextView
style="@style/txt"
android:id="@+id/text_send"
android:textColor="#000000"
android:text="@string/nothing"/>
</LinearLayout>
</ScrollView>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/displays_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"/>
<Button
android:text="Cancel"
android:onClick="onCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/displays_icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px"
android:src="@mipmap/ic_launcher" >
</ImageView>
<TextView
android:id="@+id/displays_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px" >
</TextView>
</LinearLayout>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout style="@style/wrpV" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/open_file_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@+id/open_file_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0" />
<LinearLayout style="@style/wrpH">
<Button style="@style/btn50" android:text="@string/btn_back" android:onClick="onBack" />
<Button style="@style/btn50" android:text="@string/btn_cncl" android:onClick="onCancel"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout style="@style/wrpV" xmlns:android="http://schemas.android.com/apk/res/android">
<Button
style="@style/btn"
android:id="@+id/btn_wb_l"
android:text="@string/txt_BlackAndWhiteL"
android:onClick="onWhiteAndBlackLevelClick"/>
<Button
style="@style/btn"
android:id="@+id/btn_wbrl"
android:text="@string/txt_BlackWhiteRedL"
android:onClick="onWhiteBlackRedLevelClick"/>
<Button
style="@style/btn"
android:id="@+id/btn_wb_d"
android:text="@string/txt_BlackAndWhiteD"
android:onClick="onWhiteAndBlackDitheringClick"/>
<Button
style="@style/btn"
android:id="@+id/btn_wbrd"
android:text="@string/txt_BlackWhiteRedD"
android:onClick="onWhiteBlackRedDitheringClick"/>
<TextView style="@style/txt" android:id="@+id/txt_indexed"/>
<ImageView style="@style/txt" android:id="@+id/img_indexed" android:scaleType="fitCenter"/>
<LinearLayout style="@style/btn" android:orientation="horizontal">
<Button style="@style/btn50" android:text="@string/btn_okey" android:onClick="onOk" />
<Button style="@style/btn50" android:text="@string/btn_cncl" android:onClick="onCancel"/>
</LinearLayout>
</LinearLayout>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/device_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>

@ -0,0 +1,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:text=""
android:id="@+id/bt_dev_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:textSize="20dp"
android:textColor="#0040FF"/>
<TextView
android:text=""
android:id="@+id/bt_dev_addr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:textSize="12dp"
android:textColor="#0040FF"/>
</LinearLayout>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="56dp"
android:minWidth="56dp">
<ProgressBar
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"/>
</FrameLayout>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/test_txt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/test_edt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:text="Send"
android:onClick="onSendClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/upload_text"
android:text="Uploading"
android:textColor="#000000"
android:textSize="30dp"
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.0"/>
<Button
android:text="@string/btn_back"
android:onClick="onCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_item_ring"
app:showAsAction="ifRoom"
android:title=""/>
<item
android:id="@+id/menu_item_scan"
app:showAsAction="ifRoom|withText"
android:title="SCAN"/>
<item
android:id="@+id/menu_item_stop"
app:showAsAction="ifRoom|withText"
android:title="STOP"/>
</menu>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save