mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Public Member Functions | List of all members
Pwm Class Reference

Detailed Description

This file defines the PWM interface for libmraa

Pwm pwm = new mraa.Pwm(3);
pwm.period_us(200);
pwm.enable(true);
float value = 0;
for (int i = 100; i > 0; --i) {
value += 0.01;
pwm.write(value);
Thread.sleep(50);
if (value >= 1) {
value = 0;
}
}

Public Member Functions

synchronized void delete ()
 
 Pwm (int pin, boolean owner, int chipid)
 
 Pwm (int pin, boolean owner)
 
 Pwm (int pin)
 
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 (boolean enable)
 
int max_period ()
 
int min_period ()
 

Constructor & Destructor Documentation

Pwm ( int  pin,
boolean  owner,
int  chipid 
)

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
Pwm ( int  pin)

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

Parameters
pwm_contextvoid * to a PWM context

Member Function Documentation

Result enable ( boolean  enable)

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
int max_period ( )

Get the maximum PWM period in us

Returns
max PWM period in us
int min_period ( )

Get the minimum PWM period in us

Returns
min PWM period in us
Result period ( float  period)

Set the PWM period as seconds represented in a float

Parameters
periodPeriod represented as a float in seconds
Returns
Result of operation
Result period_ms ( int  ms)

Set period, milliseconds

Parameters
msmilliseconds for period
Returns
Result of operation
Result period_us ( int  us)

Set period, microseconds

Parameters
usmicroseconds as period
Returns
Result of operation
Result pulsewidth ( float  seconds)

Set pulsewidth, as represented by seconds in a float

Parameters
secondsThe duration of a pulse
Returns
Result of operation
Result pulsewidth_ms ( int  ms)

Set pulsewidth, milliseconds

Parameters
msmilliseconds for pulsewidth
Returns
Result of operation
Result pulsewidth_us ( int  us)

The pulsewidth, microseconds

Parameters
usmicroseconds for pulsewidth
Returns
Result of operation
float read ( )

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
Result write ( float  percentage)

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

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