summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-31 10:09:38 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-31 10:09:38 (GMT)
commit1eada36ff4953cb6b52e249c2908e5c74a7917d1 (patch)
tree1dff459382394d80aef55ee7ea73b4987199e873
parent6212a6275a2678f9512656c450a7ffa9ef14c084 (diff)
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>
-rwxr-xr-xtools/themer.py2
-rw-r--r--wasp/wasp.py14
2 files changed, 13 insertions, 3 deletions
diff --git a/tools/themer.py b/tools/themer.py
index 622142f..9eee132 100755
--- a/tools/themer.py
+++ b/tools/themer.py
@@ -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),
diff --git a/wasp/wasp.py b/wasp/wasp.py
index 2422cfd..488f92f 100644
--- a/wasp/wasp.py
+++ b/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()