mraa  0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Pages
Public Member Functions
Pwm Class Reference

Detailed Description

This file defines the PWM interface for libmraa

mraa::Pwm* pwm;
pwm = new mraa::Pwm(3);
if (pwm == NULL) {
}
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;
}
}
delete pwm;

Public Member Functions

 Pwm (int pin, bool owner=true, int chipid=-1)
 
 ~Pwm ()
 
mraa_result_t write (float percentage)
 
float read ()
 
mraa_result_t period (float period)
 
mraa_result_t period_ms (int ms)
 
mraa_result_t period_us (int us)
 
mraa_result_t pulsewidth (float seconds)
 
mraa_result_t pulsewidth_ms (int ms)
 
mraa_result_t pulsewidth_us (int us)
 
mraa_result_t enable (bool enable)
 
mraa_result_t config_ms (int period, float duty)
 
mraa_result_t config_percent (int period, float duty)
 

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
chipidthe pwmchip to use, use only in raw mode unexport the pin from sysfs, default behaviour is you are the owner if the pinmapper exported it

Here is the call graph for this function:

~Pwm ( )
inline

Pwm destructor

Here is the call graph for this function:

Member Function Documentation

mraa_result_t 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 on 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 ouput duty-cycle percentage, as a float

Returns
A floating-point value representing percentage of output. The value should lie between 0.0f (representing on 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:

mraa_result_t 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:

mraa_result_t period_ms ( int  ms)
inline

Set period, milliseconds

Parameters
msmilliseconds for period
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t period_us ( int  us)
inline

Set period, microseconds

Parameters
usmicroseconds as period
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t pulsewidth ( float  seconds)
inline

Set pulsewidth, As represnted by seconds in a (float)

Parameters
secondsThe duration of a pulse
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t pulsewidth_ms ( int  ms)
inline

Set pulsewidth, milliseconds

Parameters
msmilliseconds for pulsewidth
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t pulsewidth_us ( int  us)
inline

The pulsewidth, microseconds

Parameters
usmicroseconds for pulsewidth
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t 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:

mraa_result_t config_ms ( int  period,
float  duty 
)
inline

Set the period and duty of a PWM object.

Parameters
periodrepresented in ms.
dutyrepresnted in ms as float.
Returns
Result of operation

Here is the call graph for this function:

mraa_result_t config_percent ( int  period,
float  duty 
)
inline

Set the period and duty (percent) of a PWM object.

Parameters
periodas represented in ms.
dutypercentage i.e. 50% = 0.5f
Returns
Result of operation

Here is the call graph for this function:


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