def doTemp():
    fps = 30
    current_millis = lambda: int(round(time.time() * 1000))
    off = bytearray([0, 0, 0])
    sleepTime = 0.1
    myledData = bytearray()
    colors = getColorArgs()

    for i in range(hyperion.ledCount):
        myledData += bytearray([0, 0, 0])

    color = colors[0]
    myledData[150] = colors[0][0]
    myledData[151] = colors[0][1]
    myledData[152] = colors[0][2]
    myledData[180] = colors[1][0]
    myledData[181] = colors[1][1]
    myledData[182] = colors[1][2]
    myledData[310] = colors[2][0]
    myledData[311] = colors[2][1]
    myledData[312] = colors[2][2]

    # Start the write data loop
    while not hyperion.abort():
        hyperion.setColor(myledData)
        time.sleep(sleepTime)
Пример #2
0
def shiftLED(ledData, increment, limit, lightPos=None):
    state = 0
    while state < limit and not hyperion.abort():
        ledData = ledData[increment:] + ledData[:increment]

        if (lightPos):
            tmp = ledData[lightPos]
            ledData[lightPos] = light

        hyperion.setColor(ledData)

        if (lightPos):
            ledData[lightPos] = tmp

        time.sleep(sleepTime)
        state += 1
Пример #3
0
def shiftLED(ledData, increment, limit, lightPos=None):
	state = 0
	while state < limit and not hyperion.abort():
		ledData = ledData[increment:] + ledData[:increment]

		if (lightPos):
			tmp = ledData[lightPos]
			ledData[lightPos] = light

		hyperion.setColor(ledData)

		if (lightPos):
			ledData[lightPos] = tmp

		time.sleep(sleepTime)
		state += 1
    def runScene(self):
        print "Starting led scene loop..."
        #30 fps sleep time
        sleepTime = 1.0 / fps
        lastTime = current_millis();
        while not hyperion.abort():
            # hyperion.setColor(ledData[colorIndex])
            # colorIndex = (colorIndex + 1) % len(ledData)
            now = current_millis()
            elapsed = now - lastTime
            lastTime = now
            self.updateObjects(elapsed)

            #create a new empty scene to paint on
            ledScene = bytearray()
            for i in range(hyperion.ledCount):
                ledScene += off
            self.paintObjects(ledScene)
            hyperion.setColor(ledScene)

            time.sleep(sleepTime)
Пример #5
0
import errno

# Get the parameters
udpPort = int(hyperion.args.get('udpPort', 2812))

UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
UDPSock.setblocking(False)

listen_addr = ("",udpPort)
print "udp.py: bind socket port:",udpPort
UDPSock.bind(listen_addr)

hyperion.setColor(hyperion.ledCount *  bytearray((int(0), int(0), int(0))) )

# Start the write data loop
while not hyperion.abort():
		try:
			data,addr = UDPSock.recvfrom(4500)
#			print data.strip(),len(data),addr
			if (len(data)%3 == 0):
#				print "numleds ",len(data)/3
				ledData = bytearray()
				for i in range(hyperion.ledCount):
					if (i<(len(data)/3)):
							ledData += data[i*3+0]
							ledData += data[i*3+1]
							ledData += data[i*3+2]
					else:
							ledData += 	bytearray((int(0), int(0), int(0)))

				hyperion.setColor(ledData)
