This file defines the PWM interface for libmraa
if (pwm == NULL) {
}
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
float value = 0.0f;
while (running == 0) {
value = value + 0.01f;
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
}
delete pwm;
Pwm |
( |
int |
pin, |
|
|
bool |
owner = true , |
|
|
int |
chipid = -1 |
|
) |
| |
|
inline |
instanciates a PWM object on a pin
- Parameters
-
pin | the pin number used on your board |
owner | if you are the owner of the pin the destructor will unexport the pin from sysfs, default behaviour is you are the owner if the pinmapper exported it |
chipid | the pwmchip to use, use only in raw mode |
Pwm |
( |
void * |
pwm_context | ) |
|
|
inline |
Pwm constructor, takes a pointer to the PWM context and initialises the class
- Parameters
-
Result write |
( |
float |
percentage | ) |
|
|
inline |
Set the output duty-cycle percentage, as a float
- Parameters
-
percentage | A floating-point value representing percentage of output. The value should lie between 0.0f (representing 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f |
- Returns
- Result of operation
Read the output duty-cycle percentage, as a float
- Returns
- A floating-point value representing percentage of output. The value should lie between 0.0f (representing 0%) and 1.0f Values above or below this range will be set at either 0.0f or 1.0f
Set the PWM period as seconds represented in a float
- Parameters
-
period | Period represented as a float in seconds |
- Returns
- Result of operation
Set period, milliseconds
- Parameters
-
ms | milliseconds for period |
- Returns
- Result of operation
Set period, microseconds
- Parameters
-
- Returns
- Result of operation
Result pulsewidth |
( |
float |
seconds | ) |
|
|
inline |
Set pulsewidth, as represented by seconds in a float
- Parameters
-
seconds | The duration of a pulse |
- Returns
- Result of operation
Result pulsewidth_ms |
( |
int |
ms | ) |
|
|
inline |
Set pulsewidth, milliseconds
- Parameters
-
ms | milliseconds for pulsewidth |
- Returns
- Result of operation
Result pulsewidth_us |
( |
int |
us | ) |
|
|
inline |
The pulsewidth, microseconds
- Parameters
-
us | microseconds for pulsewidth |
- Returns
- Result of operation
Set the enable status of the PWM pin. None zero will assume on with output being driven and 0 will disable the output
- Parameters
-
enable | enable status of pin |
- Returns
- Result of operation
Get the maximum PWM period in us
- Returns
- max PWM period in us
Get the minimum PWM period in us
- Returns
- min PWM period in us
The documentation for this class was generated from the following file: