Exemple #1
0
    def __init__(self, ip='127.0.0.1:7890', debug=False):
        threading.Thread.__init__(self)

        self.fc = opc.Client(ip)
        self.debug = debug
        self.state = 0
        self.direction = True
        self.position = 0
        self.initialized = False
        self.timetillon = datetime.now().time()
        self.timetilloff = datetime.now().time()
        self.specialdays = {}
        self.is_special_day = False
        self.special_day_colors = None
        self.last_initialized_date = datetime.min.date()
        self.initspecialdays()
        self.check_special_day()
        self.offsets = [randint(0, 1023) for x in range(150)]

        self.halloween_states = [0] * GRG_LEN

        #One-off events
        self.manual_show_test = False
        self.g_open = False
        self.g_close = False

        self.w = Weather()
        self.w.daemon = True
        self.w.start()

        if self.fc.can_connect():
            print('Connected to Fadecandy')
        else:
            print('WARNING: could not connect to fadecandy')
Exemple #2
0
    def start(self):
        logger.info("Starting Tryptofan...")
        self.opc_client = opc.Client('localhost:7890')

        apps = [
            (r'/ws', handlers.ControllerHandler, {
                'tryptofan': self
            }),
            (r'/(.*)', handlers.IndexStaticFileHandler, {
                'path': settings.WEBROOT
            }),
        ]
        application = Application(apps)
        self.http_server = HTTPServer(application)

        self.updater = PeriodicCallback(self.update, 1000 / settings.FRAMERATE)

        for i in range(settings.BLADES):
            blade = Blade(self.pixels, i * settings.BLADE_PIXELS,
                          self.state[i][0], self.state[i][1], self.state[i][2])
            self.blades.append(blade)

        self.http_server.listen(settings.HTTP_PORT)
        self.updater.start()
        IOLoop.instance().start()
Exemple #3
0
    def __init__(self, input_recorder=None, fullShell=False, framerate=15, path='../'):
        #set path
        self.path = path
        
        #open fadecandy client connection
        self.client = opc.Client('localhost:7890')
        
        #load default video files
        self.framerate = framerate
        self.reactframerate = 1000
        self.show = 'Hearts'
        self.switch = 0
        self.loadVideoFile(shell=True, back=True, snout=True)
        self.video = True
        self.z = 0
        self.totmax = 0
        
        #load audio recorder
        self.input_recorder = input_recorder

        #load strip lens
        self.stripLens = np.loadtxt(self.path+"LoveBug/StripLens.csv",delimiter=',').astype(int)

        #load 2d point mapping
        self.shellPoints2d = np.loadtxt(self.path+"LoveBug/LED2DPoints.csv",delimiter=',').astype(int)
        self.shellPoints2d2 = np.loadtxt(self.path+"LoveBug/LED2DPoints2.csv",delimiter=',').astype(int)
        self.backflap2d = np.loadtxt(self.path+"LoveBug/BackFlap2D.csv",delimiter=',').astype(int)
        self.snout2d = np.loadtxt(self.path+"LoveBug/Snout2D.csv",delimiter=',').astype(int)
        self.fullShell = fullShell
Exemple #4
0
    def fc_connect(self):
        """Attempt to connect to our fadecandy server"""
        self.fc_conn = opc.Client(self.fc_host)

        if (not self.fc_conn.can_connect()):
            print "Could not connect to server:", self.fc_host

        return self.fc_conn
Exemple #5
0
 def __init__(self, parent, initial_display):
     QtCore.QThread.__init__(self, parent)
     self.__exiting = False
     self.__display = initial_display
     self.__opc_client = opc.Client(self.OPC_ADDRESS)
     self.__lepton_frame = None
     self.__movement = None
     self.__color_adjustment_enabled = False
Exemple #6
0
def createAndPlayStrip(frames):
    client = opc.Client('localhost:7890')
    strip = []
    createStrip(strip)
    #strip[3*60+0] = (255,255,255)  i = 60r + l
    client.put_pixels(strip, channel=255)
    run(strip, frames)
    return strip
Exemple #7
0
def run(strip, j):
    client = opc.Client('localhost:7890')
    i = 0
    while i < j:
        #client.put_pixels(strip,channel=255)
        moveStrip(strip)
        client.put_pixels(strip, channel=255)
        time.sleep(0.025)
        i += 1
