/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
59 by edam
removed ulibc, fixed button, added text rendering
1
/*
2
 * text_renderer.cc
3
 *
4
 * Copyright (C) 2011 Tim Marston <tim@ed.am> and Dan Marston.
5
 *
6
 * This file is part of propeller-clock (hereafter referred to as "this
7
 * program"). See http://ed.am/dev/software/arduino/propeller-clock for more
8
 * information.
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Lesser General Public License as published
12
 * by the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Lesser General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Lesser General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
#include "text_renderer.h"
24
#include "config.h"
25
#include "Arduino.h"
26
#include <avr/pgmspace.h>
27
#include "display.h"
28
29
30
TextRenderer &TextRenderer::get_instance()
31
{
32
	static TextRenderer text_renderer;
33
	return text_renderer;
34
}
35
36
37
PString &TextRenderer::get_pstring()
38
{
39
	// reset renderer
40
	_duration = 0;
41
	_last_millis = ::millis();
42
	_scroll = -TEXT_DISPLAY_SEGMENTS;
43
44
	return _message;
45
}
46
47
48
void TextRenderer::draw_reset()
49
{
50
	// how many milliseconds have elapsed since last frame?
51
	unsigned long millis = ::millis();
52
	if( millis > _last_millis )
53
		_duration = millis - _last_millis;
54
	_last_millis = millis;
55
56
	// move on scroll pos
57
	_scroll += ( _duration * TEXT_SCROLL_SPEED / 1000 );
58
	if( _scroll > (signed long)_message.length() * 8 * TEXT_SCALE )
59
		_scroll -= (signed long)_message.length() * 8 * TEXT_SCALE + TEXT_DISPLAY_SEGMENTS;
60
}
61
62
63
void TextRenderer::draw_scroll( int segment )
64
{
65
	segment = xform_segment( segment );
66
	if( segment < 0 )
67
		Display::leds_off();
68
	else
69
		render( (long)segment + _scroll );
70
}
71
72
73
TextRenderer::TextRenderer()
74
    :
75
	_message( _message_buffer, sizeof( _message_buffer ) ),
76
	_glyph_cache_char( '\0' ),
77
	_font( 0 )
78
{
79
}
80
81
82
int TextRenderer::xform_segment( int segment )
83
{
84
	if( segment < TEXT_DISPLAY_SEGMENTS / 2 )
85
		return segment + TEXT_DISPLAY_SEGMENTS / 2;
86
	else if( segment >= NUM_SEGMENTS - TEXT_DISPLAY_SEGMENTS / 2 )
87
		return segment - ( NUM_SEGMENTS - TEXT_DISPLAY_SEGMENTS / 2 );
88
	else
89
		return - 1;
90
}
91
92
93
void TextRenderer::render( int x )
94
{
95
	// handle negative x
96
	if( x < 0 ) {
97
		Display::leds_off();
98
		return;
99
	}
100
101
	// scale font
102
	x /= TEXT_SCALE;
103
104
	// fetch a glyph
105
	int pos = x / 8;
106
	char c = ( pos >= 0 && pos < (signed)_message.length() )? _message[ pos ] : ' ';
107
	if( c != _glyph_cache_char ) {
108
		_glyph_cache_char = c;
109
		get_glyph( c, _glyph_cache );
110
	}
111
112
	// draw a column
113
	char col_data = _glyph_cache[ x % 8 ];
114
	for( int a = 0; a < 8; a++ )
115
		Display::led( 8 - a, ( col_data & ( 1 << a ) )? true : false );
116
}
117
118
119
void TextRenderer::get_glyph( char c, char *glyph )
120
{
121
	static char fonts[][ 66 * 8 ] PROGMEM = {
122
		{ // INVD-A
123
			0x00, 0x7c, 0x7e, 0x12, 0x12, 0x12, 0x7e, 0x7c, // A
124
			0x00, 0x7e, 0x7e, 0x4a, 0x4a, 0x4a, 0x7e, 0x34, // B
125
			0x00, 0x3c, 0x7e, 0x42, 0x42, 0x42, 0x66, 0x24, // C
126
			0x00, 0x7e, 0x7e, 0x42, 0x42, 0x66, 0x3c, 0x18, // D
127
			0x00, 0x7e, 0x7e, 0x4a, 0x4a, 0x4a, 0x42, 0x00, // E
128
			0x00, 0x7e, 0x7e, 0x0a, 0x0a, 0x0a, 0x02, 0x00, // F
129
			0x00, 0x3c, 0x7e, 0x42, 0x52, 0x52, 0x76, 0x34, // G
130
			0x00, 0x7e, 0x7e, 0x08, 0x08, 0x08, 0x7e, 0x7e, // H
131
			0x00, 0x42, 0x42, 0x7e, 0x7e, 0x42, 0x42, 0x00, // I
132
			0x00, 0x30, 0x70, 0x40, 0x40, 0x40, 0x7e, 0x3e, // J
133
			0x00, 0x7e, 0x7e, 0x08, 0x1c, 0x36, 0x62, 0x40, // K
134
			0x00, 0x7e, 0x7e, 0x40, 0x40, 0x40, 0x40, 0x00, // L
135
			0x00, 0x7e, 0x7e, 0x0c, 0x18, 0x0c, 0x7e, 0x7e, // M
136
			0x00, 0x7e, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x7e, // N
137
			0x00, 0x3c, 0x7e, 0x42, 0x42, 0x42, 0x7e, 0x3c, // O
138
			0x00, 0x7e, 0x7e, 0x12, 0x12, 0x12, 0x1e, 0x0c, // P
139
			0x00, 0x3c, 0x7e, 0x52, 0x52, 0x62, 0x7e, 0x3c, // Q
140
			0x00, 0x7e, 0x7e, 0x12, 0x12, 0x32, 0x7e, 0x4c, // R
141
			0x00, 0x24, 0x6e, 0x4a, 0x4a, 0x4a, 0x7a, 0x30, // S
142
			0x00, 0x02, 0x02, 0x7e, 0x7e, 0x02, 0x02, 0x00, // T
143
			0x00, 0x3e, 0x7e, 0x40, 0x40, 0x40, 0x7e, 0x3e, // U
144
			0x00, 0x1e, 0x3e, 0x60, 0x40, 0x60, 0x3e, 0x1e, // V
145
			0x00, 0x3e, 0x7e, 0x60, 0x30, 0x60, 0x7e, 0x3e, // W
146
			0x00, 0x42, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x42, // X
147
			0x02, 0x06, 0x0c, 0x78, 0x78, 0x0c, 0x06, 0x02, // Y
148
			0x00, 0x42, 0x62, 0x72, 0x5a, 0x4e, 0x46, 0x42, // Z
149
			0x00, 0x20, 0x74, 0x54, 0x54, 0x7c, 0x78, 0x00, // a
150
			0x00, 0x00, 0x7e, 0x7e, 0x48, 0x48, 0x78, 0x30, // b
151
			0x00, 0x00, 0x38, 0x7c, 0x44, 0x44, 0x00, 0x00, // c
152
			0x00, 0x30, 0x78, 0x48, 0x48, 0x7e, 0x7e, 0x00, // d
153
			0x00, 0x38, 0x7c, 0x54, 0x54, 0x5c, 0x08, 0x00, // e
154
			0x00, 0x00, 0x7c, 0x7e, 0x0a, 0x02, 0x00, 0x00, // f
155
			0x00, 0x18, 0xbc, 0xa4, 0xa4, 0xfc, 0x7c, 0x00, // g
156
			0x00, 0x7e, 0x7e, 0x08, 0x08, 0x78, 0x70, 0x00, // h
157
			0x00, 0x00, 0x48, 0x7a, 0x7a, 0x40, 0x00, 0x00, // i
158
			0x00, 0x00, 0x40, 0xc0, 0x80, 0xfa, 0x7a, 0x00, // j
159
			0x00, 0x00, 0x7e, 0x7e, 0x10, 0x3c, 0x64, 0x40, // k
160
			0x00, 0x00, 0x00, 0x3e, 0x7e, 0x40, 0x40, 0x00, // l
161
			0x7c, 0x7c, 0x04, 0x78, 0x7c, 0x04, 0x7c, 0x78, // m
162
			0x00, 0x7c, 0x7c, 0x04, 0x04, 0x7c, 0x78, 0x00, // n
163
			0x00, 0x38, 0x7c, 0x44, 0x44, 0x7c, 0x38, 0x00, // o
164
			0x00, 0xfc, 0xfc, 0x24, 0x24, 0x3c, 0x18, 0x00, // p
165
			0x00, 0x18, 0x3c, 0x24, 0x24, 0xfc, 0xfc, 0x80, // q
166
			0x00, 0x00, 0x78, 0x7c, 0x04, 0x04, 0x00, 0x00, // r
167
			0x00, 0x48, 0x5c, 0x54, 0x54, 0x74, 0x20, 0x00, // s
168
			0x00, 0x04, 0x3e, 0x7e, 0x44, 0x44, 0x00, 0x00, // t
169
			0x00, 0x3c, 0x7c, 0x40, 0x40, 0x7c, 0x3c, 0x00, // u
170
			0x00, 0x0c, 0x3c, 0x70, 0x60, 0x3c, 0x0c, 0x00, // v
171
			0x3c, 0x7c, 0x40, 0x30, 0x40, 0x7c, 0x3c, 0x00, // w
172
			0x00, 0x44, 0x6c, 0x38, 0x38, 0x6c, 0x44, 0x00, // x
173
			0x00, 0x1c, 0xbc, 0xa0, 0xa0, 0xfc, 0x7c, 0x00, // y
174
			0x00, 0x44, 0x64, 0x74, 0x5c, 0x4c, 0x44, 0x00, // z
175
			0x00, 0x3c, 0x7e, 0x52, 0x4a, 0x46, 0x7e, 0x3c, // 0
176
			0x00, 0x00, 0x44, 0x44, 0x7e, 0x7e, 0x40, 0x40, // 1
177
			0x00, 0x64, 0x76, 0x52, 0x52, 0x52, 0x5e, 0x4c, // 2
178
			0x00, 0x24, 0x66, 0x42, 0x4a, 0x4a, 0x7e, 0x34, // 3
179
			0x00, 0x30, 0x28, 0x24, 0x7e, 0x7e, 0x20, 0x20, // 4
180
			0x00, 0x2e, 0x6e, 0x4a, 0x4a, 0x4a, 0x7a, 0x32, // 5
181
			0x00, 0x3c, 0x7e, 0x4a, 0x4a, 0x4a, 0x7a, 0x30, // 6
182
			0x00, 0x02, 0x02, 0x62, 0x72, 0x1a, 0x0e, 0x06, // 7
183
			0x00, 0x34, 0x7e, 0x4a, 0x4a, 0x4a, 0x7e, 0x34, // 8
184
			0x00, 0x0c, 0x5e, 0x52, 0x52, 0x52, 0x7e, 0x3c, // 9
185
			0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // -
186
			0x00, 0x00, 0x00, 0x6c, 0x6c, 0x00, 0x00, 0x00, // :
187
			0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, // .
188
			0x00, 0x00, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x00, // ,
189
		}, { // INVD-D
190
			0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x7f, 0x7f, // A
191
			0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x7f, 0x77, // B
192
			0x00, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x77, 0x77, // C
193
			0x00, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f, 0x3e, // D
194
			0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x63, 0x63, // E
195
			0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x03, 0x03, // F
196
			0x00, 0x7f, 0x7f, 0x41, 0x49, 0x49, 0x7b, 0x7b, // G
197
			0x00, 0x7f, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x7f, // H
198
			0x00, 0x41, 0x41, 0x7f, 0x7f, 0x41, 0x41, 0x00, // I
199
			0x00, 0x60, 0x60, 0x40, 0x40, 0x40, 0x7f, 0x7f, // J
200
			0x00, 0x7f, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x77, // K
201
			0x00, 0x7f, 0x7f, 0x40, 0x40, 0x40, 0x60, 0x60, // L
202
			0x00, 0x7f, 0x7f, 0x02, 0x04, 0x02, 0x7f, 0x7f, // M
203
			0x00, 0x7f, 0x7f, 0x06, 0x0c, 0x18, 0x7f, 0x7f, // N
204
			0x00, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f, 0x7f, // O
205
			0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x0f, 0x0f, // P
206
			0x00, 0x7f, 0x7f, 0x41, 0x51, 0x21, 0x7f, 0x7f, // Q
207
			0x00, 0x7f, 0x7f, 0x09, 0x09, 0x09, 0x7f, 0x77, // R
208
			0x00, 0x6f, 0x6f, 0x49, 0x49, 0x49, 0x7b, 0x7b, // S
209
			0x00, 0x01, 0x01, 0x7f, 0x7f, 0x01, 0x01, 0x00, // T
210
			0x00, 0x7f, 0x7f, 0x40, 0x40, 0x40, 0x7f, 0x7f, // U
211
			0x00, 0x1f, 0x3f, 0x60, 0x40, 0x60, 0x3f, 0x1f, // V
212
			0x00, 0x7f, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x7f, // W
213
			0x00, 0x77, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x77, // X
214
			0x00, 0x6f, 0x6f, 0x48, 0x48, 0x48, 0x7f, 0x7f, // Y
215
			0x00, 0x63, 0x73, 0x59, 0x4d, 0x47, 0x63, 0x61, // Z
216
			0x00, 0x74, 0x74, 0x54, 0x54, 0x7c, 0x7c, 0x00, // a
217
			0x00, 0x7f, 0x7f, 0x44, 0x44, 0x7c, 0x7c, 0x00, // b
218
			0x00, 0x7c, 0x7c, 0x44, 0x44, 0x6c, 0x6c, 0x00, // c
219
			0x00, 0x7c, 0x7c, 0x44, 0x44, 0x7f, 0x7f, 0x00, // d
220
			0x00, 0x7c, 0x7c, 0x54, 0x54, 0x5c, 0x5c, 0x00, // e
221
			0x00, 0x00, 0x04, 0x7f, 0x7f, 0x05, 0x05, 0x01, // f
222
			0x00, 0xbc, 0xbc, 0xa4, 0xa4, 0xfc, 0xfc, 0x00, // g
223
			0x00, 0x7f, 0x7f, 0x04, 0x04, 0x7c, 0x7c, 0x00, // h
224
			0x00, 0x44, 0x44, 0x7d, 0x7d, 0x40, 0x40, 0x00, // i
225
			0x00, 0x80, 0x80, 0xfd, 0xfd, 0x00, 0x00, 0x00, // j
226
			0x00, 0x7f, 0x7f, 0x10, 0x10, 0x7c, 0x6c, 0x00, // k
227
			0x00, 0x00, 0x00, 0x7f, 0x7f, 0x40, 0x40, 0x00, // l
228
			0x00, 0x7c, 0x7c, 0x04, 0x7c, 0x04, 0x7c, 0x7c, // m
229
			0x00, 0x7c, 0x7c, 0x04, 0x04, 0x7c, 0x7c, 0x00, // n
230
			0x00, 0x7c, 0x7c, 0x44, 0x44, 0x7c, 0x7c, 0x00, // o
231
			0x00, 0xfc, 0xfc, 0x24, 0x24, 0x3c, 0x3c, 0x00, // p
232
			0x00, 0x3c, 0x3c, 0x24, 0x24, 0xfc, 0xfc, 0x00, // q
233
			0x00, 0x7c, 0x7c, 0x04, 0x04, 0x0c, 0x0c, 0x00, // r
234
			0x00, 0x5c, 0x5c, 0x54, 0x54, 0x74, 0x74, 0x00, // s
235
			0x00, 0x00, 0x04, 0x7f, 0x7f, 0x44, 0x44, 0x00, // t
236
			0x00, 0x7c, 0x7c, 0x40, 0x40, 0x7c, 0x7c, 0x00, // u
237
			0x00, 0x1c, 0x3c, 0x60, 0x60, 0x3c, 0x1c, 0x00, // v
238
			0x00, 0x7c, 0x7c, 0x40, 0x7c, 0x40, 0x7c, 0x7c, // w
239
			0x00, 0x6c, 0x7c, 0x10, 0x10, 0x7c, 0x6c, 0x00, // x
240
			0x00, 0xbc, 0xbc, 0xa0, 0xa0, 0xfc, 0xfc, 0x00, // y
241
			0x00, 0x64, 0x74, 0x54, 0x54, 0x5c, 0x4c, 0x00, // z
242
			0x00, 0x7f, 0x7f, 0x51, 0x49, 0x45, 0x7f, 0x7f, // 0
243
			0x00, 0x41, 0x41, 0x7f, 0x7f, 0x40, 0x40, 0x00, // 1
244
			0x00, 0x7b, 0x7b, 0x49, 0x49, 0x49, 0x4f, 0x4f, // 2
245
			0x00, 0x63, 0x63, 0x49, 0x49, 0x49, 0x7f, 0x7f, // 3
246
			0x00, 0x1f, 0x1f, 0x10, 0x10, 0x7f, 0x7f, 0x10, // 4
247
			0x00, 0x6f, 0x6f, 0x49, 0x49, 0x49, 0x79, 0x79, // 5
248
			0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x7b, 0x7b, // 6
249
			0x00, 0x03, 0x03, 0x71, 0x79, 0x0d, 0x07, 0x03, // 7
250
			0x00, 0x7f, 0x7f, 0x49, 0x49, 0x49, 0x7f, 0x7f, // 8
251
			0x00, 0x6f, 0x6f, 0x49, 0x49, 0x49, 0x7f, 0x7f, // 9
252
			0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // -
253
			0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, // :
254
			0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, // .
255
			0x00, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, // ,
256
		}, { // INVD-G
257
			0x7c, 0x7e, 0x22, 0x7e, 0x7e, 0x7e, 0x7c, 0x00, // A
258
			0x7c, 0x7e, 0x7e, 0x7e, 0x4a, 0x7e, 0x34, 0x00, // B
259
			0x3c, 0x7e, 0x7e, 0x7e, 0x42, 0x76, 0x34, 0x00, // C
260
			0x7c, 0x7e, 0x7e, 0x7e, 0x42, 0x7e, 0x3c, 0x00, // D
261
			0x3c, 0x7e, 0x7e, 0x7e, 0x4a, 0x4a, 0x00, 0x00, // E
262
			0x7c, 0x7e, 0x7e, 0x7e, 0x12, 0x12, 0x00, 0x00, // F
263
			0x3c, 0x7e, 0x7e, 0x7e, 0x52, 0x76, 0x34, 0x00, // G
264
			0x7e, 0x7e, 0x7e, 0x7e, 0x08, 0x7e, 0x7e, 0x00, // H
265
			0x00, 0x42, 0x7e, 0x7e, 0x7e, 0x7e, 0x42, 0x00, // I
266
			0x30, 0x70, 0x42, 0x7e, 0x7e, 0x7e, 0x3e, 0x00, // J
267
			0x7e, 0x7e, 0x7e, 0x7e, 0x08, 0x76, 0x62, 0x00, // K
268
			0x00, 0x3e, 0x7e, 0x7e, 0x7e, 0x40, 0x40, 0x00, // L
269
			0x7e, 0x7e, 0x7e, 0x7c, 0x08, 0x7c, 0x7e, 0x00, // M
270
			0x7e, 0x7e, 0x7e, 0x7c, 0x08, 0x7e, 0x7e, 0x00, // N
271
			0x3c, 0x7e, 0x7e, 0x7e, 0x42, 0x7e, 0x3c, 0x00, // O
272
			0x7c, 0x7e, 0x7e, 0x7e, 0x12, 0x1e, 0x0c, 0x00, // P
273
			0x3c, 0x7e, 0x7e, 0x7e, 0x42, 0xfe, 0xbc, 0x00, // Q
274
			0x7c, 0x7e, 0x7e, 0x7e, 0x12, 0x7e, 0x6c, 0x00, // R
275
			0x24, 0x6e, 0x5e, 0x7e, 0x7a, 0x76, 0x24, 0x00, // S
276
			0x00, 0x02, 0x7e, 0x7e, 0x7e, 0x7e, 0x02, 0x00, // T
277
			0x3e, 0x7e, 0x7e, 0x7e, 0x40, 0x7e, 0x3e, 0x00, // U
278
			0x1e, 0x3e, 0x7e, 0x7e, 0x40, 0x3e, 0x1e, 0x00, // V
279
			0x3e, 0x7e, 0x7e, 0x7e, 0x20, 0x7e, 0x3e, 0x00, // W
280
			0x42, 0x66, 0x3e, 0x7e, 0x7c, 0x66, 0x42, 0x00, // X
281
			0x06, 0x0e, 0x7e, 0x7e, 0x70, 0x0e, 0x06, 0x00, // Y
282
			0x62, 0x72, 0x7a, 0x7e, 0x5e, 0x4e, 0x46, 0x00, // Z
283
			0x38, 0x7c, 0x44, 0x3c, 0x7c, 0x7c, 0x78, 0x00, // a
284
			0x3f, 0x7f, 0x7f, 0x7f, 0x44, 0x7c, 0x38, 0x00, // b
285
			0x38, 0x7c, 0x7c, 0x7c, 0x44, 0x6c, 0x28, 0x00, // c
286
			0x38, 0x7c, 0x44, 0x3f, 0x7f, 0x7f, 0x7f, 0x00, // d
287
			0x38, 0x7c, 0x7c, 0x7c, 0x54, 0x5c, 0x28, 0x00, // e
288
			0x88, 0xfe, 0xff, 0xff, 0x7f, 0x09, 0x0a, 0x00, // f
289
			0x58, 0xbc, 0xa4, 0xfc, 0xfc, 0xfc, 0x78, 0x00, // g
290
			0x7f, 0x7f, 0x7f, 0x7f, 0x04, 0x7c, 0x78, 0x00, // h
291
			0x00, 0x00, 0x7a, 0x7f, 0x7f, 0x7a, 0x00, 0x00, // i
292
			0x00, 0x80, 0xfa, 0xff, 0xff, 0x7a, 0x00, 0x00, // j
293
			0x7f, 0x7f, 0x7f, 0x7f, 0x24, 0x7c, 0x58, 0x00, // k
294
			0x00, 0x00, 0x3f, 0x7f, 0x7f, 0x7f, 0x40, 0x00, // l
295
			0x78, 0x7c, 0x7c, 0x04, 0x7c, 0x04, 0x7c, 0x78, // m
296
			0x7c, 0x7c, 0x7c, 0x78, 0x04, 0x7c, 0x78, 0x00, // n
297
			0x38, 0x7c, 0x7c, 0x7c, 0x44, 0x7c, 0x38, 0x00, // o
298
			0xfc, 0xfc, 0xfc, 0xf8, 0x44, 0x7c, 0x38, 0x00, // p
299
			0x38, 0x7c, 0x44, 0xfc, 0xfc, 0xfc, 0xf8, 0x00, // q
300
			0x7c, 0x7c, 0x7c, 0x7c, 0x04, 0x0c, 0x08, 0x00, // r
301
			0x28, 0x5c, 0x5c, 0x7c, 0x74, 0x74, 0x28, 0x00, // s
302
			0x04, 0x3e, 0x7e, 0x7e, 0x7e, 0x44, 0x24, 0x00, // t
303
			0x3c, 0x7c, 0x40, 0x3c, 0x7c, 0x7c, 0x7c, 0x00, // u
304
			0x1c, 0x3c, 0x7c, 0x7c, 0x60, 0x3c, 0x1c, 0x00, // v
305
			0x3c, 0x7c, 0x7c, 0x40, 0x7c, 0x40, 0x7c, 0x3c, // w
306
			0x44, 0x6c, 0x3c, 0x7c, 0x78, 0x6c, 0x44, 0x00, // x
307
			0x9c, 0xbc, 0xfc, 0xfc, 0x60, 0x3c, 0x1c, 0x00, // y
308
			0x64, 0x74, 0x3c, 0x7c, 0x5c, 0x4c, 0x24, 0x00, // z
309
			0x3c, 0x7e, 0x42, 0x7e, 0x7e, 0x7e, 0x3c, 0x00, // 0
310
			0x00, 0x42, 0x7e, 0x7e, 0x7e, 0x7e, 0x40, 0x00, // 1
311
			0x64, 0x72, 0x7a, 0x7e, 0x5e, 0x4e, 0x44, 0x00, // 2
312
			0x24, 0x66, 0x4a, 0x7e, 0x7e, 0x7e, 0x34, 0x00, // 3
313
			0x0e, 0x1e, 0x10, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, // 4
314
			0x2e, 0x6e, 0x4e, 0x7a, 0x7a, 0x7a, 0x32, 0x00, // 5
315
			0x3c, 0x7e, 0x7e, 0x7e, 0x4a, 0x7a, 0x34, 0x00, // 6
316
			0x02, 0x62, 0x7a, 0x7e, 0x7e, 0x1e, 0x06, 0x00, // 7
317
			0x34, 0x7e, 0x4e, 0x7e, 0x7a, 0x7e, 0x34, 0x00, // 8
318
			0x2c, 0x5e, 0x52, 0x7e, 0x7e, 0x7e, 0x3c, 0x00, // 9
319
			0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // -
320
			0x00, 0x00, 0x28, 0x7c, 0x7c, 0x28, 0x00, 0x00, // :
321
			0x00, 0x00, 0x30, 0x78, 0x78, 0x30, 0x00, 0x00, // .
322
			0x00, 0x00, 0x10, 0xb8, 0xf8, 0x70, 0x00, 0x00, // ,
323
		}, { // INVD-B
324
			0x00, 0x78, 0x7f, 0x09, 0x09, 0x0f, 0x78, 0x00, // A
325
			0x00, 0x7f, 0x79, 0x49, 0x49, 0x4f, 0x78, 0x00, // B
326
			0x00, 0x7f, 0x79, 0x41, 0x41, 0x41, 0x63, 0x00, // C
327
			0x00, 0x7f, 0x79, 0x41, 0x41, 0x41, 0x7f, 0x00, // D
328
			0x00, 0x00, 0x7f, 0x79, 0x49, 0x49, 0x41, 0x00, // E
329
			0x00, 0x00, 0x7f, 0x79, 0x09, 0x09, 0x01, 0x00, // F
330
			0x00, 0x7f, 0x79, 0x41, 0x41, 0x49, 0x7b, 0x00, // G
331
			0x00, 0x7f, 0x78, 0x08, 0x08, 0x08, 0x7f, 0x00, // H
332
			0x00, 0x00, 0x00, 0x7f, 0x78, 0x00, 0x00, 0x00, // I
333
			0x00, 0x60, 0x40, 0x40, 0x40, 0x7f, 0x78, 0x00, // J
334
			0x00, 0x7f, 0x78, 0x08, 0x08, 0x0f, 0x78, 0x00, // K
335
			0x00, 0x00, 0x7f, 0x78, 0x40, 0x40, 0x40, 0x00, // L
336
			0x00, 0x7f, 0x79, 0x01, 0x7f, 0x01, 0x7f, 0x00, // M
337
			0x00, 0x7f, 0x79, 0x01, 0x01, 0x01, 0x7f, 0x00, // N
338
			0x00, 0x7f, 0x41, 0x41, 0x41, 0x43, 0x7f, 0x00, // O
339
			0x00, 0x7f, 0x79, 0x09, 0x09, 0x09, 0x0f, 0x00, // P
340
			0x00, 0x7f, 0x41, 0x41, 0x61, 0x61, 0x7f, 0x00, // Q
341
			0x00, 0x7f, 0x79, 0x09, 0x09, 0x0f, 0x78, 0x00, // R
342
			0x00, 0x6f, 0x49, 0x49, 0x49, 0x79, 0x7b, 0x00, // S
343
			0x00, 0x01, 0x01, 0x7f, 0x79, 0x01, 0x01, 0x00, // T
344
			0x00, 0x7f, 0x78, 0x40, 0x40, 0x40, 0x7f, 0x00, // U
345
			0x00, 0x0f, 0x7f, 0x40, 0x40, 0x78, 0x0f, 0x00, // V
346
			0x00, 0x7f, 0x78, 0x40, 0x7f, 0x40, 0x7f, 0x00, // W
347
			0x00, 0x77, 0x78, 0x08, 0x08, 0x08, 0x77, 0x00, // X
348
			0x00, 0x0f, 0x08, 0x78, 0x78, 0x08, 0x0f, 0x00, // Y
349
			0x00, 0x7b, 0x79, 0x49, 0x49, 0x49, 0x6f, 0x00, // Z
350
			0x00, 0x74, 0x74, 0x54, 0x54, 0x7c, 0x00, 0x00, // a
351
			0x00, 0x7f, 0x74, 0x44, 0x44, 0x7c, 0x00, 0x00, // b
352
			0x00, 0x7c, 0x74, 0x44, 0x44, 0x6c, 0x00, 0x00, // c
353
			0x00, 0x7c, 0x74, 0x44, 0x44, 0x7f, 0x00, 0x00, // d
354
			0x00, 0x7c, 0x74, 0x54, 0x54, 0x5c, 0x00, 0x00, // e
355
			0x00, 0x00, 0x04, 0x7f, 0x75, 0x01, 0x00, 0x00, // f
356
			0x00, 0xbc, 0xb4, 0xa4, 0xa4, 0xfc, 0x00, 0x00, // g
357
			0x00, 0x7f, 0x74, 0x04, 0x04, 0x7c, 0x00, 0x00, // h
358
			0x00, 0x00, 0x00, 0x7d, 0x71, 0x00, 0x00, 0x00, // i
359
			0x00, 0x00, 0x80, 0xbd, 0xf1, 0x00, 0x00, 0x00, // j
360
			0x00, 0x7f, 0x70, 0x10, 0x1c, 0x70, 0x00, 0x00, // k
361
			0x00, 0x00, 0x00, 0x7f, 0x78, 0x00, 0x00, 0x00, // l
362
			0x00, 0x7c, 0x74, 0x04, 0x7c, 0x04, 0x7c, 0x00, // m
363
			0x00, 0x7c, 0x74, 0x04, 0x04, 0x7c, 0x00, 0x00, // n
364
			0x00, 0x7c, 0x74, 0x44, 0x44, 0x7c, 0x00, 0x00, // o
365
			0x00, 0xfc, 0x34, 0x24, 0x24, 0x3c, 0x00, 0x00, // p
366
			0x00, 0x3c, 0x34, 0x24, 0x24, 0xfc, 0x00, 0x00, // q
367
			0x00, 0x00, 0x7c, 0x74, 0x04, 0x04, 0x00, 0x00, // r
368
			0x00, 0x5c, 0x54, 0x54, 0x74, 0x74, 0x00, 0x00, // s
369
			0x00, 0x00, 0x04, 0x7f, 0x74, 0x00, 0x00, 0x00, // t
370
			0x00, 0x7c, 0x70, 0x40, 0x40, 0x7c, 0x00, 0x00, // u
371
			0x00, 0x1c, 0x7c, 0x40, 0x70, 0x1c, 0x00, 0x00, // v
372
			0x00, 0x7c, 0x70, 0x40, 0x7c, 0x40, 0x7c, 0x00, // w
373
			0x00, 0x6c, 0x70, 0x10, 0x10, 0x6c, 0x00, 0x00, // x
374
			0x00, 0xbc, 0xb0, 0xa0, 0xa0, 0xfc, 0x00, 0x00, // y
375
			0x00, 0x74, 0x74, 0x54, 0x54, 0x5c, 0x00, 0x00, // z
376
			0x00, 0x7f, 0x41, 0x41, 0x41, 0x79, 0x7f, 0x00, // 0
377
			0x00, 0x00, 0x00, 0x78, 0x7f, 0x00, 0x00, 0x00, // 1
378
			0x00, 0x7b, 0x79, 0x49, 0x49, 0x49, 0x4f, 0x00, // 2
379
			0x00, 0x63, 0x49, 0x49, 0x49, 0x7f, 0x78, 0x00, // 3
380
			0x00, 0x1f, 0x11, 0x11, 0x71, 0x7f, 0x10, 0x00, // 4
381
			0x00, 0x6f, 0x49, 0x49, 0x49, 0x79, 0x79, 0x00, // 5
382
			0x00, 0x7f, 0x49, 0x49, 0x49, 0x79, 0x7b, 0x00, // 6
383
			0x00, 0x01, 0x01, 0x01, 0x79, 0x7f, 0x00, 0x00, // 7
384
			0x00, 0x78, 0x4f, 0x49, 0x49, 0x7f, 0x78, 0x00, // 8
385
			0x00, 0x1f, 0x11, 0x11, 0x11, 0x71, 0x7f, 0x00, // 9
386
			0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, // -
387
			0x00, 0x00, 0x00, 0x6c, 0x6c, 0x00, 0x00, 0x00, // :
388
			0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, // .
389
			0x00, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x00, // ,
390
		}
391
	};
392
393
	int pos;
394
	if( c >= 'A' && c <= 'Z' )
395
		pos = c - 'A';
396
	else if( c >= 'a' && c <= 'z' )
397
		pos = c - 'a' + 26;
398
	else if( c >= '0' && c <= '9' )
399
		pos = c - '0' + 52;
400
	else if( c == '-' )
401
		pos = 62;
402
	else if( c == ':' )
403
		pos = 63;
404
	else if( c == '.' )
405
		pos = 64;
406
	else if( c == ',' )
407
		pos = 65;
408
	else
409
		pos = -1;
410
411
	if( pos == -1 )
412
		memset( glyph, 0, 8 );
413
	else
414
		memcpy_P( glyph, &( fonts[ _font ][ pos * 8 ] ), 8 );
415
}