Mode base class
This is the base class. We just ensure there are implementations of important methods in derived classes so we have a nice common interface...
To implement a mode:
- Create a class derived from Mode
- Implement modeUpdate() in your class to do mode-specific things
- Optionally over-ride begin(), modeStart() and modeStop()
- If you want periodic calls to modeUpdate(), call setUpdatePeriod() from your class constructor
To use a mode in a sketch:
- call begin() before use
- call start() when starting a mode (this will in turn call modeStart())
- call stop() when stopping a mode (this will in turn call modeStop())
- call update() frequently (this will in turn call modeUpdate())
A typical sketch will switch modes by calling a function like this:
...
void switchMode(
Mode* newMode)
{
CurrentMode = newMode;
}
Definition at line 39 of file Mode.h.
virtual void Mode::update |
( |
| ) |
|
|
inlinevirtual |
Allocate timeslice.
This should be called frequently (typically from loop()). It will in turn call modeUpdate(), which must be implemented in all derived classes, and should contain user-code to be executed frequently.
It is not generally implemeneted in normal derived classes - modeUpdate() should be used instead for class secific updates. If it is, it should call Mode::update().
Reimplemented in BrownoutMode.
Definition at line 85 of file Mode.h.