Example #1
0
    def __init__(self,
                 host=DEFAULT_HOST,
                 port=DEFAULT_PORT,
                 led_num=DEFAULT_LED_NUM):
        self.host = host
        self.port = port
        self.led_num = led_num

        self.address = '{host}:{port}'.format(host=host, port=port)
        # Create a client object
        self.client = opc.Client(self.address)

        # Test if it can connect (optional)
        if self.client.can_connect():
            logger.info('connected to %s' % self.address)
        else:
            # We could exit here, but instead let's just print a warning
            # and then keep trying to send pixels in case the server
            # appears later
            raise Exception('WARNING: could not connect to %s' % self.address)
from lib.fadecandy.core import opc
import time

ADDRESS = 'localhost:7890'

# Create a client object
client = opc.Client(ADDRESS)

# Test if it can connect (optional)
if client.can_connect():
    print('connected to %s' % ADDRESS)
else:
    # We could exit here, but instead let's just print a warning
    # and then keep trying to send pixels in case the server
    # appears later
    print('WARNING: could not connect to %s' % ADDRESS)

# Send pixels forever at 30 frames per second
while True:
    my_pixels = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
    if client.put_pixels(my_pixels, channel=0):
        print('...')
    else:
        print('not connected')
    time.sleep(1 / 30.0)

import numpy as np


def init_pixels():
    linspace = np.linspace(0, 2 * np.pi, 64)
Example #3
0
#!/usr/bin/env python

# Open Pixel Control version of the "measuring_stick" Arduino sketch:
# For each group of 64 LEDs (one strip), lights all LEDs with every
# multiple of 10 lit green.

from lib.fadecandy.core import opc
import time

numStrings = 8
client = opc.Client('localhost:7890')

string = [(128, 128, 128)] * 64
for i in range(7):
    string[10 * i] = (128, 255, 128)

# Immediately display new frame
pixels = string * numStrings
client.put_pixels(pixels)
client.put_pixels(pixels)