Esempio n. 1
0
        public static LEDData FromColors(LEDColorData colorData)
        {
            LEDData data = LEDData.Empty;

            for (int i = 0; i < NUMLEDS_KEYBOARD; i++)
            {
                data.Keyboard[i].Color(colorData.Keyboard[i]);
            }
            for (int i = 0; i < NUMLEDS_STRIP; i++)
            {
                data.Strip[i].Color(colorData.Strip[i]);
            }
            for (int i = 0; i < NUMLEDS_MOUSE; i++)
            {
                data.Mouse[i].Color(colorData.Mouse[i]);
            }
            for (int i = 0; i < NUMLEDS_MOUSEPAD; i++)
            {
                data.Mousepad[i].Color(colorData.Mousepad[i]);
            }
            for (int i = 0; i < NUMLEDS_HEADSET; i++)
            {
                data.Headset[i].Color(colorData.Headset[i]);
            }
            for (int i = 0; i < NUMLEDS_KEYPAD; i++)
            {
                data.Keypad[i].Color(colorData.Keypad[i]);
            }
            for (int i = 0; i < NUMLEDS_GENERAL; i++)
            {
                data.General[i].Color(colorData.General[i]);
            }

            return(data);
        }
Esempio n. 2
0
        private void SendGeneralData(LEDData data)
        {
            byte[] colorArray = data.General.ToByteArray();

            for (int i = 0; i < 5; i++)
            {
                int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                ChromaAnimationAPI.Set1DColor(baseGeneralAnim, 0, i, color);
            }
            ChromaAnimationAPI.PreviewFrame(baseGeneralAnim, 0);
        }
Esempio n. 3
0
        private void SendHeadsetData(LEDData data)
        {
            byte[] colorArray = data.Mousepad.ToByteArray();

            for (int i = 0; i < 2; i++)
            {
                int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                ChromaAnimationAPI.Set1DColor(baseHeadsetAnim, 0, i, color);
            }
            ChromaAnimationAPI.PreviewFrame(baseHeadsetAnim, 0);
        }
Esempio n. 4
0
        private void SendMousepadData(LEDData data)
        {
            byte[] colorArray = data.Mousepad.ToByteArray();

            for (int i = 0; i < 16; i++)
            {
                int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                ChromaAnimationAPI.Set1DColor(baseMousepadAnim, 0, 16 - i, color); // inverted order
            }
            ChromaAnimationAPI.PreviewFrame(baseMousepadAnim, 0);
        }
Esempio n. 5
0
        /*  public void SendData(int ledCount, byte[] data, LightingMode mode)
         * {
         *    Task.Run(() => sender.Send(1, SanitizeDataArray(ledCount, data, mode)));
         * }*/

        public void SendData(LEDFrame frame)
        {
            if (!frame.Zones.HasFlag(LightZone.Strip))
            {
                return;
            }
            LEDData data = frame.Leds;

            //sender.Send(1, SanitizeDataArray(ledCount, data, mode))
            sender.Send(1, data.Strip.ToByteArray(this.reverseOrder));
        }
Esempio n. 6
0
        private void SendKeypadData(LEDData data)
        {
            byte[] colorArray = data.Keypad.ToByteArray();

            for (int col = 0; col < 4; col++)
            {
                for (int row = 0; row < 5; row++)
                {
                    int index = col * 5 + row;
                    int color = ChromaAnimationAPI.GetRGB(colorArray[index * 3], colorArray[index * 3 + 1], colorArray[index * 3 + 2]);
                    ChromaAnimationAPI.Set2DColor(baseKeypadAnim, 0, col, row, color);
                }
            }
            ChromaAnimationAPI.PreviewFrame(baseKeypadAnim, 0);
        }
Esempio n. 7
0
        private void SendKeyboardData(LEDData data)
        {
            byte[] colorArray = data.Keyboard.ToByteArray();

            int black = ChromaAnimationAPI.GetRGB(0, 0, 0);

            foreach (Keyboard.RZKEY key in numPadKeys)
            {
                ChromaAnimationAPI.SetKeyColor(baseKeyboardAnim, 0, (int)key, black);
            }
            for (int i = 0; i < 88; i++) // TODO: NUMPAD
            {
                int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                ChromaAnimationAPI.SetKeyColor(baseKeyboardAnim, 0, (int)indexKeyMap[i], color);
            }
            ChromaAnimationAPI.PreviewFrame(baseKeyboardAnim, 0);
        }
Esempio n. 8
0
 public LEDFrame(object sender, LEDData ledData, LightZone zones, bool priority = false)
 {
     if (sender == null)
     {
         this.SenderChain = new List <object>();
     }
     else
     {
         this.SenderChain = new List <object>()
         {
             sender
         }
     };
     this.Leds     = ledData;
     this.Zones    = zones;
     this.Priority = priority;
 }
Esempio n. 9
0
        public void SendData(LEDFrame frame) // TODO: Abstract away these details, make parent class
        {
            if (!enabled || disposed)
            {
                return;
            }
            LEDData data = frame.Leds;

            // KEYBOARD
            if (frame.Zones.HasFlag(LightZone.Keyboard))
            {
                SendKeyboardData(data);
            }

            // MOUSE
            if (frame.Zones.HasFlag(LightZone.Mouse))
            {
                SendMouseData(data);
            }

            // MOUSEPAD
            if (frame.Zones.HasFlag(LightZone.Mouse))
            {
                SendMousepadData(data);
            }

            // HEADSET
            if (frame.Zones.HasFlag(LightZone.Headset))
            {
                SendHeadsetData(data);
            }

            // 2D KEYPAD
            if (frame.Zones.HasFlag(LightZone.Keypad))
            {
                SendKeypadData(data);
            }

            // GENERAL (CHROMA LINK)
            if (frame.Zones.HasFlag(LightZone.General))
            {
                SendGeneralData(data);
            }
        }
Esempio n. 10
0
        private void SendMouseData(LEDData data)
        {
            byte[] colorArray = data.Mouse.ToByteArray();

            for (int i = 0; i < 16; i++)
            {
                int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);

                ushort number;
                byte   upper;
                byte   lower;
                if (i == 0) // logo and bottom leds
                {
                    foreach (RZLED2 led in MOUSE_BOTTOM_LEDS)
                    {
                        number = Convert.ToUInt16(RZLED2.RZLED2_LOGO);
                        upper  = (byte)(number >> 8);
                        lower  = (byte)(number & 0xff);
                        ChromaAnimationAPI.Set2DColor(baseMouseAnim, 0, upper, lower, color);
                    }
                }
                else if (i == 1) // scrollwheel and backlight
                {
                    number = Convert.ToUInt16(RZLED2.RZLED2_SCROLLWHEEL);
                    upper  = (byte)(number >> 8);
                    lower  = (byte)(number & 0xff);
                    ChromaAnimationAPI.Set2DColor(baseMouseAnim, 0, upper, lower, color);

                    number = Convert.ToUInt16(RZLED2.RZLED2_BACKLIGHT);
                    upper  = (byte)(number >> 8);
                    lower  = (byte)(number & 0xff);
                    ChromaAnimationAPI.Set2DColor(baseMouseAnim, 0, upper, lower, color);
                }
                else
                {
                    number = Convert.ToUInt16(MOUSE_LEDS[i]);
                    upper  = (byte)(number >> 8);
                    lower  = (byte)(number & 0xff);
                    ChromaAnimationAPI.Set2DColor(baseMouseAnim, 0, upper, lower, color);
                }
            }
            ChromaAnimationAPI.PreviewFrame(baseMouseAnim, 0);
        }