/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 14:55:12 UTC
  • Revision ID: tim@ed.am-20120518145512-4dg4ble01d47a8z5
moved rount Time a bit, and passed _button to SettingsMajorMode so that it can
come in and out of send_interim mode

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "Arduino.h"
28
28
 
29
29
 
 
30
void InfoMode::draw( int segment )
 
31
{
 
32
        Text::draw( 0, segment );
 
33
        if( _flavour == 1 )
 
34
                Text::draw( 1, segment );
 
35
}
 
36
 
30
37
 
31
38
void InfoMode::draw_reset()
32
39
{
34
41
        {
35
42
        case 0: {
36
43
                        PString str0( Text::_messages[ 0 ], MESSAGE_LEN * 4 );
 
44
                        str0.begin();
37
45
                        str0.format(
38
46
                                        "Propeller Clock mk.1   ...   "
39
47
                                        "Created by Tim and Dan Marston in 2012   ...   "
40
48
                                        "http://ed.am/dev/elec/propeller-clock" );
41
 
                        Text::set_message_text( 0, str0 );
 
49
                        Text::set_message( 0, str0 );
42
50
                }
43
51
                break;
44
52
        case 1: {
45
53
                        PString str0( Text::_messages[ 0 ], MESSAGE_LEN );
46
54
                        PString str1( Text::_messages[ 1 ], MESSAGE_LEN );
 
55
                        str0.begin();
 
56
                        str1.begin();
47
57
                        str0.format( "RPM" );
48
58
                        unsigned long millis = ::millis();
49
59
                        str1.format( "%ld",
50
60
                                        (unsigned long)60 * 1000 / ( millis - _millis_last ) );
51
61
                        _millis_last = millis;
52
 
                        Text::set_message_text( 0, str0 );
53
 
                        Text::set_message_text( 1, str1 );
54
 
                }
55
 
                break;
56
 
        case 2: {
57
 
                        PString str0( Text::_messages[ 0 ], MESSAGE_LEN );
58
 
                        PString str1( Text::_messages[ 1 ], MESSAGE_LEN );
59
 
                        str0.format( "FPS" );
60
 
                        unsigned long millis = ::millis();
61
 
                        str1.format( "%ld",
62
 
                                        (unsigned long)1000 / ( millis - _millis_last ) );
63
 
                        _millis_last = millis;
64
 
                        Text::set_message_text( 0, str0 );
65
 
                        Text::set_message_text( 1, str1 );
 
62
                        Text::set_message( 0, str0 );
 
63
                        Text::set_message( 1, str1 );
66
64
                }
67
65
                break;
68
66
        }
80
78
 
81
79
void InfoMode::press()
82
80
{
83
 
        if( ++_flavour >= 3 )
 
81
        if( ++_flavour >= 2 )
84
82
                _flavour = 0;
85
83
 
86
84
        reset_messages();
89
87
 
90
88
void InfoMode::reset_messages()
91
89
{
92
 
        Text::reset();
93
 
 
94
90
        switch( _flavour )
95
91
        {
96
92
        case 0:
97
 
                Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
 
93
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_THREEQUARTERS |
98
94
                                Text::MODE_HSCROLL, Text::SCALE_SMALL );
99
95
                break;
100
 
        case 1: // fall through
101
 
        case 2:
102
 
                Text::set_up_message( 0, Text::MODE_TOP | Text::MODE_HALF,
 
96
        case 1:
 
97
                Text::reset_message( 0, Text::MODE_TOP | Text::MODE_HALF,
103
98
                                Text::SCALE_FAT );
104
 
                Text::set_up_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF,
 
99
                Text::reset_message( 1, Text::MODE_BOTTOM | Text::MODE_HALF,
105
100
                                Text::SCALE_FAT );
106
101
                break;
107
102
        }