Toggle Navigation
Hatchery
Eggs
Battery Info
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
""" Battery Info =========== This app shows the Power information for the Badge. """ import buttons import color import display import os import utime import power import leds def update_leds(voltage): test = 3.4 for i in range(11): if voltage > test: leds.set(i,[50,50,50]) else: leds.set(i,[0,0,0]) test += 0.07 def main(): disp = display.open() disp.clear().update() page = 0 while True: if buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT) != 0: page ^= 1 disp.clear() voltage = power.read_battery_voltage() if page == 0: disp.print("Bat {} V".format(str(round(voltage,2))), posy=0) disp.print("Bat {} mA".format(str(round(power.read_battery_current()*1000.,2))), posy=20) disp.print("Sys {} V".format(str(round(power.read_system_voltage(),2))), posy=40) else: disp.print("Chg {} V".format(str(round(power.read_chargein_voltage(),2))), posy=0) disp.print("Chg {} mA".format(str(round(power.read_chargein_current()*1000.,2))), posy=20) disp.print("Thm {} V".format(str(round(power.read_thermistor_voltage(),2))), posy=40) disp.update() update_leds(voltage) utime.sleep_ms(200) if __name__ == "__main__": main()