ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
HeadsUpDisplay Class Reference

Renders and displays information on an SSD1306/SH1106 display. More...

#include <SSD1306.h>

Inheritance diagram for HeadsUpDisplay:
Collaboration diagram for HeadsUpDisplay:

Public Member Functions

 HeadsUpDisplay (Vector2D faceMin, Vector2D faceMax)
 Constructs a HeadsUpDisplay with face rendering boundaries.
 
void SetFaceArray (const __FlashStringHelper **faceNames)
 Sets the array of face names.
 
void SetFaceMin (Vector2D faceMin)
 Sets the minimum face rendering coordinates.
 
void SetFaceMax (Vector2D faceMax)
 Sets the maximum face rendering coordinates.
 
void Initialize ()
 Initializes the display and related components.
 
void ResetI2CBus ()
 Resets the I2C bus in case of communication errors.
 
void Update ()
 Updates the display content based on the current state.
 
void SetEffect (Effect *effect)
 Sets the sub-effect to be applied to the display.
 
void ApplyEffect (IPixelGroup *pixelGroup)
 Applies the effect to the specified pixel group.
 
void CheckInvertPrintText (int16_t x, int16_t y, uint8_t menu, const String &str)
 Prints text conditionally inverted based on menu selection.
 
- Public Member Functions inherited from Effect
 Effect ()
 Default constructor for the Effect class.
 
void SetRatio (float ratio)
 Sets the scaling ratio for the effect.
 

Private Member Functions

void ResetDisplayBuffer ()
 Resets the display buffer to a blank state.
 
void EnableBitFaceRender (float xIn, float yIn)
 Enables rendering for a bitmap face within specified coordinates.
 
void UpdateFaceInformation ()
 Updates face rendering information.
 

Private Attributes

const __FlashStringHelperpercentArray [10] = {F("10%"), F("20%"), F("30%"), F("40%"), F("50%"), F("60%"), F("70%"), F("80%"), F("90%"), F("100%")}
 Battery percentages.
 
const __FlashStringHelpereffectArray [10] = {F("NONE"), F("PHASEY"), F("PHASEX"), F("PHASER"), F("GLITCHX"), F("MAGNET"), F("FISHEYE"), F("BLURH"), F("BLURV"), F("BLURR")}
 
const __FlashStringHelpercolorArray [10] = {F("GRDIENT"), F("YELLOW"), F("ORANGE"), F("WHITE"), F("GREEN"), F("PURPLE"), F("RED"), F("BLUE"), F("RAINBOW"), F("NOISE")}
 
const __FlashStringHelperonOffArray [2] = {F("OFFLINE"), F("ONLINE")}
 Online/Offline statuses.
 
const __FlashStringHelperhueArray [10] = {F("0 DEG"), F("36 DEG"), F("72 DEG"), F("108 DEG"), F("144 DEG"), F("180 DEG"), F("216 DEG"), F("252 DEG"), F("288 DEG"), F("324 DEG")}
 Hue options.
 
