Simple single-color 8x8x8 LED Cube with AVRs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

font.c 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * font.c
  3. *
  4. * Copyright 2012 Thomas Buck <xythobuz@me.com>
  5. *
  6. * This file is part of LED-Cube.
  7. *
  8. * LED-Cube is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * LED-Cube is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <stdint.h>
  22. #include <avr/io.h>
  23. #include <avr/pgmspace.h>
  24. uint8_t font[95][8];
  25. uint8_t fontBuff[8];
  26. uint8_t *getFont(char c) {
  27. uint8_t i;
  28. if (!((c >= 0x20) && (c <= 0x7E))) {
  29. if ((c == '\r') || (c == '\n')) {
  30. c = '!';
  31. } else {
  32. c = '?';
  33. }
  34. }
  35. for (i = 0; i < 8; i++) {
  36. fontBuff[i] = pgm_read_byte(&(font[(uint8_t)(c - 0x20)][i]));
  37. }
  38. return fontBuff;
  39. }
  40. // Source: http://www.mikrocontroller.net/topic/54860
  41. // Author: Benedikt K
  42. // This is a LCD Font originally for Codepage 850.
  43. // Because of size restraints, i cut everything but
  44. // the printable ascii range, 0x20 to 0x7E
  45. // Not really pretty on the cube, but enough for now.
  46. uint8_t font[95][8] PROGMEM = {
  47. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20
  48. {0x0C,0x1E,0x1E,0x0C,0x0C,0x00,0x0C,0x00}, // 0x21
  49. {0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00}, // 0x22
  50. {0x36,0x36,0x7F,0x36,0x7F,0x36,0x36,0x00}, // 0x23
  51. {0x0C,0x3E,0x03,0x1E,0x30,0x1F,0x0C,0x00}, // 0x24
  52. {0x00,0x63,0x33,0x18,0x0C,0x66,0x63,0x00}, // 0x25
  53. {0x1C,0x36,0x1C,0x6E,0x3B,0x33,0x6E,0x00}, // 0x26
  54. {0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00}, // 0x27
  55. {0x18,0x0C,0x06,0x06,0x06,0x0C,0x18,0x00}, // 0x28
  56. {0x06,0x0C,0x18,0x18,0x18,0x0C,0x06,0x00}, // 0x29
  57. {0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00}, // 0x2A
  58. {0x00,0x0C,0x0C,0x3F,0x0C,0x0C,0x00,0x00}, // 0x2B
  59. {0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06}, // 0x2C
  60. {0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0x2D
  61. {0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00}, // 0x2E
  62. {0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00}, // 0x2F
  63. {0x1E,0x33,0x3B,0x3F,0x37,0x33,0x1E,0x00}, // 0x30
  64. {0x0C,0x0F,0x0C,0x0C,0x0C,0x0C,0x3F,0x00}, // 0x31
  65. {0x1E,0x33,0x30,0x1C,0x06,0x33,0x3F,0x00}, // 0x32
  66. {0x1E,0x33,0x30,0x1C,0x30,0x33,0x1E,0x00}, // 0x33
  67. {0x38,0x3C,0x36,0x33,0x7F,0x30,0x30,0x00}, // 0x34
  68. {0x3F,0x03,0x1F,0x30,0x30,0x33,0x1E,0x00}, // 0x35
  69. {0x1C,0x06,0x03,0x1F,0x33,0x33,0x1E,0x00}, // 0x36
  70. {0x3F,0x33,0x30,0x18,0x0C,0x06,0x06,0x00}, // 0x37
  71. {0x1E,0x33,0x33,0x1E,0x33,0x33,0x1E,0x00}, // 0x38
  72. {0x1E,0x33,0x33,0x3E,0x30,0x18,0x0E,0x00}, // 0x39
  73. {0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00}, // 0x3A
  74. {0x00,0x00,0x0C,0x0C,0x00,0x0E,0x0C,0x06}, // 0x3B
  75. {0x18,0x0C,0x06,0x03,0x06,0x0C,0x18,0x00}, // 0x3C
  76. {0x00,0x00,0x3F,0x00,0x3F,0x00,0x00,0x00}, // 0x3D
  77. {0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00}, // 0x3E
  78. {0x1E,0x33,0x30,0x18,0x0C,0x00,0x0C,0x00}, // 0x3F
  79. {0x3E,0x63,0x7B,0x7B,0x7B,0x03,0x1E,0x00}, // 0x40
  80. {0x0C,0x1E,0x33,0x33,0x3F,0x33,0x33,0x00}, // 0x41
  81. {0x3F,0x66,0x66,0x3E,0x66,0x66,0x3F,0x00}, // 0x42
  82. {0x3C,0x66,0x03,0x03,0x03,0x66,0x3C,0x00}, // 0x43
  83. {0x3F,0x36,0x66,0x66,0x66,0x36,0x3F,0x00}, // 0x44
  84. {0x7F,0x46,0x16,0x1E,0x16,0x46,0x7F,0x00}, // 0x45
  85. {0x7F,0x46,0x16,0x1E,0x16,0x06,0x0F,0x00}, // 0x46
  86. {0x3C,0x66,0x03,0x03,0x73,0x66,0x7C,0x00}, // 0x47
  87. {0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x00}, // 0x48
  88. {0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00}, // 0x49
  89. {0x78,0x30,0x30,0x30,0x33,0x33,0x1E,0x00}, // 0x4A
  90. {0x67,0x66,0x36,0x1E,0x36,0x66,0x67,0x00}, // 0x4B
  91. {0x0F,0x06,0x06,0x06,0x46,0x66,0x7F,0x00}, // 0x4C
  92. {0x63,0x77,0x7F,0x6B,0x63,0x63,0x63,0x00}, // 0x4D
  93. {0x63,0x67,0x6F,0x7B,0x73,0x63,0x63,0x00}, // 0x4E
  94. {0x1C,0x36,0x63,0x63,0x63,0x36,0x1C,0x00}, // 0x4F
  95. {0x3F,0x66,0x66,0x3E,0x06,0x06,0x0F,0x00}, // 0x50
  96. {0x1E,0x33,0x33,0x33,0x3B,0x1E,0x38,0x00}, // 0x51
  97. {0x3F,0x66,0x66,0x3E,0x1E,0x36,0x67,0x00}, // 0x52
  98. {0x1E,0x33,0x07,0x1C,0x38,0x33,0x1E,0x00}, // 0x53
  99. {0x3F,0x2D,0x0C,0x0C,0x0C,0x0C,0x1E,0x00}, // 0x54
  100. {0x33,0x33,0x33,0x33,0x33,0x33,0x3F,0x00}, // 0x55
  101. {0x33,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00}, // 0x56
  102. {0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00}, // 0x57
  103. {0x63,0x63,0x36,0x1C,0x36,0x63,0x63,0x00}, // 0x58
  104. {0x33,0x33,0x33,0x1E,0x0C,0x0C,0x1E,0x00}, // 0x59
  105. {0x7F,0x33,0x19,0x0C,0x46,0x63,0x7F,0x00}, // 0x5A
  106. {0x1E,0x06,0x06,0x06,0x06,0x06,0x1E,0x00}, // 0x5B
  107. {0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00}, // 0x5C
  108. {0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00}, // 0x5D
  109. {0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00}, // 0x5E
  110. {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF}, // 0x5F
  111. {0x0C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00}, // 0x60
  112. {0x00,0x00,0x1E,0x30,0x3E,0x33,0x6E,0x00}, // 0x61
  113. {0x07,0x06,0x3E,0x66,0x66,0x66,0x3D,0x00}, // 0x62
  114. {0x00,0x00,0x1E,0x33,0x03,0x33,0x1E,0x00}, // 0x63
  115. {0x38,0x30,0x30,0x3E,0x33,0x33,0x6E,0x00}, // 0x64
  116. {0x00,0x00,0x1E,0x33,0x3F,0x03,0x1E,0x00}, // 0x65
  117. {0x1C,0x36,0x06,0x0F,0x06,0x06,0x0F,0x00}, // 0x66
  118. {0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x1F}, // 0x67
  119. {0x07,0x06,0x36,0x6E,0x66,0x66,0x67,0x00}, // 0x68
  120. {0x0C,0x00,0x0E,0x0C,0x0C,0x0C,0x1E,0x00}, // 0x69
  121. {0x18,0x00,0x1E,0x18,0x18,0x18,0x1B,0x0E}, // 0x6A
  122. {0x07,0x06,0x66,0x36,0x1E,0x36,0x67,0x00}, // 0x6B
  123. {0x0E,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00}, // 0x6C
  124. {0x00,0x00,0x37,0x7F,0x6B,0x63,0x63,0x00}, // 0x6D
  125. {0x00,0x00,0x1F,0x33,0x33,0x33,0x33,0x00}, // 0x6E
  126. {0x00,0x00,0x1E,0x33,0x33,0x33,0x1E,0x00}, // 0x6F
  127. {0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F}, // 0x70
  128. {0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78}, // 0x71
  129. {0x00,0x00,0x1B,0x36,0x36,0x06,0x0F,0x00}, // 0x72
  130. {0x00,0x00,0x3E,0x03,0x1E,0x30,0x1F,0x00}, // 0x73
  131. {0x08,0x0C,0x3E,0x0C,0x0C,0x2C,0x18,0x00}, // 0x74
  132. {0x00,0x00,0x33,0x33,0x33,0x33,0x6E,0x00}, // 0x75
  133. {0x00,0x00,0x33,0x33,0x33,0x1E,0x0C,0x00}, // 0x76
  134. {0x00,0x00,0x63,0x63,0x6B,0x7F,0x36,0x00}, // 0x77
  135. {0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00}, // 0x78
  136. {0x00,0x00,0x33,0x33,0x33,0x3E,0x30,0x1F}, // 0x79
  137. {0x00,0x00,0x3F,0x19,0x0C,0x26,0x3F,0x00}, // 0x7A
  138. {0x38,0x0C,0x0C,0x07,0x0C,0x0C,0x38,0x00}, // 0x7B
  139. {0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00}, // 0x7C
  140. {0x07,0x0C,0x0C,0x38,0x0C,0x0C,0x07,0x00}, // 0x7D
  141. {0x6E,0x3B,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7E
  142. };