mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
enable color in Image creation with config options
This commit is contained in:
@ -18,8 +18,8 @@ from pwnagotchi.voice import Voice
|
|||||||
|
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
|
||||||
WHITE = 0xff
|
WHITE = 0x181010
|
||||||
BLACK = 0x00
|
BLACK = 0xffcccc
|
||||||
ROOT = None
|
ROOT = None
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class View(object):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
name = self._state.get('name')
|
name = self._state.get('name')
|
||||||
self.set('name', name.rstrip('█').strip() if '█' in name else (name + ' █'))
|
self.set('name', name.rstrip('-').strip() if '-' in name else (name + ' -'))
|
||||||
self.update()
|
self.update()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning("non fatal error while updating view: %s" % e)
|
logging.warning("non fatal error while updating view: %s" % e)
|
||||||
@ -373,7 +373,9 @@ class View(object):
|
|||||||
state = self._state
|
state = self._state
|
||||||
changes = state.changes(ignore=self._ignore_changes)
|
changes = state.changes(ignore=self._ignore_changes)
|
||||||
if force or len(changes):
|
if force or len(changes):
|
||||||
self._canvas = Image.new('1', (self._width, self._height), WHITE)
|
colormode = '1' if not 'colormode' in self._config['ui'] else self._config['ui']['colormode']
|
||||||
|
backgroundcolor = WHITE if not 'backgroundcolor' in self._config['ui'] else self._config['ui']['backgroundcolor']
|
||||||
|
self._canvas = Image.new(colormode, (self._width, self._height), backgroundcolor)
|
||||||
drawer = ImageDraw.Draw(self._canvas)
|
drawer = ImageDraw.Draw(self._canvas)
|
||||||
|
|
||||||
plugins.on('ui_update', self)
|
plugins.on('ui_update', self)
|
||||||
|
Reference in New Issue
Block a user