Subversion Repositories libOLED

Rev

Rev 13 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13 Rev 17
Line 6... Line 6...
6
 */
6
 */
7
#include "libOLED/fontclass.H"
7
#include "libOLED/fontclass.H"
8
 
8
 
9
char font5x7_t::getPixel(char c, int x, int y)
9
char font5x7_t::getPixel(char c, int x, int y)
10
{
10
{
-
 
11
   // optional scaling
-
 
12
  if (m_mult != 1 || m_shift != 0)
-
 
13
  {
-
 
14
    x = (x * m_mult + m_round/2) >> m_shift;
-
 
15
    y = (y * m_mult + m_round/2) >> m_shift;
-
 
16
  }
-
 
17
 
-
 
18
 
11
  if (x < 0 || x >= m_width)
19
  if (x < 0 || x >= m_width)
12
    return 0;
20
    return 0;
13
  if (y < 0 || y >= m_height)
21
  if (y < 0 || y >= m_height)
14
    return 0;
22
    return 0;
15
  uint8_t pixels = 0;
23
  uint8_t pixels = 0;
Line 27... Line 35...
27
  return v;
35
  return v;
28
}
36
}
29
 
37
 
30
char font10x18_t::getPixel(char c, int x, int y)
38
char font10x18_t::getPixel(char c, int x, int y)
31
{
39
{
-
 
40
 
-
 
41
  // optional scaling
-
 
42
  if (m_mult != 1 || m_shift != 0)
-
 
43
  {
-
 
44
    x = (x * m_mult + m_round) >> m_shift;
-
 
45
    y = (y * m_mult + m_round) >> m_shift;
-
 
46
  }
-
 
47
 
32
  if (x < 0 || x >= m_width)
48
  if (x < 0 || x >= m_width)
33
    return 0;
49
    return 0;
34
  if (y < 0 || y >= m_height)
50
  if (y < 0 || y >= m_height)
35
    return 0;
51
    return 0;
36
 
52
 
-
 
53
 
37
  if (c < ' ')
54
  if (c < ' ')
38
    c = ' ';
55
    c = ' ';
39
  else if (c==0xB0)
56
  else if (c == 0xB0)
40
    c=128;
57
    c = 128;
41
  else if (c >= m_chars + ' ')
58
  else if (c >= m_chars + ' ')
42
    c = ' ';
59
    c = ' ';
43
  // bit offset into pixel row
60
  // bit offset into pixel row
44
  int xm = x + (c - ' ') * m_width;
61
  int xm = x + (c - ' ') * m_width;
45
  // row start address : rounding up 
62
  // row start address : rounding up
46
  int ym = y * (( m_width * m_chars + 7 ) / 8);
63
  int ym = y * ((m_width * m_chars + 7) / 8);
47
  int index = ym +  xm  / 8;
64
  int index = ym + xm / 8;
48
  return ((m_data[index]) >> (xm & 7)) & 1;
65
  return ((m_data[index]) >> (xm & 7)) & 1;
49
}
66
}
50
 
67
 
