/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-04-29 15:27:19 UTC
  • Revision ID: tim@ed.am-20120429152719-4cu2t9lx7bxpbml1
added adjustable text scaling factor

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "Arduino.h"
26
26
#include <avr/pgmspace.h>
27
27
#include "common.h"
 
28
#include "nvram.h"
28
29
 
29
30
 
30
31
// cached glyph
350
351
}
351
352
 
352
353
 
353
 
int TextRenderer::get_width( int message_len )
354
 
{
355
 
        return message_len * 8 * TEXT_SCALE;
 
354
void TextRenderer::init()
 
355
{
 
356
        Nvram::load( Nvram::NVRAM_FONT, _font );
 
357
        if( _font < 0 || _font >= 4 ) _font = 0;
 
358
}
 
359
 
 
360
 
 
361
int TextRenderer::get_width( int message_len, int scale )
 
362
{
 
363
        return message_len * 8 * scale;
356
364
}
357
365
 
358
366
 
359
367
void TextRenderer::render( const char *message, int message_len, int x,
360
 
                                                   bool y_flip, int y_shift )
 
368
                                                   bool y_flip, int y_shift, int scale )
361
369
{
362
370
        char glyph_col = 0;
363
371
 
365
373
        if( x >= 0 )
366
374
        {
367
375
                // scale font
368
 
                x /= TEXT_SCALE;
 
376
                x /= scale;
369
377
 
370
378
                int pos = x / 8;
371
379
                if( pos < message_len )
427
435
{
428
436
        if( ++_font >= 4 )
429
437
                _font = 0;
 
438
        Nvram::save( Nvram::NVRAM_FONT, _font );
430
439
}