import os, sys, io import time import M5 from M5 import * from hardware import Pin, I2C from unit import RFIDUnit, Relay4Unit, PAHUBUnit i2c0 = None pahub_0 = None relay4_0 = None rfid_0 = None def setup(): global i2c0, pahub_0, relay4_0, rfid_0 M5.begin() Widgets.setRotation(1) Widgets.fillScreen(0x222222) i2c0 = I2C(0, scl=Pin(33), sda=Pin(32), freq=100000) pahub_0 = PAHUBUnit(i2c=i2c0)# Initialisation du PaHUB et des unités relay4_0 = Relay4Unit(PAHUBUnit(i2c=i2c0, channel=0)) # Canal 0 du PaHUB def loop(): global i2c0, pahub_0, relay4_0, rfid_0 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")