Пример #6
0
def main():
    try:
        # use GPIO pin numbering convention
        GPIO.setmode(GPIO.BOARD)

        # set up GPIO pin for input
        GPIO.setup(GPIOFrontLight, GPIO.IN)
        GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN)
        GPIO.setup(GPIODimmer, GPIO.IN)

        GPIO.setup(GPIOFrontLight, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(GPIODimmer, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

        frontLightStatus = 0  # 0 = off , 1 = on
        ambianceLightStatus = 0  # 0 = off, 1 = on

        ambianceMode = 0  # 0 = normal ambiance light , 1 = tv ambiance mode

        dimmerValue = 1  # 0 to 10

        ledDataWandOn = bytearray()
        ledDataLampenOn = bytearray()
        ledDataWandOff = bytearray()
        ledDataLampenOff = bytearray()
        hsv = colorsys.rgb_to_hsv(250 / 255.0, 1.0, 158.0 / 255.0)
        hsvFront = colorsys.rgb_to_hsv(250.0 / 255.0, 1.0, 158.0 / 255.0)

        for i in range(1, 151):
            rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1] * 2, 1)
            ledDataWandOn += bytearray(
                (int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)))
            ledDataWandOff += bytearray((0, 0, 0))

        for i in range(1, 62):
            rgb = colorsys.hsv_to_rgb(hsvFront[0], hsvFront[1] * 2,
                                      hsvFront[2])
            ledDataLampenOn += bytearray(
                (int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)))
            ledDataLampenOff += bytearray((0, 0, 0))

        while not hyperion.abort():
            # get GPIO value
            if GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 1:
                ambianceMode = 1
        #   print("Button 2  pressed")

            if not GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 0:
                ambianceMode = 0
        #    print("Button 2 released")

            if GPIO.input(GPIOFrontLight) and frontLightStatus <> 1:
                frontLightStatus = 1

    #     print("Button 1  pressed")

            if not GPIO.input(GPIOFrontLight) and frontLightStatus <> 0:
                frontLightStatus = 0
    #      print("Button 1 released")

            if GPIO.input(GPIODimmer):
                #       print("DIMMER 1")

                timeCounter = 0

                if GPIO.input(GPIODimmer) and ambianceLightStatus == 0:
                    #          print("Light on")
                    ambianceLightStatus = 1
                    ledData = ledDataWandOn

                    if frontLightStatus == 1:
                        ledData = ledData + ledDataLampenOn
                    else:
                        ledData = ledData + ledDataLampenOff

                    hyperion.setColor(ledData)

                time.sleep(0.4)

                while GPIO.input(GPIODimmer):
                    timeCounter = timeCounter + 1
                    #          print("TIME COUNTER")
                    if timeCounter > 10:
                        ambianceLightStatus = 0

                        ledData = ledDataWandOff

                        if frontLightStatus == 1:
                            ledData = ledData + ledDataLampenOn
                        else:
                            ledData = ledData + ledDataLampenOff

                        hyperion.setColor(ledData)

#           print("Light off")

                    time.sleep(0.1)

                if ambianceLightStatus == 1 and timeCounter <= 10:
                    #        print("DIMMING")
                    ledDataWandOn = bytearray()
                    dimmerValue = dimmerValue + 1

                    if dimmerValue == 11:
                        dimmerValue = 1

                    for i in range(1, 151):
                        rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1],
                                                  dimmerValue / 10.0)
                        ledDataWandOn += bytearray(
                            (int(rgb[0] * 255), int(rgb[1] * 255),
                             int(rgb[2] * 255)))

    #     print("Dimmdone")

            ledData = bytearray()

            if ambianceLightStatus == 1:
                ledData = ledData + ledDataWandOn
            else:
                ledData = ledData + ledDataWandOff

            if frontLightStatus == 1:
                ledData = ledData + ledDataLampenOn
            else:
                ledData = ledData + ledDataLampenOff

            hyperion.setColor(ledData)

            # wait 100ms
            time.sleep(0.1)

    # reset GPIO settings if user pressed Ctrl+C
    except KeyboardInterrupt:
        print("Execution stopped by user")
        GPIO.cleanup()
Пример #7
0
import os, hyperion, time

# Get the parameters
imageFile = hyperion.args.get('image')
framesPerSecond = float(hyperion.args.get('fps', 25))
reverse       = bool(hyperion.args.get('reverse', False))

sleepTime = 1./framesPerSecond
imageList = []

if imageFile:
	imageList = [reversed(hyperion.getImage(imageFile))] if reverse else hyperion.getImage(imageFile)

# Start the write data loop
while not hyperion.abort() and imageList:
	for image in imageList:
		hyperion.setImage(image["imageWidth"], image["imageHeight"], image["imageData"])
		time.sleep(sleepTime)
Пример #8
0
	incrementOut = max(1,int(round(steps / (fadeOutTime / minStepTime) )))
	sleepTimeOut = fadeOutTime / (steps / incrementOut)
else:
	incrementOut  = sleepTimeOut  = 1

