/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:
27
27
#include "Arduino.h"
28
28
 
29
29
 
30
 
 
31
 
void InfoMode::draw_reset()
 
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()
32
74
{
33
75
        switch( _flavour )
34
76
        {
37
79
                        str0.begin();
38
80
                        str0.format(
39
81
                                        "Propeller Clock mk.1   ...   "
40
 
                                        "Created by Tim and Dan Marston in 2012   ...   "
 
82
                                        "Created by Tim and Dan Marston in 2011   ...   "
41
83
                                        "http://ed.am/dev/elec/propeller-clock" );
42
 
                        Text::set_message_text( 0, str0 );
 
84
                        Text::set_message( 0, str0 );
43
85
                }
44
86
                break;
45
87
        case 1: {
52
94
                        str1.format( "%ld",
53
95
                                        (unsigned long)60 * 1000 / ( millis - _millis_last ) );
54
96
                        _millis_last = millis;
55
 
                        Text::set_message_text( 0, str0 );
56
 
                        Text::set_message_text( 1, str1 );
 
97
                        Text::set_message( 0, str0 );
 
98
                        Text::set_message( 1, str1 );
57
99
                }
58
100
                break;
59
101
        }
60
102
}
61
103
 
62
104
 
63
 
void InfoMode::activate()
 
105
void info_mode_activate()
64
106
{
65
107
        _flavour = 0;
66
108
        _millis_last = ::millis();
67
109
 
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
 
        }
 
110
        // reset messages
 
111
        reset_messages();
98
112
}