GetPwmPinForChannel() public méthode

public GetPwmPinForChannel ( Cpu channel ) : Cpu.Pin
channel Cpu
Résultat Cpu.Pin
Exemple #1
0
        /// <summary>
        /// Build an instance of the PWM type
        /// </summary>
        /// <param name="channel">The channel</param>
        /// <param name="period">The period of the pulse</param>
        /// <param name="duration">The duration of the pulse.  The value should be a fraction of the period</param>
        /// <param name="scale">The scale factor for the period/duration (nS, uS, mS)</param>
        /// <param name="invert">Whether the output should be inverted or not</param>
        public PWM(Cpu.PWMChannel channel, uint period, uint duration, ScaleFactor scale, bool invert)
        {
            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            if (hwProvider == null)
            {
                throw new InvalidOperationException();
            }

            m_pin     = hwProvider.GetPwmPinForChannel(channel);
            m_channel = channel;
            //--//
            m_period   = period;
            m_duration = duration;
            m_scale    = scale;
            m_invert   = invert;
            //--//
            try
            {
                Init();

                Commit();

                Port.ReservePin(m_pin, true);
            }
            catch
            {
                Dispose(false);
            }
        }
Exemple #2
0
        //--//

        /// <summary>
        /// Build an instance of the PWM type
        /// </summary>
        /// <param name="channel">The channel to use</param>
        /// <param name="frequency_Hz">The frequency of the pulse in Hz</param>
        /// <param name="dutyCycle">The duty cycle of the pulse as a fraction of unity.  Value should be between 0.0 and 1.0</param>
        /// <param name="invert">Whether the output should be inverted or not</param>
        public PWM(Cpu.PWMChannel channel, double frequency_Hz, double dutyCycle, bool invert)
        {
            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            if (hwProvider == null)
            {
                throw new InvalidOperationException();
            }

            m_pin     = hwProvider.GetPwmPinForChannel(channel);
            m_channel = channel;
            //--//
            m_period   = PeriodFromFrequency(frequency_Hz, out m_scale);
            m_duration = DurationFromDutyCycleAndPeriod(dutyCycle, m_period);
            m_invert   = invert;
            //--//
            try
            {
                Init();

                Commit();

                Port.ReservePin(m_pin, true);
            }
            catch
            {
                Dispose(false);
            }
        }