Thu. Jan 9th, 2025
import os, sys, io
import M5
from M5 import *
from hardware import *
import time



rgb = None


nColour = None
x = None


def btnA_wasClicked_event(state):
  global rgb, nColour, x
  nColour = nColour + 1
  if nColour == 3:
    nColour = 0
  if nColour == 0:
    rgb.set_color(0, 0xff0000)
  if nColour == 1:
    rgb.set_color(0, 0xff6600)
  if nColour == 2:
    rgb.set_color(0, 0xffff00)


def setup():
  global rgb, nColour, x

  M5.begin()
  BtnA.setCallback(type=BtnA.CB_TYPE.WAS_CLICKED, cb=btnA_wasClicked_event)

  rgb = RGB()
  rgb.set_brightness(70)


def loop():
  global rgb, nColour, x
  M5.update()
  rgb.set_color(0, 0x33ffff)
  time.sleep(5)
  rgb.set_color(0, 0xff6600)
  time.sleep(5)


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")

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *