# Change XYZ to the UID of your Joystick Bricklet

setup:
	# Get threshold callbacks with a debounce time of 0.2 seconds (200ms)
	publish '{"debounce": 200}' to tinkerforge/request/joystick_bricklet/XYZ/set_debounce_period
	
	# Handle incoming position reached callbacks
	subscribe to tinkerforge/callback/joystick_bricklet/XYZ/position_reached
        if a message arrives
            # message contains x and y as int
            if y == 100
                print "Top"
            elseif y == -100
                print "Bottom"
            elseif x == 100
                print "Right"
            elseif x == -100
                print "Left"
            endif           
            print "\n"
	endsubscribe
	
	publish '{"register": true}' to tinkerforge/register/joystick_bricklet/XYZ/position_reached
	
	# Configure threshold for position "outside of -99, -99 to 99, 99"
	publish '{"option": "outside", "min_x": -99, "max_x": 99, "min_y": -99, "max_y": 99}' to tinkerforge/request/joystick_bricklet/XYZ/set_position_callback_threshold
