/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: 2013-03-31 17:07:36 UTC
  • Revision ID: tim@ed.am-20130331170736-hphm2hg0y6l7w6z1
made rtc-test's DS1307 library a symlink to the main one in src/util

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