wasp: manager: Byte-swap the theme encoding
Currently the theme is explicitly little endian. This does match the underlying hardware but makes it needlessly difficult to hand edit themes. Switch the default theme and theming tools over to big endian form and add comments to the default theme to support hand editing. We also expand the ASCII characters in the default them with hex codes. This is the final step needed to make hand edited themes trivial to work with. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
6212a6275a
commit
1eada36ff4
2 changed files with 13 additions and 3 deletions
|
@ -25,7 +25,7 @@ class DefaultTheme():
|
|||
def serialize(self) -> bytes:
|
||||
"""Serializes the theme for use in wasp-os"""
|
||||
def split_bytes(x: int) -> Tuple[int, int]:
|
||||
return (x & 0xFF, (x >> 8) & 0xFF)
|
||||
return ((x >> 8) & 0xFF, x & 0xFF)
|
||||
theme_bytes = bytes([
|
||||
*split_bytes(self.BLE_COLOR),
|
||||
*split_bytes(self.SCROLL_INDICATOR_COLOR),
|
||||
|
|
14
wasp/wasp.py
14
wasp/wasp.py
|
@ -117,7 +117,17 @@ class Manager():
|
|||
self.musicstate = {}
|
||||
self.musicinfo = {}
|
||||
|
||||
self._theme = b'\xef{\xef{\xef{<\xe7\xef{\xb6\xb5\xb6\xbd\xff\xff\xff9'
|
||||
self._theme = (
|
||||
b'\x7b\xef' # ble
|
||||
b'\x7b\xef' # scroll-indicator
|
||||
b'\x7b\xef' # battery
|
||||
b'\xe7\x3c' # status-clock
|
||||
b'\x7b\xef' # notify-icon
|
||||
b'\xb5\xb6' # accent-mid
|
||||
b'\xbd\xb6' # accent-lo
|
||||
b'\xff\xff' # accent-hi
|
||||
b'\x39\xff' # slider-default
|
||||
)
|
||||
|
||||
self.blank_after = 15
|
||||
|
||||
|
@ -539,6 +549,6 @@ class Manager():
|
|||
if theme_part not in theme_parts:
|
||||
raise IndexError('Theme part {} does not exist'.format(theme_part))
|
||||
idx = theme_parts.index(theme_part) * 2
|
||||
return self._theme[idx] | (self._theme[idx+1] << 8)
|
||||
return (self._theme[idx] << 8) | self._theme[idx+1]
|
||||
|
||||
system = Manager()
|
||||
|
|
Loading…
Reference in a new issue