Exemple #8
0
def get_led_controller():
    global led_controller
    if led_controller is None:
        world = LEDWorldBuilder().add_octa_circle().build()
        client = opc.Client(FC_SERVER)
        led_controller = LEDController(world, client)
        led_controller.start()
        led_controller.off()
    return led_controller
def start_opc(server):
    client = opc.Client(server)
    if client.can_connect():
        print '    connected to %s' % server
    else:
        # can't connect, but keep running in case the server appears later
        print '    WARNING: could not connect to %s' % server
    print
    return client
Exemple #10
0
 def __init__(self):
     self.numLEDs = 512
     self.columns = 16
     self.rows = 16
     self.client = opc.Client('192.168.17.64:7890')
     self.start_col = -1
     self.start_row = -1
     self.end_col = -1
     self.end_row = -1
     self.clearMaze()
Exemple #11
0
 def __init__(self):
     """ Connect to Fadecandy server, then turn off all cup lights and set cups "hit" status to False """
     self.address = config['defaults']['fadecandy_address']
     self.cup_light = [colors.Black] * 10  # blackout all cup LEDs
     self.cup_hit = [False] * 10  # reset all cups "hit" status to False
     self.balls_thrown = 0
     self.key_name = ''  # clear hit-switch variable
     self.fadecandy = opc.Client(
         self.address, verbose=config['defaults'].getboolean('verbose'))
     self._initialize()
    def __init__(self, eventQueue, opcIP_PORT='127.0.0.1:7890'):
        self.eventQueue = eventQueue
        self.IP_PORT = opcIP_PORT

        self.client = opc.Client(self.IP_PORT)
        if self.client.can_connect():
            print '    connected to %s' % self.IP_PORT
        else:
            # can't connect, but keep running in case the server appears later
            print '    WARNING: could not connect to ' + self.IP_PORT
Exemple #13
0
 def __init__(self):
     self.fc = opc.Client('localhost:7890')
     self.nfaces = 19
     self.ins = ''
     # lookup list of face names by index
     self.facemap = [chr(i + ord('a')) for i in range(self.nfaces)]
     #print str(self.facemap)
     self.numLEDs = 80
     # array of pixels
     self.px = [[0, 0, 0]] * self.numLEDs
Exemple #14
0
 def __init__(self, server_addr='localhost:7890', mock=False):
     self.mock = mock
     if mock:
         pygame.init()
         self.screen = pygame.display.set_mode((self.width * self.size,
                                                self.height * self.size))
     else:
         self.client = opc.Client(server_addr)
     self.leds = [(0, 0, 0)] * self.num_leds
     self.led_map = self.map
Exemple #15
0
def _connect(address):
    client = opc.Client(address)
    if client.can_connect():
        print('    connected to %s' % address)
    else:
        # can't connect, but keep running in case the server appears later
        print('    WARNING: could not connect to %s' % address)
    print('')

    return client
Exemple #16
0
    def __init__(self, use_websockets=False):
        """
        Setup the GUI, setup the Websockets Connection,
        provide timer and button callback updates, and display info
        """

        super(Hub, self).__init__()
        self.use_websockets = use_websockets

        # set access ctl
        self.access = 0
        self.window_state = None
        self.logged_in_user = ""
        self.start_armed = True

        # set windows
        self.lockscreen = None
        self.ledscreen = None
        self.statsscreen = None
        self.hub_voice = None

        # connection variables
        self.first_time = True
        self.red = 0
        self.green = 0
        self.blue = 0

        # LED vars
        self.num_pixels = 60
        self.led_addr = 'localhost:7890'
        self.led_client = opc.Client(self.led_addr)
        self.fast_transition = True

        # initalize the GUI
        self.initUI()

        self.rootCAPath = "/home/pi/Desktop/root-CA.crt"
        self.privateKeyPath = "/home/pi/Desktop/Access01.private.key"
        self.certificatePath = "/home/pi/Desktop/Access01.cert.pem"
        self.host = "a1qhmcyp5eh8yq.iot.us-west-2.amazonaws.com"
        self.setupAWS()

        self.WORK_PERIOD = 2000
        self.myTimer = QTimer()
        self.myTimer.timeout.connect(self.processSQS)
        self.myTimer.start(self.WORK_PERIOD)

        if self.led_client.can_connect():
            print('Connected to: ' + self.led_addr)
        else:
            print('NOT Connected to: ' + self.led_addr)

        self.window_state = WindowState.LOCK_WINDOW
        self.set_window_to_state()