def setColor(r,g,b):
	global currentR,currentG,currentB
	
	currentR = r
	currentG = g
	currentB = b
	hyperion.setColor(r,g,b)

# loop
repeatCounter = 1
while not hyperion.abort():
	# fade in
	if fadeInTime > 0:
		setColor( colors[0][0],colors[0][1],colors[0][2] )
		for step in range(0,int(steps)+1,incrementIn):
			if hyperion.abort(): break
			setColor( colors[step][0],colors[step][1],colors[step][2] )
			time.sleep(sleepTimeIn)

	# end color
	t = 0.0
	while t<colorStartTime and not hyperion.abort():
		setColor( colors[int(steps)][0],colors[int(steps)][1],colors[int(steps)][2] )
		time.sleep(minStepTime)
		t += minStepTime
Пример #9
0
import hyperion, time

# Get the parameters
imageData = hyperion.args.get('url') if hyperion.args.get('imageSource', "") == "url" else hyperion.args.get('file')
framesPerSecond = float(hyperion.args.get('fps', 25))
reverse = bool(hyperion.args.get('reverse', False))
cropLeft = int(hyperion.args.get('cropLeft', 0))
cropTop = int(hyperion.args.get('cropTop', 0))
cropRight = int(hyperion.args.get('cropRight', 0))
cropBottom = int(hyperion.args.get('cropBottom', 0))
grayscale = bool(hyperion.args.get('grayscale', False))

sleepTime = 1./framesPerSecond
imageFrameList = []

if imageData:
	if reverse:
		imageFrameList = reversed(hyperion.getImage(imageData, cropLeft, cropTop, cropRight, cropBottom, grayscale))
	else:
		imageFrameList = hyperion.getImage(imageData, cropLeft, cropTop, cropRight, cropBottom, grayscale)

# Start the write data loop
while not hyperion.abort() and imageFrameList:
	for image in imageFrameList:
		if not hyperion.abort():
			hyperion.setImage(image["imageWidth"], image["imageHeight"], image["imageData"])
			time.sleep(sleepTime)
Пример #10
0
method = locals()[method]
red = partial(method,
              b=color_start[0],
              c=color_end[0] - color_start[0],
              d=duration)
green = partial(method,
                b=color_start[1],
                c=color_end[1] - color_start[1],
                d=duration)
blue = partial(method,
               b=color_start[2],
               c=color_end[2] - color_start[2],
               d=duration)
start = time.time()
prev_color = None
while not hyperion.abort():
    current = time.time() - start
    color = (red(current), green(current), blue(current))
    if color != prev_color:
        #print(color)
        hyperion.setColor(*color)
        prev_color = color
    time.sleep(interval)
    if current >= duration:
        break

hyperion.setColor(color_end[0], color_end[1], color_end[2])
while not hyperion.abort() and maintain_color:
    time.sleep(1)
Пример #11
0
def main():
  try:
    # use GPIO pin numbering convention
    GPIO.setmode(GPIO.BOARD)

    # set up GPIO pin for input
    GPIO.setup(GPIOFrontLight, GPIO.IN)
    GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN)
    GPIO.setup(GPIODimmer, GPIO.IN)

    GPIO.setup(GPIOFrontLight, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    GPIO.setup(GPIODimmer, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)


    frontLightStatus = 0  # 0 = off , 1 = on
    ambianceLightStatus = 0 # 0 = off, 1 = on

    ambianceMode = 0 # 0 = normal ambiance light , 1 = tv ambiance mode

    dimmerValue = 1 # 0 to 10
    
    ledDataWandOn = bytearray()
    ledDataLampenOn = bytearray()
    ledDataWandOff = bytearray()
    ledDataLampenOff = bytearray()
    hsv = colorsys.rgb_to_hsv(250/255.0, 1.0, 158.0/255.0)
    hsvFront = colorsys.rgb_to_hsv(250.0/255.0, 1.0, 158.0/255.0)


    for i in range(1,151):
      rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1]*2, 1)
      ledDataWandOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
      ledDataWandOff += bytearray((0,0,0))
	 
    for i in range(1,62):
      rgb = colorsys.hsv_to_rgb(hsvFront[0], hsvFront[1]*2, hsvFront[2])
      ledDataLampenOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
      ledDataLampenOff += bytearray((0,0,0))
	
    while not hyperion.abort():
      # get GPIO value
      if GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 1:
        ambianceMode = 1
     #   print("Button 2  pressed")

      if not GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 0:
        ambianceMode = 0
    #    print("Button 2 released")

		
      if GPIO.input(GPIOFrontLight) and frontLightStatus <> 1:
        frontLightStatus = 1

   #     print("Button 1  pressed")

      if not GPIO.input(GPIOFrontLight) and frontLightStatus <> 0:
        frontLightStatus = 0
  #      print("Button 1 released")
    
    
      if GPIO.input(GPIODimmer):
 #       print("DIMMER 1")        

        timeCounter = 0
        
        if  GPIO.input(GPIODimmer) and ambianceLightStatus == 0:
