Tufty 2040 > code > Tufty 2350

I’ve found the code I need for the battery state. =)

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

It’s plugged in and fully charged.

MPY: soft reboot
100
4.214976
True
False

I’ve also found the code to read the built in light sensor.

badge.light_level()
#Returns the level detected by the light sensor as a raw u16 value.
print (badge.light_level())
MPY: soft reboot
1936

I’ll have to go dig out my flashlight and play around with what values I get. Been there and done that with my Tufty 2040.

Something doesn’t quit seem right with the case lights code though?
Or I’m doing something wrong?

@BillyTPilgrim You don’t happen to know where the code is stored for the battery widget that’s displayed on the Badge OS… App select screen is?

EDIT: It looks like its in /system/apps/menu/ui.py