/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-17 22:49:36 UTC
  • Revision ID: tim@ed.am-20120517224936-0wgyem932dlq5bs4
various tweaks, a (failed) attempt to fix text reset bug and added TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
// display flavour
31
31
static int _flavour = 0;
32
32
 
 
33
// previous millis
 
34
static unsigned long _millis_last = 0;
 
35
 
33
36
 
34
37
static void reset_messages()
35
38
{
36
39
        switch( _flavour )
37
40
        {
38
41
        case 0:
39
 
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS );
 
42
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
 
43
                                Text::MODE_HSCROLL, Text::SCALE_SMALL );
40
44
                break;
41
45
        case 1:
42
 
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_HALF );
43
 
                Text::reset_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF );
 
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 );
44
50
                break;
45
51
        }
46
52
}
66
72
 
67
73
void info_mode_draw_reset()
68
74
{
69
 
        PString str0( Text::_messages[ 0 ], MESSAGE_LEN );
70
 
        PString str1( Text::_messages[ 1 ], MESSAGE_LEN );
71
 
        str0.begin();
72
 
        str1.begin();
73
 
 
74
75
        switch( _flavour )
75
76
        {
76
 
        case 0:
77
 
                str0.format(
78
 
                        "Propeller Clock mk.1   ...   "
79
 
                        "Created by Tim and Dan Marston in 2011   ...   "
80
 
                        "http://ed.am/dev/elec/propeller-clock" );
 
77
        case 0: {
 
78
                        PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 4 );
 
79
                        str0.begin();
 
80
                        str0.format(
 
81
                                        "Propeller Clock mk.1   ...   "
 
82
                                        "Created by Tim and Dan Marston in 2011   ...   "
 
83
                                        "http://ed.am/dev/elec/propeller-clock" );
 
84
                        Text::set_message( 0, str0 );
 
85
                }
81
86
                break;
82
 
        case 1:
83
 
                str0.format( "RPM" );
84
 
                str1.format( "%d", 123 );
 
87
        case 1: {
 
88
                        PString str0( Text::_messages[ 0 ], MESSAGE_LEN );
 
89
                        PString str1( Text::_messages[ 1 ], MESSAGE_LEN );
 
90
                        str0.begin();
 
91
                        str1.begin();
 
92
                        str0.format( "RPM" );
 
93
                        unsigned long millis = ::millis();
 
94
                        str1.format( "%ld",
 
95
                                        (unsigned long)60 * 1000 / ( millis - _millis_last ) );
 
96
                        _millis_last = millis;
 
97
                        Text::set_message( 0, str0 );
 
98
                        Text::set_message( 1, str1 );
 
99
                }
85
100
                break;
86
101
        }
87
 
 
88
 
        Text::set_message( 0, str0 );
89
 
        Text::set_message( 1, str1 );
90
102
}
91
103
 
92
104
 
93
105
void info_mode_activate()
94
106
{
95
107
        _flavour = 0;
 
108
        _millis_last = ::millis();
96
109
 
97
110
        // reset messages
98
111
        reset_messages();