Exemple #17
0
def main():
    """
    Find out which pattern they want to run and go with it..
    """
    client = opc.Client(ADDRESS)
    if client.can_connect():
        print('connected to %s' % ADDRESS)
    else:
        print('WARNING: could not connect to %s' % ADDRESS)
        return
    return
def main():
    #mixer.init()
    #mixer.music.load('/home/maayand/Downloads/Wonderland_background.mp3')
    #mixer.music.play(-1)


    ADDRESS = 'localhost:7890'

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

    # Test if it can connect
    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
    i=255
    # Send pixels forever

    print('    sending pixels forever (control-c to exit)...')
    print('')

    while True:
        in_pixel = input("Enter pixel number?")
        my_pixels = [(i, i, i), (i, i, i), (i, i, i), (i, i, i), (i, i, i),
                     (i, i, i), (i, i, i), (i, i, i), (i, i, i), (i, i, i),
                     (i, i, i), (i, i, i), (i, i, i), (i, i, i), (i, i, i),
                     (i, i, i), (i, i, i), (i, i, i), (i, i, i), (i, i, i),
                     (i, i, i), (i, i, i), (i, i, i), (i, i, i), (i, i, i)]
        #i=i+1
        #if i>=255:
        #    i=0

        for x in range(num_nodes):
            all_nodes.setNodeColor(x, i, i, i)
            my_pixels[x] = (i, i, i)

        my_pixels[int(in_pixel)] = (255, 0, 0)
        all_nodes.setNodeColor(int(in_pixel), 255, 0, 0)

        # random.shuffle(my_pixels)
        if client.put_pixels(my_pixels, channel=0):
            print
            'sent'
        else:
            print
            'not connected'
        time.sleep(0.01)
    def __init__(self, bot, address):
        self.bot = bot

        self.opcClient = opc.Client(address)

        if self.opcClient.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)
Exemple #20
0
Fichier : led.py Projet : tnaoi/mdr
def strobe():
    """ strobe effect """
    num_leds = 512
    client = opc.Client("localhost:7890")

    black = [(0, 0, 0)] * num_leds
    white = [(255, 255, 255)] * num_leds

    while True:
        client.put_pixels(white)
        client.put_pixels(black)
        time.sleep(0.05)
Exemple #21
0
    def __init__(self):
        Thread.__init__(self)
        seed()

        self._end = False
        self.state = False
        self.brightness = 128
        self.effect_list = []
        self.current_effect = None

        self.client = opc.Client('localhost:7890')
        self.pixels = [(0, 0, 0)
                       ] * self.NUM_STRIPS_FC * self.NUM_LED_PER_STRIP_FC
Exemple #22
0
Fichier : led.py Projet : tnaoi/mdr
def fade():
    """ fade effect """
    client = opc.Client("localhost:7890")

    black = [(0, 0, 0)] * config.NUM_LEDS
    white = [(255, 255, 255)] * config.NUM_LEDS

    while True:
        client.put_pixels(white)
        time.sleep(0.05)

        client.put_pixels(black)
        time.sleep(0.05)
Exemple #23
0
    def __init__(self):

        self.client = opc.Client('localhost:7890')


        self.topw = [(0, 0, 0)]*3
        self.topb = [(0, 0, 0)]*4
        self.middlew = [(0, 0, 0)] *4
        self.middleb = [(0, 0, 0)]*4
        self.bottomw = [(0, 0, 0)]*4
        self.bottomb = [(0, 0, 0)] *3

        self.outv = self.topw + self.topb + self.middlew + self.middleb + self.bottomw + self.bottomb
