Damian Gabino / picoGW_mcu
Embed: (wiki syntax)

« Back to documentation index

AnalogOut Class Reference

AnalogOut Class Reference

An analog output, used for setting the voltage on a pin. More...

#include <AnalogOut.h>

Public Member Functions

 AnalogOut (PinName pin)
 Create an AnalogOut connected to the specified pin.
void write (float value)
 Set the output voltage, specified as a percentage (float)
void write_u16 (unsigned short value)
 Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF].
float read ()
 Return the current output voltage setting, measured as a percentage (float)
AnalogOutoperator= (float percent)
 An operator shorthand for write()
 operator float ()
 An operator shorthand for read()
 AnalogOut (PinName pin)
 Create an AnalogOut connected to the specified pin.
void write (float value)
 Set the output voltage, specified as a percentage (float)
void write_u16 (unsigned short value)
 Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF].
float read ()
 Return the current output voltage setting, measured as a percentage (float)
AnalogOutoperator= (float percent)
 An operator shorthand for write()
 operator float ()
 An operator shorthand for read()

Detailed Description

An analog output, used for setting the voltage on a pin.

Synchronization level: Thread safe

Example:

 // Make a sawtooth output

 #include "mbed.h"

 AnalogOut tri(p18);
 int main() {
     while(1) {
         tri = tri + 0.01;
         wait_us(1);
         if(tri == 1) {
             tri = 0;
         }
     }
 }

Definition at line 50 of file mbed-dev/api/AnalogOut.h.


Constructor & Destructor Documentation

AnalogOut ( PinName  pin )

Create an AnalogOut connected to the specified pin.

Parameters:
AnalogOutpin to connect to (18)

Definition at line 58 of file mbed-dev/api/AnalogOut.h.

AnalogOut ( PinName  pin )

Create an AnalogOut connected to the specified pin.

Parameters:
AnalogOutpin to connect to (18)

Definition at line 58 of file usb_cdc/mbed-dev/api/AnalogOut.h.


Member Function Documentation

operator float (  )

An operator shorthand for read()

Definition at line 119 of file mbed-dev/api/AnalogOut.h.

operator float (  )

An operator shorthand for read()

Definition at line 119 of file usb_cdc/mbed-dev/api/AnalogOut.h.

AnalogOut& operator= ( float  percent )

An operator shorthand for write()

Definition at line 105 of file usb_cdc/mbed-dev/api/AnalogOut.h.

AnalogOut& operator= ( float  percent )

An operator shorthand for write()

Definition at line 105 of file mbed-dev/api/AnalogOut.h.

float read (  )

Return the current output voltage setting, measured as a percentage (float)

Returns:
A floating-point value representing the current voltage being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
Note:
This value may not match exactly the value set by a previous write().

Definition at line 96 of file mbed-dev/api/AnalogOut.h.

float read ( void   )

Return the current output voltage setting, measured as a percentage (float)

Returns:
A floating-point value representing the current voltage being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
Note:
This value may not match exactly the value set by a previous write().

Definition at line 96 of file usb_cdc/mbed-dev/api/AnalogOut.h.

void write ( float  value )

Set the output voltage, specified as a percentage (float)

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

Definition at line 69 of file usb_cdc/mbed-dev/api/AnalogOut.h.

void write ( float  value )

Set the output voltage, specified as a percentage (float)

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

Definition at line 69 of file mbed-dev/api/AnalogOut.h.

void write_u16 ( unsigned short  value )

Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF].

Parameters:
value16-bit unsigned short representing the output voltage, normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)

Definition at line 80 of file mbed-dev/api/AnalogOut.h.

void write_u16 ( unsigned short  value )

Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF].

Parameters:
value16-bit unsigned short representing the output voltage, normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)

Definition at line 80 of file usb_cdc/mbed-dev/api/AnalogOut.h.