![]() |
ScreenManager v1.0.0
A lightweight C++ library for managing application screens, navigation, transitions and display timing.
|
The core class that handles registration, transitions and of course, calling the screen's draw() method.
#include <ScreenManager.h>
Public Member Functions | |
| void | begin () |
Called once during setup(). Will call the IManagedScreen::begin() method of all external screens.that have been registered. | |
| void | update (uint32_t nowMs) |
Called from your loop(). Checks if a screen transition has been requested and calls current screen's draw() at set FPS. More... | |
| template<typename T > | |
| bool | registerScreen (ScreenId id, T *screen) |
| Register a screen created externally. More... | |
| template<typename T > | |
| bool | registerScreen (ScreenId id) |
| Register a managed screen (ScreenManager will create and delete the screen) More... | |
| void | setFps (uint8_t fps) |
| Set the FPS (Frames Per Second) for draw() to be called (default is 10) More... | |
| uint8_t | getFps () |
| Get the currently set Fps. More... | |
| bool | isCurrent (const ScreenId id) |
| Return true if passed id is that of the current screen. More... | |
| bool | isPrevious (ScreenId id) |
| Return true if passed id is that of the previous screen. More... | |
| IManagedScreen * | getCurrent () |
| Get the current screen. More... | |
| ScreenId | getPreviousId () |
| Get the previous screen ID. More... | |
| bool | haveScreen (ScreenId id) |
| Check if a screen has been added and exists. More... | |
| void | requestScreen (const ScreenId nextScreen) |
| Request a transition to a named screen. More... | |
| void | requestScreen (const TransitionIntent &intent) |
| Request a screen transition. More... | |
| void | addRouter (ScreenRouter *router) |
| Add a new router for screen transitions. Routers are called in the order they are added. First to answer wins. More... | |
| bool | setInitialScreen (ScreenId id) |
| Set the Initial Screen. More... | |
| void ScreenManager::addRouter | ( | ScreenRouter * | router | ) |
Add a new router for screen transitions. Routers are called in the order they are added. First to answer wins.
| router |
| IManagedScreen * ScreenManager::getCurrent | ( | ) |
Get the current screen.
|
inline |
Get the currently set Fps.
| ScreenId ScreenManager::getPreviousId | ( | ) |
Get the previous screen ID.
| bool ScreenManager::haveScreen | ( | ScreenId | id | ) |
Check if a screen has been added and exists.
| id | The name or id used to register the screen |
| bool ScreenManager::isCurrent | ( | const ScreenId | id | ) |
Return true if passed id is that of the current screen.
| id |
| bool ScreenManager::isPrevious | ( | ScreenId | id | ) |
Return true if passed id is that of the previous screen.
| id |
|
inline |
Register a managed screen (ScreenManager will create and delete the screen)
Usage: screenManager.registerScreen<SettingsScreen>(20);
| T |
| id | A uint8_t used to identify this screen |
|
inline |
Register a screen created externally.
Usage: screenManager.registerScreen(&home, 11);
| T |
| screen | |
| id | A uint8_t used to identify this screen |
| void ScreenManager::requestScreen | ( | const ScreenId | nextScreen | ) |
Request a transition to a named screen.
Will be passed to the screen routers (if any) for validation and/or redirect.
| nextScreen |
| void ScreenManager::requestScreen | ( | const TransitionIntent & | intent | ) |
Request a screen transition.
The request will be passed to the screen routers (if any) for validation and/or redirect.
| intent | Can be Init, Back, Next, Auto or a specific screen name. Screen router resolves screen name. |
|
inline |
Set the FPS (Frames Per Second) for draw() to be called (default is 10)
| fps | 1-255 FPS. 0 means IManagedScreen::draw() will never be called. |
| bool ScreenManager::setInitialScreen | ( | ScreenId | id | ) |
Set the Initial Screen.
By default the first registered screen is the init screen
| id |
| void ScreenManager::update | ( | uint32_t | nowMs | ) |
Called from your loop(). Checks if a screen transition has been requested and calls current screen's draw() at set FPS.
Receives a timer value - in the Arduino Framework this would be millis().
| nowMs | A timer value used to determine when draw() is called (based on the setFps()) |