def __init__(self, _scl, _sda): try: self.i2c = I2CDriver(self.I2CDRIVER_COM_PORT) self.i2c.setspeed(400) except serial.serialutil.SerialException as exc: print("###ERR: Failed to connect to I2CDriver controller") print(f"###ERR: {exc}") exit()
import sys import serial import time from i2cdriver import I2CDriver, EDS if __name__ == '__main__': i2 = I2CDriver(sys.argv[1]) d = EDS.Dig2(i2) for i in range(100): d.dec(i) time.sleep(.05)
beep.beep(2, 80) else: beep.beep(1, 117) ticking = False next = millis() + 1000 v0 = v digits.brightness(255) t = v digits.dec(t) if millis() > next and (t != 0): ticking = True if ticking and millis() > next: next = millis() + 1000 beep.beep(1, 120) if t: t -= 1 else: for i in range(21): digits.brightness(255) beep.beep(75, 107) time.sleep(.1) digits.brightness(0) time.sleep(.05) digits.brightness(50) ticking = False if __name__ == '__main__': i2 = I2CDriver(sys.argv[1], True) eggtimer(i2)
def __init__(self, address=0x68, port='/dev/ttyUSB0'): self.address = address self.i2c = I2CDriver(port=port)
def connect(self, dev): self.sd = I2CDriver(dev) [w.Enable(True) for w in self.allw] self.refresh(None)