/// <summary> /// Append the Set LED Pattern command to an existing Command object /// </summary> /// <param name="c">The command.</param> /// <param name="ledPattern">The LED pattern to display</param> /// <returns>The updated command.</returns> public static Command SetLedPattern(this Command c, LedPattern ledPattern) { c.AddOpcode(Opcode.UIWrite_LED); c.AddParameter((byte)ledPattern); return(c); }
/// <summary> /// Set EV3 brick LED pattern /// </summary> /// <param name="ledPattern">Pattern to display on LED</param> /// <returns></returns> public async Task SetLedPatternAsync(LedPattern ledPattern) { var c = new Command(CommandType.DirectNoReply); c.SetLedPattern(ledPattern); await _brick.SendCommandAsyncInternal(c); }
private void InitLED() { LedPattern pattern = new LedPattern(); pattern.SwitchOn(LedPattern.Channel.Center, LedPattern.Symbol.Circle, Color.green, 255); _senso.ChangeLED(pattern); }
internal async Task SetLedPatternAsyncInternal(LedPattern ledPattern) { Command c = new Command(CommandType.DirectNoReply); c.SetLedPattern(ledPattern); await SendCommandAsyncInternal(c); }
internal async Task SetLedPatternAsyncInternal(LedPattern ledPattern) { Command c = _brick.NewCommand(CommandType.Direct); c.SetLedPattern(ledPattern); await _brick.SendCommandAsyncInternal(c); }
/// <summary> /// Set EV3 brick LED pattern /// </summary> /// <param name="ledPattern">Pattern to display on LED</param> /// <returns>A task.</returns> public Task SetLedPatternAsync(LedPattern ledPattern) { return(ExecuteDirectWithoutReplyAsync(c => { c.SetLedPattern(ledPattern); })); }
private IEnumerable <ToolStripMenuItem> GetDurations(Rule rule, LedPattern ledPattern, AudioPattern audioPattern, bool patternIsMatch, string buildDefinitionId, TriggerType triggerType, string person) { int?duration = null; if (rule != null) { duration = ledPattern == null ? rule.AudioDuration : rule.LightsDuration; } var durations = _durations.Select(d => new ToolStripMenuItem(d.Value) { Checked = patternIsMatch && duration == d.Key, Tag = new RuleDropDownItemTag { AlertType = null, BuildDefinitionId = buildDefinitionId, TriggerPerson = person, TriggerType = triggerType, LedPattern = ledPattern, AudioPattern = audioPattern, Duration = d.Key } }).ToArray(); foreach (var toolStripMenuItem in durations) { toolStripMenuItem.Click += RuleDropDownItemClick; } return(durations); }
private void StartLeds() { LedPattern selectedLedPattern = (LedPattern)_ledPatterns.SelectedItems[0].Tag; _ledEndTime = DateTime.Now.AddMilliseconds((double)(_ledDuration.Value * 100)); Program.SirenOfShameDevice.PlayLightPattern(selectedLedPattern, new TimeSpan(0, 0, 0, 0, (int)(_ledDuration.Value * 100))); }
SetLedPatternAsync(LedPattern ledPattern) { return(SetLedPatternAsyncInternal(ledPattern) #if WINRT .AsAsyncAction() #endif ); }
/// <summary> /// Controls pattern of Leds /// </summary> /// <param name="led"></param> public async static void Lights(LedPattern led) { try { await brick.DirectCommand.SetLedPatternAsync(led); } catch (Exception ex) { } }
public void InvokeSetLights(LedPattern ledPattern, int?duration) { var stopSiren = SetLights; if (stopSiren == null) { return; } stopSiren(this, new SetLightsEventArgs { LedPattern = ledPattern, Duration = duration }); }
// no need to marshall this to the UI thread b/c we don't do any UI work private void OnSetLights(int?ledPatternIndex, TimeSpan?ledDuration) { if (!_sirenOfShameDevice.IsConnected) { _log.Warn("Retrieved request to play siren, but siren wasn't connected"); return; } LedPattern ledPattern = ledPatternIndex == null ? null : _sirenOfShameDevice.LedPatterns.FirstOrDefault(i => i.Id == ledPatternIndex); _sirenOfShameDevice.PlayLightPattern(ledPattern, ledDuration); }
private void AdjustLedPattern(Direction dir, bool down) { LedPattern pattern = new LedPattern(); if (down) { pattern.SwitchOn(LedPattern.DirectionToChannel(dir), LedPattern.Symbol.Arrow, Color.yellow, 255); } else { pattern.SwitchOff(LedPattern.DirectionToChannel(dir)); } Debug.Log("Adjusted LED: " + pattern.channel + ", " + pattern.mode + ", " + pattern.symbol); _senso.ChangeLED(pattern); }
private ToolStripMenuItem LedPatternMenu(LedPattern lp, Rule rule, string buildDefinitionId, TriggerType triggerType, string person) { bool patternIsMatch = false; if (rule != null && !rule.InheritLedSettings && rule.LedPattern != null) { patternIsMatch = rule.LedPattern.Equals(lp); } var menu = new ToolStripMenuItem(lp.Name) { Checked = patternIsMatch }; AddToolStripItems(menu.DropDownItems, GetDurations(rule, lp, null, patternIsMatch, buildDefinitionId, triggerType, person)); return(menu); }
public void PlayLedAnimation(LedPattern pattern, float frequency, int duration) { SetLedAnimation(pattern, frequency, duration); }
/// <summary> /// Set EV3 brick LED pattern /// </summary> /// <param name="ledPattern">Pattern to display on LED</param> /// <returns></returns> public Task SetLedPatternAsync(LedPattern ledPattern) { return(SetLedPatternAsyncInternal(ledPattern)); }
public override void SetLEDColor(Port.Colors color) { LedPattern ledPattern = (color == Port.Colors.GREEN) ? LedPattern.Green : (color == Port.Colors.RED) ? LedPattern.Red : (color == Port.Colors.ORANGE) ? LedPattern.Orange : LedPattern.Black; brick.DirectCommand.SetLedPatternAsync(ledPattern); }
/// <summary> /// Append the Set LED Pattern command to an existing Command object /// </summary> /// <param name="ledPattern">The LED pattern to display</param> public void SetLedPattern(LedPattern ledPattern) { AddOpcode(Opcode.UIWrite_LED); AddParameter((byte)ledPattern); }
static extern int SetLedAnimation(LedPattern iPattern , float fFrequency , int iDuration);
public async Task PlayLightPattern(LedPattern ledPattern, TimeSpan?duration) { await _device.PlayLightPattern(ledPattern, duration); }
public void CallLedPattern(LedPattern pattern) { ev3Plugin.Call("setLedPattern", pattern.ToString()); }
SetLedPatternAsync(LedPattern ledPattern) { return SetLedPatternAsyncInternal(ledPattern) #if WINRT .AsAsyncAction() #endif ; }
internal async Task SetLedPatternAsyncInternal(LedPattern ledPattern) { Command c = new Command(CommandType.DirectNoReply); c.SetLedPattern(ledPattern); await _brick.SendCommandAsyncInternal(c); }
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); }
static extern int SetLedAnimation(LedPattern Pattern, float Frequency, int Duration);