Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
src
ModeManager.cpp
1
#include <MutilaDebug.h>
2
#include "ModeManager.h"
3
4
ModeManager::ModeManager() :
5
currentMode(NULL)
6
{
7
}
8
9
void
ModeManager::begin
(
Mode
* initialMode)
10
{
11
DBLN(F(
"ModeManager::begin"
));
12
switchMode
(initialMode);
13
}
14
15
void
ModeManager::update
()
16
{
17
if
(currentMode != NULL) {
18
currentMode->
update
();
19
}
20
}
21
22
void
ModeManager::switchMode
(
Mode
* newMode,
bool
force)
23
{
24
if
((newMode != currentMode) || force) {
25
if
(currentMode != NULL) {
26
currentMode->
stop
();
27
}
28
currentMode = newMode;
29
currentMode->
start
();
30
}
31
}
32
33
bool
ModeManager::modeFinished
()
34
{
35
if
(currentMode != NULL) {
36
return
currentMode->
isFinished
();
37
}
else
{
38
return
false
;
39
}
40
}
41
ModeManager::modeFinished
bool modeFinished()
Definition:
ModeManager.cpp:33
Mode::update
virtual void update()
Definition:
Mode.h:85
Mode
Definition:
Mode.h:39
ModeManager::begin
void begin(Mode *initialMode)
Definition:
ModeManager.cpp:9
Mode::stop
void stop()
Definition:
Mode.h:72
ModeManager::switchMode
void switchMode(Mode *newMode, bool force=false)
Definition:
ModeManager.cpp:22
ModeManager::update
void update()
Definition:
ModeManager.cpp:15
Mode::isFinished
virtual bool isFinished()
Definition:
Mode.h:64
Mode::start
void start()
Definition:
Mode.h:68
Generated by
1.8.15