#          print("Light on")
          ambianceLightStatus = 1
          ledData = ledDataWandOn

          if frontLightStatus == 1:
            ledData = ledData + ledDataLampenOn
          else:
            ledData = ledData + ledDataLampenOff

          hyperion.setColor(ledData)


        time.sleep(0.4)

        while GPIO.input(GPIODimmer):
          timeCounter = timeCounter + 1
#          print("TIME COUNTER")
          if timeCounter > 10:
            ambianceLightStatus = 0

            ledData = ledDataWandOff

            if frontLightStatus == 1:
              ledData = ledData + ledDataLampenOn
            else:
              ledData = ledData + ledDataLampenOff

            hyperion.setColor(ledData)

 #           print("Light off")
          
          time.sleep(0.1)
        
        if ambianceLightStatus == 1 and timeCounter <=10:
  #        print("DIMMING")
          ledDataWandOn = bytearray()
          dimmerValue = dimmerValue + 1

          if dimmerValue == 11:
	    dimmerValue = 1

          for i in range(1,151):
      	    rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], dimmerValue/10.0)
            ledDataWandOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
          
   #     print("Dimmdone")

      ledData = bytearray()

      if ambianceLightStatus == 1:
        ledData = ledData + ledDataWandOn
      else:
        ledData = ledData + ledDataWandOff

      if frontLightStatus == 1:
	ledData = ledData + ledDataLampenOn
      else:
        ledData = ledData + ledDataLampenOff   

      hyperion.setColor(ledData)
	  
      # wait 100ms
      time.sleep(0.1)

	  
	
	  
  # reset GPIO settings if user pressed Ctrl+C
  except KeyboardInterrupt:
    print("Execution stopped by user")
    GPIO.cleanup()
