2#ifndef SCREEN_MANAGER_H
3#define SCREEN_MANAGER_H
5#include "ScreenRouter.h"
6#include "ScreenEntry.h"
7#include "ScreenTransition.h"
10using ScreenId = uint8_t;
35 void update(uint32_t nowMs);
48 if (
id == 0 )
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);
93 return (uint8_t)(displayRefreshMs/1000);
220 ScreenId initialScreenId = 0;
224 uint16_t displayRefreshMs = 100;
225 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
A registration entry for an External IManagedScreen.
Definition: ScreenEntry.h:51
A registration entry for a Managed IManagedScreen.
Definition: ScreenEntry.h:83
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:16
bool isPrevious(ScreenId id)
Return true if passed id is that of the previous screen.
Definition: ScreenManager.cpp:56
bool isCurrent(const ScreenId id)
Return true if passed id is that of the current screen.
Definition: ScreenManager.cpp:51
uint8_t getFps()
Get the currently set Fps.
Definition: ScreenManager.h:92
bool registerScreen(ScreenId id)
Register a managed screen (ScreenManager will create and delete the screen)
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:30
bool haveScreen(ScreenId id)
Check if a screen has been added and exists.
Definition: ScreenManager.cpp:77
ScreenId getPreviousId()
Get the previous screen ID.
Definition: ScreenManager.cpp:70
void addRouter(ScreenRouter *router)
Add a new router for screen transitions. Routers are called in the order they are added....
Definition: ScreenManager.cpp:94
bool registerScreen(ScreenId id, T *screen)
Register a screen created externally.
Definition: ScreenManager.h:47
IManagedScreen * getCurrent()
Get the current screen.
Definition: ScreenManager.cpp:61
void setFps(uint8_t fps)
Set the FPS (Frames Per Second) for draw() to be called (default is 10)
Definition: ScreenManager.h:79
void requestScreen(const ScreenId nextScreen)
Request a transition to a named screen.
Definition: ScreenManager.cpp:86
void begin()
Called once during setup(). Will call the IManagedScreen::begin() method of all external screens....
Definition: ScreenManager.cpp:19
bool setInitialScreen(ScreenId id)
Set the Initial Screen.
Definition: ScreenManager.cpp:105
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 screen name.
Definition: ScreenTransition.h:24