minor refactoring of multi display code

This commit is contained in:
Simone Margaritelli 2019-09-28 19:24:28 +02:00
parent af6dc69248
commit ddff8d4ef4
3 changed files with 11 additions and 57 deletions

View File

@ -90,12 +90,12 @@ ui:
# ePaper display can update every 3 secs anyway
fps: 0.3
display:
# Possible options inkyphat/waveshare
type: 'inkyphat'
# Possible options red/yellow/black (black used for monocromatic displays)
display_color: 'red'
enabled: true
rotation: 180
# Possible options inkyphat/inky or waveshare/ws
type: 'ws'
# Possible options red/yellow/black (black used for monocromatic displays)
color: 'black'
video:
enabled: true
address: '10.0.0.2'

View File

@ -78,7 +78,7 @@ class Display(View):
self._video_port = config['ui']['display']['video']['port']
self._video_address = config['ui']['display']['video']['address']
self._display_type = config['ui']['display']['type']
self._display_color = config['ui']['display']['display_color']
self._display_color = config['ui']['display']['color']
self._display = None
self._httpd = None
self.canvas = None
@ -101,20 +101,24 @@ class Display(View):
core.log("could not get ip of usb0, video server not starting")
def _init_display(self):
if self._display_type == 'inkyphat':
if self._display_type in ('inkyphat', 'inky'):
from inky import InkyPHAT
self._display = InkyPHAT(self._display_color)
self._display.set_border(InkyPHAT.BLACK)
else:
elif self._display_type in ('waveshare', 'ws'):
from pwnagotchi.ui.waveshare import EPD
# core.log("display module started")
self._display = EPD()
self._display.init(self._display.FULL_UPDATE)
self._display.Clear(WHITE)
self._display.init(self._display.PART_UPDATE)
else:
core.log("unknown display type %s" % self._display_type)
self.on_render(self._on_view_rendered)
core.log("display type '%s' initialized (color:%s)" % (self._display_type, self._display_color))
def image(self):
img = None
if self.canvas is not None:

View File

@ -247,56 +247,6 @@ class View(object):
self.update()
def update(self):
"""
ncalls tottime percall cumtime percall filename:lineno(function)
19 0.001 0.000 0.007 0.000 Image.py:1137(copy)
19 0.001 0.000 0.069 0.004 Image.py:1894(rotate)
19 0.001 0.000 0.068 0.004 Image.py:2388(transpose)
1 0.000 0.000 0.000 0.000 Image.py:2432(ImagePointHandler)
1 0.000 0.000 0.000 0.000 Image.py:2437(ImageTransformHandler)
19 0.001 0.000 0.001 0.000 Image.py:2455(_check_size)
19 0.002 0.000 0.010 0.001 Image.py:2473(new)
1 0.002 0.002 0.127 0.127 Image.py:30(<module>)
1 0.000 0.000 0.001 0.001 Image.py:3103(_apply_env_variables)
1 0.000 0.000 0.000 0.000 Image.py:3139(Exif)
1 0.000 0.000 0.000 0.000 Image.py:495(_E)
1 0.000 0.000 0.000 0.000 Image.py:536(Image)
76 0.003 0.000 0.003 0.000 Image.py:552(__init__)
19 0.000 0.000 0.000 0.000 Image.py:572(size)
57 0.004 0.000 0.006 0.000 Image.py:576(_new)
76 0.001 0.000 0.002 0.000 Image.py:595(__exit__)
76 0.001 0.000 0.003 0.000 Image.py:633(__del__)
1 0.000 0.000 0.000 0.000 Image.py:71(DecompressionBombWarning)
1 0.000 0.000 0.000 0.000 Image.py:75(DecompressionBombError)
1 0.000 0.000 0.000 0.000 Image.py:79(_imaging_not_installed)
95 0.002 0.000 0.014 0.000 Image.py:842(load)
19 0.001 0.000 0.008 0.000 Image.py:892(convert)
1 0.000 0.000 0.000 0.000 ImageColor.py:20(<module>)
297 0.012 0.000 0.042 0.000 ImageDraw.py:101(_getink)
38 0.001 0.000 0.026 0.001 ImageDraw.py:153(line)
295 0.005 0.000 0.007 0.000 ImageDraw.py:252(_multiline_check)
8 0.000 0.000 0.001 0.000 ImageDraw.py:258(_multiline_split)
267/247 0.033 0.000 1.741 0.007 ImageDraw.py:263(text)
8 0.003 0.000 0.237 0.030 ImageDraw.py:282(multiline_text)
28 0.001 0.000 0.064 0.002 ImageDraw.py:328(textsize)
1 0.000 0.000 0.008 0.008 ImageDraw.py:33(<module>)
19 0.002 0.000 0.006 0.000 ImageDraw.py:355(Draw)
1 0.000 0.000 0.000 0.000 ImageDraw.py:47(ImageDraw)
19 0.002 0.000 0.004 0.000 ImageDraw.py:48(__init__)
1 0.000 0.000 0.000 0.000 ImageFont.py:123(FreeTypeFont)
3 0.000 0.000 0.002 0.001 ImageFont.py:126(__init__)
28 0.001 0.000 0.062 0.002 ImageFont.py:185(getsize)
1 0.000 0.000 0.011 0.011 ImageFont.py:28(<module>)
259 0.020 0.000 1.435 0.006 ImageFont.py:337(getmask2)
1 0.000 0.000 0.000 0.000 ImageFont.py:37(_imagingft_not_installed)
1 0.000 0.000 0.000 0.000 ImageFont.py:474(TransposedFont)
3 0.000 0.000 0.003 0.001 ImageFont.py:517(truetype)
3 0.000 0.000 0.002 0.001 ImageFont.py:542(freetype)
1 0.000 0.000 0.000 0.000 ImageFont.py:65(ImageFont)
1 0.000 0.000 0.000 0.000 ImageMode.py:17(<module>)
1 0.000 0.000 0.000 0.000 ImageMode.py:20(ModeDescriptor)
"""
with self._lock:
self._canvas = Image.new('1', (self._width, self._height), WHITE)
drawer = ImageDraw.Draw(self._canvas)