Rev 5 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 5 | Rev 7 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | 2 | ||
| 3 | void |
3 | void |
| 4 | display_t::printString (font_t &font, char const *string, uint16_t length, |
4 | display_t::printString (font_t &font, char const *string, uint16_t length, |
| 5 | colour_t colour) |
5 | colour_t colour) |
| 6 | { |
6 | { |
| - | 7 | setPixelMode(colour); |
|
| 7 | uint16_t const xSpacing = font.width () + 1; |
8 | uint16_t const xSpacing = font.width () + 1; |
| 8 | for (uint16_t yt = 0; yt < font.height (); yt++) // iterate down scan lines |
9 | for (uint16_t yt = 0; yt < font.height (); yt++) // iterate down scan lines |
| 9 | { |
10 | { |
| 10 | uint16_t ys = m_cursor_y + yt; |
11 | uint16_t ys = m_cursor_y + yt; |
| 11 | for (uint16_t xt = 0; xt < length; xt++) |
12 | for (uint16_t xt = 0; xt < length; xt++) |
| 12 | { |
13 | { |
| 13 | unsigned char c = string[xt]; |
14 | unsigned char c = string[xt]; |
| 14 | uint16_t xs = xt * xSpacing + m_cursor_x; |
15 | uint16_t xs = xt * xSpacing + m_cursor_x; |
| 15 | for (uint16_t j = 0; j < font.spacing (); j++) |
16 | for (uint16_t j = 0; j < font.spacing (); j++) |
| 16 | { |
17 | { |
| 17 | if (font.getPixel (c, j, yt) != 0) |
18 | drawPixel (j + xs, ys, font.getPixel (c, j, yt)); |
| 18 | drawPixel (j + xs, ys, colour); |
- | |
| 19 | } |
19 | } |
| 20 | } |
20 | } |
| 21 | } |
21 | } |
| 22 | // move the cursor. |
22 | // move the cursor. |
| 23 | m_cursor_x += xSpacing * length; |
23 | m_cursor_x += xSpacing * length; |
| Line 31... | Line 31... | ||
| 31 | { |
31 | { |
| 32 | uint16_t xt, yt, jt, curr_x=0; |
32 | uint16_t xt, yt, jt, curr_x=0; |
| 33 | uint16_t curr_y = m_cursor_y; |
33 | uint16_t curr_y = m_cursor_y; |
| 34 | if (scale < 1) |
34 | if (scale < 1) |
| 35 | return; |
35 | return; |
| - | 36 | setPixelMode(colour); |
|
| - | 37 | ||
| 36 | for (yt = 0; yt < font.height () * 256; yt += scale) // iterate down scan lines |
38 | for (yt = 0; yt < font.height () * 256; yt += scale) // iterate down scan lines |
| 37 | { |
39 | { |
| 38 | // iterate along the string |
40 | // iterate along the string |
| 39 | // local x plotting coordinate |
41 | // local x plotting coordinate |
| 40 | curr_x = m_cursor_x; |
42 | curr_x = m_cursor_x; |
| 41 | for (xt = 0; xt < length; xt++) |
43 | for (xt = 0; xt < length; xt++) |
| 42 | { |
44 | { |
| 43 | for (jt = 0; jt < (font.spacing ()) * 256; jt += scale) |
45 | for (jt = 0; jt < (font.spacing ()) * 256; jt += scale) |
| 44 | { |
46 | { |
| 45 | unsigned char c = (string[xt]); |
47 | unsigned char c = (string[xt]); |
| 46 | if (font.getPixel (c, jt / 256, yt / 256)) |
48 | drawPixel (curr_x, curr_y, font.getPixel (c, jt / 256, yt / 256)); |
| 47 | drawPixel (curr_x, curr_y, colour); |
- | |
| 48 | curr_x++; |
49 | curr_x++; |
| 49 | } |
50 | } |
| 50 | } |
51 | } |
| 51 | curr_y++; |
52 | curr_y++; |
| 52 | } |
53 | } |
| Line 58... | Line 59... | ||
| 58 | } |
59 | } |
| 59 | 60 | ||
| 60 | uint8_t |
61 | uint8_t |
| 61 | display_t::formatNum (char *buff, uint8_t siz, uint8_t digits, uint8_t dp_pos, int val) |
62 | display_t::formatNum (char *buff, uint8_t siz, uint8_t digits, uint8_t dp_pos, int val) |
| 62 | { |
63 | { |
| - | 64 | if(dp_pos != NO_DECIMAL) |
|
| 63 | digits++; |
65 | digits++; |
| 64 | uint8_t pos = digits; |
66 | uint8_t pos = digits; |
| 65 | uint8_t dp_loc = pos - dp_pos; |
67 | uint8_t dp_loc = pos - dp_pos; |
| 66 | uint8_t sign = 0; |
68 | uint8_t sign = 0; |
| 67 | if (val < 0) |
69 | if (val < 0) |
| Line 91... | Line 93... | ||
| 91 | } |
93 | } |
| 92 | return digits; |
94 | return digits; |
| 93 | } |
95 | } |
| 94 | 96 | ||
| 95 | void |
97 | void |
| 96 | display_t::fontDigits (font_t &font, uint8_t digits, uint8_t dp_pos, int val) |
98 | display_t::fontDigits (font_t &font, uint8_t digits, uint8_t dp_pos, int val, colour_t colour) |
| 97 | { |
99 | { |
| 98 | char buff[10] = " "; |
100 | char buff[10] = " "; |
| 99 | uint8_t wid = formatNum (buff, sizeof(buff), digits, dp_pos, val); |
101 | uint8_t wid = formatNum (buff, sizeof(buff), digits, dp_pos, val); |
| 100 | printString (font, buff, wid, WHITE ); |
102 | printString (font, buff, wid, colour ); |
| 101 | } |
103 | } |
| 102 | 104 | ||
| 103 | void |
105 | void |
| 104 | display_t::fontSigDigits (font_t &font,uint8_t x, uint8_t y, bool right_justify, uint8_t dp_pos, |
106 | display_t::fontSigDigits (font_t &font,uint8_t x, uint8_t y, bool right_justify, uint8_t dp_pos, |
| 105 | int val) |
107 | int val, colour_t colour) |
| 106 | { |
108 | { |
| 107 | char digits; |
109 | char digits; |
| 108 | char sign = 0; |
110 | char sign = 0; |
| 109 | int uval; |
111 | int uval; |
| 110 | if (val < 0) |
112 | if (val < 0) |
| Line 145... | Line 147... | ||
| 145 | } |
147 | } |
| 146 | x -= digits * font.spacing(); |
148 | x -= digits * font.spacing(); |
| 147 | } |
149 | } |
| 148 | 150 | ||
| 149 | gotoxy (x, y); |
151 | gotoxy (x, y); |
| 150 | fontDigits (font, digits, dp_pos, val); |
152 | fontDigits (font, digits, dp_pos, val,colour); |
| 151 | } |
153 | } |
| 152 | 154 | ||
| 153 | 155 | ||