RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
Photoresistor.h
Go to the documentation of this file.
1#pragma once
2#include "../Common.h"
3#include "BaseComponent.h"
5
6namespace RumPi
7{
15 {
16 protected:
19
20 public:
32
46 Photoresistor(IAnalogDigitalConverterComponent* analogToDigitalConverter, const unsigned int analogToDigitalConverterIndex);
47
59 virtual ~Photoresistor();
60
71 virtual void TurnOn() override;
72
83 virtual void TurnOff() override;
84
95 virtual void ProcessRawValues() override;
96
109 int ReadRawAnalogValue() const;
110
123 virtual std::string ToString() const override;
124
137 unsigned int GetAnalogToDigitalConverterPinIndex() const;
138
152
165 void SetAnalogToDigitalConverterPinIndex(unsigned int pinIndex);
166
180 };
181} // 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
Photoresistor (LDR) - reads ambient light as an analog value through an ADC channel.
Definition: Photoresistor.h:15
virtual ~Photoresistor()
Destroys the sensor, turning it off first.
Definition: Photoresistor.cpp:55
Photoresistor()
Builds a default photoresistor with no ADC wired yet.
Definition: Photoresistor.cpp:15
unsigned int myAnalogToDigitalConverterPinIndex
The ADC channel index this sensor reads from.
Definition: Photoresistor.h:17
virtual std::string ToString() const override
Serializes the photoresistor's raw analog value to a string.
Definition: Photoresistor.cpp:139
IAnalogDigitalConverterComponent * myAnalogToDigitalConverter
The ADC this sensor reads through.
Definition: Photoresistor.h:18
virtual void ProcessRawValues() override
No-op: the photoresistor reads its value on demand in ReadRawAnalogValue, so there are no raw values ...
Definition: Photoresistor.cpp:100
virtual void TurnOff() override
No-op: the photoresistor holds no resources that need releasing when turned off.
Definition: Photoresistor.cpp:85
void SetAnalogDigitalConverter(IAnalogDigitalConverterComponent *analogDigitalConverter)
Sets the ADC this sensor reads through.
Definition: Photoresistor.cpp:212
IAnalogDigitalConverterComponent * GetAnalogDigitalConverter() const
Gets the ADC this sensor reads through.
Definition: Photoresistor.cpp:178
virtual void TurnOn() override
No-op: the photoresistor is passive and reads on demand, so there is nothing to turn on.
Definition: Photoresistor.cpp:70
void SetAnalogToDigitalConverterPinIndex(unsigned int pinIndex)
Sets the ADC channel index this sensor reads from.
Definition: Photoresistor.cpp:195
int ReadRawAnalogValue() const
Reads the raw analog light value from the ADC, or -1 if no ADC is wired.
Definition: Photoresistor.cpp:117
unsigned int GetAnalogToDigitalConverterPinIndex() const
Gets the ADC channel index this sensor reads from.
Definition: Photoresistor.cpp:161
RumPi is the library's top-level facade.
Definition: AlertManager.h:6