I've hacked something together that's good enough for now. I can go forward with a single press and back with double press (I keep long press reserved for other functionality). Going back is a bit awkward though, since waking from deep sleep is slow and you need to time the presses properly for it to register (I'd say ~1/3s press, ~1/3 release then 1/3 press again).
The documentation is atrocious. They seem to have nuked their previous documentation and replaced it with something that's blatantly incomplete. I wouldn't be surprised if it's partially "AI" generated. Their own README's have a bunch of links that are dead. e.g.:
>We support peripheral mode over UART! The commands are listed here [dead link]
Amazing...
The examples are better, though still nonsensical in a lot of places. e.g. the example that loads from HTTP manually does a lot of manual work, including pointless double buffering on the stack, while making no mention they provide a downloadFile function.
You need to be careful with having both WiFi turned on and drawing to the display. It seems a brownout occurs and the MCU resets because both the display and the WiFi slurp a lot of power. Digging through the provided library I see that WiFi gets taken out of sleep at the start downloadFile, then back to sleep if it was (and not if it wasn't). I just put the WiFi immediately to sleep right after connecting which is stupid but an easy hack.
Loading PNG images is very slow. I first thought something was wrong with their HTTPClient since I could see the request in the log, yet needed to wait multiple seconds for the image to appear. However, it takes multiple seconds to load an image from SD card too. Poorly optimized PNG decoder I guess?
FWIW I found that with 3-bit grayscale PNG compresses significantly better than JPEG. Yet, most images hover around 200KiB, while 1200*825*3/8=371250 bytes if you were to use raw bits to store the image. It probably makes sense to use a custom format with lightweight compression on top.
In any case, here's the code I cobbled together. I plan to make something more advanced, where the Inkplate is basically a dumb terminal for my desktop PC, but I'm not going to use arduino-cli for it since I find Arduino wrappers to be shit. Too bad the Inkplate library is specifically designed for "Arduino IDE". By the way, I did find e-reader software https://github.com/turgu1/EPub-InkPlate but I don't seem able to convert from PDF to EPUB properly, hence why I just convert to images and display that. For now this suffices.
(python3 -m http.server is pretty useful)
A very simple program to fetch and display images from a server on an e-paper
device. Most useful with books converted to PNG/JPEG images.
First install dependencies (adjust for distro as needed):
apk add bash libc6-compat python3 py3-pyserial
Also get [Arduino CLI][arduino-cli]. Then:
arduino-cli lib install InkplateLibrary
arduino-cli core install Inkplate_Boards:esp32
arduino-cli compile -b Inkplate_Boards:esp32:Inkplate10V2
Make sure the board is turned on (blue LED). Install with:
arduino-cli upload -p /dev/ttyUSB0 -b Inkplate_Boards:esp32:Inkplate10
Install ImageMagick. Then:
convert -density 212 /path/to/input.pdf -dither FloydSteinberg -quality 80 -resize 1200x825 -colorspace Gray -colors 8 %05d.png
#include <Inkplate.h>
#include <WiFi.h>
#include <esp_wifi.h>
#include "config.h"
static const gpio_num_t WAKE_BUTTON = GPIO_NUM_36;
RTC_DATA_ATTR static uint16_t page_idx = -1;
static char path[512];
static Inkplate display(INKPLATE_3BIT);
void wifi_connect(void) {
display.connectWiFi(WIFI_SSID, WIFI_PASSWORD, 10, false);
WiFi.setSleep(true);
}
void wifi_wait(void) {
return;
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
}
void load_image() {
snprintf(path, sizeof path - 1, HTTP_URL_BASE"/%03d.png", page_idx);
path[sizeof path - 1] = 0;
if (!display.drawImage(path, 0, 0, false)) {
display.println(path);
display.println("Image open error");
}
display.display();
}
_Noreturn void deep_sleep(void) {
esp_sleep_enable_ext0_wakeup(WAKE_BUTTON, LOW);
esp_deep_sleep_start();
}
bool detect_second_press() {
delay(10);
int timeout = 49;
bool was_on = true;
while (timeout-- > 0) {
bool is_on = !digitalRead(WAKE_BUTTON);
if (is_on && !was_on)
return true;
was_on = is_on;
delay(10);
}
return false;
}
void setup() {
display.begin();
display.setRotation(1);
display.clearDisplay();
display.setTextColor(BLACK);
display.setCursor(10,10);
display.setTextSize(3);
if (detect_second_press())
page_idx--;
else
page_idx++;
if (display.sdCardInit()) {
load_image();
} else {
display.println("SD card init failed");
display.display();
}
deep_sleep();
}
void loop() {
}
#pragma once
#define WIFI_SSID "name"
#define WIFI_PASSWORD "password"
#define HTTP_URL_BASE "/images"
Oh, they claim the Inkplate 10 is "not suitable as e-reader". Deceptive marketing?