/// <summary> /// Raised by the <paramref name="SequencesTimer"/> elapsed event. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> private void OnSequenceTimeElapsed(object sender, System.Timers.ElapsedEventArgs args) { double time = KeeperOfTime.ElapsedMilliseconds; UInt16[] conditions = new UInt16[5]; conditions [0] = 0x0; conditions [1] = 0x0; conditions [2] = 0x0; conditions [3] = 0x0; conditions [4] = 0x0; foreach (Sequence seq in Configuration.Sequences) { if (seq.GetCurrentState(time) == DPinState.HIGH) { int arraypos = (int)seq.Pin.Number / 16; int shift = (int)seq.Pin.Number % 16; int pos = 0x1 << (int)shift; conditions [arraypos] = Convert.ToUInt16(conditions [arraypos] | pos); } } //only send new states if the is actual change if ( LastCondition [0] != conditions [0] || LastCondition [1] != conditions [1] || LastCondition [2] != conditions [2] || LastCondition [3] != conditions [3] || LastCondition [4] != conditions [4]) { ArduinoController.SetDigitalOutputPins(conditions); } LastCondition = conditions; }