Example #1
0
    def _change_RGB(self, e=None):
        self._color = Color(int(self._SV_red.get()), int(self._SV_green.get()),
                            int(self._SV_blue.get()))

        h, s, v = self._color.toHSV()
        self._SV_hue.set(h)
        self._SV_saturation.set(s * 100)
        self._SV_value.set(v * 100)
Example #2
0
    def __init__(self, parent):
        baseModule.__init__(self, parent)

        self._color = Color(255, 0, 0)

        self.mainFrame = Frame(parent)
        self.mainFrame.grid(sticky=(E, W))
        self.populateInterface(self.mainFrame)
Example #3
0
    def _updateSH(self):
        if self.__x == 0:
            self.__colorSH = Color.randomColor().mul([1.0, 0.42, 0.3])

        self._controller.clear()

        for y in range(self.__nbleds):
            col = self.__colorSH * Color.fromList(self.__data[self.__x][y])
            self._controller.buffer[y] = col.toList()

        self._controller.send()
Example #4
0
    def _updateRNB(self):
        self._controller.clear()
        color = Color.fromHSV(self.__rainbowHue, 1.0,
                              1.0).mul([1.0, 0.42, 0.3])

        for y in range(self.__nbleds):
            col = color * Color.fromList(self.__data[self.__x][y])
            self._controller.buffer[y] = col.toList()

        self.__rainbowHue += int(self._SV_rainbowSpeed.get()) / 10.0
        self.__rainbowHue %= 360.0
        self._controller.send()
Example #5
0
    def update(self):
        """ Update the leds from interface parametters """

        coefColor = Color(*self._color.toList())
        if self._SV_coefEnabled.get() == "on":
            coefColor.enhance(gr=0.60, br=0.45, bg=0.25)
        """ Update color """
        self.mainFrame.configure(background=self._color.toHex())
        """ Send colors to arduino and wait 60ms """
        for n in range(self._controller.nbLeds):
            self._controller.buffer[n] = coefColor.toList()
        self._controller.send()
Example #6
0
    def __updateRainbow(self):
        _rainbowValue = self._safeGetValueFromSlider(self._S_rainbowSpeed, 10,
                                                     0.6)

        self._V3_HSVColor[0] = (self._V3_HSVColor[0] + _rainbowValue) % 360
        RGB = Color.fromHSV(*self._V3_HSVColor)
        self._hexColor = RGB.toHex()
Example #7
0
    def __init__(self, parent):
        baseModule.__init__(self, parent)

        self._color = Color(255, 0, 0)

        self._colors = [Color() for _ in range(10)]

        self.mainFrame = Frame(parent)
        self.mainFrame.grid(sticky=(E, W))

        self.mainFrame.configure(background=self._color.toHex())

        self.populateInterface(self.mainFrame)

        self.iupdateCounter = 0
        self.newColors = []
Example #8
0
    def _change_HSV(self, e=None):
        self._color = Color.fromHSV(float(self._SV_hue.get()),
                                    float(self._SV_saturation.get()) / 100.0,
                                    float(self._SV_value.get()) / 100.0)

        self._SV_red.set(self._color.red())
        self._SV_green.set(self._color.green())
        self._SV_blue.set(self._color.blue())
Example #9
0
    def _updateFI(self):
        self._controller.clear()

        for y in range(self.__nbleds):
            col = Color.fromList(self.__data[self.__x][y])
            col.mul([1.0, 0.42, 0.3])
            self._controller.buffer[y] = col.toList()

        self._controller.send()
Example #10
0
    def interpolate(self, startColor, endColor, ratio):
        startHSV = startColor.toHSV()
        endHSV = endColor.toHSV()

        return Color.fromHSV(
            self.__linearInterpolator(max(startHSV[0], endHSV[0]),
                                      min(startHSV[0], endHSV[0]), ratio),
            self.__linearInterpolator(startHSV[1], endHSV[1], ratio),
            self.__linearInterpolator(startHSV[2], endHSV[2], ratio))
