/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: edam
  • Date: 2012-03-20 22:13:38 UTC
  • Revision ID: tim@ed.am-20120320221338-4zvmyesujc0zwwsx
updated arduino makefile

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
 
 
45
42
// time last frame
46
43
static unsigned long _last_millis;
47
44
 
93
90
                        _message_params[ message_num ] = NUM_SEGMENTS; break;
94
91
                }
95
92
                _message_params[ message_num ] = -( _message_params[ message_num ] -
96
 
                        TextRenderer::get_width( _message_lens[ message_num ],
97
 
                                        _message_scale[ message_num ] ) ) / 2;
 
93
                        TextRenderer::get_width( _message_lens[ message_num ] ) ) / 2;
98
94
        }
99
95
}
100
96
 
106
102
}
107
103
 
108
104
 
109
 
void Text::reset_message( int message_num, char mode, int scale )
 
105
void Text::reset_message( int message_num, char mode )
110
106
{
111
107
        _message_modes[ message_num ] = mode;
112
108
        _message_recalc_flags |= 1 << message_num;
113
 
        _message_scale[ message_num ] = scale;
114
109
}
115
110
 
116
111
 
139
134
}
140
135
 
141
136
 
142
 
void Text::post_draw()
143
 
{
144
 
        _do_draw_reset = false;
145
 
}
146
 
 
147
 
 
148
137
void Text::draw( int message_num, int segment )
149
138
{
150
139
        TextRenderer::buffer_in_use();
151
140
 
152
141
        // perform a mid-frame reset, as necessary
153
 
        if( _do_draw_reset ) // && segment > NUM_SEGMENTS / 2 )
154
 
        {
 
142
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
 
143
                _do_draw_reset = false;
 
144
 
155
145
                // reset message param?
156
146
                if( _message_recalc_flags & ( 1 << message_num ) ) {
157
147
                        _message_recalc_flags &= ~( 1 << message_num );
163
153
                        _message_params[ message_num ] +=
164
154
                                _duration * TEXT_SCROLL_SPEED / 1000;
165
155
                        long excess = _message_params[ message_num ] -
166
 
                                TextRenderer::get_width( _message_lens[ message_num ],
167
 
                                                _message_scale[ message_num ] );
 
156
                                TextRenderer::get_width( _message_lens[ message_num ] );
168
157
                        if( excess >= 0 ) {
169
158
                                reset_message_param( message_num );
170
159
                                _message_params[ message_num ] += excess;
222
211
        TextRenderer::render(
223
212
                _messages[ message_num ], _message_lens[ message_num ],
224
213
                (long)segment + _message_params[ message_num ],
225
 
                ( _message_modes[ message_num ] & 1 ) == 0, 0,
226
 
                _message_scale[ message_num ] );
 
214
                ( _message_modes[ message_num ] & 1 ) == 0, 0 );
227
215
}