Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 4 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | #include "libOLED/fontclass.H" |
7 | #include "libOLED/fontclass.H" |
8 | 8 | ||
9 | char |
9 | char |
10 | font5x7_t::getPixel (char c, int x, int y) |
10 | font5x7_t::getPixel (char c, int x, int y) |
11 | { |
11 | { |
12 | if (x<0 || x>m_width) |
12 | if (x < 0 || x >= m_width) |
13 | return 0; |
13 | return 0; |
14 | if (y<0 || y>m_height) |
14 | if (y < 0 || y >= m_height) |
15 | return 0; |
15 | return 0; |
16 | unsigned char pixels = 0; |
16 | uint8_t pixels = 0; |
17 | if (c < ' ') |
17 | if (c < ' ') |
18 | c = ' '; |
18 | c = ' '; |
19 | if (c >= ' ' && c <= 0x7f) |
19 | if (c >= ' ' && c <= 0x7f) |
20 | pixels = m_data[(c - ' ') * m_width + x]; |
20 | pixels = m_data[(c - ' ') * m_width + x]; |
21 | if (c == '°') |
21 | if (c == '°') |
22 | pixels = m_data[0x80 * m_width + x]; |
22 | pixels = m_data[0x80 * m_width + x]; |
23 | 23 | ||
24 | char v= (pixels >> y) & 1; |
24 | char v = (pixels >> y) & 1; |
25 | return v; |
25 | return v; |
26 | } |
26 | } |
27 | 27 | ||
28 | char |
28 | char |
29 | font10x18_t::getPixel (char c, int x, int y) |
29 | font10x18_t::getPixel (char c, int x, int y) |
30 | { |
30 | { |
31 | if (x<0 || x>m_width) |
31 | if (x < 0 || x >= m_width) |
32 | return 0; |
32 | return 0; |
33 | if (y<0 || y>m_height) |
33 | if (y < 0 || y >= m_height) |
34 | return 0; |
34 | return 0; |
35 | 35 | ||
36 | c = c & 0x7F; |
36 | c = c & 0x7F; |
37 | if (c < ' ') |
37 | if (c < ' ') |
38 | c = ' '; |
38 | c = ' '; |
- | 39 | if (c >= m_chars) |
|
- | 40 | c = ' '; |
|
39 | 41 | ||
40 | int xm = x + (c - 32) * m_width; |
42 | int xm = x + (c - 32) * m_width; |
41 | - | ||
- | 43 | int index = (y * m_width * m_chars + xm) / 8; |
|
42 | return ((m_data[(y * m_width) / 8 + (xm / 8)]) >> (xm & 7)) & 1; |
44 | return ((m_data[index]) >> (xm & 7)) & 1; |
43 | 45 | ||
44 | } |
46 | } |
45 | 47 | ||
46 | static const char font5x7_data[] = |
48 | static const char font5x7_data[] = |
47 | { 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 32 |
49 | { 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 32 |
Line 141... | Line 143... | ||
141 | 0x08, 0x0c, 0x08, 0x18, 0x08, // ~ 0x7e 126 |
143 | 0x08, 0x0c, 0x08, 0x18, 0x08, // ~ 0x7e 126 |
142 | 0x55, 0x2A, 0x55, 0x2A, 0x55, // 0x7F 127 |
144 | 0x55, 0x2A, 0x55, 0x2A, 0x55, // 0x7F 127 |
143 | 0x00, 0x06, 0x09, 0x06, 0x00, // 0x80 (remapped in code) a ° sign |
145 | 0x00, 0x06, 0x09, 0x06, 0x00, // 0x80 (remapped in code) a ° sign |
144 | 146 | ||
145 | 147 | ||
146 | - | ||
147 | 148 | ||
148 | 149 | ||
149 | 150 | ||
150 | 151 | ||
151 | 152 | ||
Line 324... | Line 325... | ||
324 | 325 | ||
325 | 326 | ||
326 | 327 | ||
327 | 328 | ||
328 | 329 | ||
329 | - | ||
330 | 330 | ||
331 | 331 | ||
332 | 332 |