/// <summary>
 /// changes the frequency but not the duty cycle
 /// changes frequency as long as passed in frequency is differnt than spec frequency
 /// </summary>
 /// <param name="spec"></param>
 /// <param name="freqHz"></param>
 public PwmOutputUpdateCommand(PwmOutputSpec spec, int freqHz)
 {
     this.PwmDef             = spec;
     this.DutyCycle          = float.NaN;
     this.PulseWidthUSec     = float.NaN;
     this.RequestedFrequency = freqHz;
 }
Example #2
0
 /// <summary>
 /// change frequency ans duty cycle
 /// </summary>
 /// <param name="spec"></param>
 /// <param name="freqHz"></param>
 /// <param name="dutyCycle"></param>
 public PwmOutputUpdateDutyCycleCommand(PwmOutputSpec spec, int freqHz, float dutyCycle)
 {
     if (freqHz <= 0)
     {
         throw new ArgumentException("Frequency must be > 0 when frequency specified" + freqHz);
     }
     this.PwmDef             = spec;
     this.DutyCycle          = dutyCycle;
     this.RequestedFrequency = freqHz;
     this.PulseWidthUSec     = float.NaN;
 }
Example #3
0
 /// <summary>
 /// changes the duty cycle but not the frequency
 /// </summary>
 /// <param name="spec"></param>
 /// <param name="dutyCycle"></param>
 public PwmOutputUpdateDutyCycleCommand(PwmOutputSpec spec, float dutyCycle)
 {
     if (spec.Frequency <= 0)
     {
         throw new ArgumentException("Spec Frequency must be > 0 when frequency not specified" + spec.Frequency);
     }
     this.PwmDef             = spec;
     this.DutyCycle          = dutyCycle;
     this.PulseWidthUSec     = float.NaN;
     this.RequestedFrequency = spec.Frequency;
 }
        private void ConfigurePwm(IOIOMessageCommandFactory commandFactory)
        {
            DigitalOutputSpec          pwmPinSpec = new DigitalOutputSpec(SERVO_PIN, DigitalOutputSpecMode.NORMAL);
            IPwmOutputConfigureCommand createPwm  = commandFactory.CreatePwmOutputConfigure(pwmPinSpec, 100);

            OurImpl_.PostMessage(createPwm);
            // message post fills in pin def so pick that up.  runs in a thread so wait until command completes
            // have to capture the PwmDef to get the frequencey
            while (createPwm.PwmDef.Frequency < 0)
            {
                System.Threading.Thread.Sleep(10);
            }
            this.ServoPinDef_ = createPwm.PwmDef;

            // value should match minimum of the slider
            IPwmOutputUpdatePulseWidthCommand command =
                new IOIOMessageCommandFactory().CreatePwmPulseWithOutputUpdate(this.ServoPinDef_, 600.0f);

            OurImpl_.PostMessage(command);
        }
Example #5
0
 public IPwmOutputCloseCommand CreatePwmOutputClose(PwmOutputSpec spec)
 {
     return(new PwmOutputCloseCommand(spec));
 }
Example #6
0
 public IPwmOutputUpdatePulseWidthCommand CreatePwmPulseWithOutputUpdate(PwmOutputSpec spec, float pulseWithUSec)
 {
     return(new PwmOutputUpdatePulseWidthCommand(spec, pulseWithUSec));
 }
Example #7
0
 public IPwmOutputUpdateDutyCycleCommand CreatePwmDutyCycleOutputUpdate(PwmOutputSpec spec, float dutyCycle)
 {
     return(new PwmOutputUpdateDutyCycleCommand(spec, dutyCycle));
 }
Example #8
0
 public IPwmOutputUpdateCommand CreatePwmOutputUpdate(PwmOutputSpec spec, int freqHz)
 {
     return(new PwmOutputUpdateCommand(spec, freqHz));
 }
Example #9
0
 public PwmOutputCloseCommand(PwmOutputSpec spec)
 {
     this.PwmDef = spec;
 }