def try_bricklet(self, uid, device_identifier, position): if device_identifier == 231 and "taskint" not in self.outputs: self.device = BrickletLEDStrip(uid, self.controller.ipcon) self.outputs["taskint"] = { "name": "Task Intensity", "type": "dimmer", } self.outputs["taskcol"] = { "name": "Task Colour", "type": "select", } self.device.set_chip_type(self.device.CHIP_TYPE_WS2811) self.device.set_channel_mapping(self.device.CHANNEL_MAPPING_BRG) print("Created LEDBrick Output")
def __init__(self): # Attribute importiert self.__UIDmaster = matrixProperties.UIDmaster # "6et15y" self.__UIDbricklet = matrixProperties.UIDbricklet # "wVj" self.__HOST = matrixProperties.HOST # "localhost" self.__PORT = matrixProperties.PORT # 4223 self.__matrixIndexRed = matrixProperties.IndexRed # 0 self.__matrixIndexGreen = matrixProperties.IndexGreen # 1 self.__matrixIndexBlue = matrixProperties.IndexBlue # 2 self.__rows = matrixProperties.ROWS # 10 self.__columns = matrixProperties.COLUMNS # 20 self.__LEDnr = matrixProperties.LEDnr # Liste LED-Nummern 0 bis 199 self.__numLEDS = matrixProperties.NUM_LEDS # 16 self.__rgb = [[0 for i in range(self.__numLEDS)] for i in range(3)] # RGB-Array self.__image = matrixProperties.defaultImage # Default-Bild setzen self.__imageIndexRed = 0 self.__imageIndexGreen = 1 self.__imageIndexBlue = 2 # Instanzvariablen self.__light = True # Boolean: True / False # Objekte print("Instanz LEDmatrix wurde erstellt.") self.__ipcon = IPConnection() # Create IP connection self.__masterBrick = BrickMaster(self.__UIDmaster, self.__ipcon) self.__brickletLEDstrip = BrickletLEDStrip( self.__UIDbricklet, self.__ipcon) # Create device object # Connect to brickd --> Verbindung Masterbrick? richtiger RGB-Kanal einstellen? self.__ipcon.connect(self.__HOST, self.__PORT) print("Verbindung zu brickd hergestellt.") self.__brickletLEDstrip.set_frame_duration( 20) # Anzeigedauer Bild: 20ms ergibt 20 Bilder pro Sekunde self.__brickletLEDstrip.set_channel_mapping( self.__brickletLEDstrip.CHANNEL_MAPPING_RGB ) # CHANNEL_MAPPING_RGB = 6 -> Farbkanal definieren (RGB statt BGR) # Callback starten self.__brickletLEDstrip.register_callback( self.__brickletLEDstrip.CALLBACK_FRAME_RENDERED, lambda x: self.__loadPicture__()) print("Callback aktiviert.")
def cb_enumerate(uid, connected_uid, position, hardware_version, firmware_version, device_identifier, enumeration_type): print("UID: " + uid) print("Enumeration Type: " + str(enumeration_type)) if enumeration_type == IPConnection.ENUMERATION_TYPE_DISCONNECTED: print("") return print("Connected UID: " + connected_uid) print("Position: " + position) print("Hardware Version: " + str(hardware_version)) print("Firmware Version: " + str(firmware_version)) print("Device Identifier: " + str(device_identifier)) print("") if device_identifier == LED_BRICKLET: print(device_identifier, uid, ipcon) led_bricklet = BrickletLEDStrip(uid, ipcon) draw(led_bricklet, TEXT)
for y in range(anzahl): if g_index % 2 == 0: r_index = Ys[y] - 1 else: r_index = 10 - Ys[y] red[g_index - 1][r_index] = r green[g_index - 1][r_index] = g blue[g_index - 1][r_index] = b if __name__ == "__main__": ipcon = IPConnection() ls = BrickletLEDStrip(UID, ipcon) ipcon.connect(HOST, PORT) fClear() sleep(1) setColor(255, 255, 255) yLine(1) yLine(10) fOn() while True: while puls != 0:
b[r_index] = 255 - (g_index + r_index) * 255 / 200 if g_index == 200: r_index = NUM_LEDS - 1 if g_index > 0: ls.set_rgb_values(g_index - NUM_LEDS, NUM_LEDS, [0] * 16, [0] * 16, [0] * 16) # Set new data for next render cycle ls.set_rgb_values(g_index, NUM_LEDS, r, g, b) if __name__ == "__main__": ipcon = IPConnection() # Create IP connection ls = BrickletLEDStrip(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Set frame duration to 50ms (20 frames per second) ls.set_frame_duration(10) # Register frame rendered callback to function cb_frame_rendered ls.register_callback(ls.CALLBACK_FRAME_RENDERED, lambda x: cb_frame_rendered(x, ls, 0, 0, 255)) # Set initial rgb values to get started ls.set_rgb_values(0, NUM_LEDS, r, g, b)