Merge pull request #19 from g0blinResearch/papirus-support

Adding support for PaPiRus display
This commit is contained in:
evilsocket
2019-09-29 21:25:06 +02:00
committed by GitHub
4 changed files with 30 additions and 1 deletions

View File

@ -50,6 +50,7 @@ The supported models are:
- [Waveshare eInk Display (V2)](https://www.waveshare.com/2.13inch-e-paper-hat.htm) - [Waveshare eInk Display (V2)](https://www.waveshare.com/2.13inch-e-paper-hat.htm)
- [Pimoroni Inky pHAT](https://shop.pimoroni.com/products/inky-phat) - [Pimoroni Inky pHAT](https://shop.pimoroni.com/products/inky-phat)
- [PaPiRus eInk Screen](https://uk.pi-supply.com/products/papirus-zero-epaper-screen-phat-pi-zero)
### Software ### Software

View File

@ -94,7 +94,7 @@ ui:
display: display:
enabled: true enabled: true
rotation: 180 rotation: 180
# Possible options inkyphat/inky or waveshare/ws # Possible options inkyphat/inky, papirus/papi or waveshare/ws
type: 'waveshare_2' type: 'waveshare_2'
# Possible options red/yellow/black (black used for monocromatic displays) # Possible options red/yellow/black (black used for monocromatic displays)
color: 'black' color: 'black'

View File

@ -3,6 +3,7 @@ from threading import Lock
import io import io
import core import core
import os
import pwnagotchi import pwnagotchi
from pwnagotchi.ui.view import WHITE, View from pwnagotchi.ui.view import WHITE, View
@ -107,6 +108,9 @@ class Display(View):
def _is_inky(self): def _is_inky(self):
return self._display_type in ('inkyphat', 'inky') return self._display_type in ('inkyphat', 'inky')
def _is_papirus(self):
return self._display_type in ('papirus', 'papi')
def _is_waveshare1(self): def _is_waveshare1(self):
return self._display_type in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1') return self._display_type in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1')
@ -119,6 +123,14 @@ class Display(View):
self._display = InkyPHAT(self._display_color) self._display = InkyPHAT(self._display_color)
self._display.set_border(InkyPHAT.BLACK) self._display.set_border(InkyPHAT.BLACK)
self._render_cb = self._inky_render self._render_cb = self._inky_render
elif self._is_papirus():
from papirus import Papirus
os.environ['EPD_SIZE'] = '2.0'
self._display = Papirus()
self._display.clear()
self._render_cb = self._papirus_render
elif self._is_waveshare1(): elif self._is_waveshare1():
from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD
# core.log("display module started") # core.log("display module started")
@ -127,6 +139,7 @@ class Display(View):
self._display.Clear(0xFF) self._display.Clear(0xFF)
self._display.init(self._display.lut_partial_update) self._display.init(self._display.lut_partial_update)
self._render_cb = self._waveshare_render self._render_cb = self._waveshare_render
elif self._is_waveshare2(): elif self._is_waveshare2():
from pwnagotchi.ui.waveshare.v2.waveshare import EPD from pwnagotchi.ui.waveshare.v2.waveshare import EPD
# core.log("display module started") # core.log("display module started")
@ -135,6 +148,7 @@ class Display(View):
self._display.Clear(WHITE) self._display.Clear(WHITE)
self._display.init(self._display.PART_UPDATE) self._display.init(self._display.PART_UPDATE)
self._render_cb = self._waveshare_render self._render_cb = self._waveshare_render
else: else:
core.log("unknown display type %s" % self._display_type) core.log("unknown display type %s" % self._display_type)
@ -177,6 +191,10 @@ class Display(View):
self._display.set_image(imgbuf) self._display.set_image(imgbuf)
self._display.show() self._display.show()
def _papirus_render(self):
self._display.display(self.canvas)
self._display.partial_update()
def _waveshare_render(self): def _waveshare_render(self):
buf = self._display.getbuffer(self.canvas) buf = self._display.getbuffer(self.canvas)
if self._is_waveshare1: if self._is_waveshare1:

View File

@ -31,6 +31,16 @@ def setup_display_specifics(config):
face_pos = (0, int(height / 4)) face_pos = (0, int(height / 4))
name_pos = (int(width / 2) - 15, int(height * .15)) name_pos = (int(width / 2) - 15, int(height * .15))
status_pos = (int(width / 2) - 15, int(height * .30)) 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_1', 'ws1', 'waveshare_1', 'waveshare1', elif config['ui']['display']['type'] in ('ws_1', 'ws1', 'waveshare_1', 'waveshare1',
'ws_2', 'ws2', 'waveshare_2', 'waveshare2'): 'ws_2', 'ws2', 'waveshare_2', 'waveshare2'):
fonts.setup(10, 9, 10, 35) fonts.setup(10, 9, 10, 35)