![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Renders and displays information on an SSD1306/SH1106 display. More...
#include <SSD1306.h>
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. | |
![]() | |
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 __FlashStringHelper * | percentArray [10] = {F("10%"), F("20%"), F("30%"), F("40%"), F("50%"), F("60%"), F("70%"), F("80%"), F("90%"), F("100%")} |
Battery percentages. | |
const __FlashStringHelper * | effectArray [10] = {F("NONE"), F("PHASEY"), F("PHASEX"), F("PHASER"), F("GLITCHX"), F("MAGNET"), F("FISHEYE"), F("BLURH"), F("BLURV"), F("BLURR")} |
const __FlashStringHelper * | colorArray [10] = {F("GRDIENT"), F("YELLOW"), F("ORANGE"), F("WHITE"), F("GREEN"), F("PURPLE"), F("RED"), F("BLUE"), F("RAINBOW"), F("NOISE")} |
const __FlashStringHelper * | onOffArray [2] = {F("OFFLINE"), F("ONLINE")} |
Online/Offline statuses. | |
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")} |
Hue options. | |
const __FlashStringHelper * | faceArray [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. | |
Effect * | subEffect |
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 | |
![]() | |
float | ratio = 0.0f |
A scaling ratio used for dynamic effect adjustments. | |
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.
HeadsUpDisplay | ( | Vector2D | faceMin, |
Vector2D | faceMax | ||
) |
Constructs a HeadsUpDisplay with face rendering boundaries.
faceMin | Minimum coordinates for face rendering. |
faceMax | Maximum coordinates for face rendering. |
Definition at line 212 of file SSD1306.cpp.
|
virtual |
Applies the effect to the specified pixel group.
pixelGroup | Pointer 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.
Prints text conditionally inverted based on menu selection.
x | X-coordinate for the text. |
y | Y-coordinate for the text. |
menu | Current menu index. |
str | The string to print. |
Definition at line 382 of file SSD1306.cpp.
References display, and Menu::GetCurrentMenu().
Referenced by UpdateFaceInformation().
Enables rendering for a bitmap face within specified coordinates.
xIn | X-coordinate input for face rendering. |
yIn | Y-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().
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().
|
private |
Resets the display buffer to a blank state.
Definition at line 331 of file SSD1306.cpp.
References faceBitmap.
Referenced by Initialize(), and Update().
void ResetI2CBus | ( | ) |
Resets the I2C bus in case of communication errors.
Definition at line 275 of file SSD1306.cpp.
Referenced by Update().
Sets the sub-effect to be applied to the display.
effect | Pointer to the Effect to be applied. |
Definition at line 311 of file SSD1306.cpp.
References subEffect.
Referenced by ProtogenProject::UpdateFace().
void SetFaceArray | ( | const __FlashStringHelper ** | faceNames | ) |
Sets the array of face names.
faceNames | Pointer to an array of face names. |
Definition at line 217 of file SSD1306.cpp.
References faceNames, and useExternalFace.
Referenced by AceAnimation::AceAnimation(), ArrowAnimation::ArrowAnimation(), BetaProject::BetaProject(), DrGonzoProject::DrGonzoProject(), DrGonzoTest::DrGonzoTest(), FursuitEyesV1::FursuitEyesV1(), ProtogenHUB75Project::ProtogenHUB75Project(), ProtogenWS35Project::ProtogenWS35Project(), SageAnimation::SageAnimation(), SplatAnimation::SplatAnimation(), and UnicornZhenjaAnimation::UnicornZhenjaAnimation().
Sets the maximum face rendering coordinates.
faceMax | Maximum coordinates for face rendering. |
Definition at line 226 of file SSD1306.cpp.
References faceMax.
Referenced by ProtogenProject::ProtogenProject().
Sets the minimum face rendering coordinates.
faceMin | Minimum coordinates for face rendering. |
Definition at line 222 of file SSD1306.cpp.
References faceMin.
Referenced by ProtogenProject::ProtogenProject().
void Update | ( | ) |
Updates the display content based on the current state.
Definition at line 281 of file SSD1306.cpp.
References CoelaSplash, didBegin, display, TimeStep::IsReady(), PrototracerSplash, ResetDisplayBuffer(), ResetI2CBus(), SCREEN_HEIGHT, SCREEN_WIDTH, splashFinished, splashTime, startMillis, timeStep, and UpdateFaceInformation().
Referenced by ProtogenProject::UpdateFace().
|
private |
Updates face rendering information.
Definition at line 348 of file SSD1306.cpp.
References CheckInvertPrintText(), colorArray, display, effectArray, faceArray, faceBitmap, faceNames, FaceTemplate, Menu::GetAccentBrightness(), Menu::GetBrightness(), Menu::GetEffectS(), Menu::GetFaceColor(), Menu::GetFaceSize(), Menu::GetFaceState(), Menu::GetFanSpeed(), Menu::GetHueB(), Menu::GetHueF(), Menu::GetMicLevel(), hueArray, onOffArray, percentArray, Menu::UseBoopSensor(), useExternalFace, and Menu::UseMicrophone().
Referenced by Update().
|
private |
Definition at line 53 of file SSD1306.h.
Referenced by UpdateFaceInformation().
True if the I2C interface started correctly.
Definition at line 63 of file SSD1306.h.
Referenced by Initialize(), and Update().
|
staticprivate |
Definition at line 72 of file SSD1306.h.
Referenced by CheckInvertPrintText(), Initialize(), Update(), and UpdateFaceInformation().
|
private |
Definition at line 52 of file SSD1306.h.
Referenced by UpdateFaceInformation().
|
staticprivate |
Background template for displaying the grids.
Definition at line 74 of file SSD1306.h.
Referenced by EnableBitFaceRender(), ResetDisplayBuffer(), and UpdateFaceInformation().
|
private |
Maximum coordinate for face on display.
Definition at line 66 of file SSD1306.h.
Referenced by EnableBitFaceRender(), HeadsUpDisplay(), and SetFaceMax().
|
private |
Minimum coordinate for face on display.
Definition at line 65 of file SSD1306.h.
Referenced by EnableBitFaceRender(), HeadsUpDisplay(), and SetFaceMin().
|
private |
Names of each face to be displayed on the screen.
Definition at line 58 of file SSD1306.h.
Referenced by SetFaceArray(), and UpdateFaceInformation().
Definition at line 145 of file SSD1306.h.
Referenced by UpdateFaceInformation().
Maximum X position for face rendering.
Definition at line 45 of file SSD1306.h.
Referenced by EnableBitFaceRender().
Minimum X position for face rendering.
Definition at line 44 of file SSD1306.h.
Referenced by EnableBitFaceRender().
Maximum Y position for face rendering.
Definition at line 47 of file SSD1306.h.
Referenced by EnableBitFaceRender().
Minimum Y position for face rendering.
Definition at line 46 of file SSD1306.h.
Referenced by EnableBitFaceRender().
|
private |
Online/Offline statuses.
Definition at line 54 of file SSD1306.h.
Referenced by UpdateFaceInformation().
|
private |
Battery percentages.
Definition at line 51 of file SSD1306.h.
Referenced by UpdateFaceInformation().
|
private |
Start time of the display for the splash screen.
Definition at line 67 of file SSD1306.h.
Referenced by Initialize(), and Update().
|
private |
Used to capture the complete rendered frame.
Definition at line 61 of file SSD1306.h.
Referenced by ApplyEffect(), and SetEffect().
To decide if it uses faceArray or faceNames for the face.
Definition at line 59 of file SSD1306.h.
Referenced by SetFaceArray(), and UpdateFaceInformation().