diff --git a/pwnagotchi/ui/display.py b/pwnagotchi/ui/display.py index 186030f..b4eb2c6 100644 --- a/pwnagotchi/ui/display.py +++ b/pwnagotchi/ui/display.py @@ -67,6 +67,9 @@ class Display(View): def is_waveshare213bc(self): return self._implementation.name == 'waveshare213bc' + def is_waveshare35lcd(self): + return self._implementation.name == 'waveshare35lcd' + def is_spotpear24inch(self): return self._implementation.name == 'spotpear24inch' diff --git a/pwnagotchi/ui/hw/__init__.py b/pwnagotchi/ui/hw/__init__.py index eb927dc..2ef7dce 100644 --- a/pwnagotchi/ui/hw/__init__.py +++ b/pwnagotchi/ui/hw/__init__.py @@ -12,6 +12,7 @@ from pwnagotchi.ui.hw.waveshare144lcd import Waveshare144lcd from pwnagotchi.ui.hw.waveshare154inch import Waveshare154inch from pwnagotchi.ui.hw.waveshare213d import Waveshare213d from pwnagotchi.ui.hw.waveshare213bc import Waveshare213bc +from pwnagotchi.ui.hw.waveshare35lcd import Waveshare35lcd from pwnagotchi.ui.hw.spotpear24inch import Spotpear24inch def display_for(config): @@ -58,5 +59,8 @@ def display_for(config): elif config['ui']['display']['type'] == 'waveshare213bc': return Waveshare213bc(config) + elif config['ui']['display']['type'] == 'waveshare35lcd': + return Waveshare35lcd(config) + elif config['ui']['display']['type'] == 'spotpear24inch': return Spotpear24inch(config) diff --git a/pwnagotchi/ui/hw/waveshare35lcd.py b/pwnagotchi/ui/hw/waveshare35lcd.py new file mode 100644 index 0000000..97011b3 --- /dev/null +++ b/pwnagotchi/ui/hw/waveshare35lcd.py @@ -0,0 +1,52 @@ +import logging + +import pwnagotchi.ui.fonts as fonts +from pwnagotchi.ui.hw.base import DisplayImpl + +import os,time + +class Waveshare35lcd(DisplayImpl): + def __init__(self, config): + super(Waveshare35lcd, self).__init__(config, 'waveshare35lcd') + self._display = None + + def layout(self): + fonts.setup(12, 10, 12, 70, 25, 9) + self._layout['width'] = 480 + self._layout['height'] = 320 + self._layout['face'] = (110, 60) + self._layout['name'] = (10, 30) + self._layout['channel'] = (0, 0) + self._layout['aps'] = (80, 0) + self._layout['uptime'] = (400, 0) + self._layout['line1'] = [0, 14, 480, 14] + self._layout['line2'] = [0,300, 480, 300] + self._layout['friend_face'] = (0, 220) + self._layout['friend_name'] = (50, 225) + self._layout['shakes'] = (10, 300) + self._layout['mode'] = (440, 300) + self._layout['status'] = { + 'pos': (80, 180), + 'font': fonts.status_font(fonts.Medium), + 'max': 100 + } + + return self._layout + + def refresh(self): + time.sleep(0.1) + + def initialize(self): + from pwnagotchi.ui.hw.libs.fb import fb + self._display = fb + logging.info("initializing waveshare 3,5inch lcd display") + self._display.ready_fb(i=1) + self._display.black_scr() + + def render(self, canvas): + self._display.show_img(canvas.rotate(0)) + self.refresh() + + def clear(self): + self._display.black_scr() + self.refresh() diff --git a/pwnagotchi/utils.py b/pwnagotchi/utils.py index a142e44..b91659b 100644 --- a/pwnagotchi/utils.py +++ b/pwnagotchi/utils.py @@ -275,6 +275,9 @@ def load_config(args): elif config['ui']['display']['type'] in ('ws_213bc', 'ws213bc', 'waveshare_213bc', 'waveshare213bc'): config['ui']['display']['type'] = 'waveshare213bc' + elif config['ui']['display']['type'] in ('waveshare35lcd'): + config['ui']['display']['type'] = 'waveshare35lcd' + elif config['ui']['display']['type'] in ('spotpear24inch'): config['ui']['display']['type'] = 'spotpear24inch'