20
20
* You should have received a copy of the GNU Lesser General Public License
21
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include "mode_switcher.h"
23
#include "switcher_major_mode.h"
24
24
#include "test_mode.h"
25
25
#include "analogue_clock_mode.h"
28
ModeSwitcher::ModeSwitcher()
26
#include "digital_clock_mode.h"
30
SwitcherMajorMode::SwitcherMajorMode()
32
for( int a = 0; a < MAX_MINOR_MODES; a++ )
30
35
static TestMode test_mode;
31
36
static AnalogueClockMode analogue_clock_mode;
33
_modes.push_back( &test_mode );
34
_modes.push_back( &analogue_clock_mode );
38
void ModeSwitcher::short_press()
40
_modes[ _mode ]->next_flavour();
44
void ModeSwitcher::long_press()
46
if( ++_mode >= (signed)_modes.size() )
37
static DigitalClockMode digital_clock_mode;
40
_modes[ mode++ ] = &digital_clock_mode;
41
_modes[ mode++ ] = &test_mode;
42
_modes[ mode++ ] = &analogue_clock_mode;
46
void SwitcherMajorMode::press()
48
_modes[ _mode ]->press();
52
void SwitcherMajorMode::long_press()
55
if( ++_mode >= MAX_MINOR_MODES )
57
} while( _modes[ _mode ] == NULL );
48
58
_modes[ _mode ]->activate();
52
void ModeSwitcher::activate()
62
void SwitcherMajorMode::activate()
55
65
_modes[ _mode ]->activate();
59
Drawer &ModeSwitcher::get_drawer()
69
Drawer &SwitcherMajorMode::get_drawer()
61
71
return *_modes[ _mode ];