/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-18 14:40:04 UTC
  • Revision ID: tim@ed.am-20120518144004-uuz2zrjmyr78wqd5
updated emacs compile command and readjusted clock shift

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();
130
139
}
131
140
 
132
141
 
 
142
void Text::post_draw()
 
143
{
 
144
        _do_draw_reset = false;
 
145
}
 
146
 
 
147
 
133
148
void Text::draw( int message_num, int segment )
134
149
{
 
150
        TextRenderer::buffer_in_use();
 
151
 
135
152
        // perform a mid-frame reset, as necessary
136
 
        if( _do_draw_reset && segment > NUM_SEGMENTS / 2 ) {
137
 
                _do_draw_reset = false;
 
153
        if( _do_draw_reset ) // && segment > NUM_SEGMENTS / 2 )
 
154
        {
 
155
                // reset message param?
 
156
                if( _message_recalc_flags & ( 1 << message_num ) ) {
 
157
                        _message_recalc_flags &= ~( 1 << message_num );
 
158
                        reset_message_param( message_num );
 
159
                }
138
160
 
139
 
                if( _message_modes[ message_num ] & MODE_HSCROLL )
140
 
                {
141
 
                        // add to horizontal scroll position
 
161
                // add to horizontal scroll position
 
162
                if( _message_modes[ message_num ] & MODE_HSCROLL ) {
142
163
                        _message_params[ message_num ] +=
143
164
                                _duration * TEXT_SCROLL_SPEED / 1000;
144
165
                        long excess = _message_params[ message_num ] -
145
 
                                TextRenderer::get_width( _message_lens[ message_num ] );
 
166
                                TextRenderer::get_width( _message_lens[ message_num ],
 
167
                                                _message_scale[ message_num ] );
146
168
                        if( excess >= 0 ) {
147
169
                                reset_message_param( message_num );
148
170
                                _message_params[ message_num ] += excess;
200
222
        TextRenderer::render(
201
223
                _messages[ message_num ], _message_lens[ message_num ],
202
224
                (long)segment + _message_params[ message_num ],
203
 
                ( _message_modes[ message_num ] & 1 ) == 0, 0 );
 
225
                ( _message_modes[ message_num ] & 1 ) == 0, 0,
 
226
                _message_scale[ message_num ] );
204
227
}