-
Notifications
You must be signed in to change notification settings - Fork 0
/
FontLetter.cpp
140 lines (135 loc) · 7.36 KB
/
FontLetter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <FontLetter.h>
//
// Constant: font8x8_1076
// Contains an 8x8 font map for unicode points U+0020 - U+007F
// Font is rotated to be more easily shifted into 8 bit high NeoPixel
// display 1 column at a time.
//
// Font is rotation of that published by:
// And subsequently mapped to font8x8_basic by:
//
static byte font8x8_1076[98][8] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ' ' 32 0x20
{ 0x00, 0x00, 0x06, 0x5f, 0x5f, 0x06, 0x00, 0x00 }, // '!' 33 0x21
{ 0x00, 0x03, 0x03, 0x00, 0x03, 0x03, 0x00, 0x00 }, // '"' 34 0x22
{ 0x14, 0x7f, 0x7f, 0x14, 0x7f, 0x7f, 0x14, 0x00 }, // '#' 35 0x23
{ 0x24, 0x2e, 0x6b, 0x6b, 0x3a, 0x12, 0x00, 0x00 }, // '$' 36 0x24
{ 0x46, 0x66, 0x30, 0x18, 0x0c, 0x66, 0x62, 0x00 }, // '%' 37 0x25
{ 0x30, 0x7a, 0x4f, 0x5d, 0x37, 0x7a, 0x48, 0x00 }, // '&' 38 0x26
{ 0x04, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ''' 39 0x27
{ 0x00, 0x1c, 0x3e, 0x63, 0x41, 0x00, 0x00, 0x00 }, // '(' 40 0x28
{ 0x00, 0x41, 0x63, 0x3e, 0x1c, 0x00, 0x00, 0x00 }, // ')' 41 0x29
{ 0x08, 0x2a, 0x3e, 0x1c, 0x1c, 0x3e, 0x2a, 0x08 }, // '*' 42 0x2a
{ 0x08, 0x08, 0x3e, 0x3e, 0x08, 0x08, 0x00, 0x00 }, // '+' 43 0x2b
{ 0x00, 0x80, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x00 }, // ',' 44 0x2c
{ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00 }, // '-' 45 0x2d
{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00 }, // '.' 46 0x2e
{ 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x01, 0x00 }, // '/' 47 0x2f
{ 0x3e, 0x7f, 0x71, 0x59, 0x4d, 0x7f, 0x3e, 0x00 }, // '0' 48 0x30
{ 0x40, 0x42, 0x7f, 0x7f, 0x40, 0x40, 0x00, 0x00 }, // '1' 49 0x31
{ 0x62, 0x73, 0x59, 0x49, 0x6f, 0x66, 0x00, 0x00 }, // '2' 50 0x32
{ 0x22, 0x63, 0x49, 0x49, 0x7f, 0x36, 0x00, 0x00 }, // '3' 51 0x33
{ 0x18, 0x1c, 0x16, 0x53, 0x7f, 0x7f, 0x50, 0x00 }, // '4' 52 0x34
{ 0x27, 0x67, 0x45, 0x45, 0x7d, 0x39, 0x00, 0x00 }, // '5' 53 0x35
{ 0x3c, 0x7e, 0x4b, 0x49, 0x79, 0x30, 0x00, 0x00 }, // '6' 54 0x36
{ 0x03, 0x03, 0x71, 0x79, 0x0f, 0x07, 0x00, 0x00 }, // '7' 55 0x37
{ 0x36, 0x7f, 0x49, 0x49, 0x7f, 0x36, 0x00, 0x00 }, // '8' 56 0x38
{ 0x06, 0x4f, 0x49, 0x69, 0x3f, 0x1e, 0x00, 0x00 }, // '9' 57 0x39
{ 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 }, // ':' 58 0x3a
{ 0x00, 0x80, 0xe6, 0x66, 0x00, 0x00, 0x00, 0x00 }, // ';' 59 0x3b
{ 0x08, 0x1c, 0x36, 0x63, 0x41, 0x00, 0x00, 0x00 }, // '<' 60 0x3c
{ 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x00 }, // '=' 61 0x3d
{ 0x00, 0x41, 0x63, 0x36, 0x1c, 0x08, 0x00, 0x00 }, // '>' 62 0x3e
{ 0x02, 0x03, 0x51, 0x59, 0x0f, 0x06, 0x00, 0x00 }, // '?' 63 0x3f
{ 0x3e, 0x7f, 0x41, 0x5d, 0x5d, 0x1f, 0x1e, 0x00 }, // '@' 64 0x40
{ 0x7c, 0x7e, 0x13, 0x13, 0x7e, 0x7c, 0x00, 0x00 }, // 'A' 65 0x41
{ 0x41, 0x7f, 0x7f, 0x49, 0x49, 0x7f, 0x36, 0x00 }, // 'B' 66 0x42
{ 0x1c, 0x3e, 0x63, 0x41, 0x41, 0x63, 0x22, 0x00 }, // 'C' 67 0x43
{ 0x41, 0x7f, 0x7f, 0x41, 0x63, 0x3e, 0x1c, 0x00 }, // 'D' 68 0x44
{ 0x41, 0x7f, 0x7f, 0x49, 0x5d, 0x41, 0x63, 0x00 }, // 'E' 69 0x45
{ 0x41, 0x7f, 0x7f, 0x49, 0x1d, 0x01, 0x03, 0x00 }, // 'F' 70 0x46
{ 0x1c, 0x3e, 0x63, 0x41, 0x51, 0x73, 0x72, 0x00 }, // 'G' 71 0x47
{ 0x7f, 0x7f, 0x08, 0x08, 0x7f, 0x7f, 0x00, 0x00 }, // 'H' 72 0x48
{ 0x00, 0x41, 0x7f, 0x7f, 0x41, 0x00, 0x00, 0x00 }, // 'I' 73 0x49
{ 0x30, 0x70, 0x40, 0x41, 0x7f, 0x3f, 0x01, 0x00 }, // 'J' 74 0x4a
{ 0x41, 0x7f, 0x7f, 0x08, 0x1c, 0x77, 0x63, 0x00 }, // 'K' 75 0x4b
{ 0x41, 0x7f, 0x7f, 0x41, 0x40, 0x60, 0x70, 0x00 }, // 'L' 76 0x4c
{ 0x7f, 0x7f, 0x0e, 0x1c, 0x0e, 0x7f, 0x7f, 0x00 }, // 'M' 77 0x4d
{ 0x7f, 0x7f, 0x06, 0x0c, 0x18, 0x7f, 0x7f, 0x00 }, // 'N' 78 0x4e
{ 0x1c, 0x3e, 0x63, 0x41, 0x63, 0x3e, 0x1c, 0x00 }, // 'O' 79 0x4f
{ 0x41, 0x7f, 0x7f, 0x49, 0x09, 0x0f, 0x06, 0x00 }, // 'P' 80 0x50
{ 0x1e, 0x3f, 0x21, 0x71, 0x7f, 0x5e, 0x00, 0x00 }, // 'Q' 81 0x51
{ 0x41, 0x7f, 0x7f, 0x09, 0x19, 0x7f, 0x66, 0x00 }, // 'R' 82 0x52
{ 0x26, 0x6f, 0x4d, 0x59, 0x73, 0x32, 0x00, 0x00 }, // 'S' 83 0x53
{ 0x03, 0x41, 0x7f, 0x7f, 0x41, 0x03, 0x00, 0x00 }, // 'T' 84 0x54
{ 0x7f, 0x7f, 0x40, 0x40, 0x7f, 0x7f, 0x00, 0x00 }, // 'U' 85 0x55
{ 0x1f, 0x3f, 0x60, 0x60, 0x3f, 0x1f, 0x00, 0x00 }, // 'V' 86 0x56
{ 0x7f, 0x7f, 0x30, 0x18, 0x30, 0x7f, 0x7f, 0x00 }, // 'W' 87 0x57
{ 0x43, 0x67, 0x3c, 0x18, 0x3c, 0x67, 0x43, 0x00 }, // 'X' 88 0x58
{ 0x07, 0x4f, 0x78, 0x78, 0x4f, 0x07, 0x00, 0x00 }, // 'Y' 89 0x59
{ 0x47, 0x63, 0x71, 0x59, 0x4d, 0x67, 0x73, 0x00 }, // 'Z' 90 0x5a
{ 0x00, 0x7f, 0x7f, 0x41, 0x41, 0x00, 0x00, 0x00 }, // '[' 91 0x5b
{ 0x01, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00 }, // '\' 92 0x5c
{ 0x00, 0x41, 0x41, 0x7f, 0x7f, 0x00, 0x00, 0x00 }, // ']' 93 0x5d
{ 0x08, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x08, 0x00 }, // '^' 94 0x5e
{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, // '_' 95 0x5f
{ 0x00, 0x00, 0x03, 0x07, 0x04, 0x00, 0x00, 0x00 }, // '`' 96 0x60
{ 0x20, 0x74, 0x54, 0x54, 0x3c, 0x78, 0x40, 0x00 }, // 'a' 97 0x61
{ 0x41, 0x7f, 0x3f, 0x48, 0x48, 0x78, 0x30, 0x00 }, // 'b' 98 0x62
{ 0x38, 0x7c, 0x44, 0x44, 0x6c, 0x28, 0x00, 0x00 }, // 'c' 99 0x63
{ 0x30, 0x78, 0x48, 0x49, 0x3f, 0x7f, 0x40, 0x00 }, // 'd' 100 0x64
{ 0x38, 0x7c, 0x54, 0x54, 0x5c, 0x18, 0x00, 0x00 }, // 'e' 101 0x65
{ 0x48, 0x7e, 0x7f, 0x49, 0x03, 0x02, 0x00, 0x00 }, // 'f' 102 0x66
{ 0x98, 0xbc, 0xa4, 0xa4, 0xf8, 0x7c, 0x04, 0x00 }, // 'g' 103 0x67
{ 0x41, 0x7f, 0x7f, 0x08, 0x04, 0x7c, 0x78, 0x00 }, // 'h' 104 0x68
{ 0x00, 0x44, 0x7d, 0x7d, 0x40, 0x00, 0x00, 0x00 }, // 'i' 105 0x69
{ 0x60, 0xe0, 0x80, 0x80, 0xfd, 0x7d, 0x00, 0x00 }, // 'j' 106 0x6a
{ 0x41, 0x7f, 0x7f, 0x10, 0x38, 0x6c, 0x44, 0x00 }, // 'k' 107 0x6b
{ 0x00, 0x41, 0x7f, 0x7f, 0x40, 0x00, 0x00, 0x00 }, // 'l' 108 0x6c
{ 0x7c, 0x7c, 0x18, 0x38, 0x1c, 0x7c, 0x78, 0x00 }, // 'm' 109 0x6d
{ 0x7c, 0x7c, 0x04, 0x04, 0x7c, 0x78, 0x00, 0x00 }, // 'n' 110 0x6e
{ 0x38, 0x7c, 0x44, 0x44, 0x7c, 0x38, 0x00, 0x00 }, // 'o' 111 0x6f
{ 0x84, 0xfc, 0xf8, 0xa4, 0x24, 0x3c, 0x18, 0x00 }, // 'p' 112 0x70
{ 0x18, 0x3c, 0x24, 0xa4, 0xf8, 0xfc, 0x84, 0x00 }, // 'q' 113 0x71
{ 0x44, 0x7c, 0x78, 0x4c, 0x04, 0x1c, 0x18, 0x00 }, // 'r' 114 0x72
{ 0x48, 0x5c, 0x54, 0x54, 0x74, 0x24, 0x00, 0x00 }, // 's' 115 0x73
{ 0x00, 0x04, 0x3e, 0x7f, 0x44, 0x24, 0x00, 0x00 }, // 't' 116 0x74
{ 0x3c, 0x7c, 0x40, 0x40, 0x3c, 0x7c, 0x40, 0x00 }, // 'u' 117 0x75
{ 0x1c, 0x3c, 0x60, 0x60, 0x3c, 0x1c, 0x00, 0x00 }, // 'v' 118 0x76
{ 0x3c, 0x7c, 0x70, 0x38, 0x70, 0x7c, 0x3c, 0x00 }, // 'w' 119 0x77
{ 0x44, 0x6c, 0x38, 0x10, 0x38, 0x6c, 0x44, 0x00 }, // 'x' 120 0x78
{ 0x9c, 0xbc, 0xa0, 0xa0, 0xfc, 0x7c, 0x00, 0x00 }, // 'y' 121 0x79
{ 0x4c, 0x64, 0x74, 0x5c, 0x4c, 0x64, 0x00, 0x00 }, // 'z' 122 0x7a
{ 0x08, 0x08, 0x3e, 0x77, 0x41, 0x41, 0x00, 0x00 }, // '{' 123 0x7b
{ 0x00, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00, 0x00 }, // '|' 124 0x7c
{ 0x41, 0x41, 0x77, 0x3e, 0x08, 0x08, 0x00, 0x00 }, // '}' 125 0x7d
{ 0x02, 0x03, 0x01, 0x03, 0x02, 0x03, 0x01, 0x00 }, // '~' 126 0x7e
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } // '' 127 0x7f
};
FontLetter::FontLetter(char c) : _letter(c), _size(8) {
_columns = font8x8_1076[c - ' '];
_column_iter = NULL;
}
uint8_t
FontLetter::size() {
return _size;
}
/* access the columns by index */
byte
FontLetter::column(byte index) {
return _columns[index];
}
byte *
FontLetter::first_column() {
_column_iter = _columns;
return _column_iter;
}
byte *
FontLetter::next_column() {
if (_column_iter >= _columns+_size-1) {
_column_iter = NULL;
} else {
_column_iter++;
}
return _column_iter;
}