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

Holds the library's runtime configuration, loaded from a JSON file. More...

#include <RumPiConfig.h>

Public Member Functions

 RumPiConfig ()
 Builds a configuration with every value set to its built-in default. More...
 
bool LoadFromJson (const nlohmann::json &configJson)
 Loads settings from an already-parsed config JSON over the current values, so any key missing from the JSON keeps its default. More...
 
unsigned int GetUpdateDelayMilliseconds () const
 Gets the update-loop delay between sensor polls, in milliseconds. More...
 
bool GetReceiverEnabled () const
 Gets whether the remote-client receiver should be started. More...
 
unsigned int GetReceiverPort () const
 Gets the TCP port the receiver listens on. More...
 
float GetLightCutoffDark () const
 Gets the lux boundary for the "dark" light-level bucket. More...
 
float GetLightCutoffVeryDim () const
 Gets the lux boundary for the "very dim" light-level bucket. More...
 
float GetLightCutoffDim () const
 Gets the lux boundary for the "dim" light-level bucket. More...
 
float GetLightCutoffNormal () const
 Gets the lux boundary for the "normal" light-level bucket. More...
 
float GetLightCutoffBright () const
 Gets the lux boundary for the "bright" light-level bucket. More...
 
void SetUpdateDelayMilliseconds (unsigned int updateDelayMilliseconds)
 Sets the update-loop delay between sensor polls, in milliseconds. More...
 
void SetReceiverEnabled (bool receiverEnabled)
 Sets whether the remote-client receiver should be started. More...
 
void SetReceiverPort (unsigned int receiverPort)
 Sets the TCP port the receiver listens on. More...
 
void SetLightCutoffDark (float lightCutoffDark)
 Sets the lux boundary for the "dark" light-level bucket. More...
 
void SetLightCutoffVeryDim (float lightCutoffVeryDim)
 Sets the lux boundary for the "very dim" light-level bucket. More...
 
void SetLightCutoffDim (float lightCutoffDim)
 Sets the lux boundary for the "dim" light-level bucket. More...
 
void SetLightCutoffNormal (float lightCutoffNormal)
 Sets the lux boundary for the "normal" light-level bucket. More...
 
void SetLightCutoffBright (float lightCutoffBright)
 Sets the lux boundary for the "bright" light-level bucket. More...
 

Private Member Functions

void SetDefaults ()
 Sets every configuration value to its built-in default. More...
 

Private Attributes

unsigned int myUpdateDelayMilliseconds
 How long the update loop waits between sensor polls, in milliseconds. More...
 
bool myReceiverEnabled
 Whether the remote-client receiver is started during Initialize(). More...
 
unsigned int myReceiverPort
 TCP port the receiver listens on (1-65535). More...
 
float myLightCutoffDark
 Lux boundary below which the light level is considered "dark" (the buckets ascend from here). More...
 
float myLightCutoffVeryDim
 Lux boundary for the "very dim" bucket. More...
 
float myLightCutoffDim
 Lux boundary for the "dim" bucket. More...
 
float myLightCutoffNormal
 Lux boundary for the "normal" bucket. More...
 
float myLightCutoffBright
 Lux boundary for the "bright" bucket. More...
 

Detailed Description

Holds the library's runtime configuration, loaded from a JSON file.

Every value defaults (in the constructor) to what used to be hard-coded around the library, so a missing file or a missing key simply leaves that value at its default. Hardware/datasheet constants (register addresses, lux coefficients, etc.) are deliberately NOT here - they are fixed by the hardware and stay compile-time constants.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ RumPiConfig()

RumPi::RumPiConfig::RumPiConfig ( )

Builds a configuration with every value set to its built-in default.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
unsigned int delay = config.GetUpdateDelayMilliseconds();
RumPiConfig()
Builds a configuration with every value set to its built-in default.
Definition: RumPiConfig.cpp:19

Member Function Documentation

◆ GetLightCutoffBright()

float RumPi::RumPiConfig::GetLightCutoffBright ( ) const

Gets the lux boundary for the "bright" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
float brightCutoff = config.GetLightCutoffBright();
Returns
The "bright" cutoff, in lux.

◆ GetLightCutoffDark()

float RumPi::RumPiConfig::GetLightCutoffDark ( ) const

Gets the lux boundary for the "dark" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
float darkCutoff = config.GetLightCutoffDark();
Returns
The "dark" cutoff, in lux.

◆ GetLightCutoffDim()

float RumPi::RumPiConfig::GetLightCutoffDim ( ) const

Gets the lux boundary for the "dim" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
float dimCutoff = config.GetLightCutoffDim();
Returns
The "dim" cutoff, in lux.

◆ GetLightCutoffNormal()

float RumPi::RumPiConfig::GetLightCutoffNormal ( ) const

Gets the lux boundary for the "normal" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
float normalCutoff = config.GetLightCutoffNormal();
Returns
The "normal" cutoff, in lux.

◆ GetLightCutoffVeryDim()

float RumPi::RumPiConfig::GetLightCutoffVeryDim ( ) const

Gets the lux boundary for the "very dim" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
float veryDimCutoff = config.GetLightCutoffVeryDim();
Returns
The "very dim" cutoff, in lux.

◆ GetReceiverEnabled()

bool RumPi::RumPiConfig::GetReceiverEnabled ( ) const

Gets whether the remote-client receiver should be started.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
if (config.GetReceiverEnabled() == true)
{
//start the receiver...
}
Returns
true if the receiver is enabled; false otherwise.

◆ GetReceiverPort()

unsigned int RumPi::RumPiConfig::GetReceiverPort ( ) const

