summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-28 11:12:16 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-28 11:12:16 (GMT)
commit8abb6f3f4ddf658c70788c028c6bde156bb018ea (patch)
tree0fd3c95b48f24716cb022d8d14fd2412db3b9aaf
parentff958d154ffd9b3a8ac1863f14adbd15aa44c8a4 (diff)
widgets: Reduce the size of the battery icon
Currently the battery icon is overlarge compared to other status bar icons such as the BT and notification icons (both of which are 32px high). Fix this by redrawing the battery artwork and updating the widgets in the status bar. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--TODO.rst2
-rw-r--r--res/battery.pngbin3471 -> 5757 bytes
-rw-r--r--wasp/icons.py14
-rw-r--r--wasp/widgets.py39
4 files changed, 31 insertions, 24 deletions
diff --git a/TODO.rst b/TODO.rst
index 78c9fe4..9cff137 100644
--- a/TODO.rst
+++ b/TODO.rst
@@ -39,7 +39,7 @@ Wasp-os
* [ ] Introduce fwd/back/vol+/vol- buttons to the music player
* [ ] Update icon for Alarm app
* [ ] Update art work for buttons in Confirmation view
- * [ ] Reduce the size of the battery charge icon slightly (match bell)
+ * [X] Reduce the size of the battery charge icon slightly (match bell)
* [ ] Applications
diff --git a/res/battery.png b/res/battery.png
index d272dbf..e579e94 100644
--- a/res/battery.png
+++ b/res/battery.png
Binary files differ
diff --git a/wasp/icons.py b/wasp/icons.py
index d9d775a..56e24d2 100644
--- a/wasp/icons.py
+++ b/wasp/icons.py
@@ -1,8 +1,18 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2020 Daniel Thompson
-# 1-bit RLE, generated from res/battery.png, 189 bytes
-battery = (36, 48, b'\x97\x0e\x14\x12\x11\x14\x10\x14\x0c\x08\x0c\x08\x08\x08\x0c\x08\x08\x08\x0c\x08\x08\x08\x0c\x08\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x0c\x04\x04\x04\x08\x04\x0b\x05\x04\x04\x08\x04\n\x06\x04\x04\x08\x04\t\x07\x04\x04\x08\x04\x08\x07\x05\x04\x08\x04\x07\x07\x06\x04\x08\x04\x06\x07\x07\x04\x08\x04\x05\x07\x08\x04\x08\x04\x04\x0e\x02\x04\x08\x04\x03\x0f\x02\x04\x08\x04\x02\x10\x02\x04\x08\x04\x02\x10\x02\x04\x08\x04\x02\x0f\x03\x04\x08\x04\x02\x0e\x04\x04\x08\x04\x08\x07\x05\x04\x08\x04\x07\x07\x06\x04\x08\x04\x06\x07\x07\x04\x08\x04\x05\x07\x08\x04\x08\x04\x04\x07\t\x04\x08\x04\x04\x06\n\x04\x08\x04\x04\x05\x0b\x04\x08\x04\x04\x04\x0c\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x04\x14\x04\x08\x1c\x08\x1c\x08\x1c\x08\x1c\x98')
+# 2-bit RLE, generated from res/battery.png, 104 bytes
+battery = (
+ b'\x02'
+ b'\x18 '
+ b'\x04\x01\x02\xca\x0c\xce\n\xce\t\xd0\x04\xc8\x08\xd0\x08\xd0'
+ b'\x08\xd0\x08\xcc\x04\x08\x04\xc8\x10\xc8\t\xc3\x04\xc8\x08\xc4'
+ b'\x04\xc8\x07\xc5\x04\xc8\x06\xc5\x05\xc8\x05\xc5\x06\xc8\x04\xc5'
+ b'\x01@\xfcA\x05\xc8\x03\xcb\x02\xc8\x02\xcc\x02\xc8\x02\xcc'
+ b'\x02\xc8\x02\xcb\x03\xc8\x05\x01\x01\xc5\x04\xc8\x06\xc5\x05\xc8'
+ b'\x05\xc5\x06\xc8\x04\xc5\x07\xc8\x04\xc4\x08\xc8\x04\xc3\t\xc8'
+ b'\x10\xc8P\xff%'
+)
# 2-bit RLE, generated from res/bomb.png, 100 bytes
bomb = (
diff --git a/wasp/widgets.py b/wasp/widgets.py
index d39de90..d1cf1fd 100644
--- a/wasp/widgets.py
+++ b/wasp/widgets.py
@@ -39,7 +39,7 @@ class BatteryMeter:
if watch.battery.charging():
if self.level != -1:
- draw.rleblit(icon, pos=(239-icon[0], 0),
+ draw.blit(icon, 239-icon[1], 0,
fg=wasp.system.theme('battery'))
self.level = -1
else:
@@ -47,30 +47,28 @@ class BatteryMeter:
if level == self.level:
return
- if level > 96:
- h = 24
- rgb = 0x07e0
- else:
- h = level // 4
- green = level // 3
- red = 31-green
- rgb = (red << 11) + (green << 6)
+ green = level // 3
+ if green > 31:
+ green = 31
+ red = 31-green
+ rgb = (red << 11) + (green << 6)
if self.level < 0 or ((level > 5) ^ (self.level > 5)):
if level > 5:
- draw.rleblit(icon, pos=(239-icon[0], 0),
+ draw.blit(icon, 239-icon[1], 0,
fg=wasp.system.theme('battery'))
else:
rgb = 0xf800
- draw.rleblit(icon, pos=(239-icon[0], 0), fg=0xf800)
+ draw.blit(icon, 239-icon[1], 0, fg=0xf800)
- x = 239 - 30
- w = 16
- if 24 - h:
- draw.fill(0, x, 14, w, 24 - h)
+ w = icon[1] - 10
+ x = 239 - 5 - w
+ h = 2*level // 11
+ if 18 - h:
+ draw.fill(0, x, 9, w, 18 - h)
if h:
- draw.fill(rgb, x, 38 - h, w, h)
+ draw.fill(rgb, x, 27 - h, w, h)
self.level = level
@@ -111,14 +109,14 @@ class Clock:
draw = wasp.watch.drawable
draw.set_font(fonts.sans28)
draw.set_color(wasp.system.theme('status-clock'))
- draw.string(t1, 52, 12, 138)
+ draw.string(t1, 52, 4, 138)
self.on_screen = now
return now
class NotificationBar:
"""Show BT status and if there are pending notifications."""
- def __init__(self, x=2, y=8):
+ def __init__(self, x=0, y=0):
self._pos = (x, y)
def draw(self):
@@ -213,10 +211,9 @@ class ScrollIndicator:
color = wasp.system.theme('scroll-indicator')
if self.up:
- draw.rleblit(icons.up_arrow, pos=self._pos, fg=color)
+ draw.blit(icons.up_arrow, self._pos[0], self._pos[1], fg=color)
if self.down:
- draw.rleblit(icons.down_arrow, pos=(self._pos[0], self._pos[1] + 13),
- fg=color)
+ draw.blit(icons.down_arrow, self._pos[0], self._pos[1]+13, fg=color)
_SLIDER_KNOB_DIAMETER = const(40)
_SLIDER_KNOB_RADIUS = const(_SLIDER_KNOB_DIAMETER // 2)