tufty-v2.0.1-micropython-with-filesystem.uf2
It’s connected via a Data only USB Cable.
Running the following from Thonny.
badge.battery_level()
#Returns an int representing the battery level as a percentage from 0 to 100.
print (badge.battery_level())
badge.battery_voltage()
#Returns a float representing the current battery voltage.
print (badge.battery_voltage())
badge.usb_connected()
#Returns a boolean reflecting whether the USB cable is currently connected.
print(badge.usb_connected())
badge.is_charging()
#Returns a boolean reflecting whether the battery is currently charging.
print(badge.is_charging())
Gets me this.
MPY: soft reboot
100
3.750865
False
False
The 100% doesn’t seem right to me?
Booting the Tufty to the OS Menu, the battery icon is full, is it supposed to show the battery charge state? It does show charging when the battery is charging.
Also, in my app, pressing B gets me
Battery 3.7V 100%
if badge.held(BUTTON_B):
screen.pen = color.white
screen.text ("Battery", 5,9)
screen.text("{:0.1f}V".format(badge.battery_voltage()), 100, 9)
screen.text("{:0.0f}%" .format(badge.battery_level()), 160, 9)
And the widget always shows full?
def draw_battery():
if badge.is_charging():
battery_level = (badge.ticks / 20) % 100
else:
battery_level = badge.battery_level()
pos = (275, 16)
size = (32, 16)
screen.pen = phosphor
screen.shape(shape.rectangle(*pos, *size))
screen.shape(shape.rectangle(pos[0] + size[0], pos[1] + 4, 2, 8))
screen.pen = background
screen.shape(shape.rectangle(pos[0] + 1, pos[1] + 1, size[0] - 2, size[1] - 2))
width = ((size[0] - 4) / 100) * battery_level
screen.pen = phosphor
screen.shape(shape.rectangle(pos[0] + 2, pos[1] + 2, width, size[1] - 4))