Example #11
0
    def update(self):
        #self._SV_SPEED.get()) != self._parent.getSpeed():
        if int(self._parent.getSpeed()) != 5:
            self._parent.setSpeed(5)  #int(self._SV_SPEED.get()))

        if self._controller.nbLeds is not None and self._controller.nbLeds > len(
                self._colors):
            self._colors = [Color() for _ in range(self._controller.nbLeds)]

        if self.iupdateCounter != 0:
            for i in range(self._controller.nbLeds):
                self._colors[i] = self.interpolate(self._colors[i],
                                                   self.newColors[i], 0.05)
                tmp = Color.fromList(self._colors[i].toList()).enhance(gr=0.60,
                                                                       br=0.45,
                                                                       bg=0.25)
                self._controller.buffer[i] = tmp.toList()
            self._controller.send()
            self.iupdateCounter -= 1

        else:

            hue = float(self._SV_hue.get())
            hueD = float(self._SV_hueD.get())
            HueValues = (hue, (hue - hueD) % 360)

            saturation = float(self._SV_saturation.get())
            saturationD = float(self._SV_saturationD.get())
            SatValues = (saturation, saturation - saturationD)

            value = float(self._SV_value.get())
            valueD = float(self._SV_valueD.get())
            ValValues = (value, value - valueD)

            self.newColors.clear()
            for i in range(self._controller.nbLeds):
                self.newColors.append(
                    Color.fromHSV(
                        randrange(min(*HueValues), max(*HueValues)),
                        randrange(min(*SatValues), max(*SatValues)) / 100.0,
                        randrange(min(*ValValues), max(*ValValues)) / 100.0))

            self.iupdateCounter = int(self._SV_SPEED.get()) // 5
Example #12
0
def __effect_rainbowstatic_full(cls, steps):
    cls.clear()

    color = Color.fromHSV(cls.vars["rainbowHue"], 1.0, 1.0)

    for c in range(cls.nbLeds):
        cls.buffer[c] = color.toList()

    cls.vars["rainbowHue"] = (cls.vars["rainbowHue"] + steps) % 360

    cls.moderate(1, 0.3, 0.42)
    cls.send()
Example #13
0
def __effect_rainbow(cls, steps):
    cls.clear()

    hue = cls.vars["startHue"]

    for c in range(cls.nbLeds):
        hue = (hue + steps) % 360
        col = Color.fromHSV(hue, 1.0, 1.0)
        cls.buffer[c] = col.toListLED()

    cls.vars["startHue"] = (cls.vars["startHue"] - steps) % 360

    cls.moderate(1, 0.3, 0.42)
    cls.send()
Example #14
0
    def __init__(self, parent):
        baseModule.__init__(self, parent)

        self._s_fileName = ""
        self._b_fileLoaded = False
        self._s_fileType = ""

        self.__nbleds = 0
        self.__nbframes = 0
        self.__data = []

        self.__colorSH = Color.zero()
        self.__rainbowHue = 0.0
        self.__x = 0

        self.mainFrame = Frame(parent)
        self.mainFrame.grid(sticky=(E, W))
        self.populateInterface(self.mainFrame)
Example #15
0
def __effect_rainbowstatic_semi(cls, colorRange, steps):
    cls.clear()

    if cls.vars["rainbowClockwise"]:
        if cls.vars["rainbowHue"] >= colorRange[1]:
            cls.vars["rainbowClockwise"] = not cls.vars["rainbowClockwise"]
    else:
        if cls.vars["rainbowHue"] <= colorRange[0]:
            cls.vars["rainbowClockwise"] = not cls.vars["rainbowClockwise"]

    color = Color.fromHSV(cls.vars["rainbowHue"], 1.0, 1.0)

    for c in range(cls.nbLeds):
        cls.buffer[c] = color.toList()

    if cls.vars["rainbowClockwise"]:
        cls.vars["rainbowHue"] = (cls.vars["rainbowHue"] + steps) % 360
    else:
        cls.vars["rainbowHue"] = (cls.vars["rainbowHue"] - steps) % 360

    cls.send()
