/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/text.cc

  • Committer: Tim Marston
  • Date: 2012-05-17 19:17:05 UTC
  • Revision ID: tim@ed.am-20120517191705-3d28d50tw8w51v7g
removed 5V regulator from scematic and replaced the connection to the regulator
on the Arduino -- ecause that's what we should be using and out seperate
regulator is only working around a fault in out arduino

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
// mode-specific message parameters
40
40
static signed long _message_params[ NUM_MESSAGE_BUFFERS ];
41
41
 
 
42
// text scaling factors
 
43
static int _message_scale[ NUM_MESSAGE_BUFFERS ];
 
44
 
42
45
// time last frame
43
46
static unsigned long _last_millis;
44
47
 
48
51
// recalculate message params, based on _duration
49
52
static bool _do_draw_reset;
50
53
 
 
54
// recalculate messages parameters (after message reset)
 
55
static unsigned char _message_recalc_flags;
 
56
 
51
57
 
52
58
void reset_message_param( int message_num )
53
59
{
87
93
                        _message_params[ message_num ] = NUM_SEGMENTS; break;
88
94
                }
89
95
                _message_params[ message_num ] = -( _message_params[ message_num ] -
90
 
                        TextRenderer::get_width( _message_lens[ message_num ] ) ) / 2;
 
96
                        TextRenderer::get_width( _message_lens[ message_num ],
 
97
                                        _message_scale[ message_num ] ) ) / 2;
91
98
        }
92
99
}
93
100
 
99
106
}
100
107
 
101
108
 
102
 
void Text::reset_message( int message_num, char mode )
 
109
void Text::reset_message( int message_num, char mode, int scale )
103
110
{
104
111
        _message_modes[ message_num ] = mode;
105
 
        reset_message_param( message_num );
 
112
        _message_recalc_flags |= 1 << message_num;
 
113
        _message_scale[ message_num ] = scale;
106
114
}
107
115
 
108
116
 
112
120
        _duration = 0;
113
121
        _last_millis = ::millis();
114
122
        _do_draw_reset = false;
 
123
        _message_recalc_flags = 0;
115
124
 
116
125
        // reset the text renderer's output buffer
117
126
        TextRenderer::reset_buffer();
132
141
 
133
142
void Text::draw( int message_num, int segment )
134
143
{
 
144
        TextRenderer::buffer_in_use();
 
145
 
135
146
        // perform a mid-frame reset, as necessary
136
147
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
137
148
                _do_draw_reset = false;
138
149
 
139
 
                if( _message_modes[ message_num ] & MODE_HSCROLL )
140
 
                {
141
 
                        // add to horizontal scroll position
 
150
                // reset message param?
 
151
                if( _message_recalc_flags & ( 1 << message_num ) ) {
 
152
                        _message_recalc_flags &= ~( 1 << message_num );
 
153
                        reset_message_param( message_num );
 
154
                }
 
155
 
 
156
                // add to horizontal scroll position
 
157
                if( _message_modes[ message_num ] & MODE_HSCROLL ) {
142
158
                        _message_params[ message_num ] +=
143
159
                                _duration * TEXT_SCROLL_SPEED / 1000;
144
160
                        long excess = _message_params[ message_num ] -
145
 
                                TextRenderer::get_width( _message_lens[ message_num ] );
 
161
                                TextRenderer::get_width( _message_lens[ message_num ],
 
162
                                                _message_scale[ message_num ] );
146
163
                        if( excess >= 0 ) {
147
164
                                reset_message_param( message_num );
148
165
                                _message_params[ message_num ] += excess;
200
217
        TextRenderer::render(
201
218
                _messages[ message_num ], _message_lens[ message_num ],
202
219
                (long)segment + _message_params[ message_num ],
203
 
                ( _message_modes[ message_num ] & 1 ) == 0, 0 );
 
220
                ( _message_modes[ message_num ] & 1 ) == 0, 0,
 
221
                _message_scale[ message_num ] );
204
222
}