Exemple #24
0
    def __init__(self,
                 server_ip_port="localhost:7890",
                 debug=False,
                 max_pixels=512):
        print "Connecting to OPC server %s, max_pixels=%d" % (server_ip_port,
                                                              max_pixels)
        self.opc = opc.Client(server_ip_port, True)

        # Load a pixel mapping from "panel name" format to channel & ix
        with open("data/opc_mapping.json") as f:
            self.panel_map = json.load(f)

        self.pixels = [(0, 0, 0)] * max_pixels
Exemple #25
0
 def __init__(self):
     self.client = opc.Client('localhost:7890')
     #make an intensity array for the whole fadecandy addressable pixels.
     self.intensity = [(0,0,0)] * 512 
     #inital ppower level is 100 (out of 255)
     self.power = 100
     self.outerLEDs=outerLEDs
     self.innerLEDs=innerLEDs
     self.totalLEDs=(outerLEDs+innerLEDs)
     self.ringStart=ringStart
     self.cabinetStart=cabinetStart
     self.cabinetLEDs=cabinetLEDs
     self.progress=0
     self.savedProgress=(0,0,0)
Exemple #26
0
    def handle(self, *args, **options):
        self.tree = opc.Client('%s:%d' %
                               (settings.TREE_HOST, settings.TREE_PORT))

        x = 0
        while True:
            drawings = self.get_drawings()
            if drawings:
                self.draw(drawings)
            else:
                x += 1
                self.update_sequence()
                self.spiral(x, 255, 255, 255)
            time.sleep(0.05)
Exemple #27
0
def tpm2():
    global frames
    pixel_data = None

    port = 0xFFE2

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    sock.bind(('127.0.0.1', port))

    client = opc.Client('localhost:7890')
    if client.can_connect():
        print 'connected'
    else:
        print 'cant connect'

    my = 30
    mx = 12
    max = mx * my
    last = 0
    data_size = 3 * 4 * 30

    while True:
        data, addr = sock.recvfrom(2000)
        head, t, size, pn, seq = struct.unpack(">BBHBB", data[0:6])
        # print hex(head),hex(t),size,pn,seq
        if last + 1 != pn:
            continue
        last = pn
        if pn == 1:
            pixel_data = data[6:6 + data_size]
        else:
            pixel_data = pixel_data + data[6:6 + data_size]
        if pn < seq:
            continue
        last = 0
        pixels = [[
            ord(pixel_data[i * 3]),
            ord(pixel_data[i * 3 + 1]),
            ord(pixel_data[i * 3 + 2])
        ] for i in range(max)]

        if record:
            frames.append(pixel_data)

        if client.put_pixels(pixels, channel=0):
            pass
        else:
            print 'not connected'
Exemple #28
0
    def __init__(self):
        self.pixels = np.zeros((512, 3), dtype='float32')
        self.diff = np.zeros((512, 3), dtype='float32')
        self.endVals = np.zeros((512, 3), dtype='float32')
        self.remaining = np.zeros((512), dtype='uint32')

        self.clockerActive = threading.Event()

        self.commands = queue.Queue(maxsize=100)
        self.frameRate = 15
        self.FCclient = opc.Client('localhost:7890')
        self.arbitration = [False, '127.0.0.1']

        bootMsg = 'Server booted at ' + str(datetime.datetime.now()) + '\n'
        self.logError(bootMsg)
Exemple #29
0
    def init_fcclient(self, ADDRESS_1='localhost:7890', ADDRESS_2=''):

        # Create a client object
        self.client = opc.Client(ADDRESS_1)

        # Test if it can connect
        if self.client.can_connect():
            print('connected to %s') % ADDRESS_1
        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... Is fcserver
            running?\nClient will retry connection each time a pixel update is
            sent' % ADDRESS_1''')
        self.clients = [self.client]
Exemple #30
0
    def __init__(self, settings):
        self.settings = settings

        self.server = opc.Client('localhost:7890')

        json_data = open('./opc/playfield.json')
        self.led_map = json.load(json_data)

        self.number_of_leds = len(self.led_map)

        self.center_x = int(self.settings['Screen']['X'] / 2)
        self.center_y = int(self.settings['Screen']['Y'] / 2)

        self.multiplier = self.settings['Screen']['Y'] / 5.5
        self.circle_diameter = int(self.settings['Screen']['Y'] / 60)
        self.circle_outline_width = int(self.circle_diameter / 2)