Example #16
0
 def update(self):
     """ Update the leds from interface parametters """
     """ Computer color if rainbow is enabled """
     if self._SV_rainbowEnabled.get() == "on":
         self.__updateRainbow()
     """ Computer value if strobe is enabled """
     if self._SV_strobeEnabled.get() == "on":
         self.__updateStrobe()
     """ Update color value with strobeValue """
     _Color_RGB = Color.fromHex(self._hexColor)
     _Color_RGB *= self._f_strobeValue
     """ Update button color """
     self._B_pickColor.configure(background=_Color_RGB.toHex())
     """ Computer color luminosity from slider """
     _Color_RGB *= int(self._S_luminosity.get()) / 100
     """ Computer color coefs """
     if self._SV_coefEnabled.get() == "on":
         _rgbList = _Color_RGB.enhance(gr=0.60, br=0.45, bg=0.25).toList()
     else:
         _rgbList = _Color_RGB.toList()
     """ Send colors to arduino and wait 60ms """
     for n in range(self._controller.nbLeds):
         self._controller.buffer[n] = _rgbList
     self._controller.send()
Example #17
0
class hsvrgb_module(baseModule):
    def __init__(self, parent):
        baseModule.__init__(self, parent)

        self._color = Color(255, 0, 0)

        self.mainFrame = Frame(parent)
        self.mainFrame.grid(sticky=(E, W))
        self.populateInterface(self.mainFrame)

    def populateInterface(self, parent):
        """
        populate the parent element with all SingleColor elements
        :param parent: the parent element of all subelements
        """
        """#################### COEF ####################"""
        self._SV_coefEnabled = StringVar(value="on")

        self._RB_coefs = self._createToggle(parent, "Disable Coef",
                                            "Enable Coef",
                                            self._SV_coefEnabled)
        self._RB_coefs[0].grid(row=0, column=0)
        self._RB_coefs[1].grid(row=0, column=1)
        """#################### HUE ####################"""
        self._SV_hue = StringVar(value="0")
        self._S_hue = Scale(parent,
                            from_=0,
                            to=360,
                            orient=HORIZONTAL,
                            variable=self._SV_hue,
                            command=self._change_HSV)
        self._S_hue.grid(row=1, column=0, columnspan=2, sticky=(E, W))
        """#################### SATURATION ####################"""
        self._SV_saturation = StringVar(value="100")
        self._S_saturation = Scale(parent,
                                   from_=0,
                                   to=100,
                                   orient=HORIZONTAL,
                                   variable=self._SV_saturation,
                                   command=self._change_HSV)
        self._S_saturation.grid(row=2, column=0, columnspan=2, sticky=(E, W))
        """#################### LUMINOSITY ####################"""
        self._SV_value = StringVar(value="100")
        self._S_value = Scale(parent,
                              from_=0,
                              to=100,
                              orient=HORIZONTAL,
                              variable=self._SV_value,
                              command=self._change_HSV)
        self._S_value.grid(row=3, column=0, columnspan=2, sticky=(E, W))
        """#################### RED ####################"""
        self._SV_red = StringVar(value="255")
        self._S_red = Scale(parent,
                            from_=0,
                            to=255,
                            orient=HORIZONTAL,
                            variable=self._SV_red,
                            command=self._change_RGB)
        self._S_red.grid(row=4, column=0, columnspan=2, sticky=(E, W))
        """#################### GREEN ####################"""
        self._SV_green = StringVar(value="0")
        self._S_green = Scale(parent,
                              from_=0,
                              to=255,
                              orient=HORIZONTAL,
                              variable=self._SV_green,
                              command=self._change_RGB)
        self._S_green.grid(row=5, column=0, columnspan=2, sticky=(E, W))
        """#################### BLUE ####################"""
        self._SV_blue = StringVar(value="0")
        self._S_blue = Scale(parent,
                             from_=0,
                             to=255,
                             orient=HORIZONTAL,
                             variable=self._SV_blue,
                             command=self._change_RGB)
        self._S_blue.grid(row=6, column=0, columnspan=2, sticky=(E, W))

    def _getHSVTuple(self):
        return float(self._SV_hue.get()), float(
            self._SV_saturation.get()) / 100.0, float(
                self._SV_value.get()) / 100.0

    def _getRGBTuple(self):
        return

    def _change_HSV(self, e=None):
        self._color = Color.fromHSV(float(self._SV_hue.get()),
                                    float(self._SV_saturation.get()) / 100.0,
                                    float(self._SV_value.get()) / 100.0)

        self._SV_red.set(self._color.red())
        self._SV_green.set(self._color.green())
        self._SV_blue.set(self._color.blue())

    def _change_RGB(self, e=None):
        self._color = Color(int(self._SV_red.get()), int(self._SV_green.get()),
                            int(self._SV_blue.get()))

        h, s, v = self._color.toHSV()
        self._SV_hue.set(h)
        self._SV_saturation.set(s * 100)
        self._SV_value.set(v * 100)

    def update(self):
        """ Update the leds from interface parametters """

        coefColor = Color(*self._color.toList())
        if self._SV_coefEnabled.get() == "on":
            coefColor.enhance(gr=0.60, br=0.45, bg=0.25)
        """ Update color """
        self.mainFrame.configure(background=self._color.toHex())
        """ Send colors to arduino and wait 60ms """
        for n in range(self._controller.nbLeds):
            self._controller.buffer[n] = coefColor.toList()
        self._controller.send()
