def __init__(self, i2c_bus): super().__init__() self.led_matrix = [[BLANK for x in range(W)] for y in range(H)] self.old_led_matrix = [[BLANK for x in range(W)] for y in range(H)] self.trelli = [[] for i in range(int(H/4))] # [[],[]] print("Creating Trelli") for x, slice in enumerate(trellis_addresses): for y, addr in enumerate(slice): t = NeoTrellis(i2c_bus, False, addr=addr) t.pixels.auto_write = False self.trelli[x].append(t) sleep(0.1) pass print("Linking Trelli") self.trellis = MultiTrellis(self.trelli) print("Trelli linked") button_cb = self.make_button_cb() print("Initializing Trelli inputs") for y in range(H): for x in range(W): pass sleep(0.01) self.trellis.activate_key(x, y, NeoTrellis.EDGE_RISING) sleep(0.01) self.trellis.activate_key(x, y, NeoTrellis.EDGE_FALLING) self.trellis.set_callback(x, y, button_cb) debug("Inputs initialized") self.blank_screen()
def __init__(self, button_bus, led_bus, i2c_bus): Thread.__init__(self, name='Display') # super(Display, self).__init__() self.button_bus = button_bus self.led_bus = led_bus debug("Creating i2c bus") lcd.flash("Creating i2c bus") # i2c_bus = busio.I2C(SCL, SDA) lcd.setup_hw(i2c_bus) debug("i2c bus created") lcd.flash("i2c bus created") debug("Creating Trelli") lcd.flash("Creating Trelli") trelli = [[], [], [], []] # addrs = trellis_addresses # Create trelli sequentially with a slight pause between each for x, slice in enumerate(trellis_addresses): for y, addr in enumerate(slice): t = NeoTrellis(i2c_bus, False, addr=addr) t.pixels.auto_write = False trelli[x].append(t) sleep(0.1) debug("Linking Trelli") lcd.flash("Linking Trelli") self.trellis = MultiTrellis(trelli) debug("Trelli linked") lcd.flash("Trelli linked") self.grid_h = H self.grid_w = W self.state = 'play' self.led_matrix = [[(0, 0, 0) for x in range(w)] for y in range(h)] self.old_led_matrix = [[(0, 0, 0) for x in range(w)] for y in range(h)] button_cb = self.make_cb() debug("Initializing Trelli inputs") lcd.flash("Initializing Trelli inputs") for y in range(self.grid_h): for x in range(self.grid_w): sleep(0.01) self.trellis.activate_key(x, y, NeoTrellis.EDGE_RISING) sleep(0.01) self.trellis.activate_key(x, y, NeoTrellis.EDGE_FALLING) self.trellis.set_callback(x, y, button_cb) self.ins_button = digitalio.DigitalInOut(D13) self.gbl_button = digitalio.DigitalInOut(D6) debug("Inputs initialized") lcd.flash("Inputs initialized") self.col_scheme = select_scheme('default') return
def __init__(self): GPIO.setmode(GPIO.BCM) GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) self.counter = 0 self.clkLastState = GPIO.input(clk) i2c_bus = busio.I2C(SCL, SDA) trelli = [ [ NeoTrellis(i2c_bus, False, addr=0x2E), NeoTrellis(i2c_bus, False, addr=0x2F), NeoTrellis(i2c_bus, False, addr=0x30) ], ] trellis = MultiTrellis(trelli)
def __init__(self): # setup trellis i2c_bus = busio.I2C(SCL, SDA) self.trellis = MultiTrellis( [ [ NeoTrellis(i2c_bus, True, addr=0x31), NeoTrellis(i2c_bus, True, addr=0x30), NeoTrellis(i2c_bus, True, addr=0x2F), NeoTrellis(i2c_bus, True, addr=0x2E), ], [ NeoTrellis(i2c_bus, True, addr=0x35), NeoTrellis(i2c_bus, True, addr=0x34), NeoTrellis(i2c_bus, True, addr=0x33), NeoTrellis(i2c_bus, True, addr=0x32), ], ] ) # interrupt pin - sync only when needed self.interrupt = digitalio.DigitalInOut(D5) self.interrupt.direction = digitalio.Direction.INPUT
uart = UARTService() advertisement = ProvideServicesAdvertisement(uart) i2c = board.I2C() trelli = [ [ NeoTrellis(i2c, False, addr=0x2F), NeoTrellis(i2c, False, addr=0x2E), ], [ NeoTrellis(i2c, False, addr=0x31), NeoTrellis(i2c, False, addr=0x30), ], ] trellis = MultiTrellis(trelli) class TrellisWrapper(object): """Wrapper that implements the basic color iface, for use with Toy""" def __init__(self, trellis, brightness=1): self.brightness = brightness self.trellis = trellis def _adjustColor(self, color): return (int(c * self.brightness) for c in color) def color(self, x, y, color): self.trellis.color(x, y, self._adjustColor(color)) def width(self):