From 395207de7b215a664d8b0995c3cb250137cbd805 Mon Sep 17 00:00:00 2001 From: James Hooker Date: Sun, 29 Sep 2019 06:23:38 +0100 Subject: [PATCH 1/3] Adding support for PaPiRus display --- README.md | 1 + sdcard/rootfs/root/pwnagotchi/config.yml | 2 +- .../pwnagotchi/scripts/pwnagotchi/ui/display.py | 13 +++++++++++++ .../root/pwnagotchi/scripts/pwnagotchi/ui/view.py | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf7fa3b9..589c4aef 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ The supported models are: - [Waveshare eInk Display (V2)](https://www.waveshare.com/2.13inch-e-paper-hat.htm) - [Pimoroni Inky pHAT](https://shop.pimoroni.com/products/inky-phat) +- [PaPiRus eInk Screen](https://www.sparkfun.com/products/14826) ### Software diff --git a/sdcard/rootfs/root/pwnagotchi/config.yml b/sdcard/rootfs/root/pwnagotchi/config.yml index e151e63f..9a2a1463 100644 --- a/sdcard/rootfs/root/pwnagotchi/config.yml +++ b/sdcard/rootfs/root/pwnagotchi/config.yml @@ -92,7 +92,7 @@ ui: display: enabled: true rotation: 180 - # Possible options inkyphat/inky or waveshare/ws + # Possible options inkyphat/inky, papirus/papi or waveshare/ws type: 'waveshare' # Possible options red/yellow/black (black used for monocromatic displays) color: 'black' diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py index 6d821a73..55621417 100644 --- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py @@ -104,6 +104,9 @@ class Display(View): def _is_inky(self): return self._display_type in ('inkyphat', 'inky') + def _is_papirus(self): + return self._display_type in ('papirus', 'papi') + def _is_waveshare(self): return self._display_type in ('waveshare', 'ws') @@ -113,6 +116,12 @@ class Display(View): self._display = InkyPHAT(self._display_color) self._display.set_border(InkyPHAT.BLACK) self._render_cb = self._inky_render + elif self._is_papirus(): + from papirus import Papirus + exec(open('/etc/default/epd-fuse').read()) + self._display = Papirus() + self._display.clear() + self._render_cb = self._papirus_render elif self._is_waveshare(): from pwnagotchi.ui.waveshare import EPD # core.log("display module started") @@ -163,6 +172,10 @@ class Display(View): self._display.set_image(imgbuf) self._display.show() + def _papirus_render(self): + self._display.display(self.canvas) + self._display.partial_update() + def _waveshare_render(self): buf = self._display.getbuffer(self.canvas) self._display.displayPartial(buf) diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py index 1c49562a..a9606429 100644 --- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py @@ -31,6 +31,14 @@ def setup_display_specifics(config): face_pos = (0, int(height / 4)) name_pos = (int(width / 2) - 15, int(height * .15)) status_pos = (int(width / 2) - 15, int(height * .30)) + elif config['ui']['display']['type'] in ('papirus', 'papi'): + fonts.setup(10, 8, 10, 23) + + width = 200 + height = 96 + face_pos = (0, int(height / 4)) + name_pos = (int(width / 2) - 15, int(height * .15)) + status_pos = (int(width / 2) - 15, int(height * .30)) elif config['ui']['display']['type'] in ('ws', 'waveshare'): fonts.setup(10, 9, 10, 35) From 29a1db106ae13ec0f8b55ed94aa25e0028dc3a11 Mon Sep 17 00:00:00 2001 From: James Hooker Date: Sun, 29 Sep 2019 06:32:16 +0100 Subject: [PATCH 2/3] Remove need to evaluate epd fuse file --- sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py index 55621417..c1d71e7a 100644 --- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py +++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py @@ -3,6 +3,7 @@ from threading import Lock import io import core +import os import pwnagotchi from pwnagotchi.ui.view import WHITE, View @@ -118,7 +119,7 @@ class Display(View): self._render_cb = self._inky_render elif self._is_papirus(): from papirus import Papirus - exec(open('/etc/default/epd-fuse').read()) + os.environ['EPD_SIZE'] = '2.0' self._display = Papirus() self._display.clear() self._render_cb = self._papirus_render From e4f8c962728f922d405e77f453fdc6b34a8b33ea Mon Sep 17 00:00:00 2001 From: James Hooker Date: Sun, 29 Sep 2019 06:38:24 +0100 Subject: [PATCH 3/3] Correcting original supplier URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 589c4aef..ff8a934c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The supported models are: - [Waveshare eInk Display (V2)](https://www.waveshare.com/2.13inch-e-paper-hat.htm) - [Pimoroni Inky pHAT](https://shop.pimoroni.com/products/inky-phat) -- [PaPiRus eInk Screen](https://www.sparkfun.com/products/14826) +- [PaPiRus eInk Screen](https://uk.pi-supply.com/products/papirus-zero-epaper-screen-phat-pi-zero) ### Software