Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
#include <ParentMode.h>
Public Member Functions | |
ParentMode () | |
Constructor. | |
void | switchMode (Mode *newMode) |
Public Member Functions inherited from Mode | |
Mode () | |
virtual void | begin () |
virtual bool | isFinished () |
void | start () |
void | stop () |
virtual void | update () |
void | setUpdatePeriod (uint16_t periodMs) |
Protected Attributes | |
Mode * | pMode |
Protected Attributes inherited from Mode | |
RunState | _state |
uint32_t | _lastUpdateMs |
uint16_t | _updatePeriodMs |
Additional Inherited Members | |
Public Types inherited from Mode | |
enum | RunState { NotStarted, Started, Running, Finished, Stopped } |
Protected Member Functions inherited from Mode | |
virtual void | modeStart () |
virtual void | modeStop () |
virtual void | modeUpdate ()=0 |
A Mode With Modes of it's own
A Parent Mode has one or more child Modes. One of these child modes is active at any one time. When the ParentModes update() member is called, the currently-active child Mode's update() is called.
Child Modes may themselves be a ParentMode, allowing for hierarchies of Modes.
It is customary for a ParentMode to implement the begin() member, and use it to call begin() for all of it's child modes. In this way the sketch which pulls in a ParentMode and it's tree of child modes must only call begin() for that one ParentMode.
Definition at line 20 of file ParentMode.h.
void ParentMode::switchMode | ( | Mode * | newMode | ) |
Switch child mode
newMode | the address of the child Mode to switch to |
Definition at line 8 of file ParentMode.cpp.