const __FlashStringHelperfaceArray [10] = {F("DEFAULT"), F("ANGRY"), F("DOUBT"), F("FROWN"), F("LOOKUP"), F("SAD"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")}
 Face names.
 
const __FlashStringHelper ** faceNames
 Names of each face to be displayed on the screen.
 
bool useExternalFace = false
 To decide if it uses faceArray or faceNames for the face.
 
EffectsubEffect
 Used to capture the complete rendered frame.
 
TimeStep timeStep = TimeStep(5)
 Limits the display to update 5 times per second.
 
bool didBegin = false
 True if the I2C interface started correctly.
 
bool splashFinished = false
 True when the splash startup screen is finished.
 
Vector2D faceMin
 Minimum coordinate for face on display.
 
Vector2D faceMax
 Maximum coordinate for face on display.
 
uint32_t startMillis
 Start time of the display for the splash screen.
 

Static Private Attributes

static const uint16_t SCREEN_WIDTH = 128
 Width of the OLED screen.
 
static const uint16_t SCREEN_HEIGHT = 64
 Height of the OLED screen.
 
static const int8_t OLED_RESET = -1
 Reset pin for the display.
 
static const uint8_t faceXMinPosition = 66
 Minimum X position for face rendering.
 
static const uint8_t faceXMaxPosition = 124
 Maximum X position for face rendering.
 
static const uint8_t faceYMinPosition = 35
 Minimum Y position for face rendering.
 
static const uint8_t faceYMaxPosition = 60
 Maximum Y position for face rendering.
 
static const uint32_t splashTime = 2500
 Duration for splash screen in milliseconds.
 
static const int bufferSize = 2048
 Buffer size for display rendering.
 
static Adafruit_SSD1306 display
 
static uint8_t faceBitmap [bufferSize]
 Background template for displaying the grids.
 
static const uint8_t CoelaSplash []
 
static const uint8_t PrototracerSplash []
 
static const uint8_t FaceTemplate []
 

Additional Inherited Members

- Protected Attributes inherited from Effect
float ratio = 0.0f
 A scaling ratio used for dynamic effect adjustments.
 

Detailed Description

Renders and displays information on an SSD1306/SH1106 display.

The HeadsUpDisplay class acts as an Effect, allowing it to intercept and process rendered frames efficiently for display on OLED screens. It supports a variety of pre-configured menus, effects, and face animations.

Definition at line 39 of file SSD1306.h.

Constructor & Destructor Documentation

◆ HeadsUpDisplay()

HeadsUpDisplay ( Vector2D  faceMin,
Vector2D  faceMax 
)

Constructs a HeadsUpDisplay with face rendering boundaries.

Parameters
faceMinMinimum coordinates for face rendering.
faceMaxMaximum coordinates for face rendering.

Definition at line 212 of file SSD1306.cpp.

References faceMax, and faceMin.

Member Function Documentation

◆ ApplyEffect()

void ApplyEffect ( IPixelGroup pixelGroup)
virtual

Applies the effect to the specified pixel group.

Parameters
pixelGroupPointer to the pixel group to process.

Implements Effect.

Definition at line 315 of file SSD1306.cpp.

References Effect::ApplyEffect(), EnableBitFaceRender(), RGBColor::G, IPixelGroup::GetColor(), IPixelGroup::GetCoordinate(), IPixelGroup::GetPixelCount(), RGBColor::R, subEffect, Vector2D::X, and Vector2D::Y.

◆ CheckInvertPrintText()

void CheckInvertPrintText ( int16_t  x,
int16_t  y,
uint8_t  menu,
const String str 
)

Prints text conditionally inverted based on menu selection.

Parameters
xX-coordinate for the text.
yY-coordinate for the text.
menuCurrent menu index.
strThe string to print.

Definition at line 382 of file SSD1306.cpp.

References display, and Menu::GetCurrentMenu().

Referenced by UpdateFaceInformation().

◆ EnableBitFaceRender()

void EnableBitFaceRender ( float  xIn,
float  yIn 
)
private

Enables rendering for a bitmap face within specified coordinates.

Parameters
xInX-coordinate input for face rendering.
yInY-coordinate input for face rendering.

Definition at line 336 of file SSD1306.cpp.

References Mathematics::ConstrainMap(), faceBitmap, faceMax, faceMin, faceXMaxPosition, faceXMinPosition, faceYMaxPosition, faceYMinPosition, Vector2D::X, and Vector2D::Y.

Referenced by ApplyEffect().

◆ Initialize()

void Initialize ( )

Initializes the display and related components.

Definition at line 230 of file SSD1306.cpp.

References didBegin, display, ResetDisplayBuffer(), and startMillis.

Referenced by ProtogenProject::Initialize().

◆ ResetDisplayBuffer()

void ResetDisplayBuffer ( )
private

Resets the display buffer to a blank state.

Definition at line 331 of file SSD1306.cpp.

References faceBitmap.

Referenced by Initialize(), and Update().

◆ ResetI2CBus()

void ResetI2CBus ( )

Resets the I2C bus in case of communication errors.

Definition at line 275 of file SSD1306.cpp.

Referenced by Update().

◆ SetEffect()

void SetEffect ( Effect effect)

Sets the sub-effect to be applied to the display.

Parameters
effectPointer to the Effect to be applied.

Definition at line 311 of file SSD1306.cpp.

References subEffect.

Referenced by ProtogenProject::UpdateFace().

◆ SetFaceArray()

◆ SetFaceMax()

void SetFaceMax ( Vector2D  faceMax)

Sets the maximum face rendering coordinates.

Parameters
faceMaxMaximum coordinates for face rendering.

Definition at line 226 of file SSD1306.cpp.

References faceMax.

Referenced by ProtogenProject::ProtogenProject().

◆ SetFaceMin()

void SetFaceMin ( Vector2D  faceMin)

Sets the minimum face rendering coordinates.

Parameters
faceMinMinimum coordinates for face rendering.

Definition at line 222 of file SSD1306.cpp.

References faceMin.

Referenced by ProtogenProject::ProtogenProject().

◆ Update()

void Update ( )

◆ UpdateFaceInformation()

Member Data Documentation

◆ bufferSize

const int bufferSize = 2048
staticprivate

Buffer size for display rendering.

Definition at line 49 of file SSD1306.h.

◆ CoelaSplash

const uint8_t CoelaSplash
staticprivate

Definition at line 11 of file SSD1306.h.

Referenced by Update().

◆ colorArray

const __FlashStringHelper* colorArray[10] = {F("GRDIENT"), F("YELLOW"), F("ORANGE"), F("WHITE"), F("GREEN"), F("PURPLE"), F("RED"), F("BLUE"), F("RAINBOW"), F("NOISE")}
private

Definition at line 53 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ didBegin

bool didBegin = false
private

True if the I2C interface started correctly.

Definition at line 63 of file SSD1306.h.

Referenced by Initialize(), and Update().

◆ display

Adafruit_SSD1306 display
staticprivate

Definition at line 72 of file SSD1306.h.

Referenced by CheckInvertPrintText(), Initialize(), Update(), and UpdateFaceInformation().

◆ effectArray

const __FlashStringHelper* effectArray[10] = {F("NONE"), F("PHASEY"), F("PHASEX"), F("PHASER"), F("GLITCHX"), F("MAGNET"), F("FISHEYE"), F("BLURH"), F("BLURV"), F("BLURR")}
private

Definition at line 52 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ faceArray

const __FlashStringHelper* faceArray[10] = {F("DEFAULT"), F("ANGRY"), F("DOUBT"), F("FROWN"), F("LOOKUP"), F("SAD"), F("AUDIO1"), F("AUDIO2"), F("AUDIO3")}
private

Face names.

Definition at line 56 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ faceBitmap

uint8_t faceBitmap
staticprivate

Background template for displaying the grids.

Definition at line 74 of file SSD1306.h.

Referenced by EnableBitFaceRender(), ResetDisplayBuffer(), and UpdateFaceInformation().

◆ faceMax

Vector2D faceMax
private

Maximum coordinate for face on display.

Definition at line 66 of file SSD1306.h.

Referenced by EnableBitFaceRender(), HeadsUpDisplay(), and SetFaceMax().

◆ faceMin

Vector2D faceMin
private

Minimum coordinate for face on display.

Definition at line 65 of file SSD1306.h.

Referenced by EnableBitFaceRender(), HeadsUpDisplay(), and SetFaceMin().

◆ faceNames

const __FlashStringHelper** faceNames
private

Names of each face to be displayed on the screen.

Definition at line 58 of file SSD1306.h.

Referenced by SetFaceArray(), and UpdateFaceInformation().

◆ FaceTemplate

const uint8_t FaceTemplate
staticprivate

Definition at line 145 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ faceXMaxPosition

const uint8_t faceXMaxPosition = 124
staticprivate

Maximum X position for face rendering.

Definition at line 45 of file SSD1306.h.

Referenced by EnableBitFaceRender().

◆ faceXMinPosition

const uint8_t faceXMinPosition = 66
staticprivate

Minimum X position for face rendering.

Definition at line 44 of file SSD1306.h.

Referenced by EnableBitFaceRender().

◆ faceYMaxPosition

const uint8_t faceYMaxPosition = 60
staticprivate

Maximum Y position for face rendering.

Definition at line 47 of file SSD1306.h.

Referenced by EnableBitFaceRender().

◆ faceYMinPosition

const uint8_t faceYMinPosition = 35
staticprivate

Minimum Y position for face rendering.

Definition at line 46 of file SSD1306.h.

Referenced by EnableBitFaceRender().

◆ hueArray

const __FlashStringHelper* hueArray[10] = {F("0 DEG"), F("36 DEG"), F("72 DEG"), F("108 DEG"), F("144 DEG"), F("180 DEG"), F("216 DEG"), F("252 DEG"), F("288 DEG"), F("324 DEG")}
private

Hue options.

Definition at line 55 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ OLED_RESET

const int8_t OLED_RESET = -1
staticprivate

Reset pin for the display.

Definition at line 43 of file SSD1306.h.

◆ onOffArray

const __FlashStringHelper* onOffArray[2] = {F("OFFLINE"), F("ONLINE")}
private

Online/Offline statuses.

Definition at line 54 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ percentArray

const __FlashStringHelper* percentArray[10] = {F("10%"), F("20%"), F("30%"), F("40%"), F("50%"), F("60%"), F("70%"), F("80%"), F("90%"), F("100%")}
private

Battery percentages.

Definition at line 51 of file SSD1306.h.

Referenced by UpdateFaceInformation().

◆ PrototracerSplash

const uint8_t PrototracerSplash
staticprivate

Definition at line 78 of file SSD1306.h.

Referenced by Update().

◆ SCREEN_HEIGHT

const uint16_t SCREEN_HEIGHT = 64
staticprivate

Height of the OLED screen.

Definition at line 42 of file SSD1306.h.

Referenced by Update().

◆ SCREEN_WIDTH

const uint16_t SCREEN_WIDTH = 128
staticprivate

Width of the OLED screen.

Definition at line 41 of file SSD1306.h.

Referenced by Update().

◆ splashFinished

bool splashFinished = false
private

True when the splash startup screen is finished.

Definition at line 64 of file SSD1306.h.

Referenced by Update().

◆ splashTime

const uint32_t splashTime = 2500
staticprivate

Duration for splash screen in milliseconds.

Definition at line 48 of file SSD1306.h.

Referenced by Update().

◆ startMillis

uint32_t startMillis
private

Start time of the display for the splash screen.

Definition at line 67 of file SSD1306.h.

Referenced by Initialize(), and Update().

◆ subEffect

Effect* subEffect
private

Used to capture the complete rendered frame.

Definition at line 61 of file SSD1306.h.

Referenced by ApplyEffect(), and SetEffect().

◆ timeStep

TimeStep timeStep = TimeStep(5)
private

Limits the display to update 5 times per second.

Definition at line 62 of file SSD1306.h.

Referenced by Update().

◆ useExternalFace

bool useExternalFace = false
private

To decide if it uses faceArray or faceNames for the face.

Definition at line 59 of file SSD1306.h.

Referenced by SetFaceArray(), and UpdateFaceInformation().


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