Пример #12
0
def main():
  try:
    # use GPIO pin numbering convention
    GPIO.setmode(GPIO.BOARD)

    # set up GPIO pin for input
    GPIO.setup(GPIOFrontLight, GPIO.IN)
    GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN)
    GPIO.setup(GPIODimmer, GPIO.IN)

    GPIO.setup(GPIOFrontLight, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
    GPIO.setup(GPIODimmer, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)


    frontLightStatus = 0  # 0 = off , 1 = on
    ambianceLightStatus = 0 # 0 = off, 1 = on

    ambianceMode = 0 # 0 = normal ambiance light , 1 = tv ambiance mode

    dimmerValue = 10 # 0 to 10

    UDP_IP = ""
    UDP_PORT = 8888

    sock = socket.socket(socket.AF_INET, # Internet
                         socket.SOCK_DGRAM) # UDP
    sock.bind((UDP_IP, UDP_PORT))
    sock.settimeout(0.3)
    
    ledDataWandOn = bytearray()
    ledDataLampenOn = bytearray()
    ledDataWandOff = bytearray()
    ledDataLampenOff = bytearray()
    hsv = colorsys.rgb_to_hsv(250/255.0, 1.0, 158.0/255.0)
    hsvFront = colorsys.rgb_to_hsv(250.0/255.0, 1.0, 158.0/255.0)


    for i in range(1,152):
      rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1]*2, 1)
      ledDataWandOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
      ledDataWandOff += bytearray((0,0,0))
	 
    for i in range(1,61):
      rgb = colorsys.hsv_to_rgb(hsvFront[0], hsvFront[1]*2, hsvFront[2])
      ledDataLampenOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
      ledDataLampenOff += bytearray((0,0,0))
	
    while not hyperion.abort():
      # get GPIO value
      if GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 1:
        ambianceMode = 1
	time.sleep(0.2)
        print("Button 2  pressed")

      if not GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 0:
        ambianceMode = 0
        ambianceLightStatus = 0
	time.sleep(0.2)
        print("Button 2 released")

		
      if GPIO.input(GPIOFrontLight) and frontLightStatus <> 1:
        frontLightStatus = 1
	time.sleep(0.2)
        print("Button 1  pressed")

      if not GPIO.input(GPIOFrontLight) and frontLightStatus <> 0:
        frontLightStatus = 0
	time.sleep(0.2)
        print("Button 1 released")
    
    
      if GPIO.input(GPIODimmer):
        print("DIMMER 1")        

        timeCounter = 0
        
        if GPIO.input(GPIODimmer) and ambianceLightStatus == 0:
          print("Light on")
          ambianceLightStatus = 1
          ledData = ledDataWandOn

          if frontLightStatus == 1:
            ledData = ledData + ledDataLampenOn
          else:
            ledData = ledData + ledDataLampenOff

          hyperion.setColor(ledData)


        time.sleep(0.4)

        while GPIO.input(GPIODimmer):
          timeCounter = timeCounter + 1
          print("TIME COUNTER")
          if timeCounter > 10:
            ambianceLightStatus = 0

            ledData = ledDataWandOff

            if frontLightStatus == 1:
              ledData = ledData + ledDataLampenOn
            else:
              ledData = ledData + ledDataLampenOff

            hyperion.setColor(ledData)

 #           print("Light off")
          
          time.sleep(0.1)
        
        if ambianceLightStatus == 1 and timeCounter <=10:
          print("DIMMING")
          ledDataWandOn = bytearray()
          dimmerValue = dimmerValue - 1

          if dimmerValue == -1:
	    dimmerValue = 10

          for i in range(1,152):
      	    rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1]*2, dimmerValue/10.0)
            ledDataWandOn += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255)))
          
        print("Dimmdone")

      ledData = bytearray()

      sleepTime = 0.1

      if ambianceMode == 1:
        srgb = bytearray(152*3)
        
        try:
          number,addr = sock.recvfrom_into(srgb) # buffer size is 
          ledDataServer = bytearray()
          for i in range(1, number-3, 3): 
            ledDataServer += bytearray((srgb[i+2], srgb[i], srgb[i+1]))
          ledData = ledData + ledDataServer        
          sleepTime = 0.01
        except socket.timeout:
          ledData = ledData + ledDataWandOff    

      else:

        if ambianceLightStatus == 1:
          ledData = ledData + ledDataWandOn
        else:
          ledData = ledData + ledDataWandOff

      if frontLightStatus == 1:
	ledData = ledData + ledDataLampenOn
      else:
        ledData = ledData + ledDataLampenOff   
           
      hyperion.setColor(ledData)
	  
      # wait 100ms
      time.sleep(sleepTime)
	  
	
	  
  # reset GPIO settings if user pressed Ctrl+C
  except KeyboardInterrupt:
    print("Execution stopped by user")
    GPIO.cleanup()
Пример #13
0
import os, hyperion, time

# Get the parameters
imageFile = hyperion.args.get('image')
framesPerSecond = float(hyperion.args.get('fps', 25))
reverse = bool(hyperion.args.get('reverse', False))

sleepTime = 1. / framesPerSecond
if imageFile:
    imageList = list(reversed(hyperion.getImage(
        imageFile))) if reverse else hyperion.getImage(imageFile)

# Start the write data loop
while not hyperion.abort() and imageList:
    for image in imageList:
        hyperion.setImage(image["imageWidth"], image["imageHeight"],
                          image["imageData"])
        time.sleep(sleepTime)
