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>
This commit is contained in:
Daniel Thompson 2020-12-28 11:12:16 +00:00
parent ff958d154f
commit 8abb6f3f4d
4 changed files with 31 additions and 24 deletions

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -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 = (

View File

@ -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)