示例#1
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);
        }
示例#2
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);
        }
示例#3
0
        public void SendData(int ledCount, byte[] colorArray, LightingMode mode)
        {
            if (!enabled)
            {
                return;
            }
            List <Point> points = new List <Point>();

            if (mode == LightingMode.Line)
            {
                for (int i = 0; i < ledCount; i++)
                {
                    Color c = Color.FromArgb(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                    int   x = (int)Utils.Scale(i, 0, ledCount, 0, 22);// TODO: Handle keyboards without numpads
                    points.Clear();
                    for (int j = 0; j < 6; j++)
                    {
                        points.Add(new Point(x, j));
                    }
                    try
                    {
                        foreach (var point in points)
                        {
                            ChromaAnimationAPI.Set2DColor(baseKeyboardAnim, 0, point.Y, point.X, ChromaAnimationAPI.GetRGB(c.R, c.G, c.B));
                        }
                        // keyboardFrame.SetKeys(points, c);
                    }
                    catch
                    {
                        Console.WriteLine("Error sending data to Chroma keyboard. Perhaps it doesn't have a keypad");
                    }
                }
            }
            else if (mode == LightingMode.Point)
            {
                for (int i = 0; i < KEYBOARD_LED_COUNT; i++)
                {
                    int col = ChromaAnimationAPI.GetRGB(colorArray[0], colorArray[1], colorArray[2]);
                    ChromaAnimationAPI.Set1DColor(baseKeyboardAnim, 0, i, col);
                }

                /*points.Clear();
                 * for (int i = 0; i < 22; i++)
                 * {
                 *  for (int j = 0; j < 6; j++)
                 *  {
                 *      points.Add(new Point(i, j));
                 *  }
                 * }
                 * try
                 * {
                 *  keyboardFrame.SetKeys(points, Color.FromArgb(colorArray[0], colorArray[1], colorArray[2]));
                 * } catch (Exception) // TODO: Handle keyboards without numpads
                 * {
                 *  Console.WriteLine("Error sending data to Chroma keyboard. Perhaps it doesn't have a keypad");
                 * }*/
            }
            else if (mode == LightingMode.Keyboard)
            {
                int black = ChromaAnimationAPI.GetRGB(0, 0, 0);
                foreach (Keyboard.RZKEY key in numPadKeys)
                {
                    ChromaAnimationAPI.SetKeyColor(baseKeyboardAnim, 0, (int)key, black);
                    //keyboardFrame.SetKey(key, Color.Black); // set numpad keys to black
                }
                for (int i = 0; i < 88; i++)
                {
                    //Color c = Color.FromArgb();
                    int color = ChromaAnimationAPI.GetRGB(colorArray[i * 3], colorArray[i * 3 + 1], colorArray[i * 3 + 2]);
                    ChromaAnimationAPI.SetKeyColor(baseKeyboardAnim, 0, (int)indexKeyMap[i], color);
                    //keyboardFrame.SetKey(indexKeyMap[i], c);
                }
            }
            else
            {
                Console.Error.WriteLine("RazerChroma: Invalid lighting mode");
                throw new ArgumentException("Invalid lighting mode");
            }

            // keyboardFrame.Update();
            ChromaAnimationAPI.PreviewFrame(baseKeyboardAnim, 0);
        }