RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::LED Class Reference

A very simple standard LED, driven by a single GPIO pin. More...

#include <LED.h>

Inheritance diagram for RumPi::LED:
[legend]
Collaboration diagram for RumPi::LED:
[legend]

Public Member Functions

 LED (unsigned int pinNumber)
 Builds an LED on the given GPIO pin and sets that pin to output mode. More...
 
virtual ~LED ()
 Destroys the LED. More...
 
virtual void TurnOn () override
 Turns the LED on (drives its pin high). More...
 
virtual void TurnOff () override
 Turns the LED off (drives its pin low). More...
 
virtual void ProcessRawValues () override
 Processes the LED's raw values. More...
 
virtual std::string ToString () const override
 Serializes the LED's state (its pin number) to a string. More...
 
unsigned int GetPinNumber () const
 Gets the GPIO pin the LED is driven on. 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...
 

Private Attributes

unsigned int myPinNumber
 The BCM GPIO pin this LED is driven on. 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...
 
- 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...
 

Detailed Description

A very simple standard LED, driven by a single GPIO pin.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ LED()

RumPi::LED::LED ( unsigned int  pinNumber)

Builds an LED on the given GPIO pin and sets that pin to output mode.

Author
Eddie O'Hagan
Date
8/13/2026
led.TurnOn();
LED(unsigned int pinNumber)
Builds an LED on the given GPIO pin and sets that pin to output mode.
Definition: LED.cpp:18
constexpr unsigned int PIN_GPIO_12
BCM GPIO pin 12.
Definition: Common.h:38
Parameters
[in]pinNumberThe BCM GPIO pin to drive the LED on.

◆ ~LED()

RumPi::LED::~LED ( )
virtual

Destroys the LED.

Nothing to clean up beyond the base class.

Author
Eddie O'Hagan
Date
8/13/2026
LED* led = new LED(PIN_GPIO_12);
delete led;

Member Function Documentation

◆ GetPinNumber()

unsigned int RumPi::LED::GetPinNumber ( ) const

Gets the GPIO pin the LED is driven on.

Author
Eddie O'Hagan
Date
8/13/2026
unsigned int pin = led.GetPinNumber();
Returns
The LED's GPIO pin number.

◆ ProcessRawValues()

void RumPi::LED::ProcessRawValues ( )
overridevirtual

Processes the LED's raw values.

The LED is output-only, so there is nothing to read each cycle - this is a no-op.

Author
Eddie O'Hagan
Date
8/13/2026
led.ProcessRawValues(); //no-op for an output-only component.

Implements RumPi::BaseComponent.

◆ ToString()

std::string RumPi::LED::ToString ( ) const
overridevirtual

Serializes the LED's state (its pin number) to a string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = led.ToString(); //"LED = PinNumber:12\n"
Returns
A string describing the LED.

Implements RumPi::BaseComponent.

◆ TurnOff()

void RumPi::LED::TurnOff ( )
overridevirtual

Turns the LED off (drives its pin low).

Author
Eddie O'Hagan
Date
8/13/2026
led.TurnOff();

Implements RumPi::BaseComponent.

◆ TurnOn()

void RumPi::LED::TurnOn ( )
overridevirtual

Turns the LED on (drives its pin high).

Author
Eddie O'Hagan
Date
8/13/2026
led.TurnOn();

Implements RumPi::BaseComponent.

Member Data Documentation

◆ myPinNumber

unsigned int RumPi::LED::myPinNumber
private

The BCM GPIO pin this LED is driven on.


The documentation for this class was generated from the following files: