I don't have the code but here is a project I'm working on using the atom matrix
Code: Select all
from m5stack import *
from m5ui import *
from uiflow import *
from IoTcloud.AWS import AWS
import i2c_bus
rgb.set_screen([])
# Describe this function...
def White_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 1:
rgb.set_screen([0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF])
# Describe this function...
def Forward_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 32:
rgb.set_screen([0x00ff00,0x00ff00,0,0,0,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0,0x00ff00,0x00ff00,0,0,0])
aws.publish(str('home'),str('message:fwdbutton'))
# Describe this function...
def Blue_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 4:
rgb.set_screen([0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff,0x0000ff])
aws.publish(str('home'),str('message:bluebutton'))
# Describe this function...
def Back_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 128:
rgb.set_screen([0,0,0,0x00ff00,0x00ff00,0,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0,0,0,0x00ff00,0x00ff00])
aws.publish(str('home'),str('message:backbutton'))
# Describe this function...
def Red_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 8:
rgb.set_screen([0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000,0xff0000])
aws.publish(str('home'),str('message:redbutton'))
# Describe this function...
def Stop_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 64:
rgb.set_screen([0,0,0,0,0,0,0xff0000,0xff0000,0xff0000,0,0,0xff0000,0xff0000,0xff0000,0,0,0xff0000,0xff0000,0xff0000,0,0,0,0,0,0])
aws.publish(str('home'),str('message:stopbutton'))
# Describe this function...
def Yellow_button():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 1:
rgb.set_screen([0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00,0xffff00])
aws.publish(str('home'),str('message:yellowbutton'))
# Describe this function...
def Green_button2():
#Change the value at the end of the below block for each button
if (i2c0.read_u8(0x03)) == 16:
rgb.set_screen([0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00,0x00ff00])
aws.publish(str('home'),str('message:greenbutton'))
def fun_home_helloword_(topic_data):
# global params
pass
def buttonA_wasPressed():
# global params
aws.publish(str('home'),str('message: matixtest'))
pass
btnA.wasPressed(buttonA_wasPressed)
aws = AWS(things_name='core2', host='a7lxppddpjt7e-ats.iot.eu-west-2.amazonaws.com', port=8883, keepalive=300, cert_file_path="/flash/res/certificate.pem.crt", private_key_path="/flash/res/private.pem.key")
aws.subscribe(str('home/helloword'), fun_home_helloword_)
aws.start()
i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x29, freq=400000)
i2c0.write_u8(0x00, 0x01)
i2c0.write_u8(0x72, 0xff)
while True:
i2c0.write_u8(0x00, 0x00)
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Stop_button()
Yellow_button()
White_button()
Blue_button()
Green_button2()
Red_button()
Back_button()
Forward_button()
wait_ms(2)