A library that maps the functions used with the mbed microcontroller to be used on with the GPIO ports of a Raspberry pi.

Embed: (wiki syntax)

« Back to documentation index

PwmOut Class Reference

PwmOut Class Reference

The PwmOut interface is used to control the frequency and mark-space ratio of a digital pulse train. More...

#include <PwmOut.h>

Inherits CPPToPigpio::CPPToPigpio.

Public Member Functions

 PwmOut (PinName pin)
 Create a PwmOut connected to the specified pin.
 PwmOut (PinName pin, float val)
 Create a PwmOut connected to the specified pin.
 PwmOut (int pin)
 Create a PwmOut connected to the specified pin.
 PwmOut (int pin, float val)
 Create a PwmOut connected to the specified pin.
void write (float val)
 Set the ouput duty-cycle, specified as a percentage (float)
float read ()
 Return the current output duty-cycle setting, measured as a percentage (float)
float period (float seconds)
 Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
float period_ms (int ms)
 Set the PWM period, specified in miliseconds (int), keeping the duty cycle the same.
float period_us (int us)
 Set the PWM period, specified in microseconds (int), keeping the duty cycle the same.
PwmOutoperator= (float val)
 A operator shorthand for write()
PwmOutoperator= (PwmOut &)
 A operator shorthand for write()
 operator float ()
 An operator shorthand for read()
 ~PwmOut ()
 Deconstructor.

Detailed Description

The PwmOut interface is used to control the frequency and mark-space ratio of a digital pulse train.

Definition at line 7 of file PwmOut.h.


Constructor & Destructor Documentation

PwmOut ( PinName  pin )

Create a PwmOut connected to the specified pin.

Parameters:
pinPwmOut pin to connect to

Definition at line 4 of file PwmOut.cc.

PwmOut ( PinName  pin,
float  val 
)

Create a PwmOut connected to the specified pin.

Parameters:
pinPwmOut pin to connect to
valueA floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.

Definition at line 12 of file PwmOut.cc.

PwmOut ( int  pin )

Create a PwmOut connected to the specified pin.

Parameters:
pinPwmOut pin to connect to

Definition at line 19 of file PwmOut.cc.

PwmOut ( int  pin,
float  val 
)

Create a PwmOut connected to the specified pin.

Parameters:
pinPwmOut pin to connect to
valueA floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.

Definition at line 27 of file PwmOut.cc.

~PwmOut (  )

Deconstructor.

Definition at line 86 of file PwmOut.cc.


Member Function Documentation

operator float (  )

An operator shorthand for read()

See also:
PwmOut::read()

Definition at line 81 of file PwmOut.cc.

PwmOut & operator= ( float  val )

A operator shorthand for write()

See also:
PwmOut::write()

Definition at line 69 of file PwmOut.cc.

PwmOut & operator= ( PwmOut rhs )

A operator shorthand for write()

See also:
PwmOut::write()

Definition at line 75 of file PwmOut.cc.

float period ( float  seconds )

Set the PWM period, specified in seconds (float), keeping the duty cycle the same.

Parameters:
secondsChange the period of a PWM signal in seconds (float) without modifying the duty cycle

Definition at line 48 of file PwmOut.cc.

float period_ms ( int  ms )

Set the PWM period, specified in miliseconds (int), keeping the duty cycle the same.

Parameters:
milisecondsChange the period of a PWM signal in miliseconds (int) without modifying the duty cycle

Definition at line 55 of file PwmOut.cc.

float period_us ( int  us )

Set the PWM period, specified in microseconds (int), keeping the duty cycle the same.

Parameters:
microsecondsChange the period of a PWM signal in microseconds (int) without modifying the duty cycle

Definition at line 62 of file PwmOut.cc.

float read (  )

Return the current output duty-cycle setting, measured as a percentage (float)

Returns:
A floating-point value representing the current duty-cycle being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing on 0%) and 1.0f (representing on 100%).

Definition at line 41 of file PwmOut.cc.

void write ( float  val )

Set the ouput duty-cycle, specified as a percentage (float)

Parameters:
valueA floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.

Definition at line 35 of file PwmOut.cc.