![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
QS-FS01 anemometer wind-speed sensor, read as an analog voltage through an ADC channel. More...
#include <QSFS01.h>
Public Member Functions | |
| QSFS01 () | |
| Builds a default anemometer with no ADC wired yet and a zero peak wind speed. More... | |
| QSFS01 (IAnalogDigitalConverterComponent *analogToDigitalConverter, const unsigned int &analogToDigitalConverterIndex) | |
| Builds an anemometer bound to the given ADC and channel index, with a zero peak wind speed. More... | |
| virtual | ~QSFS01 () |
| Destroys the sensor, turning it off first. More... | |
| virtual void | TurnOn () override |
| No-op: the anemometer is passive and reads on demand, so there is nothing to turn on. More... | |
| virtual void | TurnOff () override |
| No-op: the anemometer holds no resources that need releasing when turned off. More... | |
| double | CalculateWindSpeed () const |
| Calculates the current wind speed (m/s) from the ADC's output voltage using the datasheet's 0.4V-2.0V linear range mapped onto 0 to the sensor's max wind speed. More... | |
| double | ConsumePeakWindSpeed () |
| Returns the peak wind speed seen since the last call, then resets the peak for the next window. More... | |
| virtual void | ProcessRawValues () override |
| Samples the current wind speed and keeps the highest value seen since the last snapshot consumed the peak. More... | |
| int | ReadRawAnalogValue () const |
| Reads the raw analog value from the ADC, or -1 if no ADC is wired. More... | |
| virtual std::string | ToString () const override |
| Serializes the anemometer's raw analog value and calculated wind speed 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... | |
| double | myPeakWindSpeed |
| Highest wind speed (m/s) seen since the last read. 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... | |
QS-FS01 anemometer wind-speed sensor, read as an analog voltage through an ADC channel.
References: https://www.adafruit.com/product/1733 https://cdn-shop.adafruit.com/product-files/1733/C2192-002_datasheet.pdf
| RumPi::QSFS01::QSFS01 | ( | ) |
Builds a default anemometer with no ADC wired yet and a zero peak wind speed.
| RumPi::QSFS01::QSFS01 | ( | IAnalogDigitalConverterComponent * | analogToDigitalConverter, |
| const unsigned int & | analogToDigitalConverterIndex | ||
| ) |
Builds an anemometer bound to the given ADC and channel index, with a zero peak wind speed.
| [in] | analogToDigitalConverter | The ADC this sensor reads through. |
| [in] | analogToDigitalConverterIndex | The ADC channel index this sensor reads from. |
|
virtual |
| double RumPi::QSFS01::CalculateWindSpeed | ( | ) | const |
Calculates the current wind speed (m/s) from the ADC's output voltage using the datasheet's 0.4V-2.0V linear range mapped onto 0 to the sensor's max wind speed.
| double RumPi::QSFS01::ConsumePeakWindSpeed | ( | ) |
Returns the peak wind speed seen since the last call, then resets the peak for the next window.
| IAnalogDigitalConverterComponent * RumPi::QSFS01::GetAnalogDigitalConverter | ( | ) | const |
Gets the ADC this sensor reads through.
| unsigned int RumPi::QSFS01::GetAnalogToDigitalConverterPinIndex | ( | ) | const |
Gets the ADC channel index this sensor reads from.
|
overridevirtual |
Samples the current wind speed and keeps the highest value seen since the last snapshot consumed the peak.
Implements RumPi::BaseComponent.
| int RumPi::QSFS01::ReadRawAnalogValue | ( | ) | const |
Reads the raw analog value from the ADC, or -1 if no ADC is wired.
| void RumPi::QSFS01::SetAnalogDigitalConverter | ( | IAnalogDigitalConverterComponent * | analogDigitalConverter | ) |
Sets the ADC this sensor reads through.
| [in] | analogDigitalConverter | The ADC to set. |
| void RumPi::QSFS01::SetAnalogToDigitalConverterPinIndex | ( | unsigned int | pinIndex | ) |
Sets the ADC channel index this sensor reads from.
| [in] | pinIndex | The ADC channel index to set. |
|
overridevirtual |
Serializes the anemometer's raw analog value and calculated wind speed to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
No-op: the anemometer holds no resources that need releasing when turned off.
Implements RumPi::BaseComponent.
|
overridevirtual |
No-op: the anemometer 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.
|
protected |
Highest wind speed (m/s) seen since the last read.
ProcessRawValues raises it each sample so a gust between snapshots is not sampled away; the snapshot consumes it via ConsumePeakWindSpeed().