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