public TheaterChaser(LedSettings settings) : base(settings) { this.PrimaryColor = Color.White; this.SecondaryColor = Color.White; this.ChaseQuantity = settings.LedCount / 20; this.ChaseSpeed = 20; this.Gradient = false; this.Reverse = false; }
private void buttonLedGet_Click(object sender, EventArgs e) { Tools.HandleApiExceptions(delegate() { LedSettings settings = Api.GetStatusLed(checkLedActive.Checked); comboLedColor.SelectedIndex = (int)settings.Color; numericLedDuration.Value = settings.Duration; numericLedHighTime.Value = settings.HighTime; numericLedLowTime.Value = settings.LowTime; checkBoxLedEnabled.Checked = settings.Enabled; comboLedUsage.SelectedIndex = (int)settings.Usage; }); }
private void buttonLedSet_Click(object sender, EventArgs e) { Tools.HandleApiExceptions(delegate() { LedSettings settings = new LedSettings(); settings.Color = (LedColor)comboLedColor.SelectedIndex; settings.Duration = (int)numericLedDuration.Value; settings.HighTime = (int)numericLedHighTime.Value; settings.LowTime = (int)numericLedLowTime.Value; settings.Usage = (LedUsage)comboLedUsage.SelectedIndex; settings.Enabled = checkBoxLedEnabled.Checked; Api.SetStatusLed(checkLedActive.Checked, settings); }); }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false) { uint maxKbLength = 0; Dictionary <Color, List <Keyboard_LEDIndex> > kbIndices = null; if (sbKeyboard != null) { kbIndices = new Dictionary <Color, List <Keyboard_LEDIndex> >(); } LedColour[] mouseColors = null; foreach (KeyValuePair <DeviceKeys, Color> kv in keyColors) { if (e.Cancel) { return(false); } if (kbIndices != null) { var kbLedIdx = GetKeyboardMappingLedIndex(kv.Key); if (kbLedIdx != Keyboard_LEDIndex.NotApplicable) { if (!kbIndices.ContainsKey(kv.Value)) { kbIndices[kv.Value] = new List <Keyboard_LEDIndex>(1); } var list = kbIndices[kv.Value]; list.Add(kbLedIdx); if (list.Count > maxKbLength) { maxKbLength = (uint)list.Count; } } } if (sbMouse != null) { int moosIdx = GetMouseMappingIndex(kv.Key); if (moosIdx >= 0 && moosIdx <= MouseMapping.Length) { if (mouseColors == null) { mouseColors = new LedColour[MouseMapping.Length]; } mouseColors[moosIdx].a = kv.Value.A; mouseColors[moosIdx].r = kv.Value.R; mouseColors[moosIdx].g = kv.Value.G; mouseColors[moosIdx].b = kv.Value.B; } } } uint numKbGroups = 0; uint[] kbGroupsArr = null; LedPattern[] kbPatterns = null; LedColour[] kbColors = null; if (kbIndices != null) { numKbGroups = (uint)kbIndices.Count; kbGroupsArr = new uint[numKbGroups * (maxKbLength + 1)]; kbPatterns = new LedPattern[numKbGroups]; kbColors = new LedColour[numKbGroups]; uint currGroup = 0; foreach (var kv in kbIndices) { if (e.Cancel) { return(false); } kbPatterns[currGroup] = LedPattern.Static; kbColors[currGroup].a = kv.Key.A; kbColors[currGroup].r = kv.Key.R; kbColors[currGroup].g = kv.Key.G; kbColors[currGroup].b = kv.Key.B; uint i = currGroup * (maxKbLength + 1); kbGroupsArr[i++] = (uint)kv.Value.Count; foreach (Keyboard_LEDIndex idx in kv.Value) { kbGroupsArr[i++] = (uint)idx; } currGroup++; } kbIndices = null; } lock (action_lock) { if (e.Cancel) { return(false); } if (sbKeyboard != null && numKbGroups > 0) { try { if (sbKeyboardSettings == null) { sbKeyboardSettings = new LedSettings(); sbKeyboardSettings.persistentInDevice = false; sbKeyboardSettings.globalPatternMode = false; sbKeyboardSettings.pattern = LedPattern.Static; sbKeyboardSettings.payloadData = new LedPayloadData(); } sbKeyboardSettings.payloadData = sbKeyboard.LedPayloadInitialize(sbKeyboardSettings.payloadData.Value, numKbGroups, maxKbLength, 1); sbKeyboardSettings.payloadData = sbKeyboard.LedPayloadFillupAll(sbKeyboardSettings.payloadData.Value, numKbGroups, kbPatterns, maxKbLength + 1, kbGroupsArr, 1, 1, kbColors); sbKeyboard.SetLedSettings(sbKeyboardSettings); } catch (Exception exc) { Global.logger.Error("Failed to Update Device " + sbKeyboardInfo.friendlyName + ": " + exc.ToString()); return(false); } finally { if (sbKeyboardSettings != null && sbKeyboardSettings.payloadData.HasValue && sbKeyboardSettings.payloadData.Value.opaqueSize > 0) { sbKeyboardSettings.payloadData = sbKeyboard.LedPayloadCleanup(sbKeyboardSettings.payloadData.Value, numKbGroups); } } } if (e.Cancel) { return(false); } if (sbMouse != null && mouseColors != null) { if (sbMouseSettings == null) { sbMouseSettings = new LedSettings(); sbMouseSettings.persistentInDevice = false; sbMouseSettings.globalPatternMode = false; sbMouseSettings.pattern = LedPattern.Static; sbMouseSettings.payloadData = new LedPayloadData(); } if (sbMouseSettings.payloadData.Value.opaqueSize == 0) { var mousePatterns = new LedPattern[mouseColors.Length]; var mouseGroups = new uint[MouseMapping.Length * 2]; for (int i = 0; i < MouseMapping.Length; i++) { mouseGroups[(i * 2) + 0] = 1; //1 LED in group mouseGroups[(i * 2) + 1] = (uint)MouseMapping[i].Key; //Which LED it is mousePatterns[i] = LedPattern.Static; //LED has a host-controlled static color } try { sbMouseSettings.payloadData = sbMouse.LedPayloadInitialize(sbMouseSettings.payloadData.Value, sbMouseInfo.totalNumLeds, 1, 1); sbMouseSettings.payloadData = sbMouse.LedPayloadFillupAll(sbMouseSettings.payloadData.Value, (uint)mouseColors.Length, mousePatterns, 2, mouseGroups, 1, 1, mouseColors); } catch (Exception exc) { Global.logger.Error("Failed to setup data for " + sbMouseInfo.friendlyName + ": " + exc.ToString()); if (sbMouseSettings.payloadData.Value.opaqueSize > 0) { sbMouseSettings.payloadData = sbMouse.LedPayloadCleanup(sbMouseSettings.payloadData.Value, sbMouseInfo.totalNumLeds); } return(false); } } else { try { for (int i = 0; i < mouseColors.Length; i++) { sbMouseSettings.payloadData = sbMouse.LedPayloadFillupLedColour(sbMouseSettings.payloadData.Value, (uint)i, 1, mouseColors[i], false); } } catch (Exception exc) { Global.logger.Error("Failed to fill color data for " + sbMouseInfo.friendlyName + ": " + exc.ToString()); return(false); } } try { sbMouse.SetLedSettings(sbMouseSettings); } catch (Exception exc) { Global.logger.Error("Failed to Update Device " + sbMouseInfo.friendlyName + ": " + exc.ToString()); return(false); } } } return(true); }
public void Shutdown() { lock (action_lock) { if (sbMouse != null) { if (sbMouseSettings != null && sbMouseSettings.payloadData.HasValue && sbMouseSettings.payloadData.Value.opaqueSize > 0) { try { sbMouseSettings.payloadData = sbMouse.LedPayloadCleanup(sbMouseSettings.payloadData.Value, sbMouseInfo.totalNumLeds); } catch (Exception exc) { Global.logger.Error("There was an error freeing " + sbMouseInfo.friendlyName + ".\r\n" + exc.Message); } } sbMouseSettings = null; try { sbMouse.CloseDevice(); sbMouse.Dispose(); sbMouse = null; } catch (Exception exc) { Global.logger.Error("There was an error closing " + sbMouseInfo.friendlyName + ".\r\n" + exc.Message); } finally { if (sbMouse != null) { sbMouse.Dispose(); sbMouse = null; } } } if (sbKeyboard != null) { if (sbKeyboardSettings != null && sbKeyboardSettings.payloadData.HasValue && sbKeyboardSettings.payloadData.Value.opaqueSize > 0) { try { sbKeyboardSettings.payloadData = sbKeyboard.LedPayloadCleanup(sbKeyboardSettings.payloadData.Value, sbKeyboardSettings.payloadData.Value.opaqueSize); } catch (Exception exc) { Global.logger.Error("There was an error freeing " + sbKeyboardInfo.friendlyName + ".\r\n" + exc.Message); } } sbKeyboardSettings = null; try { sbKeyboard.CloseDevice(); sbKeyboard.Dispose(); sbKeyboard = null; } catch (Exception exc) { Global.logger.Error("There was an error closing " + sbKeyboardInfo.friendlyName + ".\r\n" + exc.Message); } finally { if (sbKeyboard != null) { sbKeyboard.Dispose(); sbKeyboard = null; } } } if (sbScanner != null) { try { sbScanner.Dispose(); sbScanner = null; } catch (Exception exc) { Global.logger.Error("There was an error closing SoundBlasterX scanner.\r\n" + exc.Message); } finally { sbScanner = null; } } } }
public NoNameScene(LedSettings settings) : base(settings) { }
public ConfigurationController(LedSettings configuration) { this._configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }
public SolidColor(LedSettings settings) : base(settings) { this.Color = Color.White; }
protected Scene(LedSettings settings) { this.Settings = settings ?? throw new ArgumentNullException(nameof(settings)); }
public Rainbow(LedSettings settings) : base(settings) { this.ChaseSpeed = 20; this.Reverse = false; }
public Breathing(LedSettings settings) : base(settings) { this.BreathSpeed = 20; this.Color = Color.Red; }