Example #18
0
    def _change_HSV(self, e=None):
        self._color = Color.fromHSV(float(self._SV_hue.get()),
                                    float(self._SV_saturation.get()) / 100.0,
                                    float(self._SV_value.get()) / 100.0)

        self.mainFrame.configure(background=self._color.toHex())
Example #19
0
class shades_module(baseModule):
    def __init__(self, parent):
        baseModule.__init__(self, parent)

        self._color = Color(255, 0, 0)

        self._colors = [Color() for _ in range(10)]

        self.mainFrame = Frame(parent)
        self.mainFrame.grid(sticky=(E, W))

        self.mainFrame.configure(background=self._color.toHex())

        self.populateInterface(self.mainFrame)

        self.iupdateCounter = 0
        self.newColors = []

    def populateInterface(self, parent):
        """
        populate the parent element with all SingleColor elements
        :param parent: the parent element of all subelements
        """
        """#################### HUE ####################"""
        self._LF_hue = LabelFrame(parent, text="H")
        self._LF_hue.grid(row=0, column=0, sticky=(E, W))

        self._SV_hue = StringVar(value="0")
        self._S_hue = Scale(self._LF_hue,
                            from_=0,
                            to=360,
                            orient=HORIZONTAL,
                            variable=self._SV_hue,
                            command=self._change_HSV)
        self._S_hue.grid(row=0, column=0, columnspan=2, sticky=E)

        self._SV_hueD = StringVar(value="60")
        self._S_hueD = Scale(self._LF_hue,
                             from_=0,
                             to=120,
                             orient=HORIZONTAL,
                             variable=self._SV_hueD)
        self._S_hueD.grid(row=1, column=0, columnspan=2, sticky=E)
        """#################### SATURATION ####################"""
        self._LF_saturation = LabelFrame(parent, text="S")
        self._LF_saturation.grid(row=1, column=0, sticky=(E, W))

        self._SV_saturation = StringVar(value="100")
        self._S_saturation = Scale(self._LF_saturation,
                                   from_=0,
                                   to=100,
                                   orient=HORIZONTAL,
                                   variable=self._SV_saturation,
                                   command=self._change_HSV)
        self._S_saturation.grid(row=0, column=0, columnspan=2, sticky=E)

        self._SV_saturationD = StringVar(value="0")
        self._S_saturationD = Scale(self._LF_saturation,
                                    from_=0,
                                    to=100,
                                    orient=HORIZONTAL,
                                    variable=self._SV_saturationD)
        self._S_saturationD.grid(row=1, column=0, columnspan=2, sticky=E)
        """#################### LUMINOSITY ####################"""
        self._LF_value = LabelFrame(parent, text="V")
        self._LF_value.grid(row=2, column=0, sticky=(E, W))

        self._SV_value = StringVar(value="100")
        self._S_value = Scale(self._LF_value,
                              from_=0,
                              to=100,
                              orient=HORIZONTAL,
                              variable=self._SV_value,
                              command=self._change_HSV)
        self._S_value.grid(row=0, column=0, columnspan=2, sticky=E)

        self._SV_valueD = StringVar(value="0")
        self._S_valueD = Scale(self._LF_value,
                               from_=0,
                               to=100,
                               orient=HORIZONTAL,
                               variable=self._SV_valueD)
        self._S_valueD.grid(row=1, column=0, columnspan=2, sticky=E)
        """#################### Speed ####################"""
        self._LF_SPEED = LabelFrame(parent, text="T")
        self._LF_SPEED.grid(row=3, column=0, sticky=(E, W))

        self._SV_SPEED = StringVar(value="60")
        self._S_SPEED = Scale(self._LF_SPEED,
                              from_=10,
                              to=500,
                              orient=HORIZONTAL,
                              variable=self._SV_SPEED)
        self._S_SPEED.grid(row=0, column=0, columnspan=2, sticky=E)

        self._B_SPEED_Reset = Button(self._LF_SPEED,
                                     command=self.resetSpeed,
                                     text="Reset speed")
        self._B_SPEED_Reset.grid(row=1, column=0, sticky=E)
        """#################### Interpolation ####################"""
        self._LF_INTERPO = LabelFrame(parent, text="I")
        self._LF_INTERPO.grid(row=4, column=0, sticky=(E, W))

        self._SV_INTERPO = StringVar(value="100")
        self._S_INTERPO = Scale(self._LF_INTERPO,
                                from_=10,
                                to=100,
                                orient=HORIZONTAL,
                                variable=self._SV_INTERPO)
        self._S_INTERPO.grid(row=0, column=0, columnspan=2, sticky=E)

    def resetSpeed(self):
        self._S_SPEED.set(5)

    def _change_HSV(self, e=None):
        self._color = Color.fromHSV(float(self._SV_hue.get()),
                                    float(self._SV_saturation.get()) / 100.0,
                                    float(self._SV_value.get()) / 100.0)

        self.mainFrame.configure(background=self._color.toHex())

    def update(self):
        #self._SV_SPEED.get()) != self._parent.getSpeed():
        if int(self._parent.getSpeed()) != 5:
            self._parent.setSpeed(5)  #int(self._SV_SPEED.get()))

        if self._controller.nbLeds is not None and self._controller.nbLeds > len(
                self._colors):
            self._colors = [Color() for _ in range(self._controller.nbLeds)]

        if self.iupdateCounter != 0:
            for i in range(self._controller.nbLeds):
                self._colors[i] = self.interpolate(self._colors[i],
                                                   self.newColors[i], 0.05)
                tmp = Color.fromList(self._colors[i].toList()).enhance(gr=0.60,
                                                                       br=0.45,
                                                                       bg=0.25)
                self._controller.buffer[i] = tmp.toList()
            self._controller.send()
            self.iupdateCounter -= 1

        else:

            hue = float(self._SV_hue.get())
            hueD = float(self._SV_hueD.get())
            HueValues = (hue, (hue - hueD) % 360)

            saturation = float(self._SV_saturation.get())
            saturationD = float(self._SV_saturationD.get())
            SatValues = (saturation, saturation - saturationD)

            value = float(self._SV_value.get())
            valueD = float(self._SV_valueD.get())
            ValValues = (value, value - valueD)

            self.newColors.clear()
            for i in range(self._controller.nbLeds):
                self.newColors.append(
                    Color.fromHSV(
                        randrange(min(*HueValues), max(*HueValues)),
                        randrange(min(*SatValues), max(*SatValues)) / 100.0,
                        randrange(min(*ValValues), max(*ValValues)) / 100.0))

            self.iupdateCounter = int(self._SV_SPEED.get()) // 5