Пример #14
0
def main():
    try:
        # use GPIO pin numbering convention
        GPIO.setmode(GPIO.BOARD)

        # set up GPIO pin for input
        GPIO.setup(GPIOFrontLight, GPIO.IN)
        GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN)
        GPIO.setup(GPIODimmer, GPIO.IN)

        GPIO.setup(GPIOFrontLight, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(GPIOSwitchAmbianceMode, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(GPIODimmer, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

        frontLightStatus = 0  # 0 = off , 1 = on
        ambianceLightStatus = 0  # 0 = off, 1 = on

        ambianceMode = 0  # 0 = normal ambiance light , 1 = tv ambiance mode

        dimmerValue = 10  # 0 to 10

        UDP_IP = ""
        UDP_PORT = 8888

        sock = socket.socket(
            socket.AF_INET,  # Internet
            socket.SOCK_DGRAM)  # UDP
        sock.bind((UDP_IP, UDP_PORT))
        sock.settimeout(0.3)

        ledDataWandOn = bytearray()
        ledDataLampenOn = bytearray()
        ledDataWandOff = bytearray()
        ledDataLampenOff = bytearray()
        hsv = colorsys.rgb_to_hsv(250 / 255.0, 1.0, 158.0 / 255.0)
        hsvFront = colorsys.rgb_to_hsv(250.0 / 255.0, 1.0, 158.0 / 255.0)

        for i in range(1, 152):
            rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1] * 2, 1)
            ledDataWandOn += bytearray(
                (int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)))
            ledDataWandOff += bytearray((0, 0, 0))

        for i in range(1, 61):
            rgb = colorsys.hsv_to_rgb(hsvFront[0], hsvFront[1] * 2,
                                      hsvFront[2])
            ledDataLampenOn += bytearray(
                (int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)))
            ledDataLampenOff += bytearray((0, 0, 0))

        while not hyperion.abort():
            # get GPIO value
            if GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 1:
                ambianceMode = 1
                time.sleep(0.2)
                print("Button 2  pressed")

            if not GPIO.input(GPIOSwitchAmbianceMode) and ambianceMode <> 0:
                ambianceMode = 0
                ambianceLightStatus = 0
                time.sleep(0.2)
                print("Button 2 released")

            if GPIO.input(GPIOFrontLight) and frontLightStatus <> 1:
                frontLightStatus = 1
                time.sleep(0.2)
                print("Button 1  pressed")

            if not GPIO.input(GPIOFrontLight) and frontLightStatus <> 0:
                frontLightStatus = 0
                time.sleep(0.2)
                print("Button 1 released")

            if GPIO.input(GPIODimmer):
                print("DIMMER 1")

                timeCounter = 0

                if GPIO.input(GPIODimmer) and ambianceLightStatus == 0:
                    print("Light on")
                    ambianceLightStatus = 1
                    ledData = ledDataWandOn

                    if frontLightStatus == 1:
                        ledData = ledData + ledDataLampenOn
                    else:
                        ledData = ledData + ledDataLampenOff

                    hyperion.setColor(ledData)

                time.sleep(0.4)

                while GPIO.input(GPIODimmer):
                    timeCounter = timeCounter + 1
                    print("TIME COUNTER")
                    if timeCounter > 10:
                        ambianceLightStatus = 0

                        ledData = ledDataWandOff

                        if frontLightStatus == 1:
                            ledData = ledData + ledDataLampenOn
                        else:
                            ledData = ledData + ledDataLampenOff

                        hyperion.setColor(ledData)

#           print("Light off")

                    time.sleep(0.1)

                if ambianceLightStatus == 1 and timeCounter <= 10:
                    print("DIMMING")
                    ledDataWandOn = bytearray()
                    dimmerValue = dimmerValue - 1

                    if dimmerValue == -1:
                        dimmerValue = 10

                    for i in range(1, 152):
                        rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1] * 2,
                                                  dimmerValue / 10.0)
                        ledDataWandOn += bytearray(
                            (int(rgb[0] * 255), int(rgb[1] * 255),
                             int(rgb[2] * 255)))

                print("Dimmdone")

            ledData = bytearray()

            sleepTime = 0.1

            if ambianceMode == 1:
                srgb = bytearray(152 * 3)

                try:
                    number, addr = sock.recvfrom_into(srgb)  # buffer size is
                    ledDataServer = bytearray()
                    for i in range(1, number - 3, 3):
                        ledDataServer += bytearray(
                            (srgb[i + 2], srgb[i], srgb[i + 1]))
                    ledData = ledData + ledDataServer
                    sleepTime = 0.01
                except socket.timeout:
                    ledData = ledData + ledDataWandOff

            else:

                if ambianceLightStatus == 1:
                    ledData = ledData + ledDataWandOn
                else:
                    ledData = ledData + ledDataWandOff

            if frontLightStatus == 1:
                ledData = ledData + ledDataLampenOn
            else:
                ledData = ledData + ledDataLampenOff

            hyperion.setColor(ledData)

            # wait 100ms
            time.sleep(sleepTime)

    # reset GPIO settings if user pressed Ctrl+C
    except KeyboardInterrupt:
        print("Execution stopped by user")
        GPIO.cleanup()
