def callback(gpio_id): client = UDPClient(HOST, PORT) if GPIO.input(gpio_id) == 0: msg = OscMessageBuilder('/start').build() GPIO.output(LED, GPIO.HIGH) else: msg = OscMessageBuilder('/stop').build() GPIO.output(LED, GPIO.LOW) client.send(msg)
def on_init(self, controller): self.osc_client = UDPClient('127.0.0.1', 6448)
def __init__(self, ip, port, allow_broadcast=False): self._udp_client = UDPClient(ip, port, allow_broadcast)
def __init__(self, ipaddr="127.0.0.1", port=12000, verbose=False): print("Publishing OSC at %s:%d" % (ipaddr, port)) self.client = UDPClient(ipaddr, port) self.verbose = verbose
import time import itertools from leap_python3 import Leap from leap_python3.Leap import Finger from pythonosc.osc_message_builder import OscMessageBuilder from pythonosc.udp_client import UDPClient HAND = 'left' FINGERS = [Finger.TYPE_THUMB, Finger.TYPE_INDEX, Finger.TYPE_MIDDLE, Finger.TYPE_RING, Finger.TYPE_PINKY] client = UDPClient('127.0.0.1', 6448) def is_expected_hand(hand): if HAND.lower() == 'left': return hand.is_left if HAND.lower() == 'right': return hand.is_right raise ValueError('Unrecognized HAND value: {}'.format(HAND)) def populate_hand_dict_from_fingers(hand_dict, fingers): for finger in fingers: if is_expected_hand(finger.hand): hand_dict[finger.type] = finger.tip_position.to_tuple() def get_raw_tip_positioning_data(frame):
from pythonosc.udp_client import UDPClient import RPi.GPIO as GPIO HOST = '127.0.0.1' PORT = 7777 SWITCH = 2 LED = 3 GPIO.setmode(GPIO.BCM) GPIO.setup(LED, GPIO.OUT) GPIO.output(LED, GPIO.LOW) GPIO.setup(SWITCH, GPIO.IN) START = OscMessageBuilder('/jack_capture/tm/start').build() STOP = OscMessageBuilder('/jack_capture/tm/stop').build() client = UDPClient(HOST, PORT) def callback(gpio_id): if GPIO.input(gpio_id) == 0: GPIO.output(LED, GPIO.HIGH) client.send(START) else: GPIO.output(LED, GPIO.LOW) client.send(STOP) def main(): GPIO.add_event_detect(SWITCH, GPIO.BOTH, callback=callback, bouncetime=100) while True: time.sleep(1)