RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
SoundSensor.h
Go to the documentation of this file.
1#pragma once
2#include <stdio.h>
3#include <iostream>
4#include <wiringPi.h>
5#include "BaseComponent.h"
6
7namespace RumPi
8{
16 {
17
18 private:
19 unsigned int myPCFBasePinNumber;
21
22 public:
36 SoundSensor(unsigned int pcfBasePinNumber, int pcfI2CAddress);
37
49 virtual ~SoundSensor();
50
61 virtual void TurnOn() override;
62
73 virtual void TurnOff() override;
74
85 virtual void ProcessRawValues() override;
86
99 virtual std::string ToString() const override;
100
113 int ReadRawAnalogValue() const;
114
127 unsigned int GetPCFBasePinNumber() const;
128
141 int GetPCFI2CAddress() const;
142
143 };
144} // namespace RumPi
Abstract base class for every component (sensor, actuator, etc.) the library manages.
Definition: BaseComponent.h:60
FC-04 sound sensor - reads sound level as an analog value through a PCF8591 ADC channel.
Definition: SoundSensor.h:16
int GetPCFI2CAddress() const
Gets the PCF8591 I2C address.
Definition: SoundSensor.cpp:132
virtual void TurnOff() override
No-op: the sound sensor holds no resources that need releasing when turned off.
Definition: SoundSensor.cpp:66
virtual std::string ToString() const override
Serializes the sensor's PCF8591 base pin number and I2C address to a string.
Definition: SoundSensor.cpp:149
virtual void TurnOn() override
No-op: the sound sensor is passive and reads on demand, so there is nothing to turn on.
Definition: SoundSensor.cpp:51
SoundSensor(unsigned int pcfBasePinNumber, int pcfI2CAddress)
Builds a sound sensor bound to the given PCF8591 base pin number and I2C address.
Definition: SoundSensor.cpp:18
virtual ~SoundSensor()
Destroys the sensor, turning it off first.
Definition: SoundSensor.cpp:36
int ReadRawAnalogValue() const
Reads the raw analog sound value from the PCF8591 base pin.
Definition: SoundSensor.cpp:98
virtual void ProcessRawValues() override
No-op: the sound sensor reads its value on demand in ReadRawAnalogValue, so there are no raw values t...
Definition: SoundSensor.cpp:81
int myPCFI2CAddress
The PCF8591 I2C address.
Definition: SoundSensor.h:20
unsigned int myPCFBasePinNumber
The PCF8591 base pin number this sensor reads from.
Definition: SoundSensor.h:19
unsigned int GetPCFBasePinNumber() const
Gets the PCF8591 base pin number this sensor reads from.
Definition: SoundSensor.cpp:115
RumPi is the library's top-level facade.
Definition: AlertManager.h:6