コード例 #1
0
        /// <summary>
        /// Adds a pulse.
        /// </summary>
        /// <param name="pulse">The pulse.</param>
        /// <exception cref="InvalidOperationException">When the wave has been prepared.</exception>
        public void AddPulse(GpioPulse pulse)
        {
            if (IsPrepared)
            {
                throw new InvalidOperationException(WaveAlreadyPreparedErrorMessage);
            }

            m_Pulses.Add(pulse);
        }
コード例 #2
0
        /// <summary>
        /// Adds a pulse.
        /// </summary>
        /// <param name="durationMicroSecs">The duration micro secs.</param>
        /// <param name="onPins">The on pins.</param>
        /// <param name="offPins">The off pins.</param>
        /// <exception cref="InvalidOperationException">When the wave has been prepared.</exception>
        public void AddPulse(int durationMicroSecs, IEnumerable <UserGpio> onPins, IEnumerable <UserGpio> offPins)
        {
            if (IsPrepared)
            {
                throw new InvalidOperationException(WaveAlreadyPreparedErrorMessage);
            }

            var onPinFlags  = PinsToBitMask(onPins);
            var offPinFlags = PinsToBitMask(offPins);

            var pulse = new GpioPulse
            {
                DurationMicroSecs = Convert.ToUInt32(durationMicroSecs),
                GpioOn            = onPinFlags,
                GpioOff           = offPinFlags,
            };

            m_Pulses.Add(pulse);
        }