Roodriiigooo actually implemented what I handwaved as "probably easy" and wrote an installation guide! Roodriiigooo you get the official UwU of appreciation |
---|
At time of writing, the pwnagotchi only allows single line, text-based emoji to be used as faces for its moods. While these faces can be edited (by editing pwnagotchi/pwnagotchi/ui/faces.py), as written they can only be changed to different single-line emoji. The layout of the pwnagotchi's face is defined on line 57 of pwnagotchi/pwnagotchi/ui/view.py, using the Text class defined in pwnagotchi/pwnagotchi/ui/components.py,
class Text(Widget):
def __init__(self, value="", position=(0, 0), font=None, color=0, wrap=False, max_length=0):
super().__init__(position, color)
self.value = value
self.font = font
self.wrap = wrap
self.max_length = max_length
self.wrapper = TextWrapper(width=self.max_length, replace_whitespace=False) if wrap else None
def draw(self, canvas, drawer):
if self.value is not None:
if self.wrap:
text = '\n'.join(self.wrapper.wrap(self.value))
else:
text = self.value
drawer.text(self.xy, text, font=self.font, fill=self.color)
The same file also defines a Bitmap class which is never used, likely a holdover from work done towards fulfilling requests to make BMP faces a feature going as far back as 2019.
class Bitmap(Widget):
def __init__(self, path, xy, color=0):
super().__init__(xy, color)
self.image = Image.open(path)
def draw(self, canvas, drawer):
canvas.paste(self.image, self.xy)
Because the pwnagotchi display is rendered on the fly1 we should be able to fairly simply replace the emoji defined in faces.py with custom images.
class View(object):
def __init__(self, config, impl, state=None):
global ROOT
# setup faces from the configuration in case the user customized them
faces.load_from_config(config['ui']['faces'])
self._state = State(state={
'face': Text(value=faces.SLEEP, position=self._layout['face'], color=BLACK, font=fonts.Huge),
'status': Text(value=self._voice.default(),
position=self._layout['status']['pos'],
color=BLACK,
font=self._layout['status']['font'],
wrap=True,
# the current maximum number of characters per line, assuming each character is 6 pixels wide
max_length=self._layout['status']['max']),
The aim of this project is to replace the text pwnagotchi face with bitmap faces in the absence of an update that does same. The faces used are all custom drawn by me and fit within a 64x64px square. Some examples are shown below.
Footnotes
-
(I think, but the code there is annoying and I'd rather poke at it than spend an hour glaring at it keeping track of all the
.super
and shit) ↩