51
static const char font5x7_data[] =
68
static const char font5x7_data[] =
52
    {
69
    {
Line 147... Line 164...
147
        0x08, 0x0c, 0x08, 0x18, 0x08, // ~ 0x7e 126
164
        0x08, 0x0c, 0x08, 0x18, 0x08, // ~ 0x7e 126
148
        0x55, 0x2A, 0x55, 0x2A, 0x55, //  0x7F 127
165
        0x55, 0x2A, 0x55, 0x2A, 0x55, //  0x7F 127
149
        0x00, 0x06, 0x09, 0x06, 0x00, // 0x80 (remapped in code) a degrees sign
166
        0x00, 0x06, 0x09, 0x06, 0x00, // 0x80 (remapped in code) a degrees sign
150
        0x49, 0x7f, 0x49, 0x49, 0x36, //  0x81 (remapped in code) a sort of Bluetooth symbol
167
        0x49, 0x7f, 0x49, 0x49, 0x36, //  0x81 (remapped in code) a sort of Bluetooth symbol// (1<<2) / 5  sized large font  4/5
151
};
168
152
#if defined(USE_OLD_FONT)#else#endif
-
 
153
 
-
 
154
font5x7_t small_font(96, font5x7_data);
-
 
155
 
-
 
156
font10x18_t large_font(97, font10x18_data);
-
 
157
 
-
 
158
-
 
159
-
 
160
-
 
161
-
 
162
-
 
163
-
 
164
-
 
165
-
 
166
-
 
167
-
 
168
-
 
169
-
 
170
-
 
171
-
 
172
-
 
173
-
 
174
-
 
175
-
 
176
-
 
177
-
 
178
-
 
179
-
 
180
-
 
181
-
 
182
-
 
183
-
 
184
-
 
185
-
 
186
-
 
187
-
 
188
-
 
189
-
 
190
-
 
191
-
 
192
-
 
193
-
 
194
-
 
195
-
 
196
-
 
197
-
 
198
-
 
199
-
 
200
-
 
201
-
 
202
-
 
203
-
 
204
-
 
205
-
 
206
-
 
207
-
 
208
-
 
209
-
 
210
-
 
211
-
 
212
-
 
213
-
 
214
-
 
215
-
 
216
-
 
217
-
 
218
-
 
219
-
 
220
-
 
221
-
 
222
-
 
223
-
 
224
-
 
225
-
 
226
-
 
227
-
 
228
-
 
229
-
 
230
-
 
231
-
 
232
-
 
233
-
 
234
-
 
235
-
 
236
-
 
237
-
 
238
-
 
239
-
 
240
-
 
241
-
 
242
-
 
243
-
 
244
-
 
245
-
 
246
-
 
247
-
 
248
-
 
249
-
 
250
-
 
251
-
 
252
-
 
253
-
 
254
-
 
255
-
 
256
-
 
257
-
 
258
-
 
259
-
 
260
-
 
261
-
 
262
-
 
263
-
 
264
-
 
265
-
 
266
-
 
267
-
 
268
-
 
269
-
 
270
-
 
271
-
 
272
-
 
273
-
 
274
-
 
275
-
 
276
-
 
277
-
 
278
-
 
279
-
 
280
-
 
281
-
 
282
-
 
283
-
 
284
-
 
285
-
 
286
-
 
287
-
 
288
-
 
289
-
 
290
-
 
291
-
 
292
-
 
293
-
 
294
-
 
295
-
 
296
-
 
297
-
 
298
-
 
299
-
 
300
-
 
301
-
 
302
-
 
303
-
 
304
-
 
305
-
 
306
-
 
307
-
 
308
-
 
309
-
 
310
-
 
311
-
 
312
-
 
313
-
 
314
-
 
315
-
 
316
-
 
317
-
 
318
-
 
319
-
 
320
-
 
321
-
 
322
-
 
323
-
 
324
-
 
325
-
 
326
-
 
327
-
 
328
-
 
329
-
 
330
-
 
331
-
 
332
-
 
333
-
 
334
169
335
-
 
336
170
337
171
338
172
339
173
340
174
341
175
342
176
343
177
344
178
345
179
346
180
347
181
348
182
349
183
350
184
351
185
352
186
353
187
354
188
355
189
356
190
357
191
358
192
359
193
360
194
361
195
362
196
363
197
364
198
365
199
366
200
367
201
368
202
369
203
370
204
371
205
372
206
373
207
374
208
375
209
376
210
377
211
378
212
379
213
380
214
381
215
382
216
383
217
384
218
385
219
386
220
387
221
388
222
389
223
390
224
391
225
392
226
393
227
394
228
395
229
396
230
397
231
398
232
399
233
400
234
401
235
402
236
403
237
404
238
405
239
406
240
407
241
408
242
409
243
410
244
411
245
412
246
413
247
414
248
415
249
416
250
417
251
418
252
419
253
420
254
421
255
422
256
423
257
424
258
425
259
426
260
427
261
428
262
429
263
430
264
431
265
432
266
433
267
434
268
435
269
436
270
437
271
438
272
439
273
440
274
441
275
442
276
443
277
444
278
445
279
446
280
447
281
448
282
449
283
450
284
451
285
452
286
453
287
454
288
455
289
456
290
457
291
458
292
459
293
460
294
461
295
462
296
463
297
464
298
465
299
466
300
467
301
468
302
469
303
470
304
471
305
472
306
473
307
474
308
475
309
476
310
477
311
478
312
479
313
480
314
481
315
482
316
483
317
484
318
485
319
486
320
487
321
488
322
489
323
490
324
491
325
492
326
493
327
494
328
495
329
496
330
497
331
498
332
499
333
500
334
501
335
502
336
503
337
504
338
505
339
506
340
507
341
508
342
509
343
510
344
511
345
512
346
513
347
514
348
515
349
516
350
517
351
518
352
519
353
520
354
521
355
522
356
523
357
524
358
-
 
359
-
 
360
525
361