![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
Photoresistor (LDR) - reads ambient light as an analog value through an ADC channel. More...
#include <Photoresistor.h>
Public Member Functions | |
| Photoresistor () | |
| Builds a default photoresistor with no ADC wired yet. More... | |
| Photoresistor (IAnalogDigitalConverterComponent *analogToDigitalConverter, const unsigned int analogToDigitalConverterIndex) | |
| Builds a photoresistor bound to the given ADC and channel index. More... | |
| virtual | ~Photoresistor () |
| Destroys the sensor, turning it off first. More... | |
| virtual void | TurnOn () override |
| No-op: the photoresistor is passive and reads on demand, so there is nothing to turn on. More... | |
| virtual void | TurnOff () override |
| No-op: the photoresistor holds no resources that need releasing when turned off. More... | |
| virtual void | ProcessRawValues () override |
| No-op: the photoresistor reads its value on demand in ReadRawAnalogValue, so there are no raw values to process. More... | |
| int | ReadRawAnalogValue () const |
| Reads the raw analog light value from the ADC, or -1 if no ADC is wired. More... | |
| virtual std::string | ToString () const override |
| Serializes the photoresistor's raw analog value to a string. More... | |
| unsigned int | GetAnalogToDigitalConverterPinIndex () const |
| Gets the ADC channel index this sensor reads from. More... | |
| IAnalogDigitalConverterComponent * | GetAnalogDigitalConverter () const |
| Gets the ADC this sensor reads through. More... | |
| void | SetAnalogToDigitalConverterPinIndex (unsigned int pinIndex) |
| Sets the ADC channel index this sensor reads from. More... | |
| void | SetAnalogDigitalConverter (IAnalogDigitalConverterComponent *analogDigitalConverter) |
| Sets the ADC this sensor reads through. More... | |
Public Member Functions inherited from RumPi::BaseComponent | |
| BaseComponent () | |
| Builds a base component with an unknown type and an empty name. More... | |
| virtual | ~BaseComponent () |
| Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More... | |
| virtual void | TurnOn ()=0 |
| Turns the component on (e.g. More... | |
| virtual void | TurnOff ()=0 |
| Turns the component off. More... | |
| virtual std::string | ToString () const =0 |
| Serializes the component's current readings to a string (usually JSON). More... | |
| virtual void | ProcessRawValues ()=0 |
| Reads and processes the component's latest raw values (called once per poll). More... | |
| virtual EComponentType | GetComponentType () const |
| Gets the component's type. More... | |
| const std::string & | GetName () const |
| Gets the component's unique per-instance name. More... | |
| void | SetName (const std::string &name) |
| Sets the component's unique per-instance name. More... | |
Protected Attributes | |
| unsigned int | myAnalogToDigitalConverterPinIndex |
| The ADC channel index this sensor reads from. More... | |
| IAnalogDigitalConverterComponent * | myAnalogToDigitalConverter |
| The ADC this sensor reads through. More... | |
Protected Attributes inherited from RumPi::BaseComponent | |
| EComponentType | myComponentType |
| The kind of component this is (set by each concrete subclass). More... | |
| std::string | myName |
| A unique per-instance name, assigned when the component is added to the manager. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from RumPi::BaseComponent | |
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| Maps an EComponentType to its string name. More... | |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More... | |
Photoresistor (LDR) - reads ambient light as an analog value through an ADC channel.
| RumPi::Photoresistor::Photoresistor | ( | ) |
Builds a default photoresistor with no ADC wired yet.
| RumPi::Photoresistor::Photoresistor | ( | IAnalogDigitalConverterComponent * | analogToDigitalConverter, |
| const unsigned int | analogToDigitalConverterIndex | ||
| ) |
Builds a photoresistor bound to the given ADC and channel index.
| [in] | analogToDigitalConverter | The ADC this sensor reads through. |
| [in] | analogToDigitalConverterIndex | The ADC channel index this sensor reads from. |
|
virtual |
Destroys the sensor, turning it off first.
| IAnalogDigitalConverterComponent * RumPi::Photoresistor::GetAnalogDigitalConverter | ( | ) | const |
Gets the ADC this sensor reads through.
| unsigned int RumPi::Photoresistor::GetAnalogToDigitalConverterPinIndex | ( | ) | const |
Gets the ADC channel index this sensor reads from.
|
overridevirtual |
No-op: the photoresistor reads its value on demand in ReadRawAnalogValue, so there are no raw values to process.
Implements RumPi::BaseComponent.
| int RumPi::Photoresistor::ReadRawAnalogValue | ( | ) | const |
Reads the raw analog light value from the ADC, or -1 if no ADC is wired.
| void RumPi::Photoresistor::SetAnalogDigitalConverter | ( | IAnalogDigitalConverterComponent * | analogDigitalConverter | ) |
Sets the ADC this sensor reads through.
| [in] | analogDigitalConverter | The ADC to set. |
| void RumPi::Photoresistor::SetAnalogToDigitalConverterPinIndex | ( | unsigned int | pinIndex | ) |
Sets the ADC channel index this sensor reads from.
| [in] | pinIndex | The ADC channel index to set. |
|
overridevirtual |
Serializes the photoresistor's raw analog value to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
No-op: the photoresistor holds no resources that need releasing when turned off.
Implements RumPi::BaseComponent.
|
overridevirtual |
No-op: the photoresistor is passive and reads on demand, so there is nothing to turn on.
Implements RumPi::BaseComponent.
|
protected |
The ADC this sensor reads through.
|
protected |
The ADC channel index this sensor reads from.