Jump to content

BricketLEDStripV2 - register_callback does not work


frankred

Recommended Posts

The first three leds getting the correct color, but why is my callback function my_callback not beeing called?

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "Lc7" # Change XYZ to the UID of your LED Strip Bricklet 2.0
LED_AMOUNT = 493
CLEAR_MATRIX = [0,0,0] * LED_AMOUNT

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_led_strip_v2 import BrickletLEDStripV2

def clearAll():
	ls.set_led_values(0, CLEAR_MATRIX)

def remove(index):
	ls.set_led_values(index, [0,0,0])

def set(index, r,g,b):
	ls.set_led_values(index, [r,g,b])

def my_callback():
	print('my callback called')

if __name__ == "__main__":
    ipcon = IPConnection()
    ls = BrickletLEDStripV2(UID, ipcon)
    ipcon.connect(HOST, PORT) 

    ls.set_frame_started_callback_configuration(True)
    ls.set_channel_mapping(BrickletLEDStripV2.CHANNEL_MAPPING_RGB)
    ls.set_frame_duration(100)
    ls.register_callback('my_callback', my_callback)
    ls.set_led_values(0, [255, 0, 0, 0, 255, 0, 0, 0, 255])

    input("Press key to exit\n")

    ipcon.disconnect()

 

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...