/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: Tim Marston
  • Date: 2012-05-18 18:29:50 UTC
  • Revision ID: tim@ed.am-20120518182950-t85bn9a21n72uzm8
text messages are now individually enabled and draw()n automatically

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 )
66
 
{
67
 
        Text::draw( 0, segment );
68
 
        if( _flavour == 1 )
69
 
                Text::draw( 1, segment );
70
 
}
71
 
 
72
 
 
73
 
void info_mode_draw_reset()
 
30
 
 
31
void InfoMode::draw_reset()
74
32
{
75
33
        switch( _flavour )
76
34
        {
79
37
                        str0.begin();
80
38
                        str0.format(
81
39
                                        "Propeller Clock mk.1   ...   "
82
 
                                        "Created by Tim and Dan Marston in 2011   ...   "
 
40
                                        "Created by Tim and Dan Marston in 2012   ...   "
83
41
                                        "http://ed.am/dev/elec/propeller-clock" );
84
 
                        Text::set_message( 0, str0 );
 
42
                        Text::set_message_text( 0, str0 );
85
43
                }
86
44
                break;
87
45
        case 1: {
94
52
                        str1.format( "%ld",
95
53
                                        (unsigned long)60 * 1000 / ( millis - _millis_last ) );
96
54
                        _millis_last = millis;
97
 
                        Text::set_message( 0, str0 );
98
 
                        Text::set_message( 1, str1 );
 
55
                        Text::set_message_text( 0, str0 );
 
56
                        Text::set_message_text( 1, str1 );
99
57
                }
100
58
                break;
101
59
        }
102
60
}
103
61
 
104
62
 
105
 
void info_mode_activate()
 
63
void InfoMode::activate()
106
64
{
107
65
        _flavour = 0;
108
66
        _millis_last = ::millis();
109
67
 
110
 
        // reset messages
111
 
        reset_messages();
 
68
        reset_messages();
 
69
}
 
70
 
 
71
 
 
72
void InfoMode::press()
 
73
{
 
74
        if( ++_flavour >= 2 )
 
75
                _flavour = 0;
 
76
 
 
77
        reset_messages();
 
78
}
 
79
 
 
80
 
 
81
void InfoMode::reset_messages()
 
82
{
 
83
        Text::reset();
 
84
 
 
85
        switch( _flavour )
 
86
        {
 
87
        case 0:
 
88
                Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
 
89
                                Text::MODE_HSCROLL, Text::SCALE_SMALL );
 
90
                break;
 
91
        case 1:
 
92
                Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_HALF,
 
93
                                Text::SCALE_FAT );
 
94
                Text::set_up_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF,
 
95
                                Text::SCALE_FAT );
 
96
                break;
 
97
        }
112
98
}