예제 #1
0
    def set_color(self,
                  color: utils.RGBColor,
                  start: int = 0,
                  end: int = 0,
                  fast: bool = False):
        '''
        Sets the LEDs' color in the zone between start and end

        :param color: the color to set the LEDs to
        :param start: the first LED to change
        :param end: the first unchanged LED
        :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True`
        '''
        if end == 0:
            end = len(self.leds)
        self.comms.send_header(self.device_id,
                               utils.PacketType.RGBCONTROLLER_UPDATEZONELEDS,
                               struct.calcsize(f"IiH{3*(end)}b{(end)}x"))
        buff = struct.pack("iH", self.id, end) + b''.join(
            (color.pack() for color in self._colors[:start]
             )) + (color.pack()) * (end - start)
        buff = struct.pack("I", len(buff)) + buff
        self.comms.send_data(buff)
        if not fast:
            self.update()
예제 #2
0
def FBounce(ColorWall,Speed): # makes the lights get brighter
    for color in ColorWall:
        if (ColorWall.index(color)%Speed == 0) or (ColorWall.index(color) == 254):
            if (ColorWall.index(color) == 254):
                for Device in DList:
                    Device.set_color(RGBColor(color[0], color[1], color[2]))
                    time.sleep(0.1)
            else:
                for Device in DList:
                    Device.set_color(RGBColor(color[0], color[1], color[2]))
                    time.sleep(0.01)
    time.sleep(2)
예제 #3
0
def light_background(backColorHEX: str, inopColorHEX: str, INOP: int):
    global backColor, inopColor, keyboard_zone, keyboard_leds
    #backColor = RGBColor.fromHEX(backColorHEX)
    #inopColor = RGBColor.fromHEX(inopColorHEX)
    backColor = RGBColor(0, 0, 32)
    inopColor = RGBColor(127, 0, 0)
    print(
        f'Setting global zone {keyboard_zone} background color {backColor} and INOP variables to color {inopColor}.'
    )
    #keyboard_zone.colors = backColor
    #keyboard_zone.update()
    keyboard_zone.set_color(backColor)
    for i in INOP:
        keyboard_leds[i].set_color(inopColor)
예제 #4
0
def TempAware(DL):
    import clr  # the pythonnet module. You might need to install it 'pip install pythonnet'
    clr.AddReference(
        'TempAware\\OpenHardwareMonitorLib.dll')  #enter your dll path
    from OpenHardwareMonitor.Hardware import Computer
    tempature = 0
    colorplusdown = 0
    c = Computer()
    c.CPUEnabled = True  # get the Info about CPU
    c.GPUEnabled = True  # get the Info about GPU
    c.Open()
    for DName in range(0, len(c.Hardware)):
        if ("GPU" in str(c.Hardware[DName])) or ("gpu" in str(
                c.Hardware[DName])):
            while True:
                for Sen in range(0, (len(c.Hardware[DName].Sensors))):
                    if "temperature" in str(
                            c.Hardware[1].Sensors[Sen].Identifier):
                        tempature = (c.Hardware[1].Sensors[Sen].get_Value())
                        print(tempature)
                        c.Hardware[1].Update()
                        if 19 > tempature:
                            for Device in DL:
                                colorplusdown = (tempature) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(0 + colorplusdown),
                                             int(255)))
                            time.sleep(1)
                        elif 38 > tempature >= 19:
                            for Device in DL:
                                colorplusdown = (tempature - 19) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(255),
                                             int(255 - colorplusdown)))
                            time.sleep(1)
                        elif 57 > tempature >= 38:
                            for Device in DL:
                                colorplusdown = (tempature - 38) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0 + colorplusdown), int(255),
                                             int(0)))
                            time.sleep(1)
                        elif 76 >= tempature >= 57:
                            for Device in DL:
                                colorplusdown = (tempature - 57) * 255 / 10
                                Device.set_color(
                                    RGBColor(int(255),
                                             int(255 - colorplusdown), int(0)))
                            time.sleep(1)
