From f0c5ad4b74a0461757f0bf5984a36ca6754b6f77 Mon Sep 17 00:00:00 2001 From: Dispsylala Date: Sun, 13 Oct 2019 17:18:27 +0100 Subject: [PATCH 1/2] Overrides default inky library to change timings on black rendering --- pwnagotchi/ui/display.py | 6 +++--- pwnagotchi/ui/inkyphat/__init__.py | 0 pwnagotchi/ui/inkyphat/inkyfast.py | 23 ++++++++++++++++++++++ pwnagotchi/ui/inkyphat/inkyphatfast.py | 27 ++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 pwnagotchi/ui/inkyphat/__init__.py create mode 100644 pwnagotchi/ui/inkyphat/inkyfast.py create mode 100644 pwnagotchi/ui/inkyphat/inkyphatfast.py diff --git a/pwnagotchi/ui/display.py b/pwnagotchi/ui/display.py index ff7ee5e..065dbd8 100644 --- a/pwnagotchi/ui/display.py +++ b/pwnagotchi/ui/display.py @@ -136,9 +136,9 @@ class Display(View): def _init_display(self): if self.is_inky(): logging.info("initializing inky display") - from inky import InkyPHAT - self._display = InkyPHAT(self._display_color) - self._display.set_border(InkyPHAT.BLACK) + from pwnagotchi.ui.inkyphat.inkyphatfast import InkyPHATFast + self._display = InkyPHATFast(self._display_color) + self._display.set_border(InkyPHATFast.BLACK) self._render_cb = self._inky_render elif self.is_papirus(): diff --git a/pwnagotchi/ui/inkyphat/__init__.py b/pwnagotchi/ui/inkyphat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pwnagotchi/ui/inkyphat/inkyfast.py b/pwnagotchi/ui/inkyphat/inkyfast.py new file mode 100644 index 0000000..bdbd3ec --- /dev/null +++ b/pwnagotchi/ui/inkyphat/inkyfast.py @@ -0,0 +1,23 @@ +from inky.inky import Inky, CS0_PIN, DC_PIN, RESET_PIN, BUSY_PIN + + +class InkyFast(Inky): + + def __init__(self, resolution=(400, 300), colour='black', cs_pin=CS0_PIN, dc_pin=DC_PIN, reset_pin=RESET_PIN, + busy_pin=BUSY_PIN, h_flip=False, v_flip=False): + super(InkyFast, self).__init__(resolution, colour, cs_pin, dc_pin, reset_pin, busy_pin, h_flip, v_flip) + + self._luts['black'] = [ + 0b01001000, 0b10100000, 0b00010000, 0b00010000, 0b00010011, 0b00000000, 0b00000000, + 0b01001000, 0b10100000, 0b10000000, 0b00000000, 0b00000011, 0b00000000, 0b00000000, + 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0b01001000, 0b10100101, 0b00000000, 0b10111011, 0b00000000, 0b00000000, 0b00000000, + 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, + 0x04, 0x04, 0x04, 0x04, 0x04, + 0x10, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x08, 0x08, 0x10, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + ] \ No newline at end of file diff --git a/pwnagotchi/ui/inkyphat/inkyphatfast.py b/pwnagotchi/ui/inkyphat/inkyphatfast.py new file mode 100644 index 0000000..e39433b --- /dev/null +++ b/pwnagotchi/ui/inkyphat/inkyphatfast.py @@ -0,0 +1,27 @@ +"""Inky pHAT e-Ink Display Driver.""" +from . import inkyfast + + +class InkyPHATFast(inkyfast.InkyFast): + """Inky wHAT e-Ink Display Driver.""" + + WIDTH = 212 + HEIGHT = 104 + + WHITE = 0 + BLACK = 1 + RED = 2 + YELLOW = 2 + + def __init__(self, colour): + """Initialise an Inky pHAT Display. + + :param colour: one of red, black or yellow, default: black + + """ + inkyfast.InkyFast.__init__( + self, + resolution=(self.WIDTH, self.HEIGHT), + colour=colour, + h_flip=False, + v_flip=False) \ No newline at end of file From e9899dda94b7015af0204552e6a5d862a4bbf651 Mon Sep 17 00:00:00 2001 From: Dispsylala Date: Sun, 13 Oct 2019 17:40:58 +0100 Subject: [PATCH 2/2] Overrides default inky library to change timings on black rendering --- pwnagotchi/ui/inkyphat/inkyfast.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/ui/inkyphat/inkyfast.py b/pwnagotchi/ui/inkyphat/inkyfast.py index bdbd3ec..955e8e6 100644 --- a/pwnagotchi/ui/inkyphat/inkyfast.py +++ b/pwnagotchi/ui/inkyphat/inkyfast.py @@ -13,7 +13,8 @@ class InkyFast(Inky): 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01001000, 0b10100101, 0b00000000, 0b10111011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, - 0x04, 0x04, 0x04, 0x04, 0x04, + # The following timings have been reduced to avoid the fade to black + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,