Пример #15
0
import time
import colorsys
import math
import itertools
from random import random

# create a Array for the colors
colors = bytearray(hyperion.ledCount * (0,0,0))

Speakers = [5,2]
Backwash = [7,0]
Down = [9,8,4]
ScreenTop = [6,3,1]

for set in itertools.cycle([Speakers, Backwash, Down, ScreenTop]):
    if hyperion.abort():
        break

    for sel in itertools.chain(*itertools.repeat(set, 4)):
        for i in xrange(hyperion.ledCount):
            if sel == i:
                colors[i*3] = 255
            else:
                colors[i*3] = 0

        hyperion.setColor(colors)
        time.sleep(0.2)

    for sel in set:
        colors[sel*3] = 255
        hyperion.setColor(colors)
Пример #16
0
percentage = max(1, min(percentage, 100))

# Process parameters
factor = percentage / 100.0
hsv = colorsys.rgb_to_hsv(color[0] / 255.0, color[1] / 255.0, color[2] / 255.0)

# Initialize the led data
snakeLeds = max(1, int(hyperion.ledCount * factor))
ledData = bytearray()

for i in range(hyperion.ledCount - snakeLeds):
    ledData += bytearray((0, 0, 0))

for i in range(1, snakeLeds + 1):
    rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2] / i)
    ledData += bytearray((int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)))

# Calculate the sleep time and rotation increment
increment = 3
sleepTime = rotationTime / hyperion.ledCount
while sleepTime < 0.05:
    increment *= 2
    sleepTime *= 2
increment %= hyperion.ledCount

# Start the write data loop
while not hyperion.abort():
    hyperion.setColor(ledData)
    ledData = ledData[increment:] + ledData[:increment]
    time.sleep(sleepTime)
Пример #17
0
else:
    incrementOut = sleepTimeOut = 1


def setColor(r, g, b):
    global currentR, currentG, currentB

    currentR = r
    currentG = g
    currentB = b
    hyperion.setColor(r, g, b)


# loop
repeatCounter = 1
while not hyperion.abort():
    # fade in
    if fadeInTime > 0:
        setColor(colors[0][0], colors[0][1], colors[0][2])
        for step in range(0, int(steps) + 1, incrementIn):
            if hyperion.abort(): break
            setColor(colors[step][0], colors[step][1], colors[step][2])
            time.sleep(sleepTimeIn)

    # end color
    t = 0.0
    while t < colorStartTime and not hyperion.abort():
        setColor(colors[int(steps)][0], colors[int(steps)][1],
                 colors[int(steps)][2])
        time.sleep(minStepTime)
        t += minStepTime
Пример #18
0
		imageData[offset+1] = rgb[1]
		imageData[offset+2] = rgb[2]

# Initialize the led data and args
sleepTime      = float(hyperion.args.get('speed', 1.0))*0.5
alarmColor     = hyperion.args.get('alarm-color', (255,0,0))
postColor      = hyperion.args.get('post-color', (255,174,11))
off            = bool(hyperion.args.get('shutdown-enabled', False))
width          = 12
height         = 10

imageData      = bytearray(height * width * (0,0,0))

# Start the write data loop
for i in range(6):
	if hyperion.abort():
		off = False
		break
	if i % 2:
		hyperion.setColor(alarmColor[0], alarmColor[1], alarmColor[2])
	else:
		hyperion.setColor(0, 0, 0)
	time.sleep(sleepTime)

for y in range(height,0,-1):
	if hyperion.abort():
		off = False
		break
	for x in range(width):
		setPixel(x, y-1, alarmColor)
	hyperion.setImage(width, height, imageData)