Interface for analog-to-digital converter components (e.g.
More...
#include <AnalogDigitalConverterComponent.h>
|
| | IAnalogDigitalConverterComponent () |
| | Initializes the reference voltage and full-scale count to safe 10-bit defaults; concrete ADCs overwrite both in their own constructor, so a subclass that forgets to set them still yields sane (non-garbage) conversions rather than silently wrong volts. More...
|
| |
Interface for analog-to-digital converter components (e.g.
PCF8591, MCP3008), used to read analog sensors.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ IAnalogDigitalConverterComponent()
| RumPi::IAnalogDigitalConverterComponent::IAnalogDigitalConverterComponent |
( |
| ) |
|
|
inlineprotected |
Initializes the reference voltage and full-scale count to safe 10-bit defaults; concrete ADCs overwrite both in their own constructor, so a subclass that forgets to set them still yields sane (non-garbage) conversions rather than silently wrong volts.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ ~IAnalogDigitalConverterComponent()
| RumPi::IAnalogDigitalConverterComponent::~IAnalogDigitalConverterComponent |
( |
| ) |
|
|
inlinepure virtual |
Pure virtual destructor, making this an abstract interface.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
delete adc;
IAnalogDigitalConverterComponent()
Initializes the reference voltage and full-scale count to safe 10-bit defaults; concrete ADCs overwri...
Definition: AnalogDigitalConverterComponent.h:27
◆ GetADCVoltage()
| float RumPi::IAnalogDigitalConverterComponent::GetADCVoltage |
( |
| ) |
const |
|
inline |
Gets the ADC's reference voltage.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
float voltage = adc->GetADCVoltage();
- Returns
- The ADC's reference voltage.
◆ GetMaxRawValue()
| int RumPi::IAnalogDigitalConverterComponent::GetMaxRawValue |
( |
| ) |
const |
|
inline |
Gets the ADC's full-scale raw count (e.g.
255 for an 8-bit chip, 1023 for a 10-bit chip), so callers can scale a raw reading to volts without assuming a fixed resolution.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
int fullScale = adc->GetMaxRawValue();
- Returns
- The ADC's maximum raw reading.
◆ ReadAnalogValue()
| virtual int RumPi::IAnalogDigitalConverterComponent::ReadAnalogValue |
( |
int |
adcIndex = 0 | ) |
|
|
pure virtual |
Reads an analog value from the given channel.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
int value = adc->ReadAnalogValue(0);
- Parameters
-
| [in] | adcIndex | The ADC channel index to read. |
- Returns
- The raw analog value, or -1 if the channel index is out of range.
Implemented in RumPi::MCP3008, and RumPi::PCF8591.
◆ myADCVoltage
| float RumPi::IAnalogDigitalConverterComponent::myADCVoltage |
|
protected |
The ADC's reference voltage, used to convert raw readings to volts.
◆ myMaxRawValue
| int RumPi::IAnalogDigitalConverterComponent::myMaxRawValue |
|
protected |
The ADC's full-scale raw count (255 for an 8-bit chip, 1023 for a 10-bit chip).
The documentation for this class was generated from the following file: