A class to represent a single pin configured for analog input. More...
#include <analog_pin.h>
Public Member Functions | |
void | init (AnalogDigitalConverter *adc, GPIO_TypeDef *basePort, uint16_t pin, uint8_t adc_channel) |
Initializes a pin to read analog values. More... | |
double | read () const |
Get the last reading of the pin, in volts. More... | |
uint16_t | read_raw () const |
Get the most recent reading of the pin, directly from the ADC. See AnalogDigitalConverter.read for the details on interpreting this value. More... | |
Private Attributes | |
AnalogDigitalConverter * | adc_ |
GPIO | gpio_ |
uint8_t | index_ |
A class to represent a single pin configured for analog input.
This class manages the connection to the ADC, and does some of the math for reading. This class does not initialize the ADC.
Definition at line 44 of file analog_pin.h.
void AnalogPin::init | ( | AnalogDigitalConverter * | adc, |
GPIO_TypeDef * | basePort, | ||
uint16_t | pin, | ||
uint8_t | adc_channel | ||
) |
Initializes a pin to read analog values.
This initialization includes configuring the GPIO, and adding a channel to the ADC. This does not configure the ADC. ADC configuration must happen before
adc | The ADC this pin is to use |
basePort | The GPIO definition for this pin to use |
pin | The GPIO number for the pin |
adc_channel | The ADC channel number for the pin, defined by the hardware |
Definition at line 34 of file analog_pin.cpp.
double AnalogPin::read | ( | ) | const |
Get the last reading of the pin, in volts.
Definition at line 41 of file analog_pin.cpp.
uint16_t AnalogPin::read_raw | ( | ) | const |
Get the most recent reading of the pin, directly from the ADC. See AnalogDigitalConverter.read for the details on interpreting this value.
Definition at line 46 of file analog_pin.cpp.
|
private |
Definition at line 71 of file analog_pin.h.
|
private |
Definition at line 70 of file analog_pin.h.
|
private |
Definition at line 72 of file analog_pin.h.