def scan(): strip = Strip(150) while True: strip.artnet.addr = [("192.168.89.255", 6454)] devices = strip.artnet.poll() print(devices) for i, device in enumerate(devices): strip.artnet.addr = [device] strip.clear(color[i]) strip.send() print("-> ", device, color[i], colornames[i]) time.sleep(.1) time.sleep(10)
def testFade(count): print( "*** testFade ***" ) strip = Strip(150) while count > 0: strip.clear([255, 0, 255]) strip.send() for _i in range(10): time.sleep(1) strip.fade(0.6) strip.send() count -= 1 strip.artnet.close()
def test1(): print( "*** test1 ***" ) strip = Strip(150) strip.clear([255, 0, 0]) strip.set(0, [0, 255, 0]) strip.set(strip.length - 1, [0, 0, 255]) strip.artnet.send(strip) time.sleep(3) strip.clear([0, 255, 0]) strip.set(0, [255, 0, 0]) strip.set(strip.length - 1, [0, 0, 255]) strip.artnet.send(strip) time.sleep(3) strip.clear([0, 0, 255]) strip.set(0, [255, 0, 0]) strip.set(strip.length - 1, [0, 255, 0]) strip.artnet.send(strip) time.sleep(3) strip.artnet.close()
return 255 if count < period26: count -= period16 return 255 * (period16 - count) / period16 if count < period46: return 0 if count < period56: count -= period46 return 255 * count / period16 if count < period: return 255 return 0 def rainbow(count): r = getColorValue2(count) g = getColorValue2(count - period13) b = getColorValue2(count - period23) return [r, g, b] count = 0 strip = Strip(150) strip.clear() strip.send() while True: strip.clear(rainbow(count)) strip.send() count += 1 if count >= period: count -= period time.sleep(.1)
if __name__ == '__main__': # Process arguments parser = argparse.ArgumentParser() parser.add_argument('-t', '--test', action='store_true', help='runs test') parser.add_argument('-p', '--port', action='store_const', const=50051) args = parser.parse_args() # Create server host = '[::]:%s' % parser.parse_args(['--port']).port executor = futures.ThreadPoolExecutor(max_workers=2) server = grpc.server(executor) server.add_insecure_port(host) service_pb2_grpc.add_HardwareCommandServicer_to_server(HardwareServicer(), server) # Create NeoPixel object with appropriate configuration strip = Strip() if args.test: print('Running test', flush=True) strip.test() exit(0) try: server.start() print('Running hardware server on %s' % host, flush=True) while True: time.sleep(_ONE_DAY_IN_SECONDS) except KeyboardInterrupt: strip.clear() server.stop(0)