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); }
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); }
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); }
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); }