Tue, 11 Oct 2016 00:46:18 +0200
use only one USART
with a front "AND" gate to combine both serial lines
5 | 1 | /* mbed UniGraphic library - Device specific class |
2 | * Copyright (c) 2015 Peter Drescher | |
3 | * Released under the MIT License: http://mbed.org/license/mit | |
4 | */ | |
5 | ||
6 | #include "platform.h" | |
7 | #include "SSD1322.h" | |
8 | ||
9 | ////////////////////////////////////////////////////////////////////////////////// | |
10 | // display settings /////////////////////////////////////////////////////// | |
11 | ///////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #define IC_X_SEGS 480 // SSD1322 SEG has range 0-479 (479-0 if MX=1), check your datasheet, important for the orientation | |
14 | #define IC_Y_COMS 128 // SSD1322 COM has range 0-127 (127-0 if MY=1), check your datasheet, important for the orientation | |
15 | #define BPP 4 // SSD1322 has 16 gray levels | |
16 | ||
17 | #define SSD1322_CMD_ENABLE_GRAY_SCALE_TABLE 0x00 | |
18 | #define SSD1322_CMD_SET_COLUMN_ADDR 0x15 | |
19 | #define SSD1322_CMD_WRITE_RAM 0x5C | |
20 | #define SSD1322_CMD_READ_RAM 0x5D | |
21 | #define SSD1322_CMD_SET_ROW_ADDR 0x75 | |
22 | #define SSD1322_CMD_SET_REMAP 0xA0 | |
23 | #define SSD1322_CMD_SET_DISPLAY_START_LINE 0xA1 | |
24 | #define SSD1322_CMD_SET_DISPLAY_OFFSET 0xA2 | |
25 | #define SSD1322_CMD_SET_DISPLAY_MODE_OFF 0xA4 | |
26 | #define SSD1322_CMD_SET_DISPLAY_MODE_ON 0xA5 | |
27 | #define SSD1322_CMD_SET_DISPLAY_MODE_NORMAL 0xA6 | |
28 | #define SSD1322_CMD_SET_DISPLAY_MODE_INVERSE 0xA7 | |
29 | #define SSD1322_CMD_ENABLE_PARTIAL_DISPLAY 0xA8 | |
30 | #define SSD1322_CMD_EXIT_PARTIAL_DISPLAY 0xA9 | |
31 | #define SSD1322_CMD_SET_FUNCTION_SELECTION 0xAB | |
32 | #define SSD1322_CMD_SET_DISPLAY_OFF 0xAE | |
33 | #define SSD1322_CMD_SET_DISPLAY_ON 0xAF | |
34 | #define SSD1322_CMD_SET_PHASE_LENGTH 0xB1 | |
35 | #define SSD1322_CMD_SET_CLOCK_DIVIDER 0xB3 | |
36 | #define SSD1322_CMD_DISPLAY_ENHANCEMENT 0xB4 | |
37 | #define SSD1322_CMD_SET_GPIO 0xB5 | |
38 | #define SSD1322_CMD_SET_SECOND_PRECHARGE_PERIOD 0xB6 | |
39 | #define SSD1322_CMD_SET_GRAY_SCALE_TABLE 0xB8 | |
40 | #define SSD1322_CMD_SET_DEFAULT_LINEAR_GRAY_SCALE_TABLE 0xB9 | |
41 | #define SSD1322_CMD_SET_PRECHARGE_VOLTAGE 0xBB | |
42 | #define SSD1322_CMD_SET_VCOMH_VOLTAGE 0xBE | |
43 | #define SSD1322_CMD_SET_CONTRAST_CURRENT 0xC1 | |
44 | #define SSD1322_CMD_MASTER_CURRENT_CONTROL 0xC7 | |
45 | #define SSD1322_CMD_SET_MULTIPLEX_RATIO 0xCA | |
46 | #define SSD1322_CMD_DISPLAY_ENHANCEMENT_B 0xD1 | |
47 | #define SSD1322_CMD_SET_COMMAND_LOCK 0xFD | |
48 | ||
49 | // set for some OLED displays | |
50 | //#define ALTERNATE_OLED_VERSION | |
51 | ||
52 | ||
53 | static const uint8_t oledInit[] = { | |
54 | SSD1322_CMD_SET_COMMAND_LOCK, 1, 0x12, /* Unlock OLED driver IC*/ | |
55 | SSD1322_CMD_SET_DISPLAY_OFF, 0, | |
56 | SSD1322_CMD_SET_CLOCK_DIVIDER, 1, 0x91, | |
57 | SSD1322_CMD_SET_MULTIPLEX_RATIO, 1, 0x3F, /*duty = 1/64*,64 COMS are enabled*/ | |
58 | SSD1322_CMD_SET_DISPLAY_OFFSET, 1, 0x00, | |
59 | SSD1322_CMD_SET_DISPLAY_START_LINE, 1, 0x00, /*set start line position*/ | |
60 | SSD1322_CMD_SET_REMAP, 2, 0x14, // Horizontal address increment, | |
61 | // Disable Column Address Re-map, | |
62 | // Enable Nibble Re-map,Scan from COM[N-1] to COM0, | |
63 | // Disable COM Split Odd Even | |
64 | 0x11, // Enable Dual COM mode | |
65 | SSD1322_CMD_SET_GPIO, 1, 0x00, | |
66 | SSD1322_CMD_SET_FUNCTION_SELECTION, 1, 0x01, /* selection external VDD */ | |
67 | SSD1322_CMD_DISPLAY_ENHANCEMENT, 2, 0xA0, /* enables the external VSL*/ | |
68 | 0xfd, /* 0xfd,Enhanced low GS display quality;default is 0xb5(normal),*/ | |
69 | SSD1322_CMD_SET_CONTRAST_CURRENT, 1, 0xff, /* default is 0x7f*/ | |
70 | SSD1322_CMD_MASTER_CURRENT_CONTROL, 1, 0x0f, | |
71 | /* writeCommand(0xB9); GRAY TABLE,linear Gray Scale*/ | |
72 | SSD1322_CMD_SET_PHASE_LENGTH, 1, 0xE2, /*default is 0x74*/ | |
73 | SSD1322_CMD_DISPLAY_ENHANCEMENT_B, 2, 0x82, 0x20, | |
74 | #ifdef ALTERNATE_OLED_VERSION | |
75 | SSD1322_CMD_SET_PRECHARGE_VOLTAGE, 1, 0x08, /* 0.3xVcc */ | |
76 | SSD1322_CMD_SET_SECOND_PRECHARGE_PERIOD, 1, 0x0F, /* 15 clocks */ | |
77 | #else | |
78 | SSD1322_CMD_SET_PRECHARGE_VOLTAGE, 1, 0x1F, /* 0.6xVcc */ | |
79 | SSD1322_CMD_SET_SECOND_PRECHARGE_PERIOD, 1, 0x08, /* default */ | |
80 | #endif | |
81 | SSD1322_CMD_SET_VCOMH_VOLTAGE, 1, 0x07, /*0.86xVcc;default is 0x04*/ | |
82 | SSD1322_CMD_SET_DISPLAY_MODE_NORMAL, 0, | |
83 | SSD1322_CMD_SET_DISPLAY_ON, 0 | |
84 | }; | |
85 | ||
86 | ||
87 | //////////////////////////////////////////////////////////////////////////////////////// | |
88 | //////////////////////////////////////////////////////////////////////////////////////// | |
89 | //////////////////////////////////////////////////////////////////////////////////////// | |
90 | ||
91 | ||
92 | //#include "mbed_debug.h" | |
93 | ||
94 | #define SWAP(a, b) { a ^= b; b ^= a; a ^= b; } | |
95 | ||
96 | ||
8 | 97 | SSD1322::SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, |
98 | const char *name) | |
5 | 99 | : GraphicsDisplay(name), |
8 | 100 | screensize_X(DISPLAY_WIDTH), screensize_Y(DISPLAY_HEIGHT), |
101 | _BPP(BPP), _PAGES(DISPLAY_HEIGHT/8*BPP), | |
102 | _IC_X_SEGS(IC_X_SEGS), _IC_Y_COMS(IC_Y_COMS), _IC_PAGES(IC_Y_COMS/8*BPP), | |
103 | _spi(mosi, miso, sclk), | |
104 | _DC(DC), _CS(CS), _RST(reset) | |
5 | 105 | { |
8 | 106 | _RST = 1; |
107 | _DC = 1; | |
108 | _CS = 1; | |
109 | _spi.format(8, 0); // 8 bit spi mode 0 | |
110 | _spi.frequency(Hz); | |
5 | 111 | set_auto_up(false); |
112 | foreground(0xFFFF); | |
113 | background(0x0000); | |
114 | hw_reset(); | |
115 | init(); | |
116 | set_orientation(1); | |
117 | cls(); | |
118 | locate(0,0); | |
8 | 119 | //_internalEventCallback.attach(this, &SSD1322::_cbHandler); |
5 | 120 | } |
121 | ||
122 | void SSD1322::wr_cmd8(unsigned char cmd) | |
123 | { | |
8 | 124 | _CS = 0; |
125 | _DC.write(0); // 0=cmd | |
126 | _spi.write(cmd); // write 8bit | |
127 | _DC.write(1); // 1=data next | |
128 | _CS = 1; | |
5 | 129 | } |
130 | ||
131 | void SSD1322::wr_data8(unsigned char data) | |
132 | { | |
8 | 133 | _CS = 0; |
134 | _spi.write(data); // write 8bit | |
135 | _CS = 1; | |
5 | 136 | |
137 | } | |
138 | ||
139 | void SSD1322::hw_reset() | |
140 | { | |
8 | 141 | wait_ms(15); |
142 | _DC = 1; | |
143 | _CS = 1; | |
144 | _RST = 0; // display reset | |
145 | wait_ms(2); | |
146 | _RST = 1; // end reset | |
147 | wait_ms(100); | |
5 | 148 | } |
149 | ||
150 | void SSD1322::bus_enable(bool enable) | |
151 | { | |
8 | 152 | _CS = enable ? 0:1; |
5 | 153 | } |
154 | ||
155 | ||
156 | // monochrome SSD1322 driver ICs does not have ram rotate in hw (swap raw<->columns) like TFT displays | |
157 | // for portrait views, XY swap will be done in sw in pixel() function | |
158 | void SSD1322::set_orientation(int o) | |
159 | { | |
160 | orientation = o; | |
161 | if (o & 0x01) { | |
162 | set_width(screensize_X); | |
163 | set_height(screensize_Y); | |
164 | } else { | |
165 | set_width(screensize_Y); | |
166 | set_height(screensize_X); | |
167 | } | |
168 | switch (o) { | |
169 | case (0):// portrait view -90° | |
170 | mirrorXY(Y); | |
171 | break; | |
172 | case (1): // default, landscape view 0° | |
173 | mirrorXY(NONE); | |
174 | break; | |
175 | case (2):// portrait view +90° | |
176 | mirrorXY(X); | |
177 | break; | |
178 | case (3):// landscape view +180° | |
179 | mirrorXY(XY); | |
180 | break; | |
181 | } | |
182 | } | |
183 | ||
184 | void SSD1322::mirrorXY(mirror_t mode) | |
185 | { | |
186 | // Horizontal address increment, | |
187 | // Disable Column Address Re-map, | |
188 | // Enable Nibble Re-map,Scan from COM[N-1] to COM0, | |
189 | // Disable COM Split Odd Even | |
190 | // Enable Dual COM mode | |
191 | unsigned char d; | |
192 | switch (mode) | |
193 | { | |
194 | case(NONE): | |
195 | d = 0x14; | |
196 | break; | |
197 | case(X): | |
198 | d = 0x10; | |
199 | break; | |
200 | case(Y): | |
201 | d = 0x16; | |
202 | break; | |
203 | case(XY): | |
204 | d = 0x12; | |
205 | break; | |
206 | } | |
207 | wr_cmd8(SSD1322_CMD_SET_REMAP); | |
208 | wr_data8(d); | |
209 | wr_data8(0x11); | |
210 | } | |
211 | ||
212 | void SSD1322::invert(unsigned char o) | |
213 | { | |
8 | 214 | if(o == 0) wr_cmd8(SSD1322_CMD_SET_DISPLAY_MODE_NORMAL); |
215 | else wr_cmd8(SSD1322_CMD_SET_DISPLAY_MODE_INVERSE); | |
5 | 216 | } |
217 | ||
218 | void SSD1322::set_contrast(int o) | |
219 | { | |
220 | contrast = o; | |
221 | ||
222 | wr_cmd8(SSD1322_CMD_SET_CONTRAST_CURRENT); | |
223 | wr_data8(o&0xFF); | |
224 | } | |
225 | ||
226 | int SSD1322::get_contrast(void) | |
227 | { | |
228 | return(contrast); | |
229 | } | |
230 | void SSD1322::window(int x, int y, int w, int h) { | |
231 | // current pixel location | |
232 | cur_x = x; | |
233 | cur_y = y; | |
234 | // window settings | |
235 | win_x1 = x; | |
236 | win_x2 = x + w - 1; | |
237 | win_y1 = y; | |
238 | win_y2 = y + h - 1; | |
239 | } | |
240 | void SSD1322::window_pushpixel(unsigned short color) { | |
8 | 241 | pixel(cur_x, cur_y, color); |
242 | cur_x++; | |
243 | if(cur_x > win_x2) { | |
244 | cur_x = win_x1; | |
245 | cur_y++; | |
246 | if(cur_y > win_y2) { | |
247 | cur_y = win_y1; | |
5 | 248 | } |
8 | 249 | } |
5 | 250 | } |
251 | void SSD1322::window_pushpixel(unsigned short color, unsigned int count) { | |
8 | 252 | while(count) |
5 | 253 | { |
8 | 254 | pixel(cur_x, cur_y, color); |
255 | cur_x++; | |
256 | if(cur_x > win_x2) | |
5 | 257 | { |
8 | 258 | cur_x = win_x1; |
259 | cur_y++; | |
260 | if(cur_y > win_y2) | |
5 | 261 | { |
8 | 262 | cur_y = win_y1; |
5 | 263 | } |
264 | } | |
8 | 265 | count--; |
5 | 266 | } |
267 | } | |
268 | void SSD1322::window_pushpixelbuf(unsigned short* color, unsigned int lenght) { | |
8 | 269 | while(lenght) |
5 | 270 | { |
8 | 271 | pixel(cur_x, cur_y, *color++); |
272 | cur_x++; | |
273 | if(cur_x > win_x2) | |
5 | 274 | { |
8 | 275 | cur_x = win_x1; |
276 | cur_y++; | |
277 | if(cur_y > win_y2) | |
5 | 278 | { |
8 | 279 | cur_y = win_y1; |
5 | 280 | } |
281 | } | |
8 | 282 | lenght--; |
5 | 283 | } |
284 | } | |
285 | ||
286 | unsigned short SSD1322::pixelpos(int x, int y) | |
287 | { | |
288 | if(!(orientation&1)) SWAP(x,y); | |
289 | // first check parameter | |
290 | if((x >= screensize_X) || (y >= screensize_Y)) return 0; | |
291 | ||
292 | unsigned short page = y * _BPP / 8; | |
293 | return (x + page*screensize_X); | |
294 | } | |
295 | ||
296 | void SSD1322::pixel(int x, int y, unsigned short color) | |
297 | { | |
298 | if(!(orientation&1)) SWAP(x,y); | |
299 | // first check parameter | |
300 | if((x >= screensize_X) || (y >= screensize_Y)) return; | |
301 | ||
302 | /* | |
303 | unsigned short page = y * _BPP / 8; | |
304 | unsigned char pos = y & ((8 / _BPP) - 1); // position in page | |
305 | unsigned char mask = (( 1 << _BPP) - 1); | |
306 | ||
307 | buffer[(x + page*screensize_X)] = (buffer[(x + page*screensize_X)] & ~(mask<<(pos*_BPP))) | ((color&mask)<<(pos*_BPP)); | |
308 | */ | |
309 | ||
8 | 310 | unsigned char cval = _pixelBuffer[(y*128) + x/2]; |
5 | 311 | if (x&1) { |
312 | cval = (cval & 0xF0) | (color & 0x0F); | |
313 | } else { | |
314 | cval = (cval & 0x0F) | (color & 0x0F)<<4; | |
315 | } | |
8 | 316 | _pixelBuffer[(y*128) + x/2] = cval; |
5 | 317 | } |
318 | ||
319 | unsigned short SSD1322::pixelread(int x, int y) | |
320 | { | |
321 | if(!(orientation&1)) SWAP(x,y); | |
322 | // first check parameter | |
323 | if((x >= screensize_X) || (y >= screensize_Y)) return 0; | |
324 | ||
325 | unsigned short page = y * _BPP / 8; | |
326 | unsigned char pos = y & ((8 / _BPP) - 1); // position in page | |
327 | unsigned char mask = (( 1 << _BPP) - 1); | |
328 | ||
329 | //FAUX | |
8 | 330 | return (_pixelBuffer[(x + page*screensize_X)]); // = (_pixelBuffer[(x + page*screensize_X)] & ~(mask<<(pos*_BPP))) | ((color&mask)<<(pos*_BPP)); |
5 | 331 | } |
332 | ||
333 | ||
334 | ||
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
335 | // Set row address 0~64 |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
336 | void SSD1322::set_row_address(unsigned char start_row, unsigned char end_row) |
5 | 337 | { |
338 | wr_cmd8(SSD1322_CMD_SET_ROW_ADDR); | |
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
339 | start_row &= 0x3F; |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
340 | wr_data8(start_row); |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
341 | end_row &= 0x3F; |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
342 | wr_data8(end_row); |
5 | 343 | } |
344 | ||
345 | // Set col address 0~64 for Gray mode) | |
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
346 | void SSD1322::set_column_address(unsigned char start_col, unsigned char end_col) |
5 | 347 | { |
348 | wr_cmd8(SSD1322_CMD_SET_COLUMN_ADDR); | |
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
349 | start_col = (start_col & 0x3F) + 0x1C; |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
350 | wr_data8(start_col); // where does this 0x1C (28) comes from??? |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
351 | end_col = (end_col & 0x3F) + 0x1C; |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
352 | wr_data8(end_col); |
5 | 353 | } |
354 | ||
355 | void SSD1322::copy_to_lcd(void) | |
356 | { | |
8 | 357 | unsigned int x, y; |
5 | 358 | unsigned int i; |
359 | set_row_address(0); | |
360 | set_column_address(0); | |
361 | ||
8 | 362 | memcpy((void*)_trBuffer, |
363 | (const void*)_pixelBuffer, | |
364 | DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE)); | |
365 | wr_cmd8(SSD1322_CMD_WRITE_RAM); | |
366 | ||
5 | 367 | i = 0; |
368 | for(y=0; y<64; y++) | |
369 | for(x=0; x<128; x++) | |
8 | 370 | wr_data8(_trBuffer[i++]); |
5 | 371 | } |
372 | ||
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
373 | void SSD1322::copy_to_lcd(unsigned char from_col, unsigned char to_col, |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
374 | unsigned char from_row, unsigned char to_row) |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
375 | { |
8 | 376 | unsigned int x, y; |
7
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
6
diff
changeset
|
377 | if (to_col>0x3F) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
6
diff
changeset
|
378 | to_col = 0x3F; |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
6
diff
changeset
|
379 | if (to_row>0x3F) |
5cf4034ba4e0
attempt to update display by bloc
David Douard <david.douard@logilab.fr>
parents:
6
diff
changeset
|
380 | to_row = 0x3F; |
8 | 381 | |
382 | memcpy((void*)_trBuffer, | |
383 | (const void*)_pixelBuffer, | |
384 | DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE)); | |
385 | ||
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
386 | set_row_address(from_row, to_row); |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
387 | set_column_address(from_col, to_col); |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
388 | |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
389 | wr_cmd8(SSD1322_CMD_WRITE_RAM); |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
390 | for(y=from_row; y<=to_row; y++) { |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
391 | for(x=from_col; x<=to_col; x++) { |
8 | 392 | wr_data8(_trBuffer[y*128 + 2*x]); |
393 | wr_data8(_trBuffer[y*128 + 2*x + 1]); | |
6
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
394 | } |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
395 | } |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
396 | } |
8cb67d7afd79
[SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents:
5
diff
changeset
|
397 | |
5 | 398 | unsigned long SSD1322::buffaddr(unsigned int i) |
399 | { | |
8 | 400 | return (unsigned long) &(_pixelBuffer[i]); |
5 | 401 | } |
402 | ||
403 | void SSD1322::clrbuff(const unsigned char value) | |
404 | { | |
8 | 405 | memset((void*)_pixelBuffer, value, screensize_X*_PAGES); |
5 | 406 | } |
407 | ||
408 | void SSD1322::fills(const unsigned char value) | |
409 | { | |
8 | 410 | clrbuff(value); |
411 | copy_to_lcd(); | |
5 | 412 | } |
413 | ||
414 | void SSD1322::cls(void) | |
415 | { | |
8 | 416 | clrbuff(); |
417 | copy_to_lcd(); | |
5 | 418 | } |
419 | ||
420 | ||
421 | // reset and init the lcd controller | |
422 | void SSD1322::init() | |
423 | { | |
424 | /* Start Initial Sequence ----------------------------------------------------*/ | |
425 | for (uint16_t ind=0; ind < sizeof(oledInit); ) { | |
426 | wr_cmd8(oledInit[ind++]); | |
427 | uint8_t dataSize = oledInit[ind++]; | |
428 | while (dataSize--) { | |
429 | wr_data8(oledInit[ind++]); | |
430 | } | |
431 | } | |
432 | } |