def __init__(self): self.state = 'RUN' self.i2c = I2C(scl=Pin(22), sda=Pin(21)) self.seg = Seg7x4(self.i2c) self.seg.fill(False) self.seg.show() self.count = 50 self.running = True self.but = Pin(18, Pin.IN, Pin.PULL_UP) self.but.irq(trigger=Pin.IRQ_FALLING, handler=self._but_press)
def init_display(): ''' Init and return display object ''' i2cdevs = I2C_BUS.scan() print(("I2C Devices Found: {}".format([hex(tmp) for tmp in i2cdevs]))) if not i2cdevs or len(i2cdevs) > 4: print( "I2C Bus Error. Might be disconnected, please check connections and pullups." ) print("Using Dummy Display for debugging") return DummyDisplay(enabled=True) # Configure Display Object disp = Seg7x4(I2C_BUS) return disp
# Copier ht16k33_matrix.py et ht16k33_seg dans /lib de la Pyboard # Test sur STM32F405 Feather Express from pyb import Pin from machine import I2C from ht16k33_seg import Seg7x4 i2c = I2C(1) aff = Seg7x4(i2c, address=0x70) aff.fill(0) # Efface l'affichage précédent aff.text("48.5") aff.show()