TinyCircuits Forum

TinyCircuits Products => Thumby => Topic started by: DarkGizmo on May 06, 2022, 11:34:04 AM

Title: Battery
Post by: DarkGizmo on May 06, 2022, 11:34:04 AM
I think I've read somewhere that the battery life can be up to 3-hours, but that depends on screen brigtness
What if we draw only a black screen with low brightness and make the thumby 1 FPS, could that extent to battery life to way more than 3 hours?

I've also read that the current battery status (low, medium, full) would maybe be exposed in a future update, is there a way to know if the thumby is plugged it right now?
Title: Re: Battery
Post by: DarkGizmo on May 06, 2022, 06:42:56 PM
Once again I answer my own post from a discord answer by JasonTC

Code: [Select]
import thumby
from machine import ADC

adc = ADC(26)

# Average when unplugged is around 3700
# Average when plugged is around 4000
charging_threshold = 38500
average_charging_value = adc.read_u16()

while True:
    average_charging_value = (adc.read_u16() + average_charging_value) // 2
    if average_charging_value > charging_threshold:
        thumby.display.drawText("Charging", 0, 0, 1)
        thumby.display.drawText("Not charging", 0, 0, 1)