-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b78c834
commit 543c787
Showing
6 changed files
with
97 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# rpi-epaper-api | ||
|
||
A rest API for setting the display image on a [Waveshare 4.26](https://www.waveshare.com/4.26inch-e-paper-hat.htm) | ||
A rest API for setting the display image on a [Waveshare 4.26"](https://www.waveshare.com/4.26inch-e-paper-hat.htm) | ||
eink HAT connected to a Raspberry Pi. Supports scaling and rotating the input image. Endpoints are also provided for | ||
fetching display contents and clearing the display. | ||
|
||
|
@@ -20,7 +20,7 @@ Build and run the container: | |
```commandline | ||
git clone https://github.com/adriankeenan/rpi-epaper-api.git | ||
docker build -t rpi-eink-api . | ||
docker run -p 5000:5000 rpi-eink-api --restart=always --privileged | ||
docker run -p 5000:5000 --restart=always --privileged rpi-eink-api | ||
``` | ||
|
||
Now you're ready to send images to the display! | ||
|
@@ -31,31 +31,38 @@ Now you're ready to send images to the display! | |
|
||
`POST http://rpi:5000` | ||
|
||
Set image from file | ||
```commandline | ||
curl --form [email protected] --form resize=FIT --form background=WHITE http://rpi:5000 | jq | ||
curl --form [email protected] --form resize=FIT --form background=WHITE http://rpi:5000 | ||
``` | ||
|
||
Set image from pipe | ||
```commandline | ||
cat image.jpg | curl --form image=@- --form resize=FIT --form background=WHITE http://rpi:5000 | ||
``` | ||
|
||
|
||
Data should be sent form-encoded. | ||
|
||
| Field | Description | Default | Required | | ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|----------| | ||
| `image` | Image file to display. Any image type supported by the Python PIL library should work. | No | Yes | | ||
| `resize` | `FIT` Resize keeping aspect ratio, without cropping<br>`CROP` Resize keeping aspect ratio, with cropping<br>`STRETCH` fill display, ignoring aspect ratio<br>`NONE` Display without any scaling, pixels drawn 1:1. | `FIT` | No | | ||
| `rotate` | Number of degrees to rotate counter-clockwise, supports increments of 90 degrees. | 0 | No | | ||
| `background` | Background colour to use if the image doesn't fill the display. Either `WHITE` or `BLACK`. | `WHITE` | No | | ||
| Field | Description | Default | Required | | ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|----------| | ||
| `image` | Image file to display. Any image type supported by the Python PIL library should work. | N/A | Yes | | ||
| `mode` | Display mode, corresponding to the `display_XXX` method on the `epd` object.<br>`FAST` - uses `display_Fast` for a complete screen refresh.<br>`PARTIAL` - uses `display_Partial` for incremental updates (which may cause ghosting). | `FAST` | No | | ||
| `dither` | Whether to enable dithering when converting image to mono chromatic. `true` or `1` to enable. | `true` | No | | ||
| `resize` | `FIT` Resize keeping aspect ratio, without cropping.<br>`CROP` Resize keeping aspect ratio, with cropping.<br>`STRETCH` fill display, ignoring aspect ratio.<br>`NONE` Display without any scaling, pixels drawn 1:1. | `FIT` | No | | ||
| `rotate` | Number of degrees to rotate counter-clockwise, supports increments of 90 degrees. | `0` | No | | ||
| `background` | Background colour to use if the image doesn't fill the display. Either `WHITE` or `BLACK`. | `WHITE` | No | | ||
|
||
Expect this call to take ~9 seconds. | ||
Expect this call to take ~5 seconds. | ||
|
||
Display update will be skipped if the resulting image is the same as the last request (see `updated` field in the response). | ||
|
||
This endpoint only supports a single concurrent call in order to prevent simultaneous instructions being sent to the hardware. | ||
|
||
### Fetching the current image | ||
|
||
`GET http://rpi:5000` | ||
|
||
```commandline | ||
curl http://rpi:5000/img.png | ||
curl http://rpi:5000 -o img.png | ||
``` | ||
|
||
Returns the last image (as PNG) that was successfully sent to the display. This is the exact framebuffer sent to the device (eg post-scaling). | ||
|
@@ -79,8 +86,6 @@ Reverts all pixels to the off (white) state. | |
|
||
- Although this is project is intended only for the 4.26" e-paper display, it's likely that other displays can be supported | ||
by changing the imported EDP object. | ||
- It should be possible to update only part of the display if you are sending images where only a small amount of content changes | ||
each time. Currently, only clearing and refreshing the entire display is supported. | ||
|
||
# License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ rpi.gpio | |
spidev | ||
gpiozero | ||
Flask~=3.0.3 | ||
filelock~=3.15.4 | ||
pillow~=10.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters