RumPi Linux Client 1.0
A wxWidgets desktop dashboard that visualizes a RumPi robot's live sensor data as a condition-reactive scene
HomeScenePanel Class Reference

The Home tab's stylized, condition-reactive backdrop. More...

#include <HomeScenePanel.h>

Inheritance diagram for HomeScenePanel:
[legend]
Collaboration diagram for HomeScenePanel:
[legend]

Public Member Functions

 HomeScenePanel (wxWindow *parent)
 Builds the scene panel: loads the tunable settings from ClientConfig, seeds and loads the day/night SVG art (falling back to embedded defaults), binds the paint/size/timer events, and starts the animation timer. More...
 
void Update (const RumPi::SelectedSensorReadings &readings)
 Stores the latest sensor snapshot (on the UI thread) and schedules a repaint so the overlays reflect it. More...
 

Protected Member Functions

double LocalTimeInHours () const
 Gets the current local time as a fractional number of hours (e.g. More...
 
double NightAmount () const
 Computes how "night" it is now, from 0.0 (full day) to 1.0 (full night), using a sun-elevation proxy that peaks at noon. More...
 
wxColour Co2DotColour (float co2) const
 Picks the status-dot colour for a CO2 reading, using the configured fresh/elevated thresholds and (accessibility- overridable) colours. More...
 
wxColour AirQualityDotColour (RumPi::E_AirQualityLevel airQualityLevel) const
 Picks the status-dot colour for an air-quality level, collapsing the six levels onto the same good/warning/bad palette as the CO2 dot so there is a single palette to retune for accessibility. More...
 
wxBitmapBundle LoadSceneBundle (const wxString &folder, const wxString &baseName, const char *embeddedSvg) const
 Loads a scene image bundle, preferring a user-supplied file (svg, then raster) in the images folder and falling back to the embedded SVG art. More...
 
void CreateDefaultScenesIfMissing (const wxString &folder) const
 Seeds the images folder with editable copies of the default day/night SVG art, but only when the folder does not exist yet, so a user's own art is never clobbered. More...
 
void EnsureBaseCache (int width, int height, int blendBucket)
 Rebuilds the cached day/night-crossfaded base image, but only when the draw size or the bucketed blend has changed, so the SVG art is not re-rasterized every frame. More...
 
void DrawCelestialBody (wxGraphicsContext *graphicsContext, int width, int height)
 Draws the procedural sun (day) or moon (night) arcing across the sky by real local time, clipped to the sky so it slips behind the horizon as it rises and sets. More...
 
void DrawAtmosphere (wxGraphicsContext *graphicsContext, int width, int height)
 Draws the reading-driven atmospheric overlays: dawn/dusk glow, temperature tint, humidity clouds, air-quality haze, humidity mist, and wind streaks, each mapped from its reading through a response curve. More...
 
void DrawStreetlights (wxGraphicsContext *graphicsContext, int width, int height)
 Draws the default scene's lamp posts, lit by the TSL2591 light level (brighter the darker it gets) and guarded on a present light sensor so they only appear when there is a real reading. More...
 
void DrawPills (wxGraphicsContext *graphicsContext, int width, int height)
 Draws the glanceable info pills: the location and clock along the top, and a bottom strip of reading pills (temperature, humidity, air quality, CO2, wind) with colour-coded status dots on the air-quality and CO2 pills. More...
 
void OnPaint (wxPaintEvent &event)
 Paint handler: cover-scales and blits the cached base, then composites the celestial body, atmosphere, streetlights, and info pills into a reused off-screen buffer and blits it once (flicker-free). More...
 
void RenderScene (wxPaintDC &drawContext)
 Composites one frame (base art, celestial body, atmosphere, streetlights, pills) into the off-screen buffer and blits it. More...
 
void OnSize (wxSizeEvent &event)
 Size handler: schedules a repaint so the scene re-scales to the new panel size. More...
 
void OnTimer (wxTimerEvent &event)
 Timer handler: advances the wind and cloud animation phases (a baseline drift plus an amount proportional to wind speed) and schedules a repaint. More...
 

Protected Attributes

double mySceneAspect
 The scene's aspect ratio. More...
 
wxBitmapBundle myDayScene
 Day base art (SVG bundle). More...
 
wxBitmapBundle myNightScene
 Night base art (SVG bundle). More...
 
RumPi::SelectedSensorReadings myReadings
 
wxBitmap myBaseCache
 Cached crossfaded base image. More...
 
int myBaseCacheWidth
 Width the base cache was built at. More...
 
int myBaseCacheHeight
 Height the base cache was built at. More...
 
int myBaseCacheBlendBucket
 Bucketed day/night blend the base cache was built at. More...
 
wxBitmap myFrameBuffer
 
double myWindPhase
 Current wind animation phase. More...
 
double myCloudPhase
 Current cloud animation phase. More...
 
wxTimer myAnimationTimer
 Timer that advances the animation phases between snapshots. More...
 
wxString myLocationName
 Configured location name. More...
 
double myCo2FreshMax
 Upper CO2 bound for the "fresh" band. More...
 
double myCo2ElevatedMax
 Upper CO2 bound for the "elevated" band. More...
 
double myTempWarmAbove
 Temperature above which the tint reads "warm". More...
 
double myTempCoolBelow
 Temperature below which the tint reads "cool". More...
 
double myDuskGlowOpacity
 Maximum dusk-glow overlay opacity. More...
 
double myTemperatureTintOpacity
 Maximum temperature-tint overlay opacity. More...
 
double myCloudOpacity
 Maximum cloud overlay opacity. More...
 
double myHazeOpacity
 Maximum haze overlay opacity. More...
 
double myMistOpacity
 Maximum mist overlay opacity. More...
 
double myWindOpacity
 Maximum wind overlay opacity. More...
 
wxColour myCo2FreshColour
 Indicator colour for the "fresh" CO2 band. More...
 
wxColour myCo2ElevatedColour
 Indicator colour for the "elevated" CO2 band. More...
 
wxColour myCo2HighColour
 Indicator colour for the "high" CO2 band. More...
 

Static Protected Attributes

static constexpr double DESIGN_WIDTH = 1920.0
 The SVG authoring width overlays are positioned against. More...
 

Detailed Description

The Home tab's stylized, condition-reactive backdrop.

It draws a day/night base scene (loaded once as scalable SVG art, crossfaded by local time and cached so the SVG is not re-rasterized every frame) and paints procedural overlays on top - clouds, haze, temperature tint, wind streaks, mist - plus a set of glanceable info pills. The overlays are driven by the latest SelectedSensorReadings; a wxTimer advances the motion (drifting wind and clouds) between snapshots. Tunable constants (location, thresholds, overlay opacities, frame rate) come from ClientConfig at construction.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ HomeScenePanel()

HomeScenePanel::HomeScenePanel ( wxWindow *  parent)

Builds the scene panel: loads the tunable settings from ClientConfig, seeds and loads the day/night SVG art (falling back to embedded defaults), binds the paint/size/timer events, and starts the animation timer.

Author
Eddie O'Hagan
Date
8/13/2026
HomeScenePanel* panel = new HomeScenePanel(notebook);
The Home tab's stylized, condition-reactive backdrop.
Definition: HomeScenePanel.h:26
HomeScenePanel(wxWindow *parent)
Builds the scene panel: loads the tunable settings from ClientConfig, seeds and loads the day/night S...
Definition: HomeScenePanel.cpp:52
Parameters
[in]parentThe parent window.

Member Function Documentation

◆ AirQualityDotColour()

wxColour HomeScenePanel::AirQualityDotColour ( RumPi::E_AirQualityLevel  airQualityLevel) const
protected

Picks the status-dot colour for an air-quality level, collapsing the six levels onto the same good/warning/bad palette as the CO2 dot so there is a single palette to retune for accessibility.

Author
Eddie O'Hagan
Date
8/13/2026
wxColour colour = AirQualityDotColour(RumPi::E_AirQualityLevel::AIR_QUALITY_POOR);
wxColour AirQualityDotColour(RumPi::E_AirQualityLevel airQualityLevel) const
Picks the status-dot colour for an air-quality level, collapsing the six levels onto the same good/wa...
Definition: HomeScenePanel.cpp:224
Parameters
[in]airQualityLevelThe air-quality level.
Returns
The indicator colour for the level.

◆ Co2DotColour()

wxColour HomeScenePanel::Co2DotColour ( float  co2) const
protected

Picks the status-dot colour for a CO2 reading, using the configured fresh/elevated thresholds and (accessibility- overridable) colours.

Author
Eddie O'Hagan
Date
8/13/2026
wxColour colour = Co2DotColour(650.0f);
wxColour Co2DotColour(float co2) const
Picks the status-dot colour for a CO2 reading, using the configured fresh/elevated thresholds and (ac...
Definition: HomeScenePanel.cpp:189
Parameters
[in]co2The CO2 reading, in ppm.
Returns
The indicator colour for the reading's band.

◆ CreateDefaultScenesIfMissing()

void HomeScenePanel::CreateDefaultScenesIfMissing ( const wxString &  folder) const
protected

Seeds the images folder with editable copies of the default day/night SVG art, but only when the folder does not exist yet, so a user's own art is never clobbered.

Author
Eddie O'Hagan
Date
8/13/2026
void CreateDefaultScenesIfMissing(const wxString &folder) const
Seeds the images folder with editable copies of the default day/night SVG art, but only when the fold...
Definition: HomeScenePanel.cpp:313
Parameters
[in]folderThe images folder to seed.

◆ DrawAtmosphere()

void HomeScenePanel::DrawAtmosphere ( wxGraphicsContext *  graphicsContext,
int  width,
int  height 
)
protected

Draws the reading-driven atmospheric overlays: dawn/dusk glow, temperature tint, humidity clouds, air-quality haze, humidity mist, and wind streaks, each mapped from its reading through a response curve.

Author
Eddie O'Hagan
Date
8/13/2026
DrawAtmosphere(graphicsContext, width, height);
void DrawAtmosphere(wxGraphicsContext *graphicsContext, int width, int height)
Draws the reading-driven atmospheric overlays: dawn/dusk glow, temperature tint, humidity clouds,...
Definition: HomeScenePanel.cpp:668
Parameters
[in]graphicsContextThe graphics context to draw into.
[in]widthThe draw width, in pixels.
[in]heightThe draw height, in pixels.

◆ DrawCelestialBody()

void HomeScenePanel::DrawCelestialBody ( wxGraphicsContext *  graphicsContext,
int  width,
int  height 
)
protected

Draws the procedural sun (day) or moon (night) arcing across the sky by real local time, clipped to the sky so it slips behind the horizon as it rises and sets.

Author
Eddie O'Hagan
Date
8/13/2026
DrawCelestialBody(graphicsContext, width, height);
void DrawCelestialBody(wxGraphicsContext *graphicsContext, int width, int height)
Draws the procedural sun (day) or moon (night) arcing across the sky by real local time,...
Definition: HomeScenePanel.cpp:580
Parameters
[in]graphicsContextThe graphics context to draw into.
[in]widthThe draw width, in pixels.
[in]heightThe draw height, in pixels.

◆ DrawPills()

void HomeScenePanel::DrawPills ( wxGraphicsContext *  graphicsContext,
int  width,
int  height 
)
protected

Draws the glanceable info pills: the location and clock along the top, and a bottom strip of reading pills (temperature, humidity, air quality, CO2, wind) with colour-coded status dots on the air-quality and CO2 pills.

Author
Eddie O'Hagan
Date
8/13/2026
DrawPills(graphicsContext, width, height);
void DrawPills(wxGraphicsContext *graphicsContext, int width, int height)
Draws the glanceable info pills: the location and clock along the top, and a bottom strip of reading ...
Definition: HomeScenePanel.cpp:911
Parameters
[in]graphicsContextThe graphics context to draw into.
[in]widthThe draw width, in pixels.
[in]heightThe draw height, in pixels.

◆ DrawStreetlights()

void HomeScenePanel::DrawStreetlights ( wxGraphicsContext *  graphicsContext,
int  width,
int  height 
)
protected

Draws the default scene's lamp posts, lit by the TSL2591 light level (brighter the darker it gets) and guarded on a present light sensor so they only appear when there is a real reading.

Author
Eddie O'Hagan
Date
8/13/2026
DrawStreetlights(graphicsContext, width, height);
void DrawStreetlights(wxGraphicsContext *graphicsContext, int width, int height)
Draws the default scene's lamp posts, lit by the TSL2591 light level (brighter the darker it gets) an...
Definition: HomeScenePanel.cpp:836
Parameters
[in]graphicsContextThe graphics context to draw into.
[in]widthThe draw width, in pixels.
[in]heightThe draw height, in pixels.

◆ EnsureBaseCache()

void HomeScenePanel::EnsureBaseCache ( int  width,
int  height,
int  blendBucket 
)
protected

Rebuilds the cached day/night-crossfaded base image, but only when the draw size or the bucketed blend has changed, so the SVG art is not re-rasterized every frame.

Author
Eddie O'Hagan
Date
8/13/2026
EnsureBaseCache(coverWidth, coverHeight, blendBucket);
void EnsureBaseCache(int width, int height, int blendBucket)
Rebuilds the cached day/night-crossfaded base image, but only when the draw size or the bucketed blen...
Definition: HomeScenePanel.cpp:358
Parameters
[in]widthThe draw width to build the cache at.
[in]heightThe draw height to build the cache at.
[in]blendBucketThe bucketed night amount (0 - 100) to crossfade at.

◆ LoadSceneBundle()

wxBitmapBundle HomeScenePanel::LoadSceneBundle ( const wxString &  folder,
const wxString &  baseName,
const char *  embeddedSvg 
) const
protected

Loads a scene image bundle, preferring a user-supplied file (svg, then raster) in the images folder and falling back to the embedded SVG art.

Author
Eddie O'Hagan
Date
8/13/2026
wxBitmapBundle day = LoadSceneBundle(imagesFolder, "scene_day", SCENE_DAY_SVG);
wxBitmapBundle LoadSceneBundle(const wxString &folder, const wxString &baseName, const char *embeddedSvg) const
Loads a scene image bundle, preferring a user-supplied file (svg, then raster) in the images folder a...
Definition: HomeScenePanel.cpp:258
Parameters
[in]folderThe images folder to look in.
[in]baseNameThe base file name (without extension) to look for.
[in]embeddedSvgThe embedded SVG to fall back to.
Returns
The loaded bundle, or an empty bundle if the inputs were invalid.

◆ LocalTimeInHours()

double HomeScenePanel::LocalTimeInHours ( ) const
protected

Gets the current local time as a fractional number of hours (e.g.

15.5 for 15:30).

Author
Eddie O'Hagan
Date
8/13/2026
double hours = LocalTimeInHours();
double LocalTimeInHours() const
Gets the current local time as a fractional number of hours (e.g.
Definition: HomeScenePanel.cpp:146
Returns
The local time, in hours.

◆ NightAmount()

double HomeScenePanel::NightAmount ( ) const
protected

Computes how "night" it is now, from 0.0 (full day) to 1.0 (full night), using a sun-elevation proxy that peaks at noon.

Author
Eddie O'Hagan
Date
8/13/2026
double night = NightAmount();
double NightAmount() const
Computes how "night" it is now, from 0.0 (full day) to 1.0 (full night), using a sun-elevation proxy ...
Definition: HomeScenePanel.cpp:165
Returns
The night amount, from 0.0 (day) to 1.0 (night).

◆ OnPaint()

void HomeScenePanel::OnPaint ( wxPaintEvent &  event)
protected

Paint handler: cover-scales and blits the cached base, then composites the celestial body, atmosphere, streetlights, and info pills into a reused off-screen buffer and blits it once (flicker-free).

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by wxWidgets when the panel needs repainting.
Parameters
[in]eventThe paint event.

◆ OnSize()

void HomeScenePanel::OnSize ( wxSizeEvent &  event)
protected

Size handler: schedules a repaint so the scene re-scales to the new panel size.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked by wxWidgets when the panel is resized.
Parameters
[in]eventThe size event.

◆ OnTimer()

void HomeScenePanel::OnTimer ( wxTimerEvent &  event)
protected

Timer handler: advances the wind and cloud animation phases (a baseline drift plus an amount proportional to wind speed) and schedules a repaint.

Author
Eddie O'Hagan
Date
8/13/2026
//Invoked on each animation-timer tick.
Parameters
[in]eventThe timer event.

◆ RenderScene()

void HomeScenePanel::RenderScene ( wxPaintDC &  drawContext)
protected

Composites one frame (base art, celestial body, atmosphere, streetlights, pills) into the off-screen buffer and blits it.

Split out of OnPaint so the paint handler can wrap it in a try/catch - a bad_alloc while compositing full-screen on a low-RAM Pi must not escape the wx paint handler through GTK and terminate the app.

Author
Eddie O'Hagan
Date
8/13/2026
//Called by OnPaint().
Parameters
[in]drawContextThe paint DC the finished frame is blitted to.

◆ Update()

void HomeScenePanel::Update ( const RumPi::SelectedSensorReadings &  readings)

Stores the latest sensor snapshot (on the UI thread) and schedules a repaint so the overlays reflect it.

Author
Eddie O'Hagan
Date
8/13/2026
panel->Update(readings);
Parameters
[in]readingsThe latest curated sensor readings.

Member Data Documentation

◆ DESIGN_WIDTH

constexpr double HomeScenePanel::DESIGN_WIDTH = 1920.0
staticconstexprprotected

The SVG authoring width overlays are positioned against.

◆ myAnimationTimer

wxTimer HomeScenePanel::myAnimationTimer
protected

Timer that advances the animation phases between snapshots.

◆ myBaseCache

wxBitmap HomeScenePanel::myBaseCache
protected

Cached crossfaded base image.

◆ myBaseCacheBlendBucket

int HomeScenePanel::myBaseCacheBlendBucket
protected

Bucketed day/night blend the base cache was built at.

◆ myBaseCacheHeight

int HomeScenePanel::myBaseCacheHeight
protected

Height the base cache was built at.

◆ myBaseCacheWidth

int HomeScenePanel::myBaseCacheWidth
protected

Width the base cache was built at.

◆ myCloudOpacity

double HomeScenePanel::myCloudOpacity
protected

Maximum cloud overlay opacity.

◆ myCloudPhase

double HomeScenePanel::myCloudPhase
protected

Current cloud animation phase.

◆ myCo2ElevatedColour

wxColour HomeScenePanel::myCo2ElevatedColour
protected

Indicator colour for the "elevated" CO2 band.

◆ myCo2ElevatedMax

double HomeScenePanel::myCo2ElevatedMax
protected

Upper CO2 bound for the "elevated" band.

◆ myCo2FreshColour

wxColour HomeScenePanel::myCo2FreshColour
protected

Indicator colour for the "fresh" CO2 band.

◆ myCo2FreshMax

double HomeScenePanel::myCo2FreshMax
protected

Upper CO2 bound for the "fresh" band.

◆ myCo2HighColour

wxColour HomeScenePanel::myCo2HighColour
protected

Indicator colour for the "high" CO2 band.

◆ myDayScene

wxBitmapBundle HomeScenePanel::myDayScene
protected

Day base art (SVG bundle).

◆ myDuskGlowOpacity

double HomeScenePanel::myDuskGlowOpacity
protected

Maximum dusk-glow overlay opacity.

◆ myFrameBuffer

wxBitmap HomeScenePanel::myFrameBuffer
protected

◆ myHazeOpacity

double HomeScenePanel::myHazeOpacity
protected

Maximum haze overlay opacity.

◆ myLocationName

wxString HomeScenePanel::myLocationName
protected

Configured location name.

◆ myMistOpacity

double HomeScenePanel::myMistOpacity
protected

Maximum mist overlay opacity.

◆ myNightScene

wxBitmapBundle HomeScenePanel::myNightScene
protected

Night base art (SVG bundle).

◆ myReadings

RumPi::SelectedSensorReadings HomeScenePanel::myReadings
protected

◆ mySceneAspect

double HomeScenePanel::mySceneAspect
protected

The scene's aspect ratio.

◆ myTempCoolBelow

double HomeScenePanel::myTempCoolBelow
protected

Temperature below which the tint reads "cool".

◆ myTemperatureTintOpacity

double HomeScenePanel::myTemperatureTintOpacity
protected

Maximum temperature-tint overlay opacity.

◆ myTempWarmAbove

double HomeScenePanel::myTempWarmAbove
protected

Temperature above which the tint reads "warm".

◆ myWindOpacity

double HomeScenePanel::myWindOpacity
protected

Maximum wind overlay opacity.

◆ myWindPhase

double HomeScenePanel::myWindPhase
protected

Current wind animation phase.


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