IoAbstraction
Public Member Functions | List of all members
AnalogDevice Class Referenceabstract

#include <AnalogDeviceAbstraction.h>

Inheritance diagram for AnalogDevice:
AW9523AnalogAbstraction MPR121AnalogAbstraction

Public Member Functions

virtual int getMaximumRange (AnalogDirection direction, pinid_t pin)=0
 
virtual int getBitDepth (AnalogDirection direction, pinid_t pin)=0
 
virtual void initPin (pinid_t pin, AnalogDirection direction)=0
 
virtual unsigned int getCurrentValue (pinid_t pin)=0
 
virtual float getCurrentFloat (pinid_t pin)=0
 
virtual void setCurrentValue (pinid_t pin, unsigned int newValue)=0
 
virtual void setCurrentFloat (pinid_t pin, float newValue)=0
 

Detailed Description

Describes an analog device that has commands to both read values from and write values to a device. Not all devices will support both input and output. When such a case occurs the getMaximumRange would return -1 for that direction. This abstraction can support ADC, PWM DAC and Potentiometer devices. On every device we support, calling internalAnalogIO gives the instance for the internal analog pins.

Member Function Documentation

◆ getMaximumRange()

virtual int AnalogDevice::getMaximumRange ( AnalogDirection  direction,
pinid_t  pin 
)
pure virtual
Parameters
dirthe direction required
pinthe pin for which the range is desired
Returns
the maximum range of the analog input or output on this device for the given pin

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.

◆ getBitDepth()

virtual int AnalogDevice::getBitDepth ( AnalogDirection  direction,
pinid_t  pin 
)
pure virtual
Parameters
pinthe pin for which the bit depth is required.
directionthe direction in which the depth is queried (DIR_IN, DIR_OUT)
Returns
the number of bits

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.

◆ initPin()

virtual void AnalogDevice::initPin ( pinid_t  pin,
AnalogDirection  direction 
)
pure virtual

initialises a pin as either an input or output of analog signals. No validation to check if that pin can support input or output is performed.

Parameters
pinthe pin to initialise
directionthe direction required

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.

◆ getCurrentValue()

virtual unsigned int AnalogDevice::getCurrentValue ( pinid_t  pin)
pure virtual

Returns the current value on the ADC for the given pin

Parameters
pinthe pin to read from
Returns
the current value on that pin

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.

◆ setCurrentValue()

virtual void AnalogDevice::setCurrentValue ( pinid_t  pin,
unsigned int  newValue 
)
pure virtual

Sets the current value on an output capable device to a new value

Parameters
pinthe pin to read from
newValuethe value to be set

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.

◆ setCurrentFloat()

virtual void AnalogDevice::setCurrentFloat ( pinid_t  pin,
float  newValue 
)
pure virtual

sets the current value based on a float from 0 to 1, where 0 is minimum and 1 is maximum.

Parameters
pinthe pin for which to set
newValuethe new value which should be between 0 and 1.0

Implemented in MPR121AnalogAbstraction, and AW9523AnalogAbstraction.


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