/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_renderer.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

39
39
// output buffer
40
40
static unsigned char _output_buffer;
41
41
 
 
42
// does buffer need rendering?
 
43
static bool _need_render;
 
44
 
42
45
 
43
46
// cache a glyph
44
47
void cache_glyph( char c )
367
370
                int pos = x / 8;
368
371
                if( pos < message_len )
369
372
                {
370
 
                        // ensure correct glyph is cached and pull out colun of data
 
373
                        // ensure correct glyph is cached and pull out column of data
371
374
                        cache_glyph( message[ pos ] );
372
375
                        glyph_col = _glyph_cache[ x % 8 ];
373
376
                }
392
395
void TextRenderer::reset_buffer()
393
396
{
394
397
        _output_buffer = 0;
 
398
        _need_render = false;
 
399
}
 
400
 
 
401
 
 
402
void TextRenderer::buffer_in_use()
 
403
{
 
404
        _need_render = true;
395
405
}
396
406
 
397
407
 
398
408
void TextRenderer::output_buffer()
399
409
{
 
410
        if( !_need_render ) return;
 
411
 
400
412
        for( int a = 8; a >= 0; a-- ) {
401
413
                led( a, ( _output_buffer & 1 )? true : false );
402
414
                _output_buffer >>= 1;
405
417
}
406
418
 
407
419
 
408
 
void TextRenderer::select_font( int font_num )
409
 
{
410
 
        _font = font_num;
 
420
int TextRenderer::get_font()
 
421
{
 
422
        return _font;
 
423
}
 
424
 
 
425
 
 
426
void TextRenderer::inc_font()
 
427
{
 
428
        if( ++_font >= 4 )
 
429
                _font = 0;
411
430
}