fix: cosmetic fixes for inky displays
This commit is contained in:
parent
34b52a11cd
commit
79ba5102d7
pwnagotchi
@ -128,11 +128,14 @@ def grid_inbox():
|
|||||||
|
|
||||||
def on_ui_update(ui):
|
def on_ui_update(ui):
|
||||||
new_value = ' %d (%d)' % (UNREAD_MESSAGES, TOTAL_MESSAGES)
|
new_value = ' %d (%d)' % (UNREAD_MESSAGES, TOTAL_MESSAGES)
|
||||||
if not ui.has_element('mailbox'):
|
if not ui.has_element('mailbox') and TOTAL_MESSAGES > 0:
|
||||||
logging.debug("add mailbox")
|
if ui.is_inky():
|
||||||
|
pos=(80, 0)
|
||||||
|
else:
|
||||||
|
pos=(100,0)
|
||||||
ui.add_element('mailbox',
|
ui.add_element('mailbox',
|
||||||
LabeledValue(color=BLACK, label='MSG', value=new_value,
|
LabeledValue(color=BLACK, label='MSG', value=new_value,
|
||||||
position=(100, 0),
|
position=pos,
|
||||||
label_font=fonts.Bold,
|
label_font=fonts.Bold,
|
||||||
text_font=fonts.Medium))
|
text_font=fonts.Medium))
|
||||||
ui.set('mailbox', new_value)
|
ui.set('mailbox', new_value)
|
||||||
|
@ -118,30 +118,30 @@ class Display(View):
|
|||||||
else:
|
else:
|
||||||
logging.info("could not get ip of usb0, video server not starting")
|
logging.info("could not get ip of usb0, video server not starting")
|
||||||
|
|
||||||
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):
|
def is_papirus(self):
|
||||||
return self._display_type in ('papirus', 'papi')
|
return self._display_type in ('papirus', 'papi')
|
||||||
|
|
||||||
def _is_waveshare_v1(self):
|
def is_waveshare_v1(self):
|
||||||
return self._display_type in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1')
|
return self._display_type in ('waveshare_1', 'ws_1', 'waveshare1', 'ws1')
|
||||||
|
|
||||||
def _is_waveshare_v2(self):
|
def is_waveshare_v2(self):
|
||||||
return self._display_type in ('waveshare_2', 'ws_2', 'waveshare2', 'ws2')
|
return self._display_type in ('waveshare_2', 'ws_2', 'waveshare2', 'ws2')
|
||||||
|
|
||||||
def _is_waveshare(self):
|
def is_waveshare_any(self):
|
||||||
return self._is_waveshare_v1() or self._is_waveshare_v2()
|
return self.is_waveshare_v1() or self.is_waveshare_v2()
|
||||||
|
|
||||||
def _init_display(self):
|
def _init_display(self):
|
||||||
if self._is_inky():
|
if self.is_inky():
|
||||||
logging.info("initializing inky display")
|
logging.info("initializing inky display")
|
||||||
from inky import InkyPHAT
|
from inky import InkyPHAT
|
||||||
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():
|
elif self.is_papirus():
|
||||||
logging.info("initializing papirus display")
|
logging.info("initializing papirus display")
|
||||||
from pwnagotchi.ui.papirus.epd import EPD
|
from pwnagotchi.ui.papirus.epd import EPD
|
||||||
os.environ['EPD_SIZE'] = '2.0'
|
os.environ['EPD_SIZE'] = '2.0'
|
||||||
@ -149,7 +149,7 @@ class Display(View):
|
|||||||
self._display.clear()
|
self._display.clear()
|
||||||
self._render_cb = self._papirus_render
|
self._render_cb = self._papirus_render
|
||||||
|
|
||||||
elif self._is_waveshare_v1():
|
elif self.is_waveshare_v1():
|
||||||
if self._display_color == 'black':
|
if self._display_color == 'black':
|
||||||
logging.info("initializing waveshare v1 display in monochromatic mode")
|
logging.info("initializing waveshare v1 display in monochromatic mode")
|
||||||
from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD
|
from pwnagotchi.ui.waveshare.v1.epd2in13 import EPD
|
||||||
@ -167,7 +167,7 @@ class Display(View):
|
|||||||
self._display.Clear()
|
self._display.Clear()
|
||||||
self._render_cb = self._waveshare_bc_render
|
self._render_cb = self._waveshare_bc_render
|
||||||
|
|
||||||
elif self._is_waveshare_v2():
|
elif self.is_waveshare_v2():
|
||||||
logging.info("initializing waveshare v2 display")
|
logging.info("initializing waveshare v2 display")
|
||||||
from pwnagotchi.ui.waveshare.v2.waveshare import EPD
|
from pwnagotchi.ui.waveshare.v2.waveshare import EPD
|
||||||
self._display = EPD()
|
self._display = EPD()
|
||||||
@ -186,11 +186,11 @@ class Display(View):
|
|||||||
def clear(self):
|
def clear(self):
|
||||||
if self._display is None:
|
if self._display is None:
|
||||||
logging.error("no display object created")
|
logging.error("no display object created")
|
||||||
elif self._is_inky():
|
elif self.is_inky():
|
||||||
self._display.Clear()
|
self._display.Clear()
|
||||||
elif self._is_papirus():
|
elif self.is_papirus():
|
||||||
self._display.clear()
|
self._display.clear()
|
||||||
elif self._is_waveshare():
|
elif self.is_waveshare_any():
|
||||||
self._display.Clear(WHITE)
|
self._display.Clear(WHITE)
|
||||||
else:
|
else:
|
||||||
logging.critical("unknown display type %s" % self._display_type)
|
logging.critical("unknown display type %s" % self._display_type)
|
||||||
@ -224,7 +224,7 @@ class Display(View):
|
|||||||
try:
|
try:
|
||||||
self._display.show()
|
self._display.show()
|
||||||
except:
|
except:
|
||||||
print("")
|
logging.exception("error while rendering on inky")
|
||||||
|
|
||||||
def _papirus_render(self):
|
def _papirus_render(self):
|
||||||
self._display.display(self._canvas)
|
self._display.display(self._canvas)
|
||||||
@ -232,9 +232,9 @@ class Display(View):
|
|||||||
|
|
||||||
def _waveshare_render(self):
|
def _waveshare_render(self):
|
||||||
buf = self._display.getbuffer(self._canvas)
|
buf = self._display.getbuffer(self._canvas)
|
||||||
if self._is_waveshare_v1():
|
if self.is_waveshare_v1():
|
||||||
self._display.display(buf)
|
self._display.display(buf)
|
||||||
elif self._is_waveshare_v2():
|
elif self.is_waveshare_v2():
|
||||||
self._display.displayPartial(buf)
|
self._display.displayPartial(buf)
|
||||||
|
|
||||||
def _waveshare_bc_render(self):
|
def _waveshare_bc_render(self):
|
||||||
|
@ -2,7 +2,7 @@ import _thread
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
from PIL import Image, ImageDraw
|
from PIL import ImageDraw
|
||||||
|
|
||||||
import pwnagotchi.utils as utils
|
import pwnagotchi.utils as utils
|
||||||
import pwnagotchi.plugins as plugins
|
import pwnagotchi.plugins as plugins
|
||||||
@ -17,6 +17,7 @@ WHITE = 0xff
|
|||||||
BLACK = 0x00
|
BLACK = 0x00
|
||||||
ROOT = None
|
ROOT = None
|
||||||
|
|
||||||
|
|
||||||
def setup_display_specifics(config):
|
def setup_display_specifics(config):
|
||||||
width = 0
|
width = 0
|
||||||
height = 0
|
height = 0
|
||||||
@ -25,13 +26,13 @@ def setup_display_specifics(config):
|
|||||||
status_pos = (0, 0)
|
status_pos = (0, 0)
|
||||||
|
|
||||||
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
if config['ui']['display']['type'] in ('inky', 'inkyphat'):
|
||||||
fonts.setup(10, 8, 10, 25)
|
fonts.setup(10, 8, 10, 28)
|
||||||
|
|
||||||
width = 212
|
width = 212
|
||||||
height = 104
|
height = 104
|
||||||
face_pos = (0, int(height / 4))
|
face_pos = (0, 37)
|
||||||
name_pos = (5, int(height * .15))
|
name_pos = (5, 18)
|
||||||
status_pos = (int(width / 2) - 15, int(height * .15))
|
status_pos = (102, 18)
|
||||||
|
|
||||||
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
elif config['ui']['display']['type'] in ('papirus', 'papi'):
|
||||||
fonts.setup(10, 8, 10, 23)
|
fonts.setup(10, 8, 10, 23)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user