2#ifndef SCREEN_MANAGER_H
3#define SCREEN_MANAGER_H
6#include "ScreenRouter.h"
7#include "ScreenEntry.h"
8#include "ScreenTransition.h"
11using ScreenId = uint8_t;
37 void update(uint32_t nowMs);
48 if (
id == 0 || !screen )
return false;
51 entry->instance = screen;
52 addScreenEntry(entry);
53 if ( begun ) screen->
begin();
67 if (
id == 0 )
return false;
70 addScreenEntry(entry);
83 displayRefreshMs = (uint16_t)(1000/fps);
84 displayRefreshMs = (displayRefreshMs < 4) ? 4 : displayRefreshMs;
94 if ( displayRefreshMs == 0 )
return 0;
95 return (uint8_t)(1000/displayRefreshMs);
184 ScreenEntry* getScreenEntry(
const ScreenId
id)
const;
212 ScreenId initialScreenId = 0;
216 uint16_t displayRefreshMs = 100;
217 uint32_t lastDisplayRefresh = 0;
Interface for a screen that can be managed by ScreenManager. A 'Screen' is a combination of the 'View...
Definition: IManagedScreen.h:13
virtual void begin()=0
Called after a screen is created but before start()
A registration entry for an External IManagedScreen.
Definition: ScreenEntry.h:49
A registration entry for a Managed IManagedScreen.
Definition: ScreenEntry.h:81
A registered screen. Only ever accessed by ScreenManager.
Definition: ScreenEntry.h:12
The core class that handles registration, transitions and of course, calling the screen's draw() meth...
Definition: ScreenManager.h:17
bool registerScreen(ScreenId id, IManagedScreen *screen)
Register a screen created externally with a unique ID greater than 0.
Definition: ScreenManager.h:47
bool isPrevious(const ScreenId id) const
Return true if passed id is that of the previous screen.
Definition: ScreenManager.cpp:44
uint8_t getFps() const
Get the currently set Fps.
Definition: ScreenManager.h:93
bool registerScreen(ScreenId id)
Register a managed screen with a unique ID greater than 0 (ScreenManager will create and delete the s...
Definition: ScreenManager.h:66
void update(uint32_t nowMs)
Called from your loop(). Checks if a screen transition has been requested and calls current screen's ...
Definition: ScreenManager.cpp:29
bool haveScreen(const ScreenId id) const
Check if a screen has been added and exists.
Definition: ScreenManager.cpp:65
ScreenId getPreviousId() const
Get the previous screen ID.
Definition: ScreenManager.cpp:58
void addRouter(ScreenRouter *router)
Add a new router for screen transitions. Routers are called in the order they are added....
Definition: ScreenManager.cpp:82
bool setInitialScreen(const ScreenId id)
Set the Initial Screen.
Definition: ScreenManager.cpp:93
IManagedScreen * getCurrent() const
Get the current screen or nullptr. ScreenManager::update()` must be called before the initial screen ...
Definition: ScreenManager.cpp:49
void setFps(uint8_t fps)
Set the FPS (Frames Per Second) for draw() to be called (default is 10)
Definition: ScreenManager.h:79
bool isCurrent(const ScreenId id) const
Return true if passed id is that of the current screen.
Definition: ScreenManager.cpp:39
void requestScreen(const ScreenId nextScreen)
Request a transition to a named screen.
Definition: ScreenManager.cpp:74
void begin()
Called once during setup(). Will call the IManagedScreen::begin() method of all external screens....
Definition: ScreenManager.cpp:19
Abstract class that resolves screen transitions (ie moving Next, Back or to a new screen)....
Definition: ScreenRouter.h:11
The type of transition and an optional requested ScreenId.
Definition: ScreenTransition.h:25