Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/oled_samsung.asm @ 557:f6c45ad5d493
update of p2_deco.o
author | heinrichsweikamp |
---|---|
date | Fri, 17 Feb 2012 09:46:32 +0100 |
parents | 2ac77db9c150 |
children | ab2686087bce |
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. | |
475 | 563 nop |
564 nop | |
565 nop | |
566 nop | |
330 | 567 movf PORTD,W ; Read byte. |
568 bsf oled_e_nwr ; release bus. | |
569 return | |
570 | |
571 ; ----------------------------- | |
0 | 572 ; PLED boot |
573 ; ----------------------------- | |
574 PLED_boot: | |
575 bcf oled_hv | |
576 WAITMS d'32' | |
577 bsf oled_vdd | |
578 nop | |
579 bcf oled_cs | |
580 nop | |
581 bsf oled_nreset | |
3 | 582 ; WAITMS d'10' ; Quick wake-up |
583 WAITMS d'250' ; Standard wake-up | |
0 | 584 bsf oled_e_nwr |
585 nop | |
586 bcf oled_nreset | |
587 WAIT10US d'2' | |
588 bsf oled_nreset | |
589 WAITMS d'10' | |
590 | |
591 movlw 0x24 ; 80-System 8-Bit Mode | |
592 rcall PLED_CmdWrite | |
593 | |
594 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42) | |
595 rcall PLED_CmdWrite | |
596 movlw 0x00 ; X X X X X X X RM | |
123 | 597 rcall PLED_DataWrite |
0 | 598 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL |
123 | 599 rcall PLED_DataWrite ; System Interface: RIM is ignored, Internal Clock |
0 | 600 |
601 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46) | |
602 rcall PLED_CmdWrite | |
142 | 603 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color |
123 | 604 rcall PLED_DataWrite |
142 | 605 |
606 ; Change direction for block-writes of pixels | |
607 lfsr FSR0,win_flags | |
608 btfss INDF0,0 ; BANK-SAFE bit test. | |
609 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM | |
610 btfsc INDF0,0 | |
611 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM | |
123 | 612 rcall PLED_DataWrite |
0 | 613 |
614 movlw 0x18 | |
615 rcall PLED_CmdWrite | |
616 movlw 0x00 | |
123 | 617 rcall PLED_DataWrite |
0 | 618 movlw 0x28 |
123 | 619 rcall PLED_DataWrite |
0 | 620 |
621 movlw 0xF8 | |
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 0xF9 | |
629 rcall PLED_CmdWrite | |
630 movlw 0x00 | |
123 | 631 rcall PLED_DataWrite |
0 | 632 movlw 0x0F |
123 | 633 rcall PLED_DataWrite |
0 | 634 |
635 movlw 0x10 | |
636 rcall PLED_CmdWrite | |
637 movlw 0x00 | |
123 | 638 rcall PLED_DataWrite |
0 | 639 movlw 0x00 |
123 | 640 rcall PLED_DataWrite |
0 | 641 |
642 ; Now Gamma settings... | |
643 rcall PLED_brightness_full | |
2 | 644 ;rcall PLED_brightness_low |
0 | 645 ; End Gamma Settings |
646 | |
647 rcall PLED_ClearScreen | |
648 | |
649 bsf oled_hv | |
650 WAITMS d'32' | |
411
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
651 bsf oled_hv |
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
652 WAITMS d'32' |
e6e1b89b7c3e
BUGFIX: CNS was not cleared with a "Reset Deco"
heinrichsweikamp
parents:
331
diff
changeset
|
653 bsf oled_hv |
0 | 654 |
655 movlw 0x05 | |
656 rcall PLED_CmdWrite | |
657 movlw 0x00 | |
123 | 658 rcall PLED_DataWrite |
0 | 659 movlw 0x01 |
123 | 660 rcall PLED_DataWrite ; Display ON |
0 | 661 return |
662 | |
663 | |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
483
diff
changeset
|
664 PLED_brightness_full: ; Choose between Eco and High... |
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
483
diff
changeset
|
665 btfsc oled_brightness_high ; OLED brightness (=0: Eco, =1: High) |
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
483
diff
changeset
|
666 bra PLED_brightness_full_high |
483 | 667 ; Mid |
668 movlw 0x70 | |
669 rcall PLED_CmdWrite | |
670 movlw 0x1B | |
671 rcall PLED_DataWrite | |
672 movlw 0x80 | |
673 rcall PLED_DataWrite | |
674 movlw 0x71 | |
675 rcall PLED_CmdWrite | |
676 movlw 0x1F | |
677 rcall PLED_DataWrite | |
678 movlw 0x00 | |
679 rcall PLED_DataWrite | |
680 movlw 0x72 | |
681 rcall PLED_CmdWrite | |
682 movlw 0x22 | |
683 rcall PLED_DataWrite | |
684 movlw 0x00 | |
685 rcall PLED_DataWrite | |
686 | |
687 movlw 0x73 | |
688 rcall PLED_CmdWrite | |
689 movlw 0x17 | |
690 rcall PLED_DataWrite | |
691 movlw 0x11 | |
692 rcall PLED_DataWrite | |
693 movlw 0x74 | |
694 rcall PLED_CmdWrite | |
695 movlw 0x1A | |
696 rcall PLED_DataWrite | |
697 movlw 0x0E | |
698 rcall PLED_DataWrite | |
699 | |
700 movlw 0x75 | |
701 rcall PLED_CmdWrite | |
702 movlw 0x1D | |
703 rcall PLED_DataWrite | |
704 movlw 0x15 | |
705 rcall PLED_DataWrite | |
706 movlw 0x76 | |
707 rcall PLED_CmdWrite | |
708 movlw 0x18 | |
709 rcall PLED_DataWrite | |
710 movlw 0x11 | |
711 rcall PLED_DataWrite | |
712 | |
713 movlw 0x77 | |
714 rcall PLED_CmdWrite | |
715 movlw 0x1E | |
716 rcall PLED_DataWrite | |
717 movlw 0x18 | |
718 rcall PLED_DataWrite | |
719 movlw 0x78 | |
720 rcall PLED_CmdWrite | |
721 movlw 0x1D | |
722 rcall PLED_DataWrite | |
723 movlw 0x11 | |
724 rcall PLED_DataWrite | |
725 return | |
726 | |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
483
diff
changeset
|
727 PLED_brightness_full_high: |
483 | 728 ; Full |
0 | 729 movlw 0x70 |
730 rcall PLED_CmdWrite | |
731 movlw 0x1F | |
123 | 732 rcall PLED_DataWrite |
0 | 733 movlw 0x00 |
123 | 734 rcall PLED_DataWrite |
0 | 735 movlw 0x71 |
736 rcall PLED_CmdWrite | |
737 movlw 0x23 | |
123 | 738 rcall PLED_DataWrite |
0 | 739 movlw 0x80 |
123 | 740 rcall PLED_DataWrite |
0 | 741 movlw 0x72 |
742 rcall PLED_CmdWrite | |
743 movlw 0x2A | |
123 | 744 rcall PLED_DataWrite |
0 | 745 movlw 0x80 |
123 | 746 rcall PLED_DataWrite |
0 | 747 |
748 movlw 0x73 | |
749 rcall PLED_CmdWrite | |
750 movlw 0x15 | |
123 | 751 rcall PLED_DataWrite |
0 | 752 movlw 0x11 |
123 | 753 rcall PLED_DataWrite |
0 | 754 movlw 0x74 |
755 rcall PLED_CmdWrite | |
756 movlw 0x1C | |
123 | 757 rcall PLED_DataWrite |
0 | 758 movlw 0x11 |
123 | 759 rcall PLED_DataWrite |
0 | 760 |
761 movlw 0x75 | |
762 rcall PLED_CmdWrite | |
763 movlw 0x1B | |
123 | 764 rcall PLED_DataWrite |
0 | 765 movlw 0x15 |
123 | 766 rcall PLED_DataWrite |
0 | 767 movlw 0x76 |
768 rcall PLED_CmdWrite | |
769 movlw 0x1A | |
123 | 770 rcall PLED_DataWrite |
0 | 771 movlw 0x15 |
123 | 772 rcall PLED_DataWrite |
0 | 773 |
774 movlw 0x77 | |
775 rcall PLED_CmdWrite | |
776 movlw 0x1C | |
123 | 777 rcall PLED_DataWrite |
0 | 778 movlw 0x18 |
123 | 779 rcall PLED_DataWrite |
0 | 780 movlw 0x78 |
781 rcall PLED_CmdWrite | |
782 movlw 0x21 | |
123 | 783 rcall PLED_DataWrite |
0 | 784 movlw 0x15 |
123 | 785 rcall PLED_DataWrite |
0 | 786 return |
787 | |
483 | 788 |
0 | 789 PLED_brightness_low: |
483 | 790 ;Low |
0 | 791 movlw 0x70 |
792 rcall PLED_CmdWrite | |
793 movlw 0x14 | |
123 | 794 rcall PLED_DataWrite |
0 | 795 movlw 0x00 |
123 | 796 rcall PLED_DataWrite |
0 | 797 movlw 0x71 |
798 rcall PLED_CmdWrite | |
799 movlw 0x17 | |
123 | 800 rcall PLED_DataWrite |
0 | 801 movlw 0x00 |
123 | 802 rcall PLED_DataWrite |
0 | 803 movlw 0x72 |
804 rcall PLED_CmdWrite | |
805 movlw 0x15 | |
123 | 806 rcall PLED_DataWrite |
0 | 807 movlw 0x80 |
123 | 808 rcall PLED_DataWrite |
0 | 809 |
810 movlw 0x73 | |
811 rcall PLED_CmdWrite | |
812 movlw 0x15 | |
123 | 813 rcall PLED_DataWrite |
0 | 814 movlw 0x11 |
123 | 815 rcall PLED_DataWrite |
0 | 816 movlw 0x74 |
817 rcall PLED_CmdWrite | |
818 movlw 0x14 | |
123 | 819 rcall PLED_DataWrite |
0 | 820 movlw 0x0B |
123 | 821 rcall PLED_DataWrite |
0 | 822 |
823 movlw 0x75 | |
824 rcall PLED_CmdWrite | |
825 movlw 0x1B | |
123 | 826 rcall PLED_DataWrite |
0 | 827 movlw 0x15 |
123 | 828 rcall PLED_DataWrite |
0 | 829 movlw 0x76 |
830 rcall PLED_CmdWrite | |
831 movlw 0x13 | |
123 | 832 rcall PLED_DataWrite |
0 | 833 movlw 0x0E |
123 | 834 rcall PLED_DataWrite |
0 | 835 |
836 movlw 0x77 | |
837 rcall PLED_CmdWrite | |
838 movlw 0x1C | |
123 | 839 rcall PLED_DataWrite |
0 | 840 movlw 0x18 |
123 | 841 rcall PLED_DataWrite |
0 | 842 movlw 0x78 |
843 rcall PLED_CmdWrite | |
844 movlw 0x15 | |
123 | 845 rcall PLED_DataWrite |
0 | 846 movlw 0x0E |
123 | 847 rcall PLED_DataWrite |
0 | 848 |
849 return | |
850 | |
851 PLED_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGGGGGBBBBB' | |
852 movwf oled1_temp ; Get 8Bit RGB b'RRRGGGBB' | |
853 movff oled1_temp, oled2_temp ; Copy | |
854 | |
855 ; Mask Bit 7,6,5,4,3,2 | |
856 movlw b'00000011' | |
857 andwf oled2_temp,F | |
858 | |
859 movlw b'00000000' | |
860 dcfsnz oled2_temp,F | |
861 movlw b'01010000' | |
862 dcfsnz oled2_temp,F | |
863 movlw b'10100000' | |
864 dcfsnz oled2_temp,F | |
865 movlw b'11111000' | |
866 movwf oled3_temp ; Blue done. | |
867 | |
868 movff oled1_temp, oled2_temp ; Copy | |
869 ; Mask Bit 7,6,5,1,0 | |
870 movlw b'00011100' | |
871 andwf oled2_temp,F | |
872 rrncf oled2_temp,F | |
873 rrncf oled2_temp,F | |
874 | |
875 movlw b'00000000' | |
876 dcfsnz oled2_temp,F | |
877 movlw b'00000100' | |
878 dcfsnz oled2_temp,F | |
879 movlw b'00001000' | |
880 dcfsnz oled2_temp,F | |
881 movlw b'00001100' | |
882 dcfsnz oled2_temp,F | |
883 movlw b'00010000' | |
884 dcfsnz oled2_temp,F | |
885 movlw b'00010100' | |
886 dcfsnz oled2_temp,F | |
887 movlw b'00100000' | |
888 dcfsnz oled2_temp,F | |
889 movlw b'00111111' | |
890 movwf oled4_temp | |
891 | |
892 rrcf oled4_temp,F | |
893 rrcf oled3_temp,F | |
894 | |
895 rrcf oled4_temp,F | |
896 rrcf oled3_temp,F | |
897 | |
898 rrcf oled4_temp,F | |
899 rrcf oled3_temp,F ; oled3_temp (b'GGGBBBBB') done. | |
900 | |
901 movff oled1_temp, oled2_temp ; Copy | |
902 clrf oled1_temp | |
903 | |
904 rrcf oled4_temp,F | |
905 rrcf oled1_temp,F | |
906 | |
907 rrcf oled4_temp,F | |
908 rrcf oled1_temp,F | |
909 | |
910 rrcf oled4_temp,F | |
911 rrcf oled1_temp,F ; Green done. | |
912 | |
913 ; Mask Bit 4,3,2,1,0 | |
914 movlw b'11100000' | |
915 andwf oled2_temp,F | |
916 | |
917 rrncf oled2_temp,F | |
918 rrncf oled2_temp,F | |
919 rrncf oled2_temp,F | |
920 rrncf oled2_temp,F | |
921 rrncf oled2_temp,F | |
922 | |
923 movlw b'00000000' | |
924 dcfsnz oled2_temp,F | |
925 movlw b'00000100' | |
926 dcfsnz oled2_temp,F | |
927 movlw b'00001000' | |
928 dcfsnz oled2_temp,F | |
929 movlw b'00001100' | |
930 dcfsnz oled2_temp,F | |
931 movlw b'00010000' | |
932 dcfsnz oled2_temp,F | |
933 movlw b'00010100' | |
934 dcfsnz oled2_temp,F | |
935 movlw b'00100000' | |
936 dcfsnz oled2_temp,F | |
937 movlw b'00111111' | |
938 movwf oled4_temp | |
939 | |
940 rrcf oled4_temp,F | |
941 rrcf oled1_temp,F | |
942 | |
943 rrcf oled4_temp,F | |
944 rrcf oled1_temp,F | |
945 | |
946 rrcf oled4_temp,F | |
947 rrcf oled1_temp,F | |
948 | |
949 rrcf oled4_temp,F | |
950 rrcf oled1_temp,F | |
951 | |
952 rrcf oled4_temp,F | |
953 rrcf oled1_temp,F ; Red done. | |
954 | |
955 movff oled1_temp,win_color1 | |
956 movff oled3_temp,win_color2 ; Set Bank0 Color registers... | |
957 return | |
958 |