RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
MCP3008.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include <mcp3004.h>
5
6namespace RumPi
7{
15 {
16 private:
19
20 public:
35 MCP3008(const int basePinNum, const int spiChannel, const float adcVoltage = 3.3f);
36
48 virtual ~MCP3008();
49
60 virtual void TurnOn() override;
61
72 virtual void TurnOff() override;
73
84 virtual void ProcessRawValues() override;
85
98 virtual std::string ToString() const override;
99
114 virtual int ReadAnalogValue(int adcIndex = 0) override;
115 };
116} // namespace RumPi
Interface for analog-to-digital converter components (e.g.
Definition: AnalogDigitalConverterComponent.h:14
MCP3008 analog-to-digital converter chip (SPI), providing 8 channels to read analog sensors on the Ra...
Definition: MCP3008.h:15
virtual std::string ToString() const override
Serializes the chip's base pin number, SPI channel, and ADC voltage to a string.
Definition: MCP3008.cpp:136
int myBasePinNum
The wiringPi base pin number for the chip's channels.
Definition: MCP3008.h:17
MCP3008(const int basePinNum, const int spiChannel, const float adcVoltage=3.3f)
Builds an MCP3008 ADC bound to the given base pin number, SPI channel, and reference voltage.
Definition: MCP3008.cpp:20
virtual ~MCP3008()
Destroys the ADC.
Definition: MCP3008.cpp:42
virtual void TurnOff() override
No-op: the MCP3008 holds no resources that need releasing when turned off.
Definition: MCP3008.cpp:76
virtual int ReadAnalogValue(int adcIndex=0) override
Reads an analog value from the given channel over SPI (8 possible ADCs, 0 through 7).
Definition: MCP3008.cpp:110
int mySpiChannel
The SPI channel the chip is wired to.
Definition: MCP3008.h:18
virtual void TurnOn() override
Initializes the MCP3008 for analog reads via wiringPi, reporting a warning through the AlertManager o...
Definition: MCP3008.cpp:57
virtual void ProcessRawValues() override
No-op: the MCP3008 reads its channels on demand in ReadAnalogValue, so there are no raw values to pro...
Definition: MCP3008.cpp:91
RumPi is the library's top-level facade.
Definition: AlertManager.h:6