DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
U8G2SH1106Display Class Reference

Class to implement display on an SH1106 based OLED using the U8g2 library. More...

#include <U8G2SH1106Display.h>

Inheritance diagram for U8G2SH1106Display:
Inheritance graph
[legend]
Collaboration diagram for U8G2SH1106Display:
Collaboration graph
[legend]

Public Member Functions

 U8G2SH1106Display ()
 Constructor for the display object.
 
void begin () override
 Start the display.
 
void clear () override
 Clear the display.
 
void displayStartupScreen (const char *headerText, const char *version) override
 Display the startup screen.
 
void displayProgressScreen (const char *activity, uint8_t counter) override
 Display progress screen for the specified activity.
 
void displayErrorScreen (const char *errorText) override
 Display error screen.
 
void displayMenuScreen (const char *menuName, BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex, bool selectionChanged) override
 Display a menu.
 
void displayThrottleScreen (const char *locoName, uint8_t speed, Direction direction, TrackPower trackPower, bool speedChanged, bool directionChange, bool trackPowerChanged) override
 Display the throttle screen.
 
- Public Member Functions inherited from DisplayInterface
bool needsRedraw ()
 Check if the display needs to be redrawn to prevent unnecessary redraws and flicker.
 
void setNeedsRedraw (bool redraw)
 Set the redraw flag for this display.
 
bool needsMenuRefresh ()
 Check if the menu needs refreshing - avoids a complete redraw for menu screens.
 
void setNeedsMenuRefresh (bool refresh)
 Set the refresh menu flag for this display.
 
uint8_t getMenuItemsPerPage ()
 Get the number of menu items to be displayed per page for this display.
 
void setMenuItemsPerPage (uint8_t menuItemsPerPage)
 Set the number of menu items per page this display can handle.
 
virtual ~DisplayInterface ()=default
 Destructor for the object.
 

Private Member Functions

uint8_t _calculateMenuItemsPerPage ()
 Calculates the number of menu items that will fit on screen.
 
uint16_t _calculateHeaderHeight ()
 Calculates the height of the header area.
 
uint16_t _calculateMenuItemHeight ()
 Calculates the height of the menu item area.
 
uint16_t _calculateMenuFooterHeight ()
 Calculates the height of the footer area.
 
void _clearDisplay ()
 Clear the display.
 
void _displayHeader (const char *headerText)
 Display the header text with a horizontal line separator.
 
void _displayStartupInfo (const char *version)
 Display the software version below the header text.
 
uint8_t _displayMenuItems (BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex)
 Display the list of menu items, paginated by the number that will fit on screen.
 
void _displayMenuFooter ()
 Displays the horizontal line separator and Page # text.
 
void _displayPageNumber (uint8_t pageNumber)
 Displays the provided page number within the menu footer.
 
void _displayProgress (uint8_t counter)
 Display progress bar.
 
void _displayErrorMessage (const char *errorMessage)
 Display an error message with emoji.
 
void _displayLocoSpeed (uint8_t speed)
 Update the currenty selected loco's speed.
 
void _displayLocoDirection (Direction direction)
 Update the currently selected loco's direction.
 
void _displayLocoName (const char *name)
 Update the address of the currently selected loco.
 
void _displayTrackPowerState (TrackPower trackPower)
 Update the current track power status.
 

Private Attributes

U8G2 * _oled
 
const uint8_t * _defaultFont
 
const uint8_t * _menuFont
 
const uint8_t * _speedFont
 
const uint8_t * _throttleFont
 

Detailed Description

Class to implement display on an SH1106 based OLED using the U8g2 library.

Constructor & Destructor Documentation

◆ U8G2SH1106Display()

U8G2SH1106Display::U8G2SH1106Display ( )

Constructor for the display object.

Here is the call graph for this function:

Member Function Documentation

◆ _calculateHeaderHeight()

uint16_t U8G2SH1106Display::_calculateHeaderHeight ( )
private

Calculates the height of the header area.

Returns
Header height
Here is the caller graph for this function:

◆ _calculateMenuFooterHeight()

uint16_t U8G2SH1106Display::_calculateMenuFooterHeight ( )
private

Calculates the height of the footer area.

Returns
Footer height
Here is the caller graph for this function:

◆ _calculateMenuItemHeight()

uint16_t U8G2SH1106Display::_calculateMenuItemHeight ( )
private

Calculates the height of the menu item area.

Returns
Menu item height
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _calculateMenuItemsPerPage()

uint8_t U8G2SH1106Display::_calculateMenuItemsPerPage ( )
private

Calculates the number of menu items that will fit on screen.

Returns
Number of items that will fit on screen
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _clearDisplay()

void U8G2SH1106Display::_clearDisplay ( )
private

Clear the display.

Here is the caller graph for this function:

◆ _displayErrorMessage()

void U8G2SH1106Display::_displayErrorMessage ( const char *  errorMessage)
private