예제 #5
0
def UserInput():
    """It will always return 5 things;\n
    Color1, Color2, Speed, Devices for reversal, Devices that are enables in the form of\n
    None/int, None/int, None/int, None/list, None/list. None is for a blank argument so make sure you add ``if == none`` to catch it"""
    Color1 = Color2 = Speed = ReversedDevice = OnlySet = None
    for arg in sys.argv:
        if arg == '--C1':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color1 = RGBColor(int(R), int(G), int(B))
        elif arg == '--C2':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color2 = RGBColor(int(R), int(G), int(B))
        elif arg == '--reversed':
            ReversedDevices = (
                sys.argv.index(arg) + 1
            )  # Will point to where the device(s) that need to be reversed are
            ReversedDevice = []
            if ' , ' in sys.argv[ReversedDevices]:
                for i in sys.argv[ReversedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            ReversedDevice += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[ReversedDevices].strip().casefold():
                        ReversedDevice += [D]
        elif arg == '--only-set':
            AllowedDevices = (
                sys.argv.index(arg) + 1
            )  # Will point to where the device(s) that are allowed are
            OnlySet = []
            if ' , ' in sys.argv[AllowedDevices]:
                for i in sys.argv[AllowedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            OnlySet += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[AllowedDevices].strip().casefold():
                        OnlySet += [D]
        elif arg == '--speed':
            Speed = int(sys.argv[(sys.argv.index(arg) + 1)])
        else:
            pass
    return (Color1, Color2, Speed, ReversedDevice, OnlySet)
예제 #6
0
 def __init__(self, client, DeviceIndex, LEDIndex, CBase, Index):
     self.Device = client.devices[DeviceIndex]
     self.led = self.Device.leds[LEDIndex]
     self.Index = Index
     self.CBase = CBase
     LEDList[Index][2] = True
     LEDColor = 0
     while LEDColor <= 254:
         self.led.set_color(
             RGBColor(CBase[LEDColor][0], CBase[LEDColor][1],
                      CBase[LEDColor][2]))
         time.sleep(0.1)
         LEDColor += 15
     if LEDColor > 254:
         self.led.set_color(
             RGBColor(CBase[254][0], CBase[254][1], CBase[254][2]))
     LEDList[self.Index][2] = False
예제 #7
0
 def FinishCbase(R, G, B):
     Cbase = []
     ListPos = 0
     while ListPos < len(R):
         C = RGBColor(R[ListPos], G[ListPos], B[ListPos])
         Cbase += [C]
         ListPos += 1
     return Cbase
예제 #8
0
 def put(self, device_id: int = -1):
     args = parser.parse_args()
     if device_id == -1:
         if any(c is None
                for c in (args['red'], args['blue'], args['green'])):
             return args, 400
         cli.set_color(RGBColor(args['red'], args['green'], args['blue']))
         return args, 201
     else:
         if args['mode'] is not None:
             cli.devices[device_id].set_mode(args['mode'])
             return args, 201
         elif all(c is not None
                  for c in (args['red'], args['blue'], args['green'])):
             cli.devices[device_id].set_color(
                 RGBColor(args['red'], args['green'], args['blue']))
             return args, 201
         else:
             return args, 400
예제 #9
0
def UserInput():
    Color1 = Color2 = ReversedDevice = OnlySet = None
    for arg in sys.argv:
        if arg == '--C1':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color1 = RGBColor(int(R), int(G), int(B))
        elif arg == '--C2':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color2 = RGBColor(int(R), int(G), int(B))
        elif arg == '--reversed':
            ReversedDevices = (sys.argv.index(arg) + 1)
            ReversedDevice = []
            if ' , ' in sys.argv[ReversedDevices]:
                for i in sys.argv[ReversedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            ReversedDevice += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[ReversedDevices].strip().casefold():
                        ReversedDevice += [D]
        elif arg == '--only-set':
            OnlySet = []
            AllowedDevices = (sys.argv.index(arg) + 1)
            if ' , ' in sys.argv[AllowedDevices]:
                for i in sys.argv[AllowedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            OnlySet += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[AllowedDevices].strip().casefold():
                        OnlySet += [D]
        else:
            pass
    return (Color1, Color2, ReversedDevice, OnlySet)
예제 #10
0
def CreateCBase():
    Cbase = []
    CycleSpeed = 300
    hue_range = CycleSpeed
    for i in range(hue_range):
        color = colorsys.hsv_to_rgb(i / hue_range, 1.0, 1.0)

        # Split RGB values
        R = int(color[0] * 255)
        G = int(color[1] * 255)
        B = int(color[2] * 255)
        Cbase += [RGBColor(R, G, B)]
    return (Cbase)
예제 #11
0
    def set_color(self, color: utils.RGBColor, fast: bool = False):
        '''
        Sets the color of the LED

        :param color: the color to set the LED to
        :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True`
        '''
        self.comms.send_header(self.device_id,
                               utils.PacketType.RGBCONTROLLER_UPDATESINGLELED,
                               struct.calcsize("i3bx"))
        buff = struct.pack("i", self.id) + color.pack()
        self.comms.send_data(buff)
        if not fast:
            self.update()
예제 #12
0
 def __init__(
     self,
     wrapped_action: Action,
     zones: List[int],
     leds: List[int] = None,
     color: List[int] = None,
     colors: List[List[int]] = None,
     device=None,
     device_type=None,
 ):
     super().__init__(wrapped_action)
     self.zones = zones
     self.leds = leds
     self.color = None
     self.colors = None
     if color:
         self.color = RGBColor(*color)
     elif colors:
         self.colors = [RGBColor(*color) for color in colors]
     else:
         raise Exception("Either 'color' or 'colors' should be set")
     # TODO: Add option to set modes
     # self.mode = mode
     self.device = device
예제 #13
0
def CustomSpectrumCycle(CycleSpeed=1000):
    while True:
        #credit to @James Potkukelkka on discord for MOST of the code
        hue_range = CycleSpeed  # Smaller = faster
        iteration_delay = 0.01  # 10ms
        for i in range(hue_range):
            color = colorsys.hsv_to_rgb(i / hue_range, 1.0, 1.0)

            # Split RGB values
            red = color[0] * 255
            green = color[1] * 255
            blue = color[2] * 255

            for Device in DList:
                Device.set_color(RGBColor(int(red), int(green), int(blue)))
                time.sleep(iteration_delay)
예제 #14
0
    def set_color(self, color: utils.RGBColor, fast: bool = False):
        '''
        Sets the zone's color

        :param color: the color to set the LEDs to
        :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True`
        '''
        self.comms.send_header(
            self.device_id, utils.PacketType.RGBCONTROLLER_UPDATEZONELEDS,
            struct.calcsize(f"iIH{3*(len(self.leds))}b{len(self.leds)}x"))
        buff = struct.pack("iH", self.id, len(
            self.leds)) + (color.pack()) * len(self.leds)
        buff = struct.pack("I", len(buff)) + buff
        self.comms.send_data(buff)
        if not fast:
            self.update()
예제 #15
0
 def get_complementary_rgb_colors(self, vim_color, nb_colors):
     crgbs = []
     (r, g, b) = self.vim_color_to_rgb(vim_color)
     (h, s, v) = colorsys.rgb_to_hsv(r, g, b)
     cs = max(s, 0.7)
     cv = max(v, 128)
     for i in range(nb_colors):
         j = i - 1
         if j < 0:
             delta = 0
         else:
             h_step = 0.25 / (nb_colors // 2)
             sign = (-1, 1)[j % 2]
             delta = sign * ((j // 2) + 1) * h_step
         ch = (h + 0.5 + delta) % 1.0
         (cr, cg, cb) = (int(x) for x in colorsys.hsv_to_rgb(ch, cs, cv))
         crgbs.append(RGBColor(cr, cg, cb))
     return crgbs
예제 #16
0
def set_aura_color(aura: Device):
    """
    Sets Aura color once.
    :return:
    """
    # use main color for aura
    hex_color = AURA_COLOR
    r, g, b = hex_to_rgb(hex_color)

    # calculate brightness
    brightness = get_aura_brightness()

    # apply brightness
    r *= brightness
    g *= brightness
    b *= brightness

    # round to int
    r, g, b = validate_color(r, g, b)
    # set aura sync color
    aura.set_color(RGBColor(r, g, b))
예제 #17
0
                if ColorFadeIndex < len(ColorFades) - 1:
                    ColorFadeIndex += 1
                else:
                    ColorFadeIndex = 0
                time.sleep(1)
        elif ZOType == ZoneType.MATRIX:
            pass
            #print('matrix support not done yet')


if __name__ == '__main__':
    C1, C2, Colors, Speed, Reversed, Enabled, Zones = UserInput()
    if Colors == None:
        Colors = []
        if C1 == None:
            Colors += [RGBColor(255, 0, 0)]
        else:
            Colors += [C1]
        if C2 == None:
            Colors += [RGBColor(0, 0, 255)]
        else:
            Colors += [C2]
    Enable = []
    if Enabled == None:
        Enable += [i for i in client.devices]
    elif Enabled != None:
        Enable = Enabled
    if Speed > 50:
        Speed = 50
    Passes = 51 - Speed
    if Passes < 1:
예제 #18
0
def BBounce(ColorWall,Speed): # makes the lights get darker
    for color in reversed(ColorWall):
        if (ColorWall.index(color)%Speed == 0):
            for Device in DList:
                Device.set_color(RGBColor(color[0], color[1], color[2]))
                time.sleep(0.01)
예제 #19
0
#!/usr/bin/env python3

from openrgb import OpenRGBClient
from openrgb.utils import RGBColor, DeviceType

import psutil

client = OpenRGBClient()

cooler = client.get_devices_by_type(DeviceType.COOLER)[0]
cpu_led = cooler.zones[2].leds[0]

while True:
    current_temp = int(psutil.sensors_temperatures()['k10temp'][-1].current)

    min_temp = 35
    max_temp = 65

    min_hue = 0         #Red
    max_hue = 120       #Green
    
    step = max_hue / (max_temp - min_temp)
    
    offset = current_temp - min_temp
    current_hue = max_hue - (offset * step)

    if current_hue < min_hue:
        current_hue = min_hue

    cpu_led.set_color(RGBColor.fromHSV(current_hue, 100, 100))
예제 #20
0
#!/usr/bin/env python3

# Happy belated 4th of July!

from openrgb import OpenRGBClient
from openrgb.utils import RGBColor
from time import sleep

cli = OpenRGBClient()

offsets = [(0, 1, 2), (1, 2, 0), (2, 0, 1)]

while True:
    for offset in offsets:
        for device in cli.devices:
            # Setting every third color red
            for x in range(offset[0], len(device.colors), 3):
                device.colors[x] = RGBColor(255, 0, 0)
            # Setting every third color white
            for x in range(offset[1], len(device.colors), 3):
                device.colors[x] = RGBColor(255, 255, 255)
            # Setting every third color blue
            for x in range(offset[2], len(device.colors), 3):
                device.colors[x] = RGBColor(0, 0, 255)
        cli.show()  # Updates all devices
        sleep(.5)
예제 #21
0
# Illuminated RGB Addressable Lights based on SimConnect Variables
# by: Diego Vásquez (2020)
# This Software is Open Source under GNU License
# Utility for navigating Keyboard LED Lights for Identification
# Press up/down/left/right to move LED cursos and take note of led 'id' number
# Press ESC to exit.

from openrgb.utils import RGBColor
from pynput.keyboard import Key, Listener
from RGB import *

#####################################################################
# Pending: Read these defaults from the configuration file
rows = 6
cols = 22
lit = RGBColor(0, 0, 255)
unlit = RGBColor(0, 0, 20)
keyb = None


#####################################################################
# Keyboard Handlers
def on_press(key):
    #print('{0} pressed'.format(
    #key))
    check_key(key)


def on_release(key):
    #print('{0} release'.format(
    # key))
예제 #22
0
orgbclnt.clear()

#mclnt.on_message = on_message
mclnt.on_connect = on_connect

mclnt.connect(BROKER_HOST, BROKER_PORT)
mclnt.loop_start()


while(True):
    if heating == True:
        print("Heating On. Current Temp: " + str(current_temp) + " Temperature Setting: " + str(temp_setting))
        if current_temp > (temp_setting + 1):
            heating = False
            for device in orgbclnt.devices:
                device.set_color(RGBColor(0,0,255))
                time.sleep(0.05)
            fah_command("pause")
            print("Turning Heating Off")
            mclnt.publish('hah/heater_state', payload="OFF", retain=True)
    else:
        print("Heating Off. Current Temp: " + str(current_temp) + " Temperature Setting: " + str(temp_setting))
        if current_temp < (temp_setting - 1):
            heating = True
            for device in orgbclnt.devices:
                device.set_color(RGBColor(255,0,0))
                time.sleep(0.05)
            fah_command("unpause")
            print("Turning Heating On")
            mclnt.publish('hah/heater_state', payload="ON", retain=True)
    time.sleep(10)
예제 #23
0
        image = grab_screen(0, 0, X_RES, Y_RES)  # take a screenshot usign X
    else:
        image = ImageGrab.grab()  # take a screenshot using PIL
    #print image.size

    data = []
    for y in range(0, image.size[1], DECIMATE):  #loop over the height
        for x in range(0, image.size[0], DECIMATE):  #loop over the width
            color = image.getpixel((x, y))  #grab a pixel
            data.append(color)

    #cluster and assign labels to the pixels
    labels = clt.fit_predict(data)
    #count labels to find most popular
    label_counts = Counter(labels)
    #subset out most popular centroid
    dominant_color = clt.cluster_centers_[label_counts.most_common()[0][0]]

    # current color is blended with colors 2 frames before to smooth effect
    dominant_color += (old + 0.5 * old2)
    dominant_color /= 2.5
    # reset vars for next iteration
    old = dominant_color
    old2 = old

    red, green, blue = dominant_color
    #print(red, green, blue)
    for Device in Dlist:
        Device.set_color(RGBColor(int(red), int(green), int(blue)))
    time.sleep(0.1)
예제 #24
0
#!/usr/bin/env python3
from openrgb import OpenRGBClient
from openrgb.utils import RGBColor
import time

client = OpenRGBClient()

print(client)

print(client.devices)

client.off()

while True:
    for x in range(360):
        client.set_color(RGBColor.fromHSV(x, 100, 100), fast=True)
        time.sleep(.05)
예제 #25
0
import colorsys, random, string, sys, threading, time, os, openrgb
from openrgb.utils import DeviceType, ModeData, RGBColor, ZoneType

# or the name could also be 'The Acid's Kickin In Hard' if you want (as per @Saint Mischievous on discord)

Black = RGBColor(0, 0, 0)

def UserInput():
    """It will always return 5 things;\n
    Color1, Color2, Speed, Devices for reversal, Devices that are enables"""
    Color1 = Color2 = Speed = ReversedDevice = OnlySet = None
    for arg in sys.argv:
        if arg == '--C1':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color1 = RGBColor(int(R),int(G),int(B))
        elif arg == '--C2':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color2 = RGBColor(int(R),int(G),int(B))
        elif arg == '--reversed':
            ReversedDevices = (sys.argv.index(arg) + 1) # Will point to where the device(s) that need to be reversed are
            ReversedDevice = []
            if ' , ' in sys.argv[ReversedDevices]:
                for i in sys.argv[ReversedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            ReversedDevice += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold() == sys.argv[ReversedDevices].strip().casefold():
from Asus_argb_ambient_lighting import get_split_screen_colors

# https://openrgb-python.readthedocs.io/en/latest/pages/advanced.html
from openrgb import OpenRGBClient
from openrgb.utils import RGBColor, DeviceType
import numpy as np
import time

client = OpenRGBClient()

client.clear()  # Turns everything off

motherboard = client.get_devices_by_type(DeviceType.MOTHERBOARD)[0]
add = client.get_devices_by_type(DeviceType.MOTHERBOARD)[1]
add.leds[20].set_color(RGBColor(0, 255, 0))

cols = []
nleds = 41

split_cols = get_split_screen_colors()

EN = [0, 5]
ES = [5, 10]
SE = [10, 16]
SW = [16, 21]
WS = [21, 26]
WN = [26, 32]
NW = [32, 37]
NE = [37, 41]
splits = [EN, ES, SE, SW, WS, WN, NW, NE]
예제 #27
0
                            ZO[1][ID] = ZO[2]
                        else:
                            ZO[1][ID] -= 1
                        ID += 1
                    ZO[0].show()
            elif ZOType == ZoneType.MATRIX:
                pass
                #print('matrix support not done yet')
        time.sleep(0.1)


if __name__ == '__main__':
    C1, C2, Reversed, Enabled = UserInput()
    #print(C1, C2, Reversed, Enabled)
    if C1 == None:
        C1 = RGBColor(255, 0, 0)
    if C2 == None:
        C2 = RGBColor(0, 0, 255)
    Enable = []
    if Enabled == None:
        Enable += [i for i in client.devices]
    elif Enabled != None:
        Enable = Enabled

    PassTo = []
    for Device in Enable:
        if Reversed != None:
            for R in Reversed:
                if R == Device:
                    ReverseBool = True
                    continue
예제 #28
0
 def vim_color_to_rgb_color(self, vim_color):
     return RGBColor(*self.vim_color_to_rgb(vim_color))
예제 #29
0
def UserInput():
    Color1 = Color2 = Colors = ReversedDevice = OnlySet = Zones = None
    Speed = 50
    for arg in sys.argv:
        if arg == '--C1':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color1 = RGBColor(int(R), int(G), int(B))
        elif arg == '--C2':
            Pos = sys.argv.index(arg) + 1
            R, G, B = sys.argv[Pos:(Pos + 3)]
            Color2 = RGBColor(int(R), int(G), int(B))
        elif arg == '--colors':
            Colors = []
            ColorsSelected = (sys.argv.index(arg) + 1)
            if ',' in sys.argv[ColorsSelected]:
                for i in sys.argv[ColorsSelected].split(','):
                    RGB = i.split()
                    Colors += [RGBColor(int(RGB[0]), int(RGB[1]), int(RGB[2]))]
            else:
                print("You must specify more than one color.")
                quit()
        elif arg == '--reversed':
            ReversedDevices = (sys.argv.index(arg) + 1)
            ReversedDevice = []
            if ' , ' in sys.argv[ReversedDevices]:
                for i in sys.argv[ReversedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            ReversedDevice += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[ReversedDevices].strip().casefold():
                        ReversedDevice += [D]
        elif arg == '--only-set':
            OnlySet = []
            AllowedDevices = (sys.argv.index(arg) + 1)
            if ' , ' in sys.argv[AllowedDevices]:
                for i in sys.argv[AllowedDevices].split(' , '):
                    for D in client.devices:
                        if D.name.strip().casefold() == i.strip().casefold():
                            OnlySet += [D]
            else:
                for D in client.devices:
                    if D.name.strip().casefold(
                    ) == sys.argv[AllowedDevices].strip().casefold():
                        OnlySet += [D]
        elif arg == '--only-zones':
            Zones = []
            AllowedZones = (sys.argv.index(arg) + 1)
            if ' , ' in sys.argv[AllowedZones]:
                for i in sys.argv[AllowedZones].split(' , '):
                    for D in client.devices:
                        for Z in D.zones:
                            if Z.name.strip().casefold() == i.strip().casefold(
                            ):
                                Zones += [Z]
            else:
                for D in client.devices:
                    for Z in D.zones:
                        if Z.name.strip().casefold(
                        ) == sys.argv[AllowedZones].strip().casefold():
                            Zones += [Z]
        elif arg == '--speed':
            Speed = int(sys.argv[(sys.argv.index(arg) + 1)])
        else:
            pass
    return (Color1, Color2, Colors, Speed, ReversedDevice, OnlySet, Zones)
예제 #30
0
def InfiniteCycle(Colors, Zone, Passes, Speed):
    RunThrough = 0
    FadeCount = 5 * Passes
    ColorFades = []
    for i in range(1, len(Colors), 1):
        RedShift = (Colors[i].red - Colors[0].red) / (FadeCount + 1)
        GreenShift = (Colors[i].green - Colors[0].green) / (FadeCount + 1)
        BlueShift = (Colors[i].blue - Colors[0].blue) / (FadeCount + 1)
        Fades = []
        for f in range(FadeCount, 0, -1):
            Fades.append(
                RGBColor(int(Colors[0].red + (RedShift * f)),
                         int(Colors[0].green + (GreenShift * f)),
                         int(Colors[0].blue + (BlueShift * f))))
        ColorFades.append(Fades)
    ColorFadeIndex = 0
    while True:
        ZOType = Zone.type
        if ZOType == ZoneType.SINGLE:
            RunThrough += 1
            if (RunThrough % 3) == 0:
                if Zone.colors[0] == Colors[0]:
                    Zone.colors[0] = (Colors[1])
                elif Zone.colors[0] == Colors[1]:
                    Zone.colors[0] = (Colors[0])
                elif (Zone.colors[0] != Colors[0]) & (Zone.colors[0] !=
                                                      Colors[1]):
                    Zone.colors[0] = (Colors[1])
                Zone.show()
        elif ZOType == ZoneType.LINEAR:
            if Zone.reverse:
                Index = Zone.length - Zone.index - 1
            else:
                Index = Zone.index
            Debug(f"{Index} =======")
            for i in range(Zone.length):
                Zone.colors[i] = Colors[0]
            for p in range(1, Passes + 1, 1):
                Debug("B:-----------")
                for f in range(int(FadeCount / Passes)):
                    if Index < Zone.length - (f + 1) and Index + (f + 1) >= 0:
                        if Zone.reverse:
                            Zone.colors[Index +
                                        (f + 1)] = ColorFades[ColorFadeIndex][
                                            f * Passes + p - 1]
                            Debug(
                                f'i:{Index+(f+1)} p:{p} f:{f} f*Passes+p-1:{f*Passes+p-1} Fade:{ColorFades[ColorFadeIndex][f*Passes+p-1]}'
                            )
                        else:
                            Zone.colors[Index +
                                        (f + 1)] = ColorFades[ColorFadeIndex][
                                            f * Passes + Passes - p]
                            Debug(
                                f'i:{Index+(f+1)} p:{p} f:{f} f*Passes+Passes-p:{f*Passes+Passes-p} Fade:{ColorFades[ColorFadeIndex][f*Passes+Passes-p]}'
                            )
                if Index >= 0 and Index < Zone.length:
                    Zone.colors[Index] = Colors[ColorFadeIndex + 1]
                    Debug(Index)
                for f in range(int(FadeCount / Passes)):
                    if Index > f and Index - (f + 1) < Zone.length:
                        if Zone.reverse:
                            Zone.colors[Index -
                                        (f + 1)] = ColorFades[ColorFadeIndex][
                                            f * Passes + Passes - p]
                            Debug(
                                f'i:{Index-(f+1)} p:{p} f:{f} f*Passes+Passes-p:{f*Passes+Passes-p} Fade:{ColorFades[ColorFadeIndex][f*Passes+Passes-p]}'
                            )
                        else:
                            Zone.colors[Index -
                                        (f + 1)] = ColorFades[ColorFadeIndex][
                                            f * Passes + p - 1]
                            Debug(
                                f'i:{Index-(f+1)} p:{p} f:{f} f*Passes+p-1:{f*Passes+p-1} Fade:{ColorFades[ColorFadeIndex][f*Passes+p-1]}'
                            )
                Zone.show()
                Debug("E:-----------")
            Zone.index += 1
            if Zone.index == Zone.length + 6:
                Zone.index = -6
                if ColorFadeIndex < len(ColorFades) - 1:
                    ColorFadeIndex += 1
                else:
                    ColorFadeIndex = 0
                time.sleep(1)
        elif ZOType == ZoneType.MATRIX:
            pass