DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/DisplayInterface.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 DISPLAYINTERFACE_H
20#define DISPLAYINTERFACE_H
21
22#include "BaseMenuItem.h"
23#include <Arduino.h>
24#include <DCCEXProtocol.h>
25
30public:
32 virtual void begin() = 0;
33
35 virtual void clear() = 0;
36
40 virtual void displayStartupScreen(const char *headerText, const char *version) = 0;
41
45 virtual void displayProgressScreen(const char *activity, uint8_t counter) = 0;
46
49 virtual void displayErrorScreen(const char *errorText) = 0;
50
56 virtual void displayMenuScreen(const char *menuName, BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex,
57 bool selectionChanged) = 0;
58
67 virtual void displayThrottleScreen(const char *locoName, uint8_t speed, Direction direction, TrackPower trackPower,
68 bool speedChanged, bool directionChange, bool trackPowerChanged) = 0;
69
72 bool needsRedraw() { return _needsRedraw; }
73
76 void setNeedsRedraw(bool redraw) { _needsRedraw = redraw; }
77
81
84 void setNeedsMenuRefresh(bool refresh) { _needsMenuRefresh = refresh; }
85
89
92 void setMenuItemsPerPage(uint8_t menuItemsPerPage) { _menuItemsPerPage = menuItemsPerPage; }
93
95 virtual ~DisplayInterface() = default;
96
97private:
98 bool _needsRedraw = false;
99 bool _needsMenuRefresh = false;
100 uint8_t _menuItemsPerPage = 0;
101};
102
103#endif // DISPLAYINTERFACE_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
virtual void displayErrorScreen(const char *errorText)=0
Display error screen.
void setNeedsRedraw(bool redraw)
Set the redraw flag for this display.
Definition DisplayInterface.h:76
virtual void clear()=0
Implement this to entirely clear a display.
uint8_t getMenuItemsPerPage()
Get the number of menu items to be displayed per page for this display.
Definition DisplayInterface.h:88
bool needsMenuRefresh()
Check if the menu needs refreshing - avoids a complete redraw for menu screens.
Definition DisplayInterface.h:80
void setMenuItemsPerPage(uint8_t menuItemsPerPage)
Set the number of menu items per page this display can handle.
Definition DisplayInterface.h:92
virtual void displayStartupScreen(const char *headerText, const char *version)=0
Display the startup screen.
bool needsRedraw()
Check if the display needs to be redrawn to prevent unnecessary redraws and flicker.
Definition DisplayInterface.h:72
virtual void displayThrottleScreen(const char *locoName, uint8_t speed, Direction direction, TrackPower trackPower, bool speedChanged, bool directionChange, bool trackPowerChanged)=0
Display the throttle screen.
virtual void displayProgressScreen(const char *activity, uint8_t counter)=0
Display progress screen for the specified activity.
void setNeedsMenuRefresh(bool refresh)
Set the refresh menu flag for this display.
Definition DisplayInterface.h:84
virtual void begin()=0
Implement this to perform any initial startup methods or activities.
bool _needsRedraw
Definition DisplayInterface.h:98
bool _needsMenuRefresh
Definition DisplayInterface.h:99
virtual ~DisplayInterface()=default
Destructor for the object.
uint8_t _menuItemsPerPage
Definition DisplayInterface.h:100
virtual void displayMenuScreen(const char *menuName, BaseMenuItem *firstMenuItem, uint8_t selectedItemIndex, bool selectionChanged)=0
Display a menu.