from m5stack import *
from m5ui import *
from uiflow import *
import unit
setScreenColor(0x222222)
ext_io2_0 = unit.get(unit.EXT_IO2, unit.PORTA)
label0 = M5TextBox(232, 11, "label0", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(232, 124, "label1", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label2 = M5TextBox(152, 124, "label2", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label3 = M5TextBox(76, 124, "label3", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label6 = M5TextBox(29, 193, "BAT LEVEL", lcd.FONT_DejaVu40, 0x0bef16, rotate=0)
label4 = M5TextBox(0, 124, "label4", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label5 = M5TextBox(8, 11, "label5", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
ext_io2_0.init_i2c_address(0x45)
ext_io2_0.set_config_mode(0, 2)
ext_io2_0.set_config_mode(1, 2)
ext_io2_0.set_config_mode(2, 2)
ext_io2_0.set_config_mode(3, 2)
ext_io2_0.set_config_mode(4, 2)
ext_io2_0.set_config_mode(5, 2)
while True:
label0.setText(str(ext_io2_0.read_adc8_pin(0)))
label1.setText(str(ext_io2_0.read_adc8_pin(1)))
label2.setText(str(ext_io2_0.read_adc8_pin(2)))
label3.setText(str(ext_io2_0.read_adc8_pin(3)))
label4.setText(str(ext_io2_0.read_adc8_pin(4)))
label5.setText(str(ext_io2_0.read_adc8_pin(5)))
label6.setText(str(power.getBatteryLevel()))
wait_ms(2)
Comments
Please log in or sign up to comment.