Rev 2 | Rev 4 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 3 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | * Author: mike |
5 | * Author: mike |
6 | */ |
6 | */ |
7 | #include "libOLED/fontclass.H" |
7 | #include "libOLED/fontclass.H" |
8 | 8 | ||
9 | char |
9 | char |
10 | font5x7_t::get_pixel (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 | - | ||
17 | unsigned char pixels = 0; |
16 | unsigned char pixels = 0; |
18 | if (c < ' ') |
17 | if (c < ' ') |
19 | c = ' '; |
18 | c = ' '; |
20 | - | ||
21 | if (c >= ' ' && c <= 0x7f) |
19 | if (c >= ' ' && c <= 0x7f) |
22 | pixels = m_data[(c - ' ') * m_width + x]; |
20 | pixels = m_data[(c - ' ') * m_width + x]; |
23 | if (c == '°') |
21 | if (c == '°') |
24 | pixels = m_data[0x80 * m_width + x]; |
22 | pixels = m_data[0x80 * m_width + x]; |
25 | 23 | ||
26 | return pixels & (1 << (m_height - y)) ? 1 : 0; |
24 | char v= (pixels >> y) & 1; |
27 | 25 | return v; |
|
28 | } |
26 | } |
29 | 27 | ||
30 | char |
28 | char |
31 | font10x18_t::get_pixel (char c, int x, int y) |
29 | font10x18_t::getPixel (char c, int x, int y) |
32 | { |
30 | { |
33 | if (x < 0 || x > m_width) |
31 | if (x<0 || x>m_width) |
34 | return 0; |
32 | return 0; |
35 | if (y > 0 || y > m_height) |
33 | if (y<0 || y>m_height) |
36 | return 0; |
34 | return 0; |
- | 35 | ||
37 | c = c & 0x7F; |
36 | c = c & 0x7F; |
38 | if (c < ' ') |
37 | if (c < ' ') |
39 | c = ' '; |
38 | c = ' '; |
40 | 39 | ||
41 | int xm = x + (c - 32) * m_width; |
40 | int xm = x + (c - 32) * m_width; |
42 | 41 | ||
43 | return ((m_data[(y * m_width) / 8 + (xm / 8)]) >> (xm & 7)) & 1; |
42 | return ((m_data[(y * m_width) / 8 + (xm / 8)]) >> (xm & 7)) & 1; |
44 | 43 | ||
45 | } |
44 | } |
46 | 45 | ||
47 | static const char font5x7_data[] = |
46 | static const char font5x7_data[] = |
48 | { 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 32 |
47 | { 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 32 |