/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-03-12 21:11:20 UTC
  • Revision ID: tim@ed.am-20120312211120-r86cs574yxztgqij
added time set mode, made text renderer's buffer auto reset/output

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "config.h"
26
26
#include "Arduino.h"
27
27
#include <avr/pgmspace.h>
28
 
#include "display.h"
29
28
 
30
29
 
31
30
// the buffer for the message
49
48
// recalculate message params, based on _duration
50
49
static bool _do_draw_reset;
51
50
 
 
51
// recalculate messages parameters (after message reset)
 
52
static unsigned char _message_recalc_flags;
 
53
 
52
54
 
53
55
void reset_message_param( int message_num )
54
56
{
103
105
void Text::reset_message( int message_num, char mode )
104
106
{
105
107
        _message_modes[ message_num ] = mode;
106
 
        reset_message_param( message_num );
 
108
        _message_recalc_flags |= 1 << message_num;
107
109
}
108
110
 
109
111
 
113
115
        _duration = 0;
114
116
        _last_millis = ::millis();
115
117
        _do_draw_reset = false;
 
118
        _message_recalc_flags = 0;
116
119
 
117
120
        // reset the text renderer's output buffer
118
121
        TextRenderer::reset_buffer();
133
136
 
134
137
void Text::draw( int message_num, int segment )
135
138
{
 
139
        TextRenderer::buffer_in_use();
 
140
 
136
141
        // perform a mid-frame reset, as necessary
137
142
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
138
143
                _do_draw_reset = false;
139
144
 
140
 
                if( _message_modes[ message_num ] & MODE_HSCROLL )
141
 
                {
142
 
                        // add to horizontal scroll position
 
145
                // reset message param?
 
146
                if( _message_recalc_flags & ( 1 << message_num ) ) {
 
147
                        _message_recalc_flags &= ~( 1 << message_num );
 
148
                        reset_message_param( message_num );
 
149
                }
 
150
 
 
151
                // add to horizontal scroll position
 
152
                if( _message_modes[ message_num ] & MODE_HSCROLL ) {
143
153
                        _message_params[ message_num ] +=
144
154
                                _duration * TEXT_SCROLL_SPEED / 1000;
145
155
                        long excess = _message_params[ message_num ] -