Display an error message with emoji.

Parameters
errorMessageError message to display
Here is the caller graph for this function:

◆ _displayHeader()

void U8G2SH1106Display::_displayHeader ( const char *  headerText)
private

Display the header text with a horizontal line separator.

Parameters
headerTextText to display
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _displayLocoDirection()

void U8G2SH1106Display::_displayLocoDirection ( Direction  direction)
private

Update the currently selected loco's direction.

Parameters
directionForward|Reverse
Here is the caller graph for this function:

◆ _displayLocoName()

void U8G2SH1106Display::_displayLocoName ( const char *  name)
private

Update the address of the currently selected loco.

Parameters
addressPointer to the char array containing the name
Here is the caller graph for this function:

◆ _displayLocoSpeed()

void U8G2SH1106Display::_displayLocoSpeed ( uint8_t  speed)
private

Update the currenty selected loco's speed.

Parameters
speed8 bit integer of the speed
Here is the caller graph for this function:

◆ _displayMenuFooter()

void U8G2SH1106Display::_displayMenuFooter ( )
private

Displays the horizontal line separator and Page # text.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _displayMenuItems()

uint8_t U8G2SH1106Display::_displayMenuItems ( BaseMenuItem firstMenuItem,
uint8_t  selectedItemIndex 
)
private

Display the list of menu items, paginated by the number that will fit on screen.

Parameters
firstMenuItemPointer to the first menu item in the list
selectedItemIndexIndex of the currently selected item to highlight
Returns
Current page number
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _displayPageNumber()

void U8G2SH1106Display::_displayPageNumber ( uint8_t  pageNumber)
private

Displays the provided page number within the menu footer.

Parameters
pageNumberPage number
Here is the caller graph for this function:

◆ _displayProgress()

void U8G2SH1106Display::_displayProgress ( uint8_t  counter)
private

Display progress bar.

Parameters
counterCurrent attempt counter
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _displayStartupInfo()

void U8G2SH1106Display::_displayStartupInfo ( const char *  version)
private

Display the software version below the header text.

Parameters
versionPointer to the char array containing the version number
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _displayTrackPowerState()

void U8G2SH1106Display::_displayTrackPowerState ( TrackPower  trackPower)
private

Update the current track power status.

Parameters
trackPowerPowerOff|PowerOn|PowerUnknown
Here is the caller graph for this function:

◆ begin()

void U8G2SH1106Display::begin ( )
overridevirtual

Start the display.

Implements DisplayInterface.

◆ clear()

void U8G2SH1106Display::clear ( )
overridevirtual

Clear the display.

Implements DisplayInterface.

◆ displayErrorScreen()

void U8G2SH1106Display::displayErrorScreen ( const char *  errorText)
overridevirtual

Display error screen.

Parameters
errorTextError text to display

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayMenuScreen()

void U8G2SH1106Display::displayMenuScreen ( const char *  menuName,
BaseMenuItem firstMenuItem,
uint8_t  selectedItemIndex,
bool  selectionChanged 
)
overridevirtual

Display a menu.

Parameters
menuNameName of the menu being displayed
firstMenuItemPointer to the first menu item in the list of items
selectedItemIndexIndex of the currently selected item to be highlighted
selectionChangedFlag if the user has changed the selection

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayProgressScreen()

void U8G2SH1106Display::displayProgressScreen ( const char *  activity,
uint8_t  counter 
)
overridevirtual

Display progress screen for the specified activity.

Parameters
activityText of the activity in progress
counterCounter of the current attempt

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayStartupScreen()

void U8G2SH1106Display::displayStartupScreen ( const char *  headerText,
const char *  version 
)
overridevirtual

Display the startup screen.

Parameters
headerTextHeader text to display
versionSoftware version to display

Implements DisplayInterface.

Here is the call graph for this function:

◆ displayThrottleScreen()

void U8G2SH1106Display::displayThrottleScreen ( const char *  locoName,
uint8_t  speed,
Direction  direction,
TrackPower  trackPower,
bool  speedChanged,
bool  directionChange,
bool  trackPowerChanged 
)
overridevirtual

Display the throttle screen.

Parameters
locoNameName of the loco currently being operated
speedCurrent speed of the loco
directionCurrent direction of the loco
trackPowerCurrent track power state
speedChangedFlag if the speed has changed
directionChangeFlag if the direction has changed
trackPowerChangedFlag if the track power state has changed

Implements DisplayInterface.

Here is the call graph for this function:

Member Data Documentation

◆ _defaultFont

const uint8_t* U8G2SH1106Display::_defaultFont
private

◆ _menuFont

const uint8_t* U8G2SH1106Display::_menuFont
private

◆ _oled

U8G2* U8G2SH1106Display::_oled
private

◆ _speedFont

const uint8_t* U8G2SH1106Display::_speedFont
private

◆ _throttleFont

const uint8_t* U8G2SH1106Display::_throttleFont
private

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