Toggle Navigation
Hatchery
Eggs
BatteryMeter
BatteryMeter.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
BatteryMeter.py
raw
Content
""" Displays Battery State Authors: took, b2ag All rites reversed Not for military use """ import display, utime, power def render_text(msg1, msg2, msg3): with display.open() as disp: disp.clear() disp.print(msg1, posx=1, posy=5) disp.print(msg2, posx=11, posy=25) disp.print(msg3, posx=11, posy=49) disp.update() disp.close() while True: render_text( 'Current', str(round(power.read_battery_voltage(), 3)) + ' V', str(round(power.read_battery_current(), 3)) + ' A', ) utime.sleep(6) render_text( 'Charge', str(round(power.read_chargein_voltage(), 3)) + ' V', str(round(power.read_chargein_current(), 3)) + ' A', ) utime.sleep(3) render_text( 'Other', 'Sys ' + str(round(power.read_system_voltage(), 2)) + ' V', 'Trm ' + str(round(power.read_thermistor_voltage(), 2)) + ' V', ) utime.sleep(3)