Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/oled_samsung.asm @ 448:b41024e63f53
lib added
author | heinrichsweikamp |
---|---|
date | Sun, 14 Aug 2011 19:19:43 +0200 |
parents | 07f5b0baaa57 |
children | 05ec97e106da |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2009 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; hardware routines for S6E6D6 Samsung OLED Driver IC | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 090801 | |
142 | 21 ; History: |
22 ; 2009-08-30: [MH] last updated. | |
23 ; 2011-01-07: [jDG] Added flip_screen option | |
24 ; known bugs: pixel-write (loogbok curves) not done yet... | |
25 ; ToDo: | |
0 | 26 |
27 WIN_FONT macro win_font_input | |
28 movlw win_font_input | |
29 movff WREG,win_font | |
30 endm | |
31 | |
32 WIN_TOP macro win_top_input | |
33 movlw win_top_input | |
34 movff WREG,win_top | |
35 endm | |
36 | |
37 WIN_LEFT macro win_left_input | |
38 movlw win_left_input | |
39 movff WREG,win_leftx2 | |
40 endm | |
41 | |
42 WIN_INVERT macro win_invert_input | |
43 movlw win_invert_input | |
44 movff WREG,win_invert | |
45 endm | |
46 | |
47 WIN_COLOR macro win_color_input | |
48 movlw win_color_input | |
49 call PLED_set_color | |
50 endm | |
142 | 51 |
52 ;============================================================================= | |
53 | |
0 | 54 word_processor: ; word_processor: |
142 | 55 clrf POSTINC2 ; Required, to mark end of string. |
56 call aa_wordprocessor | |
57 movlb b'00000001' ; Back to Rambank1 | |
58 return | |
0 | 59 |
142 | 60 ;============================================================================= |
146 | 61 ; Macro to provides our own interface code. |
142 | 62 ; |
146 | 63 PIXEL_WRITE macro colRegister, rowRegister |
64 movff colRegister,win_leftx2 | |
65 movff rowRegister,win_top | |
66 call pixel_write | |
67 endm | |
123 | 68 |
146 | 69 INIT_PIXEL_WROTE macro colRegister |
70 movff colRegister,win_leftx2 | |
71 call init_pixel_write | |
72 endm | |
73 | |
74 HALF_PIXEL_WRITE macro rowRegister | |
75 movff rowRegister,win_top | |
76 call half_pixel_write | |
77 endm | |
0 | 78 |
146 | 79 ;----------------------------------------------------------------------------- |
80 ; Init for half_pixel_write | |
81 ; Set column register on OLED device, and current color. | |
82 ; Inputs: win_leftx2 | |
83 ; Outputs: win_color:2 | |
84 ; Trashed: WREG, PROD | |
85 init_pixel_write: | |
86 movff win_leftx2,WREG | |
87 mullw 2 | |
88 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
89 goto PLED_standard_color | |
90 | |
91 ;----------------------------------------------------------------------------- | |
92 ; Writes two half-pixels at position (win_top,win_leftx2) | |
93 ; Inputs: win_leftx2, win_top, win_color:2 | |
94 ; Trashed: WREG, PROD | |
95 pixel_write: | |
96 movff win_leftx2,WREG | |
97 mullw 2 | |
98 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
99 rcall half_pixel_write ; Write this half-one. | |
123 | 100 |
146 | 101 movff win_leftx2,WREG ; Address of next one |
102 mullw 2 | |
103 infsnz PRODL ; +1 | |
104 incf PRODH | |
105 rcall pixel_write_col320 | |
106 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because | |
107 ; of the autoincrement going vertical | |
108 | |
109 ;---- Do the 16bit 319-X-->X, if needed, and send to OLED ------------ | |
110 pixel_write_col320: | |
111 movff win_flags,WREG ; BEWARE: bank0 bit-test | |
112 btfss WREG,0 ; 180° rotation ? | |
113 bra pixel_write_noflip_H | |
114 | |
115 movf PRODL,W ; 16bits 319 - PROD --> PROD | |
116 sublw LOW(.319) ; 319-W --> W | |
117 movwf PRODL | |
118 movf PRODH,W | |
119 btfss STATUS,C ; Borrow = /CARRY | |
120 incf WREG | |
121 sublw HIGH(.319) | |
122 movwf PRODH | |
0 | 123 |
146 | 124 pixel_write_noflip_H: |
125 movlw 0x21 ; Start Address Vertical (.0 - .319) | |
126 rcall PLED_CmdWrite | |
127 bra PLED_DataWrite_PROD | |
128 | |
129 ;----------------------------------------------------------------------------- | |
426 | 130 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height). |
131 ; Inputs: win_leftx2, win_top, win_height, win_color:2 | |
132 ; Trashed: WREG, PROD, TABLAT, TBLPTRL | |
133 half_vertical_line: | |
134 movff win_leftx2,WREG ; Init X position. | |
135 mullw 2 | |
136 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
137 | |
138 clrf TABLAT ; Loop index. | |
139 | |
140 half_vertical_line_loop: | |
141 movff win_height,WREG ; Index reached height (Bank0 read) ? | |
142 xorwf TABLAT,W | |
143 btfsc STATUS,Z ; Equals ? | |
144 return ; Yes: done. | |
145 movff win_top,WREG ; Y = top + index (Bank0 read) | |
146 addwf TABLAT,W | |
147 rcall half_pixel_write_1 | |
148 incf TABLAT,F ; index++ | |
149 bra half_vertical_line_loop | |
150 | |
151 ;----------------------------------------------------------------------------- | |
146 | 152 ; Writes one half-pixel at position (win_top,win_leftx2). |
153 ; Inputs: win_leftx2, win_top, win_color:2 | |
154 ; Trashed: WREG, PROD | |
155 half_pixel_write: | |
156 movff win_top,WREG ; d'0' ... d'239' | |
157 | |
426 | 158 ; Variant with Y position in WREG. |
159 half_pixel_write_1: | |
146 | 160 movff win_flags,PRODL ; BEWARE: bank0 bit-test |
161 btfsc PRODL,0 ; 180° rotation ? | |
162 sublw .239 ; 239-Y --> Y | |
0 | 163 |
146 | 164 mullw 1 ; Copy row to PRODH:L |
165 movlw 0x20 ; Horizontal Address START:END | |
166 rcall PLED_CmdWrite | |
167 rcall PLED_DataWrite_PROD | |
168 | |
169 movlw 0x22 ; Start Writing Data to GRAM | |
170 rcall PLED_CmdWrite | |
171 bsf oled_rs ; Data! | |
172 movff win_color1, PORTD | |
173 bcf oled_rw | |
174 bsf oled_rw ; Upper | |
175 movff win_color2, PORTD | |
176 bcf oled_rw | |
177 bsf oled_rw ; Lower | |
178 return | |
0 | 179 |
180 ; ----------------------------- | |
181 ; PLED Display Off | |
182 ; ----------------------------- | |
183 PLED_DisplayOff: | |
184 clrf PORTD | |
185 bcf oled_hv | |
186 bcf oled_vdd | |
187 bcf oled_cs | |
188 bcf oled_e_nwr | |
189 bcf oled_rw | |
190 bcf oled_nreset | |
191 return | |
192 | |
123 | 193 ;============================================================================= |
142 | 194 ; Fast macros to write to OLED display. |
195 ; Adding a call/return adds 3 words and a pipeline flush, hence make it | |
196 ; nearly twice slower... | |
197 ; | |
198 ; Input : commande as macro parameter. | |
199 ; Output : NONE | |
200 ; Trash : WREG | |
201 ; | |
202 AA_CMD_WRITE macro cmd | |
203 movlw cmd | |
204 rcall PLED_CmdWrite | |
205 ; bcf oled_rs ; Cmd mode | |
206 ; movwf PORTD,A | |
207 ; bcf oled_rw ; Tick the clock | |
208 ; bsf oled_rw | |
209 endm | |
210 ; | |
330 | 211 ; Input : data as macro parameter. |
212 ; Output : NONE | |
213 ; Trash : WREG | |
214 ; | |
215 AA_DATA_WRITE macro data | |
216 movlw data | |
217 rcall PLED_DataWrite | |
218 endm | |
219 ; | |
142 | 220 ; Input : PRODH:L as 16bits data. |
221 ; Output : NONE | |
222 ; Trash : NONE | |
223 ; | |
224 AA_DATA_WRITE_PROD macro | |
225 rcall PLED_DataWrite_PROD | |
226 ; bsf oled_rs ; Data mode | |
227 ; movff PRODH,PORTD ; NOTE: OLED is BIGENDIAN! | |
228 ; bcf oled_rw ; Tick the clock | |
229 ; bsf oled_rw | |
230 ; movff PRODL,PORTD | |
231 ; bcf oled_rw ; Tick the clock | |
232 ; bsf oled_rw | |
233 endm | |
234 | |
235 ;============================================================================= | |
236 ; Output OLED Window Address commands. | |
237 ; Inputs : win_top, win_leftx2, win_height, aa_width. | |
238 ; Output : PortD commands. | |
239 ; Trashed: PROD | |
240 ; | |
241 PLED_box_write: | |
242 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD | |
243 mullw 2 | |
244 | |
245 movff win_flags,WREG ; BEWARE: bank0 bit-test | |
246 btfsc WREG,0 ; 180° rotation ? | |
247 bra PLED_box_flip_H ; YES: | |
248 | |
249 ;---- Normal horizontal window --------------------------------------- | |
250 ; Output 0x35 left, | |
251 ; 0x36 right == left + width - 1. | |
252 AA_CMD_WRITE 0x35 ; this is the left border | |
253 AA_DATA_WRITE_PROD ; Output left | |
254 AA_CMD_WRITE 0x21 ; Also the horizontal first pix coord. | |
255 AA_DATA_WRITE_PROD | |
256 | |
257 movf aa_width+0,W,ACCESS ; right = left + width - 1 | |
258 addwf PRODL,F | |
259 movf aa_width+1,W,ACCESS | |
260 addwfc PRODH,F | |
261 decf PRODL,F,A ; decrement result | |
262 btfss STATUS,C | |
263 decf PRODH,F,A | |
264 | |
265 AA_CMD_WRITE 0x36 ; Write and the right border | |
266 AA_DATA_WRITE_PROD | |
267 | |
268 bra PLED_box_noflip_H | |
269 | |
270 ;---- Flipped horizontal window -------------------------------------- | |
271 PLED_box_flip_H: | |
272 ; Output 0x36 flipped(left) = 319-left | |
273 ; 0x35 flipped(right) = 319-right = 320 - left - width | |
274 movf PRODL,W ; 16bits 319 - PROD --> PROD | |
275 sublw LOW(.319) ; 319-W --> W | |
276 movwf PRODL | |
277 movf PRODH,W | |
278 btfss STATUS,C ; Borrow = /CARRY | |
279 incf WREG | |
280 sublw HIGH(.319) | |
281 movwf PRODH | |
282 AA_CMD_WRITE 0x36 ; this is the left border | |
283 AA_DATA_WRITE_PROD ; Output left | |
284 AA_CMD_WRITE 0x21 | |
285 AA_DATA_WRITE_PROD | |
286 | |
287 movf aa_width+0,W ; 16bits PROD - width --> PROD | |
288 subwf PRODL,F ; PRODL - WREG --> PRODL | |
289 movf aa_width+1,W | |
290 subwfb PRODH,F | |
291 infsnz PRODL ; PROD+1 --> PROD | |
292 incf PRODH | |
293 AA_CMD_WRITE 0x35 ; this is the left border | |
294 AA_DATA_WRITE_PROD ; Output left | |
295 | |
296 PLED_box_noflip_H: | |
297 movff win_flags,WREG ; BEWARE: bank0 bit-test | |
298 btfsc WREG,0 ; 180° rotation ? | |
299 bra PLED_box_flip_V | |
300 | |
301 ;---- Normal vertical window ----------------------------------------- | |
302 ; Output 0x37 (top) (bottom) | |
303 movff win_top,PRODH ; top --> PRODH (first byte) | |
304 movff win_height,WREG | |
305 addwf PRODH,W | |
306 decf WREG | |
307 movwf PRODL ; top+height-1 --> PRODL (second byte) | |
308 | |
309 AA_CMD_WRITE 0x37 | |
310 AA_DATA_WRITE_PROD | |
311 | |
312 movff PRODH,PRODL | |
313 clrf PRODH ; Start pixel V coord == top. | |
314 AA_CMD_WRITE 0x20 | |
315 AA_DATA_WRITE_PROD | |
316 | |
317 return | |
318 | |
319 ;---- Flipped vertical window ---------------------------------------- | |
320 ; Output 0x37 flipped(bottom) = 239-bottom = 240 - top - height | |
321 ; flipped(top) = 239-top | |
322 PLED_box_flip_V: | |
323 movff win_top,PRODL | |
324 movff win_height,WREG | |
325 addwf PRODL,W | |
326 sublw .240 ; 240 - top - height | |
327 movwf PRODH ; First byte | |
328 | |
329 movf PRODL,W | |
330 sublw .239 ; 249-top | |
331 movwf PRODL ; --> second byte. | |
332 | |
333 AA_CMD_WRITE 0x37 | |
334 AA_DATA_WRITE_PROD | |
335 | |
336 clrf PRODH ; Start pixel V coord. | |
337 AA_CMD_WRITE 0x20 | |
338 AA_DATA_WRITE_PROD | |
339 | |
340 return | |
341 | |
342 ;============================================================================= | |
123 | 343 ; PLED_frame : draw a frame around current box with current color. |
344 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
345 ; Outputs: (none) | |
346 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1 | |
167 | 347 global PLED_frame |
142 | 348 PLED_frame: |
349 movff win_top,aa_start+0 ; Backup everything. | |
123 | 350 movff win_height,aa_start+1 |
351 movff win_leftx2,aa_end+0 | |
352 movff win_width,aa_end+1 | |
0 | 353 |
123 | 354 ;---- TOP line ----------------------------------------------------------- |
142 | 355 movlw 1 ; row ~ height=1 |
123 | 356 movff WREG,win_height |
357 rcall PLED_box | |
0 | 358 |
123 | 359 ;---- BOTTOM line -------------------------------------------------------- |
142 | 360 movff aa_start+0,PRODL ; Get back top, |
361 movff aa_start+1,WREG ; and height | |
362 addwf PRODL,W ; top+height | |
363 decf WREG ; top+height-1 | |
364 movff WREG,win_top ; top+height-1 --> top | |
123 | 365 rcall PLED_box |
0 | 366 |
123 | 367 ;---- LEFT column -------------------------------------------------------- |
368 movff aa_start+0,win_top ; Restore top/height. | |
369 movff aa_start+1,win_height | |
370 movlw 1 ; column ~ width=1 | |
371 movff WREG,win_width | |
372 rcall PLED_box | |
0 | 373 |
123 | 374 ;---- RIGHT column ------------------------------------------------------- |
375 movff aa_end+0,WREG | |
376 movff aa_end+1,PRODL | |
377 addwf PRODL,W | |
378 decf WREG | |
379 movff WREG,win_leftx2 | |
380 bra PLED_box | |
0 | 381 |
123 | 382 ;============================================================================= |
383 ; PLED_box : fills current box with current color. | |
384 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
385 ; Outputs: (none) | |
386 ; Trashed: WREG, PROD | |
0 | 387 |
167 | 388 global PLED_box |
0 | 389 PLED_box: |
123 | 390 ;---- Define Window ------------------------------------------------------ |
142 | 391 movff win_width,WREG |
392 bcf STATUS,C | |
393 rlcf WREG | |
150 | 394 movwf aa_width+0 |
142 | 395 movlw 0 |
396 rlcf WREG | |
397 movwf aa_width+1 | |
398 rcall PLED_box_write | |
0 | 399 |
123 | 400 ;---- Fill Window -------------------------------------------------------- |
150 | 401 movlw 0x22 ; Start Writing Data to GRAM |
0 | 402 rcall PLED_CmdWrite |
403 | |
150 | 404 clrf PRODH ; Column counter. |
405 bsf oled_rs ; Data! | |
0 | 406 |
150 | 407 PLED_box2: ; Loop height times |
142 | 408 movff win_height,PRODL |
150 | 409 |
410 PLED_box3: ; loop width times | |
0 | 411 movff win_color1,PORTD |
412 bcf oled_rw | |
150 | 413 bsf oled_rw ; Upper |
0 | 414 movff win_color2,PORTD |
415 bcf oled_rw | |
150 | 416 bsf oled_rw ; Lower |
0 | 417 |
418 movff win_color1,PORTD | |
419 bcf oled_rw | |
150 | 420 bsf oled_rw ; Upper |
0 | 421 movff win_color2,PORTD |
422 bcf oled_rw | |
150 | 423 bsf oled_rw ; Lower |
424 | |
425 decfsz PRODL,F ; row loop finished ? | |
426 bra PLED_box3 ; No: continue. | |
427 | |
428 incf PRODH,F ; column count ++ | |
429 | |
430 movff win_bargraph,WREG ; current column == bargraph ? | |
431 cpfseq PRODH | |
432 bra PLED_box4 ; No: just loop. | |
0 | 433 |
150 | 434 clrf WREG ; Yes: switch to black |
435 movff WREG,win_color1 | |
436 movff WREG,win_color2 | |
437 PLED_box4: | |
438 movff win_width,WREG | |
439 cpfseq PRODH | |
440 bra PLED_box2 | |
0 | 441 |
150 | 442 movlw 0x00 ; NOP, to stop window mode |
443 rcall PLED_CmdWrite | |
444 | |
445 setf WREG ; Reset bargraph mode... | |
446 movff WREG,win_bargraph | |
447 return | |
0 | 448 |
123 | 449 ;============================================================================= |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
123
diff
changeset
|
450 ; PLED_ClearScreen: An optimized version of PLEX_box, for full screen black. |
123 | 451 ; Trashed: WREG, PROD |
0 | 452 |
167 | 453 global PLED_ClearScreen |
0 | 454 PLED_ClearScreen: |
455 movlw 0x35 ; VerticalStartAddress HIGH:LOW | |
456 rcall PLED_CmdWrite | |
123 | 457 mullw 0 |
458 rcall PLED_DataWrite_PROD | |
0 | 459 |
460 movlw 0x36 ; VerticalEndAddress HIGH:LOW | |
461 rcall PLED_CmdWrite | |
462 movlw 0x01 | |
123 | 463 rcall PLED_DataWrite |
0 | 464 movlw 0x3F |
123 | 465 rcall PLED_DataWrite |
0 | 466 |
467 movlw 0x37 ; HorizontalAddress START:END | |
468 rcall PLED_CmdWrite | |
469 movlw 0x00 | |
123 | 470 rcall PLED_DataWrite |
0 | 471 movlw 0xEF |
123 | 472 rcall PLED_DataWrite |
0 | 473 |
474 movlw 0x20 ; Start Address Horizontal (.0 - .239) | |
475 rcall PLED_CmdWrite | |
123 | 476 rcall PLED_DataWrite_PROD |
0 | 477 |
478 movlw 0x21 ; Start Address Vertical (.0 - .319) | |
479 rcall PLED_CmdWrite | |
123 | 480 rcall PLED_DataWrite_PROD |
0 | 481 |
150 | 482 movlw 0x22 ; Start Writing Data to GRAM |
0 | 483 rcall PLED_CmdWrite |
484 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
81
diff
changeset
|
485 ; See Page 101 of OLED Driver IC Datasheet how to handle rs/rw clocks |
150 | 486 bsf oled_rs ; Data! |
0 | 487 |
123 | 488 movlw .160 |
489 movwf PRODH | |
0 | 490 PLED_ClearScreen2: |
123 | 491 movlw .240 |
492 movwf PRODL | |
0 | 493 PLED_ClearScreen3: |
494 | |
150 | 495 clrf PORTD ; Need to generate trace here too. |
0 | 496 bcf oled_rw |
150 | 497 bsf oled_rw ; Upper |
81
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
3
diff
changeset
|
498 |
150 | 499 clrf PORTD ; Need to generate trace here too. |
0 | 500 bcf oled_rw |
150 | 501 bsf oled_rw ; Lower |
0 | 502 |
150 | 503 clrf PORTD ; Need to generate trace here too. |
123 | 504 bcf oled_rw |
150 | 505 bsf oled_rw ; Upper |
123 | 506 |
150 | 507 clrf PORTD ; Need to generate trace here too. |
123 | 508 bcf oled_rw |
150 | 509 bsf oled_rw ; Lower |
123 | 510 |
511 decfsz PRODL,F | |
0 | 512 bra PLED_ClearScreen3 |
123 | 513 decfsz PRODH,F |
0 | 514 bra PLED_ClearScreen2 |
515 | |
516 movlw 0x00 ; NOP, to stop Address Update Counter | |
123 | 517 bra PLED_CmdWrite |
0 | 518 |
519 ; ----------------------------- | |
520 ; PLED Write Cmd via W | |
521 ; ----------------------------- | |
522 PLED_CmdWrite: | |
523 bcf oled_rs ; Command! | |
524 movwf PORTD ; Move Data to PORTD | |
525 bcf oled_rw | |
526 bsf oled_rw | |
527 return | |
528 | |
529 ; ----------------------------- | |
530 ; PLED Write Display Data via W | |
531 ; ----------------------------- | |
532 PLED_DataWrite: | |
123 | 533 bsf oled_rs ; Data! |
534 movwf PORTD ; Move Data to PORTD | |
535 bcf oled_rw | |
536 bsf oled_rw | |
537 return | |
0 | 538 |
539 ; ----------------------------- | |
540 ; PLED Data Cmd via W | |
541 ; ----------------------------- | |
123 | 542 PLED_DataWrite_PROD: |
0 | 543 bsf oled_rs ; Data! |
123 | 544 movff PRODH,PORTD ; Move high byte to PORTD (OLED is bigendian) |
545 bcf oled_rw | |
546 bsf oled_rw | |
547 movff PRODL,PORTD ; Move low byte to PORTD | |
0 | 548 bcf oled_rw |
549 bsf oled_rw | |
550 return | |
551 | |
552 ; ----------------------------- | |
330 | 553 ; PLED Read data into WREG |
554 ; ----------------------------- | |
555 ; NOTE: you should "setf TRISD" before calling this function, | |
556 ; to make PortD an input port... | |
557 PLED_DataRead: | |
558 bsf oled_rs ; Data register. | |
559 bcf oled_e_nwr ; Read enable. | |
560 movf PORTD,W ; Read byte. | |
561 bsf oled_e_nwr ; release bus. | |
562 return | |
563 | |
564 ; ----------------------------- | |
0 | 565 ; PLED boot |
566 ; ----------------------------- | |
567 PLED_boot: | |
568 bcf oled_hv | |
569 WAITMS d'32' | |
570 bsf oled_vdd | |
571 nop | |
572 bcf oled_cs | |
573 nop | |
574 bsf oled_nreset | |
3 | 575 ; WAITMS d'10' ; Quick wake-up |
576 WAITMS d'250' ; Standard wake-up | |
0 | 577 bsf oled_e_nwr |
578 nop | |
579 bcf oled_nreset | |
580 WAIT10US d'2' | |
581 bsf oled_nreset | |
582 WAITMS d'10' | |
583 | |
584 movlw 0x24 ; 80-System 8-Bit Mode | |
585 rcall PLED_CmdWrite | |
586 | |
587 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42) | |
588 rcall PLED_CmdWrite | |
589 movlw 0x00 ; X X X X X X X RM | |
123 | 590 rcall PLED_DataWrite |
0 | 591 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL |
123 | 592 rcall PLED_DataWrite ; System Interface: RIM is ignored, Internal Clock |
0 | 593 |
594 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46) | |
595 rcall PLED_CmdWrite | |
142 | 596 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color |
123 | 597 rcall PLED_DataWrite |
142 | 598 |
599 ; Change direction for block-writes of pixels | |
600 lfsr FSR0,win_flags | |
601 btfss INDF0,0 ; BANK-SAFE bit test. | |
602 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM | |
603 btfsc INDF0,0 | |
604 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM | |
123 | 605 rcall PLED_DataWrite |
0 | 606 |
607 movlw 0x18 | |
608 rcall PLED_CmdWrite | |
609 movlw 0x00 | |
123 | 610 rcall PLED_DataWrite |
0 | 611 movlw 0x28 |
123 | 612 rcall PLED_DataWrite |
0 | 613 |
614 movlw 0xF8 | |
615 rcall PLED_CmdWrite | |
616 movlw 0x00 | |
123 | 617 rcall PLED_DataWrite |
0 | 618 movlw 0x0F |
123 | 619 rcall PLED_DataWrite |
0 | 620 |
621 movlw 0xF9 | |
622 rcall PLED_CmdWrite | |
623 movlw 0x00 | |
123 | 624 rcall PLED_DataWrite |
0 | 625 movlw 0x0F |
123 | 626 rcall PLED_DataWrite |
0 | 627 |
628 movlw 0x10 | |
629 rcall PLED_CmdWrite | |
630 movlw 0x00 | |
123 | 631 rcall PLED_DataWrite |
0 | 632 movlw 0x00 |
123 | 633 rcall PLED_DataWrite |
0 | 634 |
635 ; Now Gamma settings... | |
636 rcall PLED_brightness_full | |
2 | 637 ;rcall PLED_brightness_low |
0 | 638 ; End Gamma Settings |
639 | |
640 rcall PLED_ClearScreen | |
641 | |
642 bsf oled_hv | |
643 WAITMS d'32' | |
411
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
644 bsf oled_hv |
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
645 WAITMS d'32' |
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
646 bsf oled_hv |
0 | 647 |
648 movlw 0x05 | |
649 rcall PLED_CmdWrite | |
650 movlw 0x00 | |
123 | 651 rcall PLED_DataWrite |
0 | 652 movlw 0x01 |
123 | 653 rcall PLED_DataWrite ; Display ON |
0 | 654 return |
655 | |
656 | |
657 PLED_brightness_full: | |
658 movlw 0x70 | |
659 rcall PLED_CmdWrite | |
660 movlw 0x1F | |
123 | 661 rcall PLED_DataWrite |
0 | 662 movlw 0x00 |
123 | 663 rcall PLED_DataWrite |
0 | 664 movlw 0x71 |
665 rcall PLED_CmdWrite | |
666 movlw 0x23 | |
123 | 667 rcall PLED_DataWrite |
0 | 668 movlw 0x80 |
123 | 669 rcall PLED_DataWrite |
0 | 670 movlw 0x72 |
671 rcall PLED_CmdWrite | |
672 movlw 0x2A | |
123 | 673 rcall PLED_DataWrite |
0 | 674 movlw 0x80 |
123 | 675 rcall PLED_DataWrite |
0 | 676 |
677 movlw 0x73 | |
678 rcall PLED_CmdWrite | |
679 movlw 0x15 | |
123 | 680 rcall PLED_DataWrite |
0 | 681 movlw 0x11 |
123 | 682 rcall PLED_DataWrite |
0 | 683 movlw 0x74 |
684 rcall PLED_CmdWrite | |
685 movlw 0x1C | |
123 | 686 rcall PLED_DataWrite |
0 | 687 movlw 0x11 |
123 | 688 rcall PLED_DataWrite |
0 | 689 |
690 movlw 0x75 | |
691 rcall PLED_CmdWrite | |
692 movlw 0x1B | |
123 | 693 rcall PLED_DataWrite |
0 | 694 movlw 0x15 |
123 | 695 rcall PLED_DataWrite |
0 | 696 movlw 0x76 |
697 rcall PLED_CmdWrite | |
698 movlw 0x1A | |
123 | 699 rcall PLED_DataWrite |
0 | 700 movlw 0x15 |
123 | 701 rcall PLED_DataWrite |
0 | 702 |
703 movlw 0x77 | |
704 rcall PLED_CmdWrite | |
705 movlw 0x1C | |
123 | 706 rcall PLED_DataWrite |
0 | 707 movlw 0x18 |
123 | 708 rcall PLED_DataWrite |
0 | 709 movlw 0x78 |
710 rcall PLED_CmdWrite | |
711 movlw 0x21 | |
123 | 712 rcall PLED_DataWrite |
0 | 713 movlw 0x15 |
123 | 714 rcall PLED_DataWrite |
0 | 715 |
716 return | |
717 | |
718 PLED_brightness_low: | |
719 movlw 0x70 | |
720 rcall PLED_CmdWrite | |
721 movlw 0x14 | |
123 | 722 rcall PLED_DataWrite |
0 | 723 movlw 0x00 |
123 | 724 rcall PLED_DataWrite |
0 | 725 movlw 0x71 |
726 rcall PLED_CmdWrite | |
727 movlw 0x17 | |
123 | 728 rcall PLED_DataWrite |
0 | 729 movlw 0x00 |
123 | 730 rcall PLED_DataWrite |
0 | 731 movlw 0x72 |
732 rcall PLED_CmdWrite | |
733 movlw 0x15 | |
123 | 734 rcall PLED_DataWrite |
0 | 735 movlw 0x80 |
123 | 736 rcall PLED_DataWrite |
0 | 737 |
738 movlw 0x73 | |
739 rcall PLED_CmdWrite | |
740 movlw 0x15 | |
123 | 741 rcall PLED_DataWrite |
0 | 742 movlw 0x11 |
123 | 743 rcall PLED_DataWrite |
0 | 744 movlw 0x74 |
745 rcall PLED_CmdWrite | |
746 movlw 0x14 | |
123 | 747 rcall PLED_DataWrite |
0 | 748 movlw 0x0B |
123 | 749 rcall PLED_DataWrite |
0 | 750 |
751 movlw 0x75 | |
752 rcall PLED_CmdWrite | |
753 movlw 0x1B | |
123 | 754 rcall PLED_DataWrite |
0 | 755 movlw 0x15 |
123 | 756 rcall PLED_DataWrite |
0 | 757 movlw 0x76 |
758 rcall PLED_CmdWrite | |
759 movlw 0x13 | |
123 | 760 rcall PLED_DataWrite |
0 | 761 movlw 0x0E |
123 | 762 rcall PLED_DataWrite |
0 | 763 |
764 movlw 0x77 | |
765 rcall PLED_CmdWrite | |
766 movlw 0x1C | |
123 | 767 rcall PLED_DataWrite |
0 | 768 movlw 0x18 |
123 | 769 rcall PLED_DataWrite |
0 | 770 movlw 0x78 |
771 rcall PLED_CmdWrite | |
772 movlw 0x15 | |
123 | 773 rcall PLED_DataWrite |
0 | 774 movlw 0x0E |
123 | 775 rcall PLED_DataWrite |
0 | 776 |
777 return | |
778 | |
779 PLED_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGGGGGBBBBB' | |
780 movwf oled1_temp ; Get 8Bit RGB b'RRRGGGBB' | |
781 movff oled1_temp, oled2_temp ; Copy | |
782 | |
783 ; Mask Bit 7,6,5,4,3,2 | |
784 movlw b'00000011' | |
785 andwf oled2_temp,F | |
786 | |
787 movlw b'00000000' | |
788 dcfsnz oled2_temp,F | |
789 movlw b'01010000' | |
790 dcfsnz oled2_temp,F | |
791 movlw b'10100000' | |
792 dcfsnz oled2_temp,F | |
793 movlw b'11111000' | |
794 movwf oled3_temp ; Blue done. | |
795 | |
796 movff oled1_temp, oled2_temp ; Copy | |
797 ; Mask Bit 7,6,5,1,0 | |
798 movlw b'00011100' | |
799 andwf oled2_temp,F | |
800 rrncf oled2_temp,F | |
801 rrncf oled2_temp,F | |
802 | |
803 movlw b'00000000' | |
804 dcfsnz oled2_temp,F | |
805 movlw b'00000100' | |
806 dcfsnz oled2_temp,F | |
807 movlw b'00001000' | |
808 dcfsnz oled2_temp,F | |
809 movlw b'00001100' | |
810 dcfsnz oled2_temp,F | |
811 movlw b'00010000' | |
812 dcfsnz oled2_temp,F | |
813 movlw b'00010100' | |
814 dcfsnz oled2_temp,F | |
815 movlw b'00100000' | |
816 dcfsnz oled2_temp,F | |
817 movlw b'00111111' | |
818 movwf oled4_temp | |
819 | |
820 rrcf oled4_temp,F | |
821 rrcf oled3_temp,F | |
822 | |
823 rrcf oled4_temp,F | |
824 rrcf oled3_temp,F | |
825 | |
826 rrcf oled4_temp,F | |
827 rrcf oled3_temp,F ; oled3_temp (b'GGGBBBBB') done. | |
828 | |
829 movff oled1_temp, oled2_temp ; Copy | |
830 clrf oled1_temp | |
831 | |
832 rrcf oled4_temp,F | |
833 rrcf oled1_temp,F | |
834 | |
835 rrcf oled4_temp,F | |
836 rrcf oled1_temp,F | |
837 | |
838 rrcf oled4_temp,F | |
839 rrcf oled1_temp,F ; Green done. | |
840 | |
841 ; Mask Bit 4,3,2,1,0 | |
842 movlw b'11100000' | |
843 andwf oled2_temp,F | |
844 | |
845 rrncf oled2_temp,F | |
846 rrncf oled2_temp,F | |
847 rrncf oled2_temp,F | |
848 rrncf oled2_temp,F | |
849 rrncf oled2_temp,F | |
850 | |
851 movlw b'00000000' | |
852 dcfsnz oled2_temp,F | |
853 movlw b'00000100' | |
854 dcfsnz oled2_temp,F | |
855 movlw b'00001000' | |
856 dcfsnz oled2_temp,F | |
857 movlw b'00001100' | |
858 dcfsnz oled2_temp,F | |
859 movlw b'00010000' | |
860 dcfsnz oled2_temp,F | |
861 movlw b'00010100' | |
862 dcfsnz oled2_temp,F | |
863 movlw b'00100000' | |
864 dcfsnz oled2_temp,F | |
865 movlw b'00111111' | |
866 movwf oled4_temp | |
867 | |
868 rrcf oled4_temp,F | |
869 rrcf oled1_temp,F | |
870 | |
871 rrcf oled4_temp,F | |
872 rrcf oled1_temp,F | |
873 | |
874 rrcf oled4_temp,F | |
875 rrcf oled1_temp,F | |
876 | |
877 rrcf oled4_temp,F | |
878 rrcf oled1_temp,F | |
879 | |
880 rrcf oled4_temp,F | |
881 rrcf oled1_temp,F ; Red done. | |
882 | |
883 movff oled1_temp,win_color1 | |
884 movff oled3_temp,win_color2 ; Set Bank0 Color registers... | |
885 return | |
886 |