Gets the TCP port the receiver listens on.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
unsigned int port = config.GetReceiverPort();
Returns
The receiver's TCP port (1-65535).

◆ GetUpdateDelayMilliseconds()

unsigned int RumPi::RumPiConfig::GetUpdateDelayMilliseconds ( ) const

Gets the update-loop delay between sensor polls, in milliseconds.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
unsigned int delay = config.GetUpdateDelayMilliseconds();
Returns
The delay between polls, in milliseconds.

◆ LoadFromJson()

bool RumPi::RumPiConfig::LoadFromJson ( const nlohmann::json &  configJson)

Loads settings from an already-parsed config JSON over the current values, so any key missing from the JSON keeps its default.

A non-object (e.g. a missing or unparseable file) leaves the clean defaults in place. Bad values are validated and reverted: light cutoffs must strictly ascend, the update delay must be within 1..3,600,000 ms, and the receiver port must be 1-65535. Problems are reported through the AlertManager.

Author
Eddie O'Hagan
Date
8/13/2026
nlohmann::json configJson = nlohmann::json::parse(configFileContents);
RumPiConfig config;
if (config.LoadFromJson(configJson) == true)
{
//config now holds the file's values (with any missing keys left at their defaults).
}
Parameters
[in]configJsonThe parsed configuration object to read values from.
Returns
true if values were read from the JSON; false if it fell back to defaults.

◆ SetDefaults()

void RumPi::RumPiConfig::SetDefaults ( )
private

Sets every configuration value to its built-in default.

Called by the constructor and used to reset the configuration after a bad load.

Author
Eddie O'Hagan
Date
8/13/2026
//Called for you by the constructor; the values below are what you get out of the box.
RumPiConfig config;

◆ SetLightCutoffBright()

void RumPi::RumPiConfig::SetLightCutoffBright ( float  lightCutoffBright)

Sets the lux boundary for the "bright" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetLightCutoffBright(1000.0f);
Parameters
[in]lightCutoffBrightThe new "bright" cutoff, in lux.

◆ SetLightCutoffDark()

void RumPi::RumPiConfig::SetLightCutoffDark ( float  lightCutoffDark)

Sets the lux boundary for the "dark" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetLightCutoffDark(1.0f);
Parameters
[in]lightCutoffDarkThe new "dark" cutoff, in lux.

◆ SetLightCutoffDim()

void RumPi::RumPiConfig::SetLightCutoffDim ( float  lightCutoffDim)

Sets the lux boundary for the "dim" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetLightCutoffDim(50.0f);
Parameters
[in]lightCutoffDimThe new "dim" cutoff, in lux.

◆ SetLightCutoffNormal()

void RumPi::RumPiConfig::SetLightCutoffNormal ( float  lightCutoffNormal)

Sets the lux boundary for the "normal" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetLightCutoffNormal(200.0f);
Parameters
[in]lightCutoffNormalThe new "normal" cutoff, in lux.

◆ SetLightCutoffVeryDim()

void RumPi::RumPiConfig::SetLightCutoffVeryDim ( float  lightCutoffVeryDim)

Sets the lux boundary for the "very dim" light-level bucket.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetLightCutoffVeryDim(10.0f);
Parameters
[in]lightCutoffVeryDimThe new "very dim" cutoff, in lux.

◆ SetReceiverEnabled()

void RumPi::RumPiConfig::SetReceiverEnabled ( bool  receiverEnabled)

Sets whether the remote-client receiver should be started.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetReceiverEnabled(true);
Parameters
[in]receiverEnabledtrue to enable the receiver; false to disable it.

◆ SetReceiverPort()

void RumPi::RumPiConfig::SetReceiverPort ( unsigned int  receiverPort)

Sets the TCP port the receiver listens on.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetReceiverPort(2099);
Parameters
[in]receiverPortThe new receiver port (should be 1-65535).

◆ SetUpdateDelayMilliseconds()

void RumPi::RumPiConfig::SetUpdateDelayMilliseconds ( unsigned int  updateDelayMilliseconds)

Sets the update-loop delay between sensor polls, in milliseconds.

Author
Eddie O'Hagan
Date
8/13/2026
RumPiConfig config;
config.SetUpdateDelayMilliseconds(2000);
Parameters
[in]updateDelayMillisecondsThe new delay between polls, in milliseconds.

Member Data Documentation

◆ myLightCutoffBright

float RumPi::RumPiConfig::myLightCutoffBright
private

Lux boundary for the "bright" bucket.

◆ myLightCutoffDark

float RumPi::RumPiConfig::myLightCutoffDark
private

Lux boundary below which the light level is considered "dark" (the buckets ascend from here).

◆ myLightCutoffDim

float RumPi::RumPiConfig::myLightCutoffDim
private

Lux boundary for the "dim" bucket.

◆ myLightCutoffNormal

float RumPi::RumPiConfig::myLightCutoffNormal
private

Lux boundary for the "normal" bucket.

◆ myLightCutoffVeryDim

float RumPi::RumPiConfig::myLightCutoffVeryDim
private

Lux boundary for the "very dim" bucket.

◆ myReceiverEnabled

bool RumPi::RumPiConfig::myReceiverEnabled
private

Whether the remote-client receiver is started during Initialize().

◆ myReceiverPort

unsigned int RumPi::RumPiConfig::myReceiverPort
private

TCP port the receiver listens on (1-65535).

◆ myUpdateDelayMilliseconds

unsigned int RumPi::RumPiConfig::myUpdateDelayMilliseconds
private

How long the update loop waits between sensor polls, in milliseconds.


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