Class that provides an interface for reading and controlling analog pins. Stores information about analog input pins.
More...
#include <Wippersnapper_AnalogIO.h>
|
| Wippersnapper_AnalogIO (int32_t totalAnalogInputPins, float aRef) |
| Initializes Analog IO class. More...
|
|
| ~Wippersnapper_AnalogIO () |
| Destructor for Analog IO class.
|
|
void | setAref (float refVoltage) |
| Sets the device's reference voltage. More...
|
|
float | getAref () |
| Returns the device's reference voltage. More...
|
|
void | initAnalogInputPin (int pin, float period, wippersnapper_pin_v1_ConfigurePinRequest_Pull pullMode, wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode analogReadMode) |
| Initializes an analog input pin. More...
|
|
void | deinitAnalogPin (wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, int pin) |
| Deinitializes an analog pin. More...
|
|
void | disableAnalogInPin (int pin) |
| Disables an analog input pin from sampling. More...
|
|
uint16_t | getPinValue (int pin) |
| Reads the raw ADC value of an analog pin. Value is always scaled to 16-bit. More...
|
|
float | getPinValueVolts (int pin) |
| Calculates analog pin's voltage provided a 16-bit ADC value. More...
|
|
void | setADCResolution (int resolution) |
| Sets the device's ADC resolution, either natively via calling Arduino API's analogReadResolution() or via scaling. More...
|
|
int | getADCresolution () |
| Gets the scaled ADC resolution. More...
|
|
int | getNativeResolution () |
| Gets the device's native ADC resolution. More...
|
|
bool | timerExpired (long currentTime, analogInputPin pin, long periodOffset=0) |
| Checks if pin's period is expired. More...
|
|
void | update () |
| Iterates thru analog inputs.
|
|
bool | encodePinEvent (uint8_t pinName, wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode readMode, uint16_t pinValRaw=0, float pinValVolts=0.0) |
| Encodes an analog input pin event into a signal message and publish it to IO. More...
|
|
Class that provides an interface for reading and controlling analog pins. Stores information about analog input pins.
◆ Wippersnapper_AnalogIO()
Wippersnapper_AnalogIO::Wippersnapper_AnalogIO |
( |
int32_t |
totalAnalogInputPins, |
|
|
float |
aRef |
|
) |
| |
Initializes Analog IO class.
- Parameters
-
totalAnalogInputPins | Total number of analog input pins to allocate. |
aRef | ADC's voltage reference value, in volts. |
◆ setAref()
void Wippersnapper_AnalogIO::setAref |
( |
float |
refVoltage | ) |
|
Sets the device's reference voltage.
- Parameters
-
refVoltage | The voltage reference to use during conversions. |
◆ getAref()
float Wippersnapper_AnalogIO::getAref |
( |
| ) |
|
Returns the device's reference voltage.
- Returns
- Analog reference voltage, in volts.
◆ initAnalogInputPin()
void Wippersnapper_AnalogIO::initAnalogInputPin |
( |
int |
pin, |
|
|
float |
period, |
|
|
wippersnapper_pin_v1_ConfigurePinRequest_Pull |
pullMode, |
|
|
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode |
analogReadMode |
|
) |
| |
Initializes an analog input pin.
- Parameters
-
pin | The analog pin to read from. |
period | Time between measurements, in seconds. |
pullMode | The pin's pull value. |
analogReadMode | Defines if pin will read and return an ADC value or a voltage value. |
◆ deinitAnalogPin()
void Wippersnapper_AnalogIO::deinitAnalogPin |
( |
wippersnapper_pin_v1_ConfigurePinRequest_Direction |
direction, |
|
|
int |
pin |
|
) |
| |
Deinitializes an analog pin.
- Parameters
-
direction | The analog pin's direction. |
pin | The analog pin to deinitialize. |
◆ disableAnalogInPin()
void Wippersnapper_AnalogIO::disableAnalogInPin |
( |
int |
pin | ) |
|
Disables an analog input pin from sampling.
- Parameters
-
pin | The analog input pin to disable. |
◆ getPinValue()
uint16_t Wippersnapper_AnalogIO::getPinValue |
( |
int |
pin | ) |
|
Reads the raw ADC value of an analog pin. Value is always scaled to 16-bit.
- Parameters
-
- Returns
- The pin's ADC value.
◆ getPinValueVolts()
float Wippersnapper_AnalogIO::getPinValueVolts |
( |
int |
pin | ) |
|
Calculates analog pin's voltage provided a 16-bit ADC value.
- Parameters
-
pin | The value from a previous ADC reading. |
- Returns
- The pin's voltage.
◆ setADCResolution()
void Wippersnapper_AnalogIO::setADCResolution |
( |
int |
resolution | ) |
|
Sets the device's ADC resolution, either natively via calling Arduino API's analogReadResolution() or via scaling.
- Parameters
-
resolution | The desired analog resolution, in bits. |
◆ getADCresolution()
int Wippersnapper_AnalogIO::getADCresolution |
( |
| ) |
|
Gets the scaled ADC resolution.
- Returns
- resolution The scaled analog resolution, in bits.
◆ getNativeResolution()
int Wippersnapper_AnalogIO::getNativeResolution |
( |
| ) |
|
Gets the device's native ADC resolution.
- Returns
- resolution The native analog resolution, in bits.
◆ timerExpired()
bool Wippersnapper_AnalogIO::timerExpired |
( |
long |
currentTime, |
|
|
analogInputPin |
pin, |
|
|
long |
periodOffset = 0 |
|
) |
| |
Checks if pin's period is expired.
- Parameters
-
currentTime | The current software timer value. |
pin | The desired analog pin to check |
periodOffset | Offset to add to the pin's period (used for on_change). |
- Returns
- True if pin's period expired, False otherwise.
◆ encodePinEvent()
bool Wippersnapper_AnalogIO::encodePinEvent |
( |
uint8_t |
pinName, |
|
|
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode |
readMode, |
|
|
uint16_t |
pinValRaw = 0 , |
|
|
float |
pinValVolts = 0.0 |
|
) |
| |
Encodes an analog input pin event into a signal message and publish it to IO.
- Parameters
-
pinName | Specifies the pin's name. |
readMode | Read mode - raw ADC or voltage. |
pinValRaw | Raw pin value, used if readmode is raw. |
pinValVolts | Raw pin value expressed in Volts, used if readmode is volts. |
- Returns
- True if successfully encoded a PinEvent signal message, False otherwise.
The documentation for this class was generated from the following files: