static void UpdateLeds() { int cnt = 0; while (RunUpdateThread == true) { ActualFpsMeter.Restart(); PotentialFpsMeter.Restart(); SetLedColors(CorsairGroup); Surface.Update(); PotentialFpsMeter.Stop(); if (1000 / FPS_LIMIT - PotentialFpsMeter.ElapsedMilliseconds > 0) { Thread.Sleep(1000 / FPS_LIMIT - (int)PotentialFpsMeter.ElapsedMilliseconds); } ActualFpsMeter.Stop(); if (++cnt == 10) { cnt = 0; double ActualFps = 1000.0 / ActualFpsMeter.ElapsedMilliseconds; double PotentialFps = 1000.0 / PotentialFpsMeter.ElapsedMilliseconds; Console.SetCursorPosition(0, Console.CursorTop - 1); Console.WriteLine("FPS limit: " + FPS_LIMIT + ", Actual FPS: " + ActualFps.ToString("n2") + ", Potential FPS: " + PotentialFps.ToString("n2")); } } }
private async void PlayBlinkAnimation(int times, int delayMs, IEnumerable <Led> leds) { for (int i = 0; i < times; i++) { foreach (var led in leds) { led.Color = new Color(0, 0, 0); } surface.Update(true); await Task.Delay(delayMs); foreach (var led in leds) { led.Color = new Color(255, 255, 255); } surface.Update(true); await Task.Delay(delayMs); } }
static void GetAsusColors() { do { surface.Update(); auraMb.SyncBack(); Color[] AScolors = auraMb.Select(C => C.Color).ToArray(); colors = AScolors; //backIOColor = boardColor[0]; //pchColor = boardColor[1]; //headerOneColor = boardColor[2]; //headerTwoColor = boardColor[3]; System.Threading.Thread.Sleep(34); } while (running); }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } _brush.KeyColors = keyColors; /* * if (keyColors.ContainsKey(DeviceKeys.Peripheral_Logo)) * { * if (_deviceProvider != null) { * var device = from d in _deviceProvider.Devices where d.DeviceInfo.DeviceType == RGBDeviceType.HeadsetStand select d; * ILedGroup ledGroup = new ListLedGroup(device.First()); * ledGroup.Brush = new SolidColorBrush(new RGB.NET.Core.Color(234, 14, 214)); * } * } */ _surface.Update(); return(true); }
static void Main(string[] args) { surface.Exception += args_ => Console.WriteLine(args_.Exception.Message); LoadDevices(); /* LED Updates are triggered by an UpdateTrigger * UpdateTriggers must be registered to a surface */ TimerUpdateTrigger updateTrigger = new TimerUpdateTrigger(); surface.RegisterUpdateTrigger(updateTrigger); /* You can also trigger an update manually by calling surface.Update(); * If calling surface.Update() more than once, * an update trigger is almost always a better option. */ surface.Update(); /* To apply an led effect to some device(s), you must first make a ListLedGroup * ListLedGroups can be created from an individual IRGBDevice by passing * the IRGBDevice as a parameter to the ListLedGroup constructor. */ ILedGroup ledGroup = new ListLedGroup(surface.Leds); /* Once you have an ILedGroup with all of your desired Leds in it, * To apply an effect, you will start with a brush. * * Brushes are used to "paint" leds, and they are kinda like * bases that you can apply gradients and decorators to * - Gradients tell the brush what colors to paint where, and when. * - Decorators are like mods to a brush. */ PaintGradient(ledGroup, updateTrigger); Console.ReadLine(); }
private void LoadDevices() { RGBDeviceType deviceMask = RGBDeviceType.None; if (_config.Model.rgbDeviceSettings.useKeyboards) { deviceMask |= RGBDeviceType.Keyboard; } if (_config.Model.rgbDeviceSettings.useMice) { deviceMask |= RGBDeviceType.Mouse; } if (_config.Model.rgbDeviceSettings.useMotherboard) { deviceMask |= RGBDeviceType.Mainboard; } Console.WriteLine("Loading rgb devices..."); if (!CorsairDeviceProvider.Instance.IsInitialized) { CorsairDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } CorsairDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(CorsairDeviceProvider.Instance, deviceMask, throwExceptions: true); //razer sdk may not exist because it has to be in system directories. try { if (!RazerDeviceProvider.Instance.IsInitialized) { RazerDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } RazerDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(RazerDeviceProvider.Instance, deviceMask, throwExceptions: true); } catch { } if (!LogitechDeviceProvider.Instance.IsInitialized) { LogitechDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } LogitechDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(LogitechDeviceProvider.Instance, deviceMask, throwExceptions: true); if (!AsusDeviceProvider.Instance.IsInitialized) { AsusDeviceProvider.Instance.Initialize(deviceMask, throwExceptions: true); } AsusDeviceProvider.Instance.Exception += Instance_Exception; _surface.Load(AsusDeviceProvider.Instance, deviceMask, throwExceptions: true); _surface.AlignDevices(); foreach (var device in _surface.Devices) { var group = new ListLedGroup(device.Surface) { Brush = new SolidColorBrush(RGBConsts.Black) }; _surface.Update(); group.Detach(); } }