RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
PCF8591.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include <pcf8591.h>
5
6namespace RumPi
7{
15 {
16
17 private:
18 unsigned int myPCFBasePinNumber;
20
21 public:
37 PCF8591(unsigned int pcfBasePinNumber, int pcfI2cAddress, float adcVoltage = 3.3f);
38
50 virtual ~PCF8591();
51
62 virtual void TurnOn() override;
63
74 virtual void TurnOff() override;
75
86 virtual void ProcessRawValues() override;
87
100 virtual std::string ToString() const override;
101
116 virtual int ReadAnalogValue(int adcIndex = 0) override;
117
130 unsigned int GetPCFBasePinNumber() const;
131
144 int GetPCFI2CAddress() const;
145
146 };
147} // namespace RumPi
Interface for analog-to-digital converter components (e.g.
Definition: AnalogDigitalConverterComponent.h:14
PCF8591 analog-to-digital converter chip (I2C), used to read analog sensors on the Raspberry Pi.
Definition: PCF8591.h:15
PCF8591(unsigned int pcfBasePinNumber, int pcfI2cAddress, float adcVoltage=3.3f)
Builds a PCF8591 ADC bound to the given base pin, I2C address, and reference voltage.
Definition: PCF8591.cpp:21
int myPCFI2CAddress
The chip's I2C address.
Definition: PCF8591.h:19
unsigned int GetPCFBasePinNumber() const
Gets the wiringPi base pin; the chip's four ADC channels are read as base+0..base+3.
Definition: PCF8591.cpp:155
int GetPCFI2CAddress() const
Gets the chip's I2C address.
Definition: PCF8591.cpp:172
virtual int ReadAnalogValue(int adcIndex=0) override
Reads a fresh analog value from the given ADC channel, performing a dummy read and settle delay first...
Definition: PCF8591.cpp:117
virtual void TurnOff() override
No-op: the PCF8591 holds no resources that need releasing when turned off.
Definition: PCF8591.cpp:83
unsigned int myPCFBasePinNumber
The wiringPi base pin; pcf8591Setup maps the four ADC channels to base+0..base+3.
Definition: PCF8591.h:18
virtual ~PCF8591()
Destroys the ADC, turning it off first.
Definition: PCF8591.cpp:42
virtual void TurnOn() override
Initializes the PCF8591 for analog reads via wiringPi, reporting success or failure through the Alert...
Definition: PCF8591.cpp:57
virtual void ProcessRawValues() override
No-op: the PCF8591 reads its channels on demand in ReadAnalogValue, so there are no raw values to pro...
Definition: PCF8591.cpp:98
virtual std::string ToString() const override
Serializes the chip's base pin (with its channel range) and ADC voltage to a string.
Definition: PCF8591.cpp:189
RumPi is the library's top-level facade.
Definition: AlertManager.h:6