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 to comment
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...