import os, sys, io
import M5
from M5 import *
from hardware import *
rgb = None
color = None
def btnA_wasPressed_event(state):
global rgb, color
color = color + 1
if color == 1:
rgb.set_color(0, 0xffff33)
if color == 2:
rgb.set_color(0, 0x3366ff)
color = 0
def setup():
global rgb, color
M5.begin()
BtnA.setCallback(type=BtnA.CB_TYPE.WAS_PRESSED, cb=btnA_wasPressed_event)
rgb = RGB()
rgb.set_color(0, 0x6600cc)
rgb.set_brightness(60)
color = 0
def loop():
global rgb, color
M5.update()
if __name__ == '__main__':
try:
setup()
while True:
loop()
except (Exception, KeyboardInterrupt) as e:
try:
from utility import print_error_msg
print_error_msg(e)
except ImportError:
print("please update to latest firmware")