mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Added DummyDisplay for arbitrary screen size when headless
This commit is contained in:
@ -193,6 +193,9 @@ class Display(View):
|
|||||||
def is_inky(self):
|
def is_inky(self):
|
||||||
return self._implementation.name == 'inky'
|
return self._implementation.name == 'inky'
|
||||||
|
|
||||||
|
def is_dummy_display(self):
|
||||||
|
return self._implementation.name == 'dummydisplay'
|
||||||
|
|
||||||
def is_papirus(self):
|
def is_papirus(self):
|
||||||
return self._implementation.name == 'papirus'
|
return self._implementation.name == 'papirus'
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from pwnagotchi.ui.hw.inky import Inky
|
from pwnagotchi.ui.hw.inky import Inky
|
||||||
|
from pwnagotchi.ui.hw.dummydisplay import DummyDisplay
|
||||||
from pwnagotchi.ui.hw.papirus import Papirus
|
from pwnagotchi.ui.hw.papirus import Papirus
|
||||||
from pwnagotchi.ui.hw.oledhat import OledHat
|
from pwnagotchi.ui.hw.oledhat import OledHat
|
||||||
from pwnagotchi.ui.hw.lcdhat import LcdHat
|
from pwnagotchi.ui.hw.lcdhat import LcdHat
|
||||||
@ -69,6 +70,9 @@ def display_for(config):
|
|||||||
if config['ui']['display']['type'] == 'inky':
|
if config['ui']['display']['type'] == 'inky':
|
||||||
return Inky(config)
|
return Inky(config)
|
||||||
|
|
||||||
|
elif config['ui']['display']['type'] == 'dummydisplay':
|
||||||
|
return DummyDisplay(config)
|
||||||
|
|
||||||
elif config['ui']['display']['type'] == 'papirus':
|
elif config['ui']['display']['type'] == 'papirus':
|
||||||
return Papirus(config)
|
return Papirus(config)
|
||||||
|
|
||||||
|
43
pwnagotchi/ui/hw/dummydisplay.py
Normal file
43
pwnagotchi/ui/hw/dummydisplay.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import pwnagotchi.ui.fonts as fonts
|
||||||
|
from pwnagotchi.ui.hw.base import DisplayImpl
|
||||||
|
|
||||||
|
|
||||||
|
class DummyDisplay(DisplayImpl):
|
||||||
|
def __init__(self, config):
|
||||||
|
super(DummyDisplay, self).__init__(config, 'inky')
|
||||||
|
|
||||||
|
def layout(self):
|
||||||
|
width=480 if 'width' not in self.config else self.config['width']
|
||||||
|
height=720 if 'height' not in self.config else self.config['height']
|
||||||
|
fonts.setup(int(height/30), int(height/40), int(height/30), int(height/6), int(height/30), int(height/35))
|
||||||
|
self._layout['width'] = width
|
||||||
|
self._layout['height'] = height
|
||||||
|
self._layout['face'] = (0, int(width/12))
|
||||||
|
self._layout['name'] = (5, int(width/25))
|
||||||
|
self._layout['channel'] = (0, 0)
|
||||||
|
self._layout['aps'] = (int(width/8), 0)
|
||||||
|
self._layout['uptime'] = (width-int(width/12), 0)
|
||||||
|
self._layout['line1'] = [0, int(height/32), width, int(height/32)]
|
||||||
|
self._layout['line2'] = [0, height-int(height/25)-1, width, height-int(height/25)-1]
|
||||||
|
self._layout['friend_face'] = (0, int(height/10))
|
||||||
|
self._layout['friend_name'] = (int(width/12), int(height/10))
|
||||||
|
self._layout['shakes'] = (0, height-int(height/25))
|
||||||
|
self._layout['mode'] = (width-int(width/8), height - int (height/25))
|
||||||
|
lw, lh = fonts.Small.getsize("W")
|
||||||
|
self._layout['status'] = {
|
||||||
|
'pos': (int(width/48), int(height/3)),
|
||||||
|
'font': fonts.status_font(fonts.Small),
|
||||||
|
'max': int(width / lw)
|
||||||
|
}
|
||||||
|
return self._layout
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
def render(self, canvas):
|
||||||
|
return
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
return
|
@ -240,6 +240,8 @@ def load_config(args):
|
|||||||
# the very first step is to normalize the display name, so we don't need dozens of if/elif around
|
# the very first step is to normalize the display name, so we don't need dozens of if/elif around
|
||||||
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
||||||
config['ui']['display']['type'] = 'inky'
|
config['ui']['display']['type'] = 'inky'
|
||||||
|
elif config['ui']['display']['type'] in ('dummy', 'dummydisplay'):
|
||||||
|
config['ui']['display']['type'] = 'dummydisplay'
|
||||||
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
||||||
config['ui']['display']['type'] = 'papirus'
|
config['ui']['display']['type'] = 'papirus'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user