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