/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to src/modes/info_mode.cc

  • Committer: edam
  • Date: 2012-05-18 12:11:01 UTC
  • Revision ID: tim@ed.am-20120518121101-0wik922hyvjkcjdi
switched back to using classes for modes

Show diffs side-by-side

added added

removed removed

27
27
#include "Arduino.h"
28
28
 
29
29
 
30
 
// display flavour
31
 
static int _flavour = 0;
32
 
 
33
 
// previous millis
34
 
static unsigned long _millis_last = 0;
35
 
 
36
 
 
37
 
static void reset_messages()
38
 
{
39
 
        switch( _flavour )
40
 
        {
41
 
        case 0:
42
 
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
43
 
                                Text::MODE_HSCROLL, Text::SCALE_SMALL );
44
 
                break;
45
 
        case 1:
46
 
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_HALF,
47
 
                                Text::SCALE_FAT );
48
 
                Text::reset_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF,
49
 
                                Text::SCALE_FAT );
50
 
                break;
51
 
        }
52
 
}
53
 
 
54
 
 
55
 
void info_mode_press()
56
 
{
57
 
        if( ++_flavour >= 2 )
58
 
                _flavour = 0;
59
 
 
60
 
        // reset messages
61
 
        reset_messages();
62
 
}
63
 
 
64
 
 
65
 
void info_mode_draw( int segment )
 
30
void InfoMode::draw( int segment )
66
31
{
67
32
        Text::draw( 0, segment );
68
33
        if( _flavour == 1 )
70
35
}
71
36
 
72
37
 
73
 
void info_mode_draw_reset()
 
38
void InfoMode::draw_reset()
74
39
{
75
40
        switch( _flavour )
76
41
        {
79
44
                        str0.begin();
80
45
                        str0.format(
81
46
                                        "Propeller Clock mk.1   ...   "
82
 
                                        "Created by Tim and Dan Marston in 2011   ...   "
 
47
                                        "Created by Tim and Dan Marston in 2012   ...   "
83
48
                                        "http://ed.am/dev/elec/propeller-clock" );
84
49
                        Text::set_message( 0, str0 );
85
50
                }
102
67
}
103
68
 
104
69
 
105
 
void info_mode_activate()
 
70
void InfoMode::activate()
106
71
{
107
72
        _flavour = 0;
108
73
        _millis_last = ::millis();
109
74
 
110
 
        // reset messages
111
 
        reset_messages();
 
75
        reset_messages();
 
76
}
 
77
 
 
78
 
 
79
void InfoMode::press()
 
80
{
 
81
        if( ++_flavour >= 2 )
 
82
                _flavour = 0;
 
83
 
 
84
        reset_messages();
 
85
}
 
86
 
 
87
 
 
88
void InfoMode::reset_messages()
 
89
{
 
90
        switch( _flavour )
 
91
        {
 
92
        case 0:
 
93
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
 
94
                                Text::MODE_HSCROLL, Text::SCALE_SMALL );
 
95
                break;
 
96
        case 1:
 
97
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_HALF,
 
98
                                Text::SCALE_FAT );
 
99
                Text::reset_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF,
 
100
                                Text::SCALE_FAT );
 
101
                break;
 
102
        }
112
103
}