A relay driven by a single GPIO pin (output-only, like an LED).
More...
#include <Relay.h>
|
| | Relay (unsigned int pinNumber) |
| | Builds a relay on the given GPIO pin and sets that pin to output mode. More...
|
| |
| virtual | ~Relay () |
| | Destroys the relay. More...
|
| |
| virtual void | TurnOn () override |
| | Turns the relay on (drives its pin high). More...
|
| |
| virtual void | TurnOff () override |
| | Turns the relay off (drives its pin low). More...
|
| |
| virtual void | ProcessRawValues () override |
| | Processes the relay's raw values. More...
|
| |
| virtual std::string | ToString () const override |
| | Serializes the relay's state (its pin number) to a string. More...
|
| |
| unsigned int | GetPinNumber () const |
| | Gets the GPIO pin the relay is driven on. More...
|
| |
| | 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...
|
| |
A relay driven by a single GPIO pin (output-only, like an LED).
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ Relay()
| RumPi::Relay::Relay |
( |
unsigned int |
pinNumber | ) |
|
Builds a relay on the given GPIO pin and sets that pin to output mode.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
relay.TurnOn();
Relay(unsigned int pinNumber)
Builds a relay on the given GPIO pin and sets that pin to output mode.
Definition: Relay.cpp:18
constexpr unsigned int PIN_GPIO_21
BCM GPIO pin 21.
Definition: Common.h:47
- Parameters
-
| [in] | pinNumber | The BCM GPIO pin to drive the relay on. |
◆ ~Relay()
Destroys the relay.
Nothing to clean up beyond the base class.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
◆ GetPinNumber()
| unsigned int RumPi::Relay::GetPinNumber |
( |
| ) |
const |
Gets the GPIO pin the relay is driven on.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
unsigned int pin = relay.GetPinNumber();
- Returns
- The relay's GPIO pin number.
◆ ProcessRawValues()
| void RumPi::Relay::ProcessRawValues |
( |
| ) |
|
|
overridevirtual |
Processes the relay's raw values.
The relay is output-only, so there is nothing to read each cycle - this is a no-op.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
relay.ProcessRawValues();
Implements RumPi::BaseComponent.
◆ ToString()
| std::string RumPi::Relay::ToString |
( |
| ) |
const |
|
overridevirtual |
Serializes the relay's state (its pin number) to a string.
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
std::string data = relay.ToString();
- Returns
- A string describing the relay.
Implements RumPi::BaseComponent.
◆ TurnOff()
| void RumPi::Relay::TurnOff |
( |
| ) |
|
|
overridevirtual |
Turns the relay off (drives its pin low).
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
Implements RumPi::BaseComponent.
◆ TurnOn()
| void RumPi::Relay::TurnOn |
( |
| ) |
|
|
overridevirtual |
Turns the relay on (drives its pin high).
- Author
- Eddie O'Hagan
- Date
- 8/13/2026
Implements RumPi::BaseComponent.
◆ myPinNumber
| unsigned int RumPi::Relay::myPinNumber |
|
private |
The GPIO pin the relay is driven on.
The documentation for this class was generated from the following files:
- Source/Headers/RumPi/Components/Relay.h
- Source/Implementations/RumPi/Components/Relay.cpp