Subversion Repositories libOLED

Rev

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

Rev 10 Rev 13
Line 15... Line 15...
15
  uint8_t pixels = 0;
15
  uint8_t pixels = 0;
16
  if (c < ' ')
16
  if (c < ' ')
17
    c = ' ';
17
    c = ' ';
18
  if (c >= ' ' && c <= 0x7f)
18
  if (c >= ' ' && c <= 0x7f)
19
    pixels = m_data[(c - ' ') * m_width + x];
19
    pixels = m_data[(c - ' ') * m_width + x];
20
  if (c == '�')
20
  if (c == '\xb0')
21
    pixels = m_data[(0x80 - ' ') * m_width + x];
21
    pixels = m_data[(0x80 - ' ') * m_width + x];
22
  // handle extended char set
22
  // handle extended char set
23
  if (c >= 0x81 && c <= 0x81)
23
  if (c >= 0x81 && c <= 0x81)
24
    pixels = m_data[(0x81 - ' ') * m_width + x];
24
    pixels = m_data[(0x81 - ' ') * m_width + x];
25
 
25
 
Line 32... Line 32...
32
  if (x < 0 || x >= m_width)
32
  if (x < 0 || x >= m_width)
33
    return 0;
33
    return 0;
34
  if (y < 0 || y >= m_height)
34
  if (y < 0 || y >= m_height)
35
    return 0;
35
    return 0;
36
 
36
 
37
  c = c & 0x7F;
-
 
38
  if (c < ' ')
37
  if (c < ' ')
39
    c = ' ';
38
    c = ' ';
-
 
39
  else if (c==0xB0)
-
 
40
    c=128;
40
  if (c >= m_chars + ' ')
41
  else if (c >= m_chars + ' ')
41
    c = ' ';
42
    c = ' ';
42
 
-
 
-
 
43
  // bit offset into pixel row
43
  int xm = x + (c - ' ') * m_width;
44
  int xm = x + (c - ' ') * m_width;
-
 
45
  // row start address : rounding up 
44
  int index = (y * m_width * m_chars + xm) / 8;
46
  int ym = y * (( m_width * m_chars + 7 ) / 8);
-
 
47
  int index = ym +  xm  / 8;
45
  return ((m_data[index]) >> (xm & 7)) & 1;
48
  return ((m_data[index]) >> (xm & 7)) & 1;
46
}
49
}
47
 
50
 
48
static const char font5x7_data[] =
51
static const char font5x7_data[] =
49
    {
52
    {
Line 330... Line 333...
330
333
331
334
332
335
333
336
334
337
335
338
336
339
337
340
338
341
339
342
340
343
341
344
342
345
343
346
344
347
345
348
346
349
347
350
348
351
349
352
350
353
351
354
352
355
353
356
354
357
355
358
356
359
357
360
358
361
359
362
360
363
361
364
362
365
363
366
364
367
365
368
366
369
367
370
368
371
369
372
370
373
371
374
372
375
373
376
374
377
375
378
376
379
377
380
378
381
379
382
380
383
381
384
382
385
383
386
384
387
385
388
386
389
387
390
388
391
389
392
390
393
391
394
392
395
393
396
394
397
395
398
396
399
397
400
398
401
399
402
400
403
401
404
402
405
403
406
404
407
405
408
406
409
407
410
408
411
409
412
410
413
411
414
412
415
413
416
414
417
415
418
416
419
417
420
418
421
419
422
420
423
421
424
422
425
423
426
424
427
425
428
426
429
427
430
428
431
429
432
430
433
431
434
432
435
433
436
434
437
435
438
436
439
437
440
438
441
439
442
440
443
441
444
442
445
443
446
444
447
445
448
446
449
447
450
448
451
449
452
450
453
451
454
452
455
453
456
454
457
455
458
456
459
457
460
458
461
459
462
460
463
461
464
462
465
463
466
464
467
465
468
466
469
467
470
468
471
469
472
470
473
471
474
472
475
473
476
474
477
475
478
476
479
477
480
478
481
479
482
480
483
481
484
482
485
483
486
484
487
485
488
486
489
487
490
488
491
489
492
490
493
491
494
492
495
493
496
494
497
495
498
496
499
497
500
498
501
499
502
500
503
501
504
502
505
503
506
504
507
505
508
506
509
507
510
508
511
509
512
510
513
511
514
512
515
513
516
-
 
517
-
 
518
-
 
519
514
520
515
521
516
522
517
523
518
524