Esempio n. 1
0
        /// <summary>
        /// Attaches a handler to the PwmPulsed event to watch
        /// for changes in the pulse.
        /// </summary>
        /// <param name="pwm">The instance of SoftPwm to start.</param>
        /// <param name="eventHandler">A EventHandler method or lambda expression.</param>
        /// <returns>The ISoftPwm reference to allow chaining of methods.</returns>
        public static ISoftPwm WatchPulse(this ISoftPwm pwm, EventHandler eventHandler)
        {
            if (pwm is SoftPwm)
            {
                ((SoftPwm)pwm).PwmPulsed += eventHandler;
            }

            return(pwm);
        }
Esempio n. 2
0
        /// <summary>
        /// Attaches a handler to the PulseWidthChanged event to watch for
        /// changes to the HighPulseWidth and LowPulseWidth properties.
        /// </summary>
        /// <param name="pwm">The instance of SoftPwm to start.</param>
        /// <param name="eventHandler">A PulseWidthChangedEventHandler method or lambda expression..</param>
        /// <returns>The ISoftPwm reference to allow chaining of methods.</returns>
        public static ISoftPwm WatchPulseWidthChanges(this ISoftPwm pwm, PulseWidthChangedEventHandler eventHandler)
        {
            if (pwm is SoftPwm)
            {
                ((SoftPwm)pwm).PulseWidthChanged += eventHandler;
            }

            return(pwm);
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the value of a SoftPwm instance with the given value.
 /// </summary>
 /// <param name="pwm">The instance of SoftPwm to start.</param>
 /// <param name="value">The value to set the SoftPwm instance to.</param>
 /// <returns></returns>
 public static ISoftPwm WithValue(this ISoftPwm pwm, double value)
 {
     pwm.Value = value;
     return(pwm);
 }
Esempio n. 4
0
 /// <summary>
 /// Sets the pulse frequency (in Hz) of the SoftPwm instance.
 /// </summary>
 /// <param name="pwm">The instance of SoftPwm to start.</param>
 /// <param name="pulseFrequency">The pulse frequency to use given in Hz.</param>
 /// <returns></returns>
 public static ISoftPwm WithPulseFrequency(this ISoftPwm pwm, double pulseFrequency)
 {
     pwm.PulseFrequency = pulseFrequency;
     return(pwm);
 }
Esempio n. 5
0
 /// <summary>
 /// Starts the given SoftPwm instance.
 /// </summary>
 /// <param name="pwm">The instance of SoftPwm to start.</param>
 /// <returns></returns>
 public static ISoftPwm Start(this ISoftPwm pwm)
 {
     pwm.StartAsync();
     return(pwm);
 }