Beispiel #1
0
        /// <summary>
        /// Converts the specified RGB color to an RGBW struct.
        /// </summary>
        /// <param name="color">RGB Color to convert</param>
        /// <returns>RGBW struct for the specified color</returns>
        public RGBW ConvertToRGBW(Color color)
        {
            // If the color does NOT match the previously converted color then...
            if (_lastInputColor != color)
            {
                // Save off the input color
                _lastInputColor = color;

                // Convert the input color to a RGBW struct
                _lastConvertedColor = color.ToRGBWFast();
            }

            // Return the RGBW struct
            return(_lastConvertedColor);
        }
Beispiel #2
0
        public bool SetPanelColor(int panelID, RGBW color)
        {
            var panel = this.panels.FirstOrDefault(p => p.ID.Equals(panelID));

            if (panel != null)
            {
                panel.StreamingColor = color;
                lock (changedPanels)
                {
                    if (!changedPanels.Contains(panel))
                    {
                        changedPanels.Add(panel);
                    }
                }
                return(true);
            }
            return(false);
        }
Beispiel #3
0
 /// <summary>
 /// Sets the <see cref="RGBWLights"/> and
 /// <see cref="RGBLights"/> to a given hue.
 /// </summary>
 /// <param name="hue">To hue (0.0 - 360.0) degrees.</param>
 public void AllHue(float hue)
 {
     RGBW.SetHue(0, hue);
     RGB.SetHue(hue);
 }
Beispiel #4
0
 /// <summary>
 /// Sets the <see cref="RGBWLights"/> and
 /// <see cref="RGBLights"/> to a given 'System.Drawing.Color'
 /// </summary>
 /// <param name="color">To color to set the lights.</param>
 public void AllColor(Color color)
 {
     RGBW.SetColor(0, color);
     RGB.SetColor(color);
 }
Beispiel #5
0
 /// <summary>
 /// Sets the <see cref="RGBWLights"/> and
 /// <see cref="RGBLights"/> to white and
 /// switches 'on' all <see cref="WhiteLights"/>.
 /// </summary>
 public void AllWhite()
 {
     RGBW.SwitchWhite(0);
     White.SwitchOn();
     RGB.SetColor(Color.White);
 }
Beispiel #6
0
 /// <summary>
 /// Sets the color (attribute value) of a RGBW LED endpoint.
 /// </summary>
 /// <param name="uuid">The attribute uuid.</param>
 /// <param name="color">The color value (RGBW).</param>
 /// <returns>True if successful.</returns>
 public async Task <bool> SetColorAsync(Guid uuid, RGBW color) =>
 await SetColorAsync(uuid, ColorData.Rgbw2Hex(color));
Beispiel #7
0
 /// <summary>
 /// Returns a string representation of the RGBW color value.
 /// </summary>
 /// <param name="color">The RGBW color value.</param>
 /// <returns>The hex string representation.</returns>
 public static string Rgbw2Hex(RGBW color)
 {
     return(color.W.ToString("X2") + color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2"));
 }