Treehopper C# API
Pwm Interface Reference

This provides a generic interface to PWM operation. More...

Inheritance diagram for Pwm:
HardwarePwm Pca9632.Pin Pin Pin

Public Member Functions

Task EnablePwmAsync ()
 Enable the PWM functionality More...
 
Task DisablePwmAsync ()
 Disables the PWM functionality More...
 

Properties

double DutyCycle [get, set]
 Get or set the duty cycle (0-1) of the pin More...
 
double PulseWidth [get, set]
 Get or set the pulse width, in microseconds, of the pin More...
 

Detailed Description

This provides a generic interface to PWM operation.

Since both the SoftPwm and HardwarePwm classes implement this interface, it is useful for applications that are agnostic to differing resolutions or amount of jitter, and only need basic DutyCycle or PulseWidth control.

Since HardwarePwm and SoftPwm have different periods (and different ways of setting the period), period control is not available in this interface. However, HardwarePwm initializes to a period of approximately 780 Hz and SoftPwm initializes with a period of approximately 100 Hz. These values are suitable for LED dimming, motor control, and other common applications. If higher (or lower) frequencies are desired, your library should use HardwarePwm or SoftPwm directly.

Member Function Documentation

◆ EnablePwmAsync()

Task EnablePwmAsync ( )

Enable the PWM functionality

///

Returns
An awaitable task that completes when the PWM functionality is enabled

Implemented in Pin, Pin, Pca9632.Pin, and HardwarePwm.

◆ DisablePwmAsync()

Task DisablePwmAsync ( )

Disables the PWM functionality

Returns
An awaitable task that completes when the PWM functionality is disabled

Implemented in Pin, Pin, Pca9632.Pin, and HardwarePwm.

Property Documentation

◆ DutyCycle

double DutyCycle
getset

Get or set the duty cycle (0-1) of the pin

◆ PulseWidth

double PulseWidth
getset

Get or set the pulse width, in microseconds, of the pin


The documentation for this interface was generated from the following file: