RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
AnalogDigitalConverterComponent.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include "BaseComponent.h"
4
5namespace RumPi
6{
14 {
15 protected:
18
28 {
29 myADCVoltage = 3.3f;
30 myMaxRawValue = 1023;
31 }
32
33 public:
45 virtual inline ~IAnalogDigitalConverterComponent() = 0;
46
61 virtual int ReadAnalogValue(int adcIndex = 0) = 0;
62
75 inline float GetADCVoltage() const
76 {
77 return myADCVoltage;
78 }
79
93 inline int GetMaxRawValue() const
94 {
95 return myMaxRawValue;
96 }
97 };
98
100} // namespace RumPi
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
Interface for analog-to-digital converter components (e.g.
Definition: AnalogDigitalConverterComponent.h:14
float myADCVoltage
The ADC's reference voltage, used to convert raw readings to volts.
Definition: AnalogDigitalConverterComponent.h:16
virtual ~IAnalogDigitalConverterComponent()=0
Pure virtual destructor, making this an abstract interface.
Definition: AnalogDigitalConverterComponent.h:99
int GetMaxRawValue() const
Gets the ADC's full-scale raw count (e.g.
Definition: AnalogDigitalConverterComponent.h:93
IAnalogDigitalConverterComponent()
Initializes the reference voltage and full-scale count to safe 10-bit defaults; concrete ADCs overwri...
Definition: AnalogDigitalConverterComponent.h:27
int myMaxRawValue
The ADC's full-scale raw count (255 for an 8-bit chip, 1023 for a 10-bit chip).
Definition: AnalogDigitalConverterComponent.h:17
float GetADCVoltage() const
Gets the ADC's reference voltage.
Definition: AnalogDigitalConverterComponent.h:75
virtual int ReadAnalogValue(int adcIndex=0)=0
Reads an analog value from the given channel.
RumPi is the library's top-level facade.
Definition: AlertManager.h:6