DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/U8G2SH1106Display.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 * © 2023 Peter Cole
4 *
5 * This is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * It is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this code. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef U8G2SH1106DISPLAY_H
20#define U8G2SH1106DISPLAY_H
21
22#include "Defines.h"
23#include "DisplayInterface.h"
24#include <U8g2lib.h>
25#if (OLED_CONNECTION == OLED_SPI)
26#include <SPI.h>
27#endif // OLED_CONNECTION
28
31public:
34
36 void begin() override;
37
39 void clear() override;
40
44 void displayStartupScreen(const char *headerText, const char *version) override;
45
49 void displayProgressScreen(const char *activity, uint8_t counter) override;
50
53 void displayErrorScreen(const char *errorText) override;
54
60 void displayMenuScreen(const char *menuName, BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex,
61 bool selectionChanged) override;
62
71 void displayThrottleScreen(const char *locoName, uint8_t speed, Direction direction, TrackPower trackPower,
72 bool speedChanged, bool directionChange, bool trackPowerChanged) override;
73
74private:
75 U8G2 *_oled;
76 const uint8_t *_defaultFont;
77 const uint8_t *_menuFont;
78 const uint8_t *_speedFont;
79 const uint8_t *_throttleFont;
80
84
87 uint16_t _calculateHeaderHeight();
88
91 uint16_t _calculateMenuItemHeight();
92
96
98 void _clearDisplay();
99
102 void _displayHeader(const char *headerText);
103
106 void _displayStartupInfo(const char *version);
107
112 uint8_t _displayMenuItems(BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex);
113
115 void _displayMenuFooter();
116
119 void _displayPageNumber(uint8_t pageNumber);
120
123 void _displayProgress(uint8_t counter);
124
127 void _displayErrorMessage(const char *errorMessage);
128
131 void _displayLocoSpeed(uint8_t speed);
132
135 void _displayLocoDirection(Direction direction);
136
139 void _displayLocoName(const char *name);
140
143 void _displayTrackPowerState(TrackPower trackPower);
144};
145
146#endif // U8G2SH1106DISPLAY_H
Base class for all menu item types, and all menu item types must inherit from this....
Definition BaseMenuItem.h:28
Interface class to abstract construction of what is displayed on screen from the physical implementat...
Definition DisplayInterface.h:29
Class to implement display on an SH1106 based OLED using the U8g2 library.
Definition U8G2SH1106Display.h:30
void _clearDisplay()
Clear the display.
Definition U8G2SH1160Display.cpp:137
const uint8_t * _throttleFont
Definition U8G2SH1106Display.h:79
uint8_t _calculateMenuItemsPerPage()
Calculates the number of menu items that will fit on screen.
Definition U8G2SH1160Display.cpp:113
void displayMenuScreen(const char *menuName, BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex, bool selectionChanged) override
Display a menu.
Definition U8G2SH1160Display.cpp:73
void clear() override
Clear the display.
Definition U8G2SH1160Display.cpp:43
uint16_t _calculateMenuItemHeight()
Calculates the height of the menu item area.
Definition U8G2SH1160Display.cpp:126
U8G2 * _oled
Definition U8G2SH1106Display.h:75
uint16_t _calculateHeaderHeight()
Calculates the height of the header area.
Definition U8G2SH1160Display.cpp:120
void _displayErrorMessage(const char *errorMessage)
Display an error message with emoji.
Definition U8G2SH1160Display.cpp:255
void displayErrorScreen(const char *errorText) override
Display error screen.
Definition U8G2SH1160Display.cpp:65
uint16_t _calculateMenuFooterHeight()
Calculates the height of the footer area.
Definition U8G2SH1160Display.cpp:131
U8G2SH1106Display()
Constructor for the display object.
Definition U8G2SH1160Display.cpp:21
void _displayHeader(const char *headerText)
Display the header text with a horizontal line separator.
Definition U8G2SH1160Display.cpp:142
void _displayLocoSpeed(uint8_t speed)
Update the currenty selected loco's speed.
Definition U8G2SH1160Display.cpp:263
uint8_t _displayMenuItems(BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex)
Display the list of menu items, paginated by the number that will fit on screen.
Definition U8G2SH1160Display.cpp:170
void _displayStartupInfo(const char *version)
Display the software version below the header text.
Definition U8G2SH1160Display.cpp:153
void _displayProgress(uint8_t counter)
Display progress bar.
Definition U8G2SH1160Display.cpp:242
const uint8_t * _speedFont
Definition U8G2SH1106Display.h:78
void _displayLocoDirection(Direction direction)
Update the currently selected loco's direction.
Definition U8G2SH1160Display.cpp:282
const uint8_t * _defaultFont
Definition U8G2SH1106Display.h:76
void displayThrottleScreen(const char *locoName, uint8_t speed, Direction direction, TrackPower trackPower, bool speedChanged, bool directionChange, bool trackPowerChanged) override
Display the throttle screen.
Definition U8G2SH1160Display.cpp:90
void _displayLocoName(const char *name)
Update the address of the currently selected loco.
Definition U8G2SH1160Display.cpp:303
void _displayMenuFooter()
Displays the horizontal line separator and Page # text.
Definition U8G2SH1160Display.cpp:207
void begin() override
Start the display.
Definition U8G2SH1160Display.cpp:36
void _displayPageNumber(uint8_t pageNumber)
Displays the provided page number within the menu footer.
Definition U8G2SH1160Display.cpp:225
void displayStartupScreen(const char *headerText, const char *version) override
Display the startup screen.
Definition U8G2SH1160Display.cpp:48
const uint8_t * _menuFont
Definition U8G2SH1106Display.h:77
void displayProgressScreen(const char *activity, uint8_t counter) override
Display progress screen for the specified activity.
Definition U8G2SH1160Display.cpp:56
void _displayTrackPowerState(TrackPower trackPower)
Update the current track power status.
Definition U8G2SH1160Display.cpp:312