mraa  1.8.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Public Member Functions
Pwm Class Reference

Detailed Description

This file defines the PWM interface for libmraa

mraa::Pwm pwm(3);
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
pwm.enable(true);
float value = 0.0f;
while (running == 0) {
value = value + 0.01f;
pwm.write(value);
usleep(50000);
if (value >= 1.0f) {
value = 0.0f;
}
}

Public Member Functions

 Pwm (int pin, bool owner=true, int chipid=-1)
 
 Pwm (void *pwm_context)
 
 ~Pwm ()
 
Result write (float percentage)
 
float read ()
 
Result period (float period)
 
Result period_ms (int ms)
 
Result period_us (int us)
 
Result pulsewidth (float seconds)
 
Result pulsewidth_ms (int ms)
 
Result pulsewidth_us (int us)
 
Result enable (bool enable)
 
int max_period ()
 
int min_period ()
 

Constructor & Destructor Documentation

Pwm ( int  pin,
bool  owner = true,
int  chipid = -1 
)
inline

instanciates a PWM object on a pin

Parameters
pinthe pin number used on your board
ownerif 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
chipidthe pwmchip to use, use only in raw mode

Here is the call graph for this function:

Pwm ( void *  pwm_context)
inline

Pwm constructor, takes a pointer to the PWM context and initialises the class

Parameters
pwm_contextvoid * to a PWM context
~Pwm ( )
inline

Pwm destructor

Here is the call graph for this function:

Member Function Documentation

Result write ( float  percentage)
inline

Set the output duty-cycle percentage, as a float

Parameters
percentageA 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

Here is the call graph for this function:

float read ( )
inline

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

Here is the call graph for this function:

Result period ( float  period)
inline

Set the PWM period as seconds represented in a float

Parameters
periodPeriod represented as a float in seconds
Returns
Result of operation

Here is the call graph for this function:

Result period_ms ( int  ms)
inline

Set period, milliseconds

Parameters
msmilliseconds for period
Returns
Result of operation

Here is the call graph for this function:

Result period_us ( int  us)
inline

Set period, microseconds

Parameters
usmicroseconds as period
Returns
Result of operation

Here is the call graph for this function:

Result pulsewidth ( float  seconds)
inline

Set pulsewidth, as represented by seconds in a float

Parameters
secondsThe duration of a pulse
Returns
Result of operation

Here is the call graph for this function:

Result pulsewidth_ms ( int  ms)
inline

Set pulsewidth, milliseconds

Parameters
msmilliseconds for pulsewidth
Returns
Result of operation

Here is the call graph for this function:

Result pulsewidth_us ( int  us)
inline

The pulsewidth, microseconds

Parameters
usmicroseconds for pulsewidth
Returns
Result of operation

Here is the call graph for this function:

Result enable ( bool  enable)
inline

Set the enable status of the PWM pin. None zero will assume on with output being driven and 0 will disable the output

Parameters
enableenable status of pin
Returns
Result of operation

Here is the call graph for this function:

int max_period ( )
inline

Get the maximum PWM period in us

Returns
max PWM period in us

Here is the call graph for this function:

int min_period ( )
inline

Get the minimum PWM period in us

Returns
min PWM period in us

Here is the call graph for this function:


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