Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dadav committed Apr 2, 2020
1 parent 5bac678 commit 0dedd09
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 44 deletions.
44 changes: 20 additions & 24 deletions pwnagotchi/ui/fonts.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
from PIL import ImageFont

FONT_NAME = None
FONT_NAME_FACES = 'DejaVuSansMono'
# should not be changed
FONT_NAME = 'DejaVuSansMono'

# can be changed
STATUS_FONT_NAME = None
SIZE_OFFSET = 0

Bold = None
BoldSmall = None
BoldBig = None
Medium = None
Small = None
Huge = None
FaceHuge = None
FaceBold = None


def init(config):
global FONT_NAME, SIZE_OFFSET
FONT_NAME = config['ui']['font']['name']
global STATUS_FONT_NAME, SIZE_OFFSET
STATUS_FONT_NAME = config['ui']['font']['name']
SIZE_OFFSET = config['ui']['font']['size_offset']
setup(10, 8, 10, 25, 25, 9)


def setup(bold, bold_small, medium, huge, bold_big, small):
global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FaceHuge, FaceBold, FONT_NAME, FONT_NAME_FACES, SIZE_OFFSET

Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small + SIZE_OFFSET)
Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium + SIZE_OFFSET)
FaceHuge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, huge)
FaceBold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME_FACES, bold)

try:
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small + SIZE_OFFSET)
Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold + SIZE_OFFSET)
BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big + SIZE_OFFSET)
Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge + SIZE_OFFSET)
except OSError:
BoldSmall = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_small + SIZE_OFFSET)
Bold = ImageFont.truetype("%s.ttf" % FONT_NAME, bold + SIZE_OFFSET)
BoldBig = ImageFont.truetype("%s.ttf" % FONT_NAME, bold_big + SIZE_OFFSET)
Huge = ImageFont.truetype("%s.ttf" % FONT_NAME, huge + SIZE_OFFSET)
def status_font(old_font):
global STATUS_FONT_NAME, SIZE_OFFSET
return old_font.font_variant(font=STATUS_FONT_NAME, size=old_font.size + SIZE_OFFSET)


def setup(bold, bold_small, medium, huge, bold_big, small):
global Bold, BoldSmall, Medium, Huge, BoldBig, Small, FONT_NAME

Small = ImageFont.truetype("%s.ttf" % FONT_NAME, small)
Medium = ImageFont.truetype("%s.ttf" % FONT_NAME, medium)
BoldSmall = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_small)
Bold = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold)
BoldBig = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, bold_big)
Huge = ImageFont.truetype("%s-Bold.ttf" % FONT_NAME, huge)
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, config, name):
# status is special :D
'status': {
'pos': (0, 0),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium),
'max': 20
}
}
Expand Down
4 changes: 2 additions & 2 deletions pwnagotchi/ui/hw/dfrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def layout(self):
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium),
'max': 20
}
return self._layout
Expand All @@ -40,4 +40,4 @@ def render(self, canvas):
self._display.display(buf)

def clear(self):
self._display.Clear(0xFF)
self._display.Clear(0xFF)
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/inky.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (102, 18),
'font': fonts.Small,
'font': fonts.status_font(fonts.Small),
'max': 20
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/lcdhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (215, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium),
'max': 20
}

Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/oledhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (103, 10)
self._layout['status'] = {
'pos': (30, 18),
'font': fonts.Small,
'font': fonts.status_font(fonts.Small),
'max': 18
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/papirus.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def layout(self):
self._layout['mode'] = (175, 86)
self._layout['status'] = {
'pos': (85, 14),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 16
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/spotpear24inch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def layout(self):
self._layout['mode'] = (280, 220)
self._layout['status'] = {
'pos': (80, 160),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium),
'max': 20
}

Expand Down
4 changes: 2 additions & 2 deletions pwnagotchi/ui/hw/waveshare1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def layout(self):
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
else:
Expand All @@ -47,7 +47,7 @@ def layout(self):
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (91, 15),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare144lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (0, 117)
self._layout['status'] = {
'pos': (65, 26),
'font': fonts.Small,
'font': fonts.status_font(fonts.Small),
'max': 12
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare154inch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (170, 187)
self._layout['status'] = {
'pos': (5, 90),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
return self._layout
Expand Down
4 changes: 2 additions & 2 deletions pwnagotchi/ui/hw/waveshare2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def layout(self):
self._layout['mode'] = (225, 109)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
else:
Expand All @@ -48,7 +48,7 @@ def layout(self):
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (125, 20),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 14
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare213bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (91, 15),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare213d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (187, 93)
self._layout['status'] = {
'pos': (91, 15),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 20
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare27inch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (239, 163)
self._layout['status'] = {
'pos': (38, 93),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 40
}
return self._layout
Expand Down
2 changes: 1 addition & 1 deletion pwnagotchi/ui/hw/waveshare29inch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def layout(self):
self._layout['mode'] = (268, 114)
self._layout['status'] = {
'pos': (130, 25),
'font': fonts.Medium,
'font': fonts.status_font(fonts.Medium)
'max': 28
}
return self._layout
Expand Down
4 changes: 2 additions & 2 deletions pwnagotchi/ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def __init__(self, config, impl, state=None):
'line1': Line(self._layout['line1'], color=BLACK),
'line2': Line(self._layout['line2'], color=BLACK),

'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.FaceHuge),
'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge),

'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.FaceBold, color=BLACK),
'friend_face': Text(value=None, position=self._layout['friend_face'], font=fonts.Bold, color=BLACK),
'friend_name': Text(value=None, position=self._layout['friend_name'], font=fonts.BoldSmall,
color=BLACK),

Expand Down

0 comments on commit 0dedd09

Please sign in to comment.