Class PwmChannel
Represents a single PWM channel.
public sealed class PwmChannel : IDisposable
- Inheritance
-
PwmChannel
- Implements
- Inherited Members
- Extension Methods
Constructors
PwmChannel(int, int, int, double)
Creates a new instance of the PwmChannel running on the current platform.
public PwmChannel(int chip, int channel, int frequency = 400, double dutyCyclePercentage = 0.5)
Parameters
chip
intThe PWM chip number, formally known as TIM channel.
channel
intThe PWM channel number.
frequency
intThe frequency in hertz.
dutyCyclePercentage
doubleThe duty cycle percentage represented as a value between 0.0 and 1.0.
Remarks
To create a PwmChannel from a GPIO pin number, please use CreateFromPin(int, int, double).
Properties
DutyCycle
The duty cycle represented as a value between 0.0 and 1.0.
public double DutyCycle { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Value must be between 0.0 and 1.0.
Frequency
The frequency in hertz.
public int Frequency { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Value must not be negative.
Methods
Create(int, int, int, double)
Creates a new instance of the PwmChannel running on the current platform.
public static PwmChannel Create(int chip, int channel, int frequency = 400, double dutyCyclePercentage = 0.5)
Parameters
chip
intThe PWM chip number, formally known as TIM channel.
channel
intThe channel number.
frequency
intThe frequency in hertz.
dutyCyclePercentage
doubleThe duty cycle percentage represented as a value between 0.0 and 1.0.
Returns
CreateFromPin(int, int, double)
Creates a PwmChannel from a pin number.
public static PwmChannel CreateFromPin(int pin, int frequency = 400, double dutyCyclePercentage = 0.5)
Parameters
pin
intThe pin number.
frequency
intThe frequency in hertz.
dutyCyclePercentage
doubleThe duty cycle percentage represented as a value between 0.0 and 1.0.
Returns
- PwmChannel
A PWM channel
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Start()
Starts the PWM channel.
public void Start()
Stop()
Stops the PWM channel.
public void Stop()