Rev 7 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7 | Rev 9 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | return (width * height / 8); |
15 | return (width * height / 8); |
16 | } |
16 | } |
17 | 17 | ||
18 | enum colour_t |
18 | enum colour_t |
19 | { |
19 | { |
20 | BLACK, /* and 0, invert 0 */ |
20 | BLACK, /* and 0, invert 0 */ |
21 | WHITE, /* and 0, invert 1 */ |
21 | WHITE, /* and 0, invert 1 */ |
22 | OVERLAY, /* and 1, invert 0 */ |
22 | OVERLAY, /* and 1, invert 0 */ |
23 | INVERT, /* and 1, invert 1 */ |
23 | INVERT, /* and 1, invert 1 */ |
24 | }; |
24 | }; |
25 | 25 | ||
26 | class display_t |
26 | class display_t |
27 | { |
27 | { |
28 | public: |
28 | public: |
Line 38... | Line 38... | ||
38 | width (); |
38 | width (); |
39 | int16_t |
39 | int16_t |
40 | height (); |
40 | height (); |
41 | 41 | ||
42 | // common hardware reset . |
42 | // common hardware reset . |
- | 43 | void |
|
43 | void reset(); |
44 | reset (); |
44 | 45 | ||
45 | void |
46 | void |
46 | init (); |
47 | init (); |
47 | 48 | ||
48 | /// \brief Clear display to colour |
49 | /// \brief Clear display to colour |
Line 67... | Line 68... | ||
67 | 68 | ||
68 | void |
69 | void |
69 | dim (uint8_t contrast); |
70 | dim (uint8_t contrast); |
70 | 71 | ||
71 | // set drawing mode |
72 | // set drawing mode |
- | 73 | void |
|
72 | void setPixelMode(colour_t colour) |
74 | setPixelMode (colour_t colour) |
- | 75 | { |
|
73 | { m_colour = colour; } |
76 | m_colour = colour; |
74 | 77 | } |
|
75 | 78 | ||
76 | void |
79 | void |
77 | drawPixel (int16_t x, int16_t y, bool pixel); |
80 | drawPixel (int16_t x, int16_t y, bool pixel); |
78 | 81 | ||
79 | void |
82 | void |
80 | drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
83 | drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
81 | 84 | ||
- | 85 | void |
|
82 | void drawRectangle (int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
86 | drawRectangle (int16_t x1, int16_t y1, int16_t x2, int16_t y2, |
83 | - | ||
- | 87 | colour_t color); |
|
84 | 88 | ||
- | 89 | // position cursor absolute |
|
85 | void |
90 | void |
86 | gotoxy (int x, int y) |
91 | gotoxy (int x, int y) |
87 | { |
92 | { |
88 | m_cursor_x = x; |
93 | m_cursor_x = x; |
89 | m_cursor_y = y; |
94 | m_cursor_y = y; |
90 | } |
95 | } |
- | 96 | ||
- | 97 | // position cursor relative |
|
- | 98 | void |
|
- | 99 | moveby (int x, int y) |
|
91 | ; |
100 | { |
- | 101 | m_cursor_x += x; |
|
- | 102 | m_cursor_y += y; |
|
- | 103 | } |
|
92 | 104 | ||
93 | // pixel to pixel plotting |
105 | // pixel to pixel plotting |
94 | /// \param font The font to use |
106 | /// \param font The font to use |
95 | /// \param string The characters to plot |
107 | /// \param string The characters to plot |
96 | /// \param length The length of the string |
108 | /// \param length The length of the string |
97 | /// \param colour |
109 | /// \param colour |
98 | void |
110 | void |
99 | printString (font_t &font, char const *string, uint16_t length, |
111 | printString (font_t &font, char const *string, uint16_t length, |
100 | colour_t colour=WHITE); |
112 | colour_t colour = WHITE); |
101 | 113 | ||
102 | // scaled plotting |
114 | // scaled plotting |
103 | /// \param font The font to use |
115 | /// \param font The font to use |
104 | /// \param string The characters to plot |
116 | /// \param string The characters to plot |
105 | /// \param length The length of the string |
117 | /// \param length The length of the string |
106 | /// \param scale The scale factor is 256/scale so 256 is 1:1, 128 is twice the size |
118 | /// \param scale The scale factor is 256/scale so 256 is 1:1, 128 is twice the size |
107 | /// \param colour |
119 | /// \param colour |
108 | void |
120 | void |
109 | printScaledString (font_t &font, char const *string, |
121 | printScaledString (font_t &font, char const *string, uint16_t length, |
110 | uint16_t length, uint16_t scale, |
- | |
111 | colour_t colour=WHITE); |
122 | uint16_t scale, colour_t colour = WHITE); |
112 | - | ||
113 | 123 | ||
114 | static const uint8_t NO_DECIMAL = 255; |
124 | static const uint8_t NO_DECIMAL = 255; |
115 | 125 | ||
116 | void |
126 | void |
117 | fontDigits (font_t &font, uint8_t digits, uint8_t dp_pos, int val, colour_t colour=WHITE); |
127 | fontDigits (font_t &font, uint8_t digits, uint8_t dp_pos, int val, |
- | 128 | colour_t colour = WHITE); |
|
118 | 129 | ||
119 | void |
130 | void |
120 | fontSigDigits (font_t &font,uint8_t x, uint8_t y, bool right_justify, uint8_t dp_pos, |
131 | fontSigDigits (font_t &font, uint8_t x, uint8_t y, bool right_justify, |
121 | int val, colour_t colour = WHITE); |
132 | uint8_t dp_pos, int val, colour_t colour = WHITE); |
122 | 133 | ||
123 | int |
134 | int |
124 | cursor_x () |
135 | cursor_x () |
125 | { |
136 | { |
126 | return m_cursor_x; |
137 | return m_cursor_x; |
Line 147... | Line 158... | ||
147 | oledReset () = 0; |
158 | oledReset () = 0; |
148 | 159 | ||
149 | virtual void |
160 | virtual void |
150 | oledWrite (uint8_t *buff, uint8_t len) = 0; |
161 | oledWrite (uint8_t *buff, uint8_t len) = 0; |
151 | 162 | ||
152 | 163 | uint8_t |
|
153 | uint8_t formatNum (char *buff, uint8_t siz, uint8_t digits, uint8_t dp_pos, int val); |
164 | formatNum (char *buff, uint8_t siz, uint8_t digits, uint8_t dp_pos, int val); |
154 | - | ||
155 | 165 | ||
156 | int const m_width; // pixel width |
166 | int const m_width; // pixel width |
157 | int const m_height; // pixel height |
167 | int const m_height; // pixel height |
158 | int const m_ramwidth; // OLED controller ram pixel width |
168 | int const m_ramwidth; // OLED controller ram pixel width |
159 | 169 |