Mercurial > public > hwos_code
annotate src/tft.asm @ 642:a9a0188091e4
fix rare upgrade issue with OSTC sport 2019 hardware
author | heinrichsweikamp |
---|---|
date | Thu, 14 Jan 2021 16:24:07 +0100 |
parents | 8c1f1f334275 |
children | 070528a88715 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
634 | 3 ; File tft.asm combined next generation V3.09.4n |
0 | 4 ; |
623 | 5 ; low-level Display Outputs |
0 | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. | |
11 | |
275 | 12 #include "hwos.inc" |
0 | 13 #include "wait.inc" |
14 #include "varargs.inc" | |
15 #include "tft_outputs.inc" | |
16 #include "eeprom_rs232.inc" | |
17 | |
634 | 18 ;----------------------------------------------------------------------------- |
0 | 19 ; Basic bit-level macros |
20 | |
582 | 21 RD_H macro |
22 bsf tft_rd,0 | |
23 endm | |
0 | 24 |
582 | 25 RD_L macro |
26 bcf tft_rd,0 | |
27 endm | |
0 | 28 |
582 | 29 RS_H macro |
30 bsf tft_rs,0 | |
31 endm | |
0 | 32 |
582 | 33 RS_L macro |
34 bcf tft_rs,0 | |
35 endm | |
0 | 36 |
582 | 37 NCS_H macro |
38 bsf tft_cs,0 | |
39 endm | |
0 | 40 |
582 | 41 NCS_L macro |
42 bcf tft_cs,0 | |
43 endm | |
0 | 44 |
582 | 45 WR_H macro |
46 bsf tft_nwr,0 | |
47 endm | |
0 | 48 |
582 | 49 WR_L macro |
50 bcf tft_nwr,0 | |
51 endm | |
0 | 52 |
634 | 53 ;----------------------------------------------------------------------------- |
582 | 54 ; Byte-level macros |
55 | |
0 | 56 Index_out macro low_b |
57 movlw low_b | |
58 rcall TFT_CmdWrite | |
59 endm | |
60 | |
61 Parameter_out macro high_b, low_b | |
62 movlw high_b | |
604 | 63 movwf PORTA ; upper |
0 | 64 movlw low_b |
65 rcall TFT_DataWrite | |
66 endm | |
67 | |
634 | 68 ;============================================================================= |
604 | 69 tft CODE |
634 | 70 ;============================================================================= |
582 | 71 |
72 global TFT_ClearScreen | |
0 | 73 TFT_ClearScreen: |
628 | 74 btfsc screen_type2 ; screen type 2? |
623 | 75 bra TFT_ClearScreen_display2; YES |
628 | 76 btfsc screen_type3 ; screen type 3? |
77 bra TFT_ClearScreen_display3; YES | |
623 | 78 |
604 | 79 Index_out 0x50 ; window horizontal start address |
582 | 80 Parameter_out 0x00, 0x00 ; 0-239 |
604 | 81 Index_out 0x51 ; window horizontal end address |
582 | 82 Parameter_out 0x00, 0xEF ; 0-239 |
604 | 83 Index_out 0x52 ; window vertical start address |
582 | 84 Parameter_out 0x00, 0x00 ; 0-319 |
604 | 85 Index_out 0x53 ; window vertical end address |
582 | 86 Parameter_out 0x01, 0x3F ; 0-319 |
604 | 87 Index_out 0x20 ; frame memory horizontal address |
582 | 88 Parameter_out 0x00, 0x00 ; 0-239 |
604 | 89 Index_out 0x21 ; frame memory vertical address |
582 | 90 Parameter_out 0x01, 0x3F ; 0-319 |
0 | 91 |
604 | 92 Index_out 0x22 ; frame memory data write start |
0 | 93 |
604 | 94 RD_H ; not read |
95 RS_H ; data | |
96 NCS_L ; not CS | |
97 clrf PORTH ; data lower | |
0 | 98 |
99 movlw d'10' | |
100 movwf tft_temp3 | |
101 TFT_ClearScreen2: | |
102 movlw d'30' | |
103 movwf tft_temp2 | |
104 TFT_ClearScreen3: | |
604 | 105 clrf tft_temp1 ; 30*10*256=76800 pixels -> clear complete 240*320 |
582 | 106 bcf INTCON,GIE |
0 | 107 TFT_ClearScreen4: |
108 WR_L | |
604 | 109 WR_H ; tick |
0 | 110 decfsz tft_temp1,F |
111 bra TFT_ClearScreen4 | |
582 | 112 bsf INTCON,GIE |
0 | 113 decfsz tft_temp2,F |
114 bra TFT_ClearScreen3 | |
115 decfsz tft_temp3,F | |
116 bra TFT_ClearScreen2 | |
582 | 117 |
118 movlw 0x00 ; NOP, to stop window mode | |
604 | 119 bra TFT_CmdWrite ; and return |
582 | 120 |
623 | 121 TFT_ClearScreen_display2: |
122 movlw 0x02 ; column address start | |
608 | 123 rcall TFT_CmdWrite |
124 movlw 0x00 | |
125 rcall TFT_DataWrite | |
126 movlw 0x03 | |
127 rcall TFT_CmdWrite | |
128 movlw 0x00 | |
129 rcall TFT_DataWrite | |
130 | |
623 | 131 movlw 0x04 ; column address end |
608 | 132 rcall TFT_CmdWrite |
133 movlw 0x00 | |
134 rcall TFT_DataWrite | |
135 movlw 0x05 | |
136 rcall TFT_CmdWrite | |
137 movlw 0xEF | |
138 rcall TFT_DataWrite | |
139 | |
623 | 140 movlw 0x06 ; row address start |
608 | 141 rcall TFT_CmdWrite |
142 movlw 0x00 | |
143 rcall TFT_DataWrite | |
144 movlw 0x07 | |
145 rcall TFT_CmdWrite | |
146 movlw 0x00 | |
147 rcall TFT_DataWrite | |
148 | |
623 | 149 movlw 0x08 ; row address end |
608 | 150 rcall TFT_CmdWrite |
151 movlw 0x01 | |
152 rcall TFT_DataWrite | |
153 movlw 0x09 | |
154 rcall TFT_CmdWrite | |
155 movlw 0x3F | |
156 rcall TFT_DataWrite | |
157 | |
623 | 158 movlw 0x22 ; start writing data to GRAM |
608 | 159 rcall TFT_CmdWrite |
160 | |
628 | 161 movlw .160 ; 160 x 240 x 6 = 230400 ticks |
162 TFT_ClearScreen_display2_loop0: | |
623 | 163 bsf tft_rs ; data! |
608 | 164 movwf PRODH |
165 clrf PORTH | |
623 | 166 TFT_ClearScreen_display2_loop1: |
608 | 167 movlw .240 |
168 movwf PRODL | |
623 | 169 TFT_ClearScreen_display2_loop2: |
608 | 170 bcf tft_nwr |
623 | 171 bsf tft_nwr ; upper |
608 | 172 bcf tft_nwr |
623 | 173 bsf tft_nwr ; high |
608 | 174 bcf tft_nwr |
623 | 175 bsf tft_nwr ; lower |
608 | 176 bcf tft_nwr |
623 | 177 bsf tft_nwr ; upper |
608 | 178 bcf tft_nwr |
623 | 179 bsf tft_nwr ; high |
608 | 180 bcf tft_nwr |
623 | 181 bsf tft_nwr ; lower |
608 | 182 decfsz PRODL,F |
623 | 183 bra TFT_ClearScreen_display2_loop2 |
608 | 184 decfsz PRODH,F |
623 | 185 bra TFT_ClearScreen_display2_loop1 |
186 return | |
0 | 187 |
628 | 188 TFT_ClearScreen_display3: |
189 movlw 0x35 ; vertical start address HIGH:LOW | |
190 rcall TFT_CmdWrite | |
631 | 191 mullw 0 |
628 | 192 rcall TFT_DataWrite_PROD |
193 | |
194 movlw 0x36 ; vertical end address HIGH:LOW | |
195 rcall TFT_CmdWrite | |
196 movlw 0x01 | |
197 rcall TFT_DataWrite | |
198 movlw 0x3F | |
199 rcall TFT_DataWrite | |
200 | |
201 movlw 0x37 ; horizontal address START:END | |
202 rcall TFT_CmdWrite | |
203 movlw 0x00 | |
204 rcall TFT_DataWrite | |
205 movlw 0xEF | |
206 rcall TFT_DataWrite | |
207 | |
208 movlw 0x20 ; start address horizontal (.0 - .239) | |
209 rcall TFT_CmdWrite | |
210 rcall TFT_DataWrite_PROD | |
211 | |
212 movlw 0x21 ; start address vertical (.0 - .319) | |
213 rcall TFT_CmdWrite | |
214 rcall TFT_DataWrite_PROD | |
215 | |
216 movlw 0x22 ; start writing data to GRAM | |
217 rcall TFT_CmdWrite | |
218 | |
219 movlw .107 ; 107 x 240 x 6 = 154080 ticks (153600 would be enough) | |
220 bra TFT_ClearScreen_display2_loop0 | |
221 | |
222 | |
582 | 223 global TFT_DisplayOff |
0 | 224 TFT_DisplayOff: |
628 | 225 bcf lightsen_power ; power-down light sensor |
631 | 226 btfsc screen_type3 ; screen type 3 ? |
227 bra TFT_DisplayOff_display3 ; YES - screen needs special power-down sequence | |
228 clrf CCP1CON ; NO - stop PWM | |
229 bcf PORTC,2 ; - pull PWM out to GND | |
0 | 230 clrf PORTA |
582 | 231 clrf PORTH |
623 | 232 RD_L ; LOW |
233 RS_L ; LOW | |
640 | 234 WR_L |
235 NCS_L | |
623 | 236 bcf tft_nreset |
237 bsf tft_power ; inverted... | |
628 | 238 return |
239 | |
240 TFT_DisplayOff_display3: | |
241 movlw 0x05 | |
242 rcall TFT_CmdWrite | |
243 movlw 0x00 | |
244 rcall TFT_DataWrite | |
245 movlw 0x00 | |
246 rcall TFT_DataWrite | |
247 WAITMS d'32' | |
248 clrf CCP1CON ; stop PWM | |
249 bcf PORTC,2 ; pull PWM out to GND | |
250 WAITMS d'32' | |
251 movlw 0x10 | |
252 rcall TFT_CmdWrite | |
253 movlw 0x00 | |
254 rcall TFT_DataWrite | |
255 movlw 0x01 | |
256 rcall TFT_DataWrite | |
257 WAITMS d'100' | |
258 clrf PORTH | |
259 bcf tft_nwr | |
260 bcf tft_cs | |
261 bcf tft_nreset | |
262 WAITMS d'10' | |
263 bsf tft_power ; inverted... | |
0 | 264 return |
265 | |
266 ; ----------------------------- | |
267 ; TFT boot | |
268 ; ----------------------------- | |
582 | 269 |
270 global TFT_boot | |
0 | 271 TFT_boot: |
623 | 272 ; switch off backlight |
273 clrf CCP1CON ; stop PWM | |
274 bcf PORTC,2 ; pull PWM out to GND | |
275 | |
0 | 276 clrf PORTA |
277 clrf PORTH | |
628 | 278 |
0 | 279 RD_L ; LOW |
280 nop | |
628 | 281 WR_L |
282 nop | |
283 NCS_L ; Not CS | |
0 | 284 nop |
285 bcf tft_nreset | |
286 WAITMS d'1' | |
287 bcf tft_power ; inverted... | |
288 WAITMS d'1' | |
289 RD_H ; Keep high | |
628 | 290 nop |
0 | 291 WAITMS d'2' |
292 bsf tft_nreset | |
461 | 293 WAITMS d'5' |
294 bcf tft_nreset | |
295 WAITMS d'5' | |
296 bsf tft_nreset | |
0 | 297 WAITMS d'150' |
628 | 298 WR_H ; release bus |
604 | 299 bsf lightsen_power ; supply power to light sensor |
0 | 300 |
628 | 301 btfsc screen_type3 ; display type 3 ? |
302 bra TFT_boot_screen3 ; YES | |
303 | |
582 | 304 ; Data Transfer Synchronization |
0 | 305 Parameter_out 0x00, 0x00 |
306 Parameter_out 0x00, 0x00 | |
582 | 307 |
623 | 308 btfsc screen_type2 ; display type 2 ? |
309 bra TFT_boot_screen2 ; YES | |
608 | 310 |
623 | 311 ; Get screen type from Bootloader-Info |
582 | 312 movlw 0x7B |
313 movwf TBLPTRL | |
314 movlw 0xF7 | |
315 movwf TBLPTRH | |
316 movlw 0x01 | |
317 movwf TBLPTRU | |
623 | 318 TBLRD*+ ; reads 0x6E for cR and USB OSTC3, 0x00 for BLE (2 and 3), and 0x02 for display 1 OSTC |
319 movlw 0x02 ; coding for display 1 | |
320 cpfseq TABLAT ; display 1 ? | |
321 bra TFT_boot_0 ; NO - display 0 | |
360 | 322 |
323 TFT_boot_1: | |
582 | 324 ; Init through config table... |
325 movlw 0x74 | |
326 movwf TBLPTRL | |
327 movlw 0xF7 | |
328 movwf TBLPTRH | |
329 movlw 0x01 | |
330 movwf TBLPTRU | |
628 | 331 bsf screen_type1 |
582 | 332 bra TFT_boot_com |
360 | 333 |
441
360acdcda0d7
+BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents:
436
diff
changeset
|
334 TFT_boot_0: |
582 | 335 ; Init through config table... |
336 movlw LOW display0_config_table | |
337 movwf TBLPTRL | |
338 movlw HIGH display0_config_table | |
339 movwf TBLPTRH | |
340 movlw UPPER display0_config_table | |
341 movwf TBLPTRU | |
628 | 342 bcf screen_type1 |
582 | 343 |
360 | 344 TFT_boot_com: |
582 | 345 rcall display0_init_loop |
0 | 346 |
582 | 347 Index_out 0x03 |
348 btfsc flip_screen ; 180° rotation ? | |
604 | 349 bra TFT_boot2 ; YES |
360 | 350 |
628 | 351 btfss screen_type1 ; display1? |
604 | 352 bra TFT_boot1a ; NO |
582 | 353 Parameter_out 0x10, 0x00 ; display1 |
354 bra TFT_boot3 | |
360 | 355 TFT_boot1a: |
582 | 356 Parameter_out 0x50, 0x20 ; display0 |
357 bra TFT_boot3 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
358 TFT_boot2: |
628 | 359 btfss screen_type1 ; display1? |
604 | 360 bra TFT_boot2a ; NO |
582 | 361 Parameter_out 0x10, 0x30 ; display1 |
362 bra TFT_boot3 | |
360 | 363 TFT_boot2a: |
582 | 364 Parameter_out 0x50, 0x10 ; display0 |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
365 TFT_boot3: |
0 | 366 Index_out 0x22 |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
152
diff
changeset
|
367 rcall TFT_ClearScreen |
0 | 368 Index_out 0x07 |
312 | 369 Parameter_out 0x01, 0x33 |
0 | 370 return |
371 | |
372 display0_config_table: | |
582 | 373 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end |
374 db 0xA4,0x00,0x01,0xFF,.002,0x00 | |
375 db 0x09,0x00,0x01,0x92,0x04,0x00 | |
376 db 0x93,0x04,0x02,0x94,0x00,0x02 | |
377 db 0x07,0x00,0x00,0x10,0x04,0x30 | |
378 db 0x11,0x02,0x37,0x12,0x11,0x8D | |
379 db 0x13,0x11,0x00,0x01,0x01,0x00 | |
380 db 0x02,0x02,0x00,0x03,0x50,0x20 | |
381 db 0x0A,0x00,0x08,0x0D,0x00,0x00 | |
382 db 0x0E,0x00,0x30,0xFF,.151,0x00 | |
383 db 0x12,0x11,0xBD,0x20,0x00,0x00 | |
384 db 0x21,0x00,0x00,0x30,0x06,0x02 | |
385 db 0x31,0x56,0x0D,0x32,0x05,0x07 | |
386 db 0x33,0x06,0x09,0x34,0x00,0x00 | |
387 db 0x35,0x09,0x06,0x36,0x57,0x05 | |
388 db 0x37,0x0D,0x06,0x38,0x02,0x06 | |
389 db 0x39,0x00,0x00,0xFF,0x00,0x00 | |
0 | 390 |
391 display0_init_loop: | |
582 | 392 TBLRD*+ |
393 movlw 0xFF | |
394 cpfseq TABLAT | |
623 | 395 bra display0_config_write ; write configuration data pair to display |
582 | 396 ; Delay ms or quit (return) |
397 TBLRD*+ | |
623 | 398 tstfsz TABLAT ; end of configuration data? |
604 | 399 bra $+4 ; NO |
400 return ; YES - done | |
582 | 401 movf TABLAT,W |
604 | 402 call WAITMSX ; wait WREG milliseconds |
403 TBLRD*+ ; dummy read (Third byte of delay command) | |
404 bra display0_init_loop ; loop | |
0 | 405 |
604 | 406 display0_config_write: ; with command in WREG |
582 | 407 movf TABLAT,W |
604 | 408 rcall TFT_CmdWrite ; write command |
409 TBLRD*+ ; get config0 | |
582 | 410 movff TABLAT,PORTA |
604 | 411 TBLRD*+ ; get config1 |
582 | 412 movf TABLAT,W |
623 | 413 rcall TFT_DataWrite ; write configuration |
604 | 414 bra display0_init_loop ; loop |
0 | 415 |
623 | 416 |
608 | 417 TFT_boot_screen2: |
623 | 418 rcall display1_init ; initialization sequence |
608 | 419 |
623 | 420 btfss flip_screen ; 180° rotation? |
421 bra TFT_ClearScreen ; NO - done: clear screen and return | |
422 ; flip the GRAM | |
423 Index_out 0x16 | |
424 movlw 0x48 ; flip image in the GRAM (very elegant with display 2...) | |
425 rcall TFT_DataWrite ; Write configuration | |
426 bra TFT_ClearScreen ; clear screen and return | |
608 | 427 |
628 | 428 TFT_boot_screen3: |
429 rcall display1_init ; init sequence | |
430 rcall TFT_ClearScreen | |
431 setf CCPR1L ; duty cycle, 255 is required for OLED | |
432 ; Set brightness | |
433 movff opt_brightness,PRODL ; =0: Eco, =1:Medium, =2:Full | |
434 incf PRODL,F ; +1 | |
435 dcfsnz PRODL,F | |
436 rcall TFT_display3_low | |
437 dcfsnz PRODL,F | |
438 rcall TFT_display3_med | |
439 dcfsnz PRODL,F | |
440 rcall TFT_display3_high | |
441 ; ToDo: Flip.... | |
442 return | |
443 | |
608 | 444 display1_init: |
623 | 445 movlw LOW (0x1F8BC ) |
446 movwf TBLPTRL | |
447 movlw HIGH (0x1F8BC & 0xFFFF) | |
448 movwf TBLPTRH | |
449 movlw UPPER (0x1F8BC ) | |
450 movwf TBLPTRU | |
608 | 451 display1_init_loop: |
623 | 452 TBLRD*+ |
453 movlw 0xFF ; coding for end of configuration or wait step | |
454 cpfseq TABLAT | |
455 bra display1_config_write ; write configuration pair to display | |
456 ; Delay ms or quit (return) | |
457 TBLRD*+ | |
458 tstfsz TABLAT ; end of configuration? | |
459 bra $+4 ; NO - skip return | |
460 return ; YES - done | |
461 movf TABLAT,W ; read waiting time | |
462 call WAITMSX ; wait WREG milliseconds | |
463 bra display1_init_loop ; loop | |
464 display1_config_write: ; with command in WREG | |
465 movf TABLAT,W | |
466 rcall TFT_CmdWrite ; write command | |
467 TBLRD*+ ; get configuration | |
468 movf TABLAT,W | |
469 rcall TFT_DataWrite ; write configuration | |
628 | 470 btfss screen_type3 ; screen 3 ? |
471 bra display1_init_loop ; NO - loop | |
472 ; Screen 3 gets another byte from the table | |
473 TBLRD*+ ; get configuration | |
474 movf TABLAT,W | |
475 rcall TFT_DataWrite ; write configuration | |
623 | 476 bra display1_init_loop ; loop |
608 | 477 |
623 | 478 |
479 global TFT_CmdWrite | |
608 | 480 TFT_CmdWrite: |
481 RS_L ; command | |
628 | 482 ; btfsc screen_type2 |
483 ; bra TFT_CmdWrite_screen2 | |
608 | 484 clrf PORTA ; upper |
485 bcf INTCON,GIE | |
486 movwf PORTH ; lower | |
487 WR_L | |
488 WR_H ; tick | |
489 bsf INTCON,GIE | |
490 return | |
628 | 491 ;TFT_CmdWrite_screen2: |
492 ; movwf PORTH ; lower | |
493 ; WR_L | |
494 ; WR_H ; tick | |
495 ; return; | |
608 | 496 |
497 global TFT_DataWrite | |
498 TFT_DataWrite: | |
499 RS_H ; data | |
628 | 500 ; btfsc screen_type2 |
501 ; bra TFT_DataWrite_screen2 | |
608 | 502 bcf INTCON,GIE |
623 | 503 movwf PORTH ; lower |
608 | 504 WR_L |
505 WR_H ; tick | |
506 bsf INTCON,GIE | |
507 return | |
628 | 508 ;TFT_DataWrite_screen2: |
509 ; movwf PORTH ; lower | |
510 ; WR_L | |
511 ; WR_H ; tick | |
512 ; return | |
608 | 513 |
623 | 514 |
634 | 515 ;----------------------------------------------------------------------------- |
0 | 516 ; Smooth lighting-up of the display: |
517 ; | |
518 ; Trashes: WREG, PRODL | |
519 ; Typical usage: | |
604 | 520 ; clrf CCPR1L ; backlight off |
582 | 521 ; [draw splash screen] |
522 ; call TFT_DisplayFadeIn | |
634 | 523 ; |
582 | 524 global TFT_Display_FadeIn |
0 | 525 TFT_Display_FadeIn: |
623 | 526 movlw CCP1CON_VALUE ; get configuration |
527 movwf CCP1CON ; set configuration | |
604 | 528 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor |
628 | 529 btfsc screen_type3 |
634 | 530 bra TFT_Display_FadeIn_1 |
604 | 531 clrf CCPR1L ; backlight off - to be sure |
582 | 532 movff max_CCPR1L,PRODL |
0 | 533 TFT_Display_FadeIn_0: |
604 | 534 incf CCPR1L,F ; duty cycle |
582 | 535 WAITMS d'2' |
536 decfsz PRODL,F | |
623 | 537 bra TFT_Display_FadeIn_0 |
604 | 538 bcf tft_is_dimming ; dimming done |
582 | 539 return |
628 | 540 TFT_Display_FadeIn_1: |
541 setf CCPR1L | |
542 return | |
0 | 543 |
634 | 544 ;----------------------------------------------------------------------------- |
0 | 545 ; Smooth lighting-off of the display: |
546 ; Trashes: WREG, PRODL | |
634 | 547 ; |
582 | 548 global TFT_Display_FadeOut |
0 | 549 TFT_Display_FadeOut: |
582 | 550 movff max_CCPR1L,PRODL |
604 | 551 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor |
628 | 552 btfsc screen_type3 |
640 | 553 return ; Do not fade out screen type 3 |
0 | 554 TFT_Display_FadeOut_0: |
604 | 555 movff PRODL,CCPR1L ; duty cycle |
582 | 556 WAITMS d'1' |
557 decfsz PRODL,F | |
558 bra TFT_Display_FadeOut_0 | |
628 | 559 TFT_Display_FadeOut_1: |
582 | 560 clrf CCPR1L |
561 return | |
0 | 562 |
634 | 563 ;----------------------------------------------------------------------------- |
564 ; OLED brightness control | |
565 ; | |
628 | 566 TFT_display3_high: ; 0x01F8F8 |
567 movlw LOW (0x01F8F8 ) | |
568 movwf TBLPTRL | |
569 movlw HIGH (0x01F8F8 & 0xFFFF) | |
570 movwf TBLPTRH | |
571 movlw UPPER (0x01F8F8 ) | |
572 movwf TBLPTRU | |
573 bra display1_init_loop ; and return | |
574 | |
575 TFT_display3_med: ; 0x01F91C | |
576 movlw LOW (0x01F91C ) | |
577 movwf TBLPTRL | |
578 movlw HIGH (0x01F91C & 0xFFFF) | |
579 movwf TBLPTRH | |
580 movlw UPPER (0x01F91C ) | |
581 movwf TBLPTRU | |
582 bra display1_init_loop ; and return | |
583 | |
584 TFT_display3_low: ; 0x01F8D4 | |
585 movlw LOW (0x01F8D4 ) | |
586 movwf TBLPTRL | |
587 movlw HIGH (0x01F8D4 & 0xFFFF) | |
588 movwf TBLPTRH | |
589 movlw UPPER (0x01F8D4 ) | |
590 movwf TBLPTRU | |
591 bra display1_init_loop ; and return | |
592 | |
0 | 593 |
634 | 594 ;----------------------------------------------------------------------------- |
595 ; colored (filled) Boxes | |
596 ; | |
597 global box_std_block, box_black_block, box_color_block, box_color | |
0 | 598 |
604 | 599 box_std_block: ; use white color |
582 | 600 setf WREG |
634 | 601 bra box_color_block |
604 | 602 box_black_block: ; use black color |
582 | 603 clrf WREG |
634 | 604 box_color_block: ; use color from WREG |
582 | 605 rcall TFT_set_color |
606 VARARGS_BEGIN | |
607 VARARGS_GET8 win_top | |
608 VARARGS_GET8 win_height | |
609 VARARGS_GET8 win_leftx2 | |
610 VARARGS_GET8 win_width | |
611 VARARGS_END | |
612 bra TFT_box | |
0 | 613 |
634 | 614 box_color: ; use color from WREG and pre-set coordinates |
615 rcall TFT_set_color | |
616 bra TFT_box | |
0 | 617 |
618 | |
634 | 619 ;----------------------------------------------------------------------------- |
620 ; colored Frames | |
621 ; | |
622 global box_frame_std, box_frame_color | |
623 | |
624 box_frame_std: ; use white color | |
582 | 625 setf WREG |
634 | 626 box_frame_color: ; use color from WREG |
582 | 627 rcall TFT_set_color |
628 VARARGS_BEGIN | |
629 VARARGS_GET8 win_top | |
630 VARARGS_GET8 win_height | |
631 VARARGS_GET8 win_leftx2 | |
632 VARARGS_GET8 win_width | |
633 VARARGS_END | |
634 bra TFT_frame | |
634 | 635 |
0 | 636 |
634 | 637 ; ;----------------------------------------------------------------------------- |
638 ; ; Init for half_pixel_write | |
639 ; ; Set column register on TFT device, and current color. | |
640 ; ; Inputs: win_leftx2 | |
641 ; ; Outputs: win_color_1/_2 | |
642 ; ; Trashed: WREG, PROD | |
643 ; ; | |
644 ; ; global init_pixel_write | |
645 ; ;init_pixel_write: | |
646 ; ; movf win_leftx2,W | |
647 ; ; mullw 2 | |
648 ; ; rcall pixel_write_col320 ; start address vertical (.0 - .319) | |
649 ; ; setf WREG | |
650 ; ; bra TFT_set_color | |
651 | |
0 | 652 |
653 ;----------------------------------------------------------------------------- | |
634 | 654 ; Draw two half-pixels at position (win_top,win_leftx2) |
655 ; Inputs: win_leftx2, win_top, win_color_1/_2 | |
0 | 656 ; Trashed: WREG, PROD |
634 | 657 ; |
582 | 658 global pixel_write |
0 | 659 pixel_write: |
582 | 660 movf win_leftx2,W |
623 | 661 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
604 | 662 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
663 rcall half_pixel_write ; write this half-one | |
628 | 664 |
604 | 665 movf win_leftx2,W ; address of next one |
623 | 666 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
667 INCI PROD ; PROD++ | |
582 | 668 rcall pixel_write_col320 |
628 | 669 bra half_pixel_write ; and return... note: cmd 0x20 is mandatory, because |
582 | 670 ; of the auto-increment going vertical |
0 | 671 |
672 global pixel_write_col320 | |
673 pixel_write_col320: | |
628 | 674 btfsc screen_type2 ; display type 2 ? |
675 bra pixel_write_col320_d2 ; YES | |
676 btfsc screen_type1 ; display type 1 ? | |
677 bra pixel_write_col320_d1 ; YES | |
678 btfsc screen_type3 ; display type 3 ? | |
679 bra pixel_write_col320_d3 ; YES | |
680 ; NO to all - display type 0 | |
582 | 681 btfss flip_screen ; 180° rotation? |
604 | 682 bra pixel_write_noflip_H ; NO |
683 bra pixel_write_flip_H ; YES | |
623 | 684 pixel_write_col320_d1: ; display type 1 |
582 | 685 btfsc flip_screen ; 180° rotation? |
623 | 686 bra pixel_write_noflip_H ; YES |
604 | 687 pixel_write_flip_H: ; flip d0 |
688 movf PRODL,W ; 16 bits 319 - PROD --> PROD | |
623 | 689 sublw LOW .319 ; 319-W --> W |
582 | 690 movwf PRODL |
691 movf PRODH,W | |
604 | 692 btfss STATUS,C ; borrow = /CARRY |
582 | 693 incf WREG |
623 | 694 sublw HIGH .319 |
582 | 695 movwf PRODH |
151 | 696 |
697 pixel_write_noflip_H: | |
604 | 698 Index_out 0x21 ; frame memory vertical address |
582 | 699 bra TFT_DataWrite_PROD ; and return... |
0 | 700 |
608 | 701 pixel_write_col320_d2: |
623 | 702 movlw 0x06 |
703 rcall TFT_CmdWrite | |
704 movf PRODH,W | |
705 rcall TFT_DataWrite | |
706 movlw 0x07 | |
707 rcall TFT_CmdWrite | |
708 movf PRODL,W | |
709 rcall TFT_DataWrite | |
608 | 710 |
623 | 711 incf PRODL,F |
712 movlw .0 | |
713 addwfc PRODH,F ; +1 | |
608 | 714 |
623 | 715 movlw 0x08 |
716 rcall TFT_CmdWrite | |
717 movf PRODH,W | |
718 rcall TFT_DataWrite | |
719 movlw 0x09 | |
720 rcall TFT_CmdWrite | |
721 movf PRODL,W | |
722 bra TFT_DataWrite ; ... and return | |
608 | 723 |
628 | 724 pixel_write_col320_d3: |
725 movlw 0x21 ; start address vertical (.0 - .319) | |
726 rcall TFT_CmdWrite | |
727 bra TFT_DataWrite_PROD ; and return... | |
728 | |
0 | 729 ;----------------------------------------------------------------------------- |
634 | 730 ; Write one half-pixel at position (win_top,win_leftx2). |
731 ; Inputs: win_leftx2, win_top, win_color_1/_2 | |
0 | 732 ; Trashed: WREG, PROD |
634 | 733 ; |
582 | 734 global half_pixel_write |
0 | 735 half_pixel_write: |
628 | 736 movf win_top,W ; d'0' ... d'239' |
737 ; Variant with Y position in WREG | |
0 | 738 half_pixel_write_1: |
628 | 739 btfsc screen_type2 ; display type 2 ? |
740 bra half_pixel_write_1_display2 ; YES | |
741 btfsc screen_type3 ; display type 3 ? | |
742 bra half_pixel_write_1_display3 ; YES | |
608 | 743 |
628 | 744 half_pixel_write_1_display1: |
582 | 745 btfss flip_screen ; 180° rotation? |
746 sublw .239 ; 239-Y --> Y | |
604 | 747 mullw .1 ; copy row to PRODL (PRODH=0) |
748 Index_out 0x20 ; frame memory horizontal address | |
582 | 749 rcall TFT_DataWrite_PROD |
0 | 750 |
604 | 751 Index_out 0x22 ; frame memory data write start |
752 RS_H ; data | |
582 | 753 bcf INTCON,GIE |
604 | 754 movff win_color1,PORTA ; upper |
755 movff win_color2,PORTH ; lower | |
582 | 756 WR_L |
604 | 757 WR_H ; tick |
582 | 758 bsf INTCON,GIE |
759 return | |
0 | 760 |
628 | 761 half_pixel_write_1_display2: |
623 | 762 mullw 1 ; copy row to PRODL (PRODH=0) |
763 ; Row address start | |
764 movlw 0x02 | |
765 rcall TFT_CmdWrite | |
766 movlw .0 | |
767 rcall TFT_DataWrite | |
768 movlw 0x03 | |
769 rcall TFT_CmdWrite | |
770 movf PRODL,W | |
771 rcall TFT_DataWrite | |
608 | 772 |
623 | 773 incf PRODL,F |
608 | 774 |
623 | 775 movlw 0x04 |
776 rcall TFT_CmdWrite | |
777 movlw .0 | |
778 rcall TFT_DataWrite | |
779 movlw 0x05 | |
780 rcall TFT_CmdWrite | |
781 movf PRODL,W | |
782 rcall TFT_DataWrite | |
608 | 783 |
784 movff win_color1,PRODH | |
785 movff win_color2,PRODL | |
786 rcall convert_for_display2 | |
787 | |
623 | 788 movlw 0x22 ; start writing data to GRAM |
789 rcall TFT_CmdWrite | |
790 RS_H ; data | |
791 movff win_color5, PORTH | |
608 | 792 WR_L |
623 | 793 WR_H ; tick |
794 movff win_color4, PORTH | |
608 | 795 WR_L |
623 | 796 WR_H ; tick |
797 movff win_color3, PORTH | |
608 | 798 WR_L |
623 | 799 WR_H ; tick |
800 return | |
608 | 801 |
628 | 802 half_pixel_write_1_display3: |
803 mullw 1 ; copy row to PRODL (PRODH=0) | |
804 | |
805 movlw 0x20 ; horizontal address START:END | |
806 rcall TFT_CmdWrite | |
807 rcall TFT_DataWrite_PROD | |
808 | |
809 movlw 0x22 ; start writing data to GRAM | |
810 rcall TFT_CmdWrite | |
811 RS_H ; data | |
812 movff win_color1, PORTH | |
813 WR_L | |
814 WR_H ; tick | |
815 movff win_color2, PORTH | |
816 WR_L | |
817 WR_H ; tick | |
818 return ; done | |
819 | |
0 | 820 ;----------------------------------------------------------------------------- |
634 | 821 ; Draw a vertical line of half-pixel at position (win_top,win_leftx2,win_height). |
822 ; Inputs: win_leftx2, win_top, win_height, win_color_1/_2 | |
0 | 823 ; Trashed: WREG, PROD, TABLAT, TBLPTRL |
634 | 824 ; |
0 | 825 global half_vertical_line |
826 half_vertical_line: | |
604 | 827 clrf TABLAT ; loop index |
0 | 828 |
829 half_vertical_line_loop: | |
604 | 830 movf win_leftx2,W ; init X position |
623 | 831 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
604 | 832 movf TABLAT,W ; get loop index |
833 andlw .1 ; just low bit | |
834 xorwf PRODL,F ; and use it to jitter current X position | |
835 rcall pixel_write_col320 ; start address vertical (.0 - .319) | |
0 | 836 |
604 | 837 movf win_height,W ; index reached height (bank0 read) ? |
582 | 838 xorwf TABLAT,W |
604 | 839 btfsc STATUS,Z ; Equal ? |
840 return ; YES - done | |
841 movf win_top,W ; Y = top + index (bank0 read) | |
582 | 842 addwf TABLAT,W |
843 rcall half_pixel_write_1 | |
844 incf TABLAT,F ; index++ | |
845 bra half_vertical_line_loop | |
0 | 846 |
847 ;----------------------------------------------------------------------------- | |
634 | 848 ; Draw a horizontal line of half-pixel at position (win_top,win_leftx2,win_width). |
849 ; Inputs: win_leftx2, win_top, win_width, win_color_1/_2 | |
0 | 850 ; Trashed: WREG, PROD, TABLAT, TBLPTRL |
634 | 851 ; |
0 | 852 global half_horizontal_line |
853 half_horizontal_line: | |
604 | 854 clrf TABLAT ; loop index |
0 | 855 |
856 half_horizontal_line_loop: | |
604 | 857 movf win_leftx2,W ; init X position |
623 | 858 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
604 | 859 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
860 movf win_width,W ; index reached height (bank0 read) ? | |
582 | 861 xorwf TABLAT,W |
604 | 862 btfsc STATUS,Z ; equal ? |
863 return ; YES - done | |
864 movf win_top,W ; Y = top + index (bank0 read) | |
582 | 865 addwf TABLAT,W |
866 rcall half_pixel_write_1 | |
867 incf TABLAT,F ; index++ | |
868 bra half_horizontal_line_loop | |
0 | 869 |
870 | |
871 ;----------------------------------------------------------------------------- | |
634 | 872 ; TFT Data Command |
873 ; | |
0 | 874 TFT_DataWrite_PROD: |
623 | 875 ; RD_H ; keep high |
876 RS_H ; data | |
877 btfsc screen_type2 ; screen type 2 ? | |
878 bra TFT_DataWrite_PROD_display2 ; YES | |
628 | 879 btfsc screen_type3 ; screen type 3 ? |
880 bra TFT_DataWrite_PROD_display2 ; YES | |
623 | 881 bcf INTCON,GIE ; NO - |
882 movff PRODH,PORTA ; - move high byte to PORTA | |
883 movff PRODL,PORTH ; - move low byte to PORTH | |
884 WR_L ; - tick | |
885 WR_H ; - tack | |
886 bsf INTCON,GIE ; - | |
887 return ; - done | |
0 | 888 |
608 | 889 TFT_DataWrite_PROD_display2: |
623 | 890 movff PRODH,PORTH ; move high byte to PORTH (display 2 is big endian) |
891 WR_L ; tick | |
892 WR_H ; tack | |
893 movff PRODL,PORTH ; move low byte to PORTH | |
894 WR_L ; tick | |
895 WR_H ; tack | |
628 | 896 btfsc screen_type3 ; screen type 3 ? |
897 return ; YES - done | |
898 movff win_color3,PORTH ; NO - move low(est) byte to PORTH | |
899 WR_L ; - tick | |
900 WR_H ; - tack | |
901 return ; - done | |
623 | 902 |
608 | 903 |
0 | 904 TFT_DataRead_PROD: |
604 | 905 Index_out 0x22 ; frame memory data read start |
360 | 906 TFT_CmdRead_PROD: |
604 | 907 setf TRISA ; port A as input |
908 setf TRISH ; port H as input | |
909 RS_H ; data | |
910 WR_H ; not write | |
911 RD_L ; read | |
582 | 912 nop |
913 nop | |
914 nop | |
604 | 915 RD_H ; tick |
582 | 916 nop |
917 nop | |
918 nop | |
604 | 919 RD_L ; read |
582 | 920 nop |
921 ;nop | |
922 ;nop | |
923 movff PORTA,PRODH | |
924 movff PORTH,PRODL | |
604 | 925 RD_H ; tick |
582 | 926 nop |
604 | 927 clrf TRISA ; port A as output |
928 clrf TRISH ; port H as output | |
0 | 929 return |
930 | |
634 | 931 ;----------------------------------------------------------------------------- |
604 | 932 ; Output TFT Window Address commands |
933 ; Inputs : win_top, win_leftx2, win_height, win_width | |
934 ; Output : PortA/PortH commands | |
0 | 935 ; Trashed: PROD |
634 | 936 ; |
582 | 937 global TFT_box_write |
0 | 938 TFT_box_write: |
634 | 939 movf win_leftx2,W ; compute left = 2 * leftx2 --> PROD |
940 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL | |
0 | 941 |
634 | 942 btfsc screen_type2 ; screen type 2 ? |
943 bra TFT_box_write_display2 ; YES | |
944 btfsc screen_type3 ; screen type 3 ? | |
945 bra TFT_box_write_display3 ; YES | |
946 btfsc screen_type1 ; screen type 1 ? | |
947 bra TFT_box_write_display1 ; YES | |
608 | 948 |
623 | 949 ; screen type 0 |
634 | 950 TFT_box_write_display0: |
951 btfsc flip_screen ; 180° rotation? | |
952 bra TFT_box_do_flip_H ; YES | |
953 bra TFT_box_no_flip_H ; NO | |
954 | |
955 ; screen type 1 | |
956 TFT_box_write_display1: | |
957 btfss flip_screen ; 180° rotation? | |
958 bra TFT_box_do_flip_H ; NO | |
959 ;bra TFT_box_no_flip_H ; YES | |
960 | |
582 | 961 ;---- Normal horizontal window --------------------------------------- |
634 | 962 TFT_box_no_flip_H: |
604 | 963 Index_out 0x52 ; window vertical start address |
964 rcall TFT_DataWrite_PROD ; output left | |
965 Index_out 0x21 ; frame memory vertical address | |
966 rcall TFT_DataWrite_PROD ; output left | |
0 | 967 |
582 | 968 movf win_width+0,W ; right = left + width - 1 |
432 | 969 addwf PRODL,F |
970 movf win_width+1,W | |
971 addwfc PRODH,F | |
623 | 972 decf PRODL,F ; right-- |
582 | 973 btfss STATUS,C |
432 | 974 decf PRODH,F |
0 | 975 |
604 | 976 Index_out 0x53 ; window vertical end address |
582 | 977 rcall TFT_DataWrite_PROD |
634 | 978 bra TFT_box_common_H |
0 | 979 |
582 | 980 ;---- Flipped horizontal window -------------------------------------- |
634 | 981 TFT_box_do_flip_H: |
623 | 982 ; calculate new coordinate |
604 | 983 movf PRODL,W ; 16 bits 319 - PROD --> PROD |
623 | 984 sublw LOW .319 ; 319 - WREG --> WREG |
582 | 985 movwf PRODL |
986 movf PRODH,W | |
604 | 987 btfss STATUS,C ; borrow = /CARRY |
582 | 988 incf WREG |
623 | 989 sublw HIGH .319 |
582 | 990 movwf PRODH |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
991 |
604 | 992 Index_out 0x53 ; window vertical start address |
993 rcall TFT_DataWrite_PROD ; output left | |
994 Index_out 0x21 ; frame memory vertical address | |
995 rcall TFT_DataWrite_PROD ; output left | |
151 | 996 |
623 | 997 ; calculate new coordinate |
604 | 998 movf win_width+0,W ; 16 bits PROD - width --> PROD |
582 | 999 subwf PRODL,F ; PRODL - WREG --> PRODL |
1000 movf win_width+1,W | |
1001 subwfb PRODH,F | |
623 | 1002 INCI PROD ; PROD++ |
151 | 1003 |
604 | 1004 Index_out 0x52 ; window vertical end address |
582 | 1005 rcall TFT_DataWrite_PROD |
151 | 1006 |
634 | 1007 TFT_box_common_H: |
582 | 1008 btfss flip_screen ; 180° rotation ? |
634 | 1009 bra TFT_box_no_flip_V ; NO |
1010 ;bra TFT_box_do_flip_V ; YES | |
151 | 1011 |
582 | 1012 ;---- Flipped vertical window ----------------------------------------- |
634 | 1013 TFT_box_do_flip_V: |
623 | 1014 ; calculate new coordinate |
582 | 1015 movff win_top,PRODH ; top --> PRODH (first byte) |
1016 movf win_height,W | |
1017 addwf PRODH,W | |
432 | 1018 decf WREG |
604 | 1019 movwf PRODL ; top + height - 1 --> PRODL (second byte) |
151 | 1020 |
604 | 1021 Index_out 0x50 ; window horizontal start address |
432 | 1022 movf PRODH,W |
604 | 1023 rcall TFT_DataWrite ; lower (and tick) |
151 | 1024 |
604 | 1025 Index_out 0x51 ; window horizontal end address |
582 | 1026 movf PRODL,W |
604 | 1027 rcall TFT_DataWrite ; lower (and tick) |
582 | 1028 |
604 | 1029 Index_out 0x20 ; frame memory horizontal address |
432 | 1030 movf PRODH,W |
604 | 1031 bra TFT_DataWrite ; lower (and tick) and return |
151 | 1032 |
582 | 1033 ;---- Normal vertical window ---------------------------------------- |
634 | 1034 TFT_box_no_flip_V: |
582 | 1035 movff win_top,PRODL |
1036 movf win_height,W | |
1037 addwf PRODL,W | |
1038 sublw .240 ; 240 - top - height | |
604 | 1039 movwf PRODH ; first byte |
0 | 1040 |
432 | 1041 movf PRODL,W |
604 | 1042 sublw .239 ; 239 - top |
1043 movwf PRODL ; --> second byte | |
0 | 1044 |
604 | 1045 Index_out 0x50 ; window horizontal start address |
432 | 1046 movf PRODH,W |
604 | 1047 rcall TFT_DataWrite ; lower (and tick) |
0 | 1048 |
604 | 1049 Index_out 0x51 ; window horizontal end address |
432 | 1050 movf PRODL,W |
604 | 1051 rcall TFT_DataWrite ; lower (and tick) |
0 | 1052 |
604 | 1053 Index_out 0x20 ; frame memory horizontal address |
432 | 1054 movf PRODL,W |
604 | 1055 bra TFT_DataWrite ; lower (and tick) and return |
582 | 1056 |
608 | 1057 |
623 | 1058 TFT_box_write_display2: |
631 | 1059 ; setup left border |
623 | 1060 movlw 0x06 |
1061 rcall TFT_CmdWrite | |
1062 movf PRODH,W | |
1063 rcall TFT_DataWrite | |
1064 movlw 0x07 | |
1065 rcall TFT_CmdWrite | |
1066 movf PRODL,W | |
1067 rcall TFT_DataWrite | |
608 | 1068 |
623 | 1069 movf win_width+0,W ; right = left + width - 1 |
1070 addwf PRODL,F | |
1071 movf win_width+1,W | |
1072 addwfc PRODH,F | |
631 | 1073 decf PRODL,F ; decrement result |
623 | 1074 btfss STATUS,C |
631 | 1075 decf PRODH,F |
608 | 1076 |
631 | 1077 ; setup right border |
623 | 1078 movlw 0x08 |
1079 rcall TFT_CmdWrite | |
1080 movf PRODH,W | |
1081 rcall TFT_DataWrite | |
1082 movlw 0x09 | |
1083 rcall TFT_CmdWrite | |
1084 movf PRODL,W | |
1085 rcall TFT_DataWrite | |
1086 | |
1087 ;---- Normal vertical window ----------------------------------------- | |
1088 ; Output (top) (bottom) | |
1089 movff win_top,PRODH ; top --> PRODH (first byte) | |
1090 movf win_height,W | |
1091 addwf PRODH,W | |
1092 decf WREG | |
1093 movwf PRODL ; top+height-1 --> PRODL (second byte) | |
608 | 1094 |
623 | 1095 movlw 0x02 |
1096 rcall TFT_CmdWrite | |
1097 movlw 0x00 | |
1098 rcall TFT_DataWrite | |
1099 movlw 0x03 | |
1100 rcall TFT_CmdWrite | |
1101 movf PRODH,W | |
1102 rcall TFT_DataWrite | |
608 | 1103 |
623 | 1104 movlw 0x04 |
1105 rcall TFT_CmdWrite | |
1106 movlw 0x00 | |
1107 rcall TFT_DataWrite | |
1108 movlw 0x05 | |
1109 rcall TFT_CmdWrite | |
1110 movf PRODL,W | |
1111 bra TFT_DataWrite ; ... and return | |
0 | 1112 |
628 | 1113 TFT_box_write_display3: |
1114 ;---- Normal horizontal window --------------------------------------- | |
1115 ; Output 0x35 left, | |
631 | 1116 ; 0x36 right == left + width - 1. |
628 | 1117 |
1118 Index_out 0x35 ; window vertical start address | |
1119 rcall TFT_DataWrite_PROD ; output left | |
1120 Index_out 0x21 ; also the horizontal first pix coordinate | |
1121 rcall TFT_DataWrite_PROD ; output left | |
1122 | |
631 | 1123 movf win_width+0,W ; right = left + width - 1 |
628 | 1124 addwf PRODL,F |
631 | 1125 movf win_width+1,W |
628 | 1126 addwfc PRODH,F |
631 | 1127 decf PRODL,F ; decrement result |
634 | 1128 btfss STATUS,C |
631 | 1129 decf PRODH,F |
628 | 1130 |
631 | 1131 Index_out 0x36 ; write and the right border |
628 | 1132 rcall TFT_DataWrite_PROD |
1133 | |
1134 ;---- Normal vertical window ----------------------------------------- | |
1135 ; Output 0x37 (top) (bottom) | |
1136 movff win_top,PRODH ; top --> PRODH (first byte) | |
1137 movff win_height,WREG | |
1138 addwf PRODH,W | |
1139 decf WREG | |
1140 movwf PRODL ; top + height - 1 --> PRODL (second byte) | |
1141 | |
1142 Index_out 0x37 | |
1143 rcall TFT_DataWrite_PROD | |
1144 | |
1145 movff PRODH,PRODL | |
1146 clrf PRODH ; start pixel V coord == top. | |
1147 Index_out 0x20 | |
1148 bra TFT_DataWrite_PROD ; and return... | |
1149 | |
1150 | |
634 | 1151 ;----------------------------------------------------------------------------- |
604 | 1152 ; TFT_frame : draw a frame around current box with current color |
0 | 1153 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
1154 ; Outputs: (none) | |
1155 ; Trashed: WREG, PROD, aa_start:2, aa_end:2 | |
634 | 1156 ; |
582 | 1157 global TFT_frame |
1158 TFT_frame: | |
623 | 1159 movff win_top,tft_save_top ; backup everything |
1160 movff win_height,tft_save_height | |
1161 movff win_leftx2,tft_save_left | |
631 | 1162 movff win_width+0,tft_save_width |
0 | 1163 |
582 | 1164 ;---- TOP line ----------------------------------------------------------- |
623 | 1165 movlw .1 ; row ~ height = 1 |
582 | 1166 movwf win_height |
1167 rcall TFT_box | |
0 | 1168 |
582 | 1169 ;---- BOTTOM line -------------------------------------------------------- |
623 | 1170 movff tft_save_top,PRODL ; get back top |
1171 movff tft_save_height,WREG ; get back height | |
1172 addwf PRODL,W ; top + height | |
1173 decf WREG ; top + height - 1 | |
1174 movwf win_top ; top + height - 1 --> top | |
582 | 1175 rcall TFT_box |
0 | 1176 |
582 | 1177 ;---- LEFT column -------------------------------------------------------- |
623 | 1178 movff tft_save_top,win_top ; restore top/height |
1179 movff tft_save_height,win_height | |
1180 movlw .1 ; column ~ width = 1 | |
582 | 1181 movwf win_width+0 |
1182 rcall TFT_box | |
1183 | |
1184 ;---- RIGHT column ------------------------------------------------------- | |
623 | 1185 movff tft_save_left,WREG |
1186 movff tft_save_width,PRODL | |
582 | 1187 addwf PRODL,W |
1188 decf WREG | |
1189 movwf win_leftx2 | |
1190 rcall TFT_box | |
1191 | |
1192 ;---- Restore everything ------------------------------------------------- | |
623 | 1193 movff tft_save_left,win_leftx2 |
631 | 1194 movff tft_save_width,win_width+0 |
582 | 1195 return |
0 | 1196 |
634 | 1197 ;----------------------------------------------------------------------------- |
604 | 1198 ; TFT_box: fills current box with current color |
1199 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
0 | 1200 ; Outputs: (none) |
1201 ; Trashed: WREG, PROD | |
634 | 1202 ; |
582 | 1203 global TFT_box |
0 | 1204 TFT_box: |
582 | 1205 ;---- Define Window ------------------------------------------------------ |
1206 bcf STATUS,C | |
1207 rlcf win_width+0,F | |
1208 rlcf win_width+1,F ; x2 | |
604 | 1209 rcall TFT_box_write ; setup box |
0 | 1210 |
582 | 1211 bcf STATUS,C |
1212 rrcf win_width+1,F ; width /= 2 | |
1213 rrcf win_width+0,F | |
0 | 1214 |
582 | 1215 ;---- Fill Window -------------------------------------------------------- |
604 | 1216 Index_out 0x22 ; frame memory data write start |
1217 clrf PRODH ; column counter | |
1218 RS_H ; data | |
0 | 1219 |
628 | 1220 btfsc screen_type2 ; display type 2 ? |
1221 bra TFT_box_display2 ; YES | |
1222 btfsc screen_type3 ; display type 3 ? | |
1223 bra TFT_box_display3 ; YES | |
1224 | |
604 | 1225 TFT_box2: ; loop height times |
0 | 1226 movff win_height,PRODL |
1227 | |
582 | 1228 TFT_box3: ; loop width times |
623 | 1229 bcf INTCON,GIE |
604 | 1230 movff win_color1,PORTA ; upper |
1231 movff win_color2,PORTH ; lower | |
634 | 1232 WR_L ; tick |
1233 WR_H ; ... | |
1234 WR_L ; tick | |
1235 WR_H ; ... | |
582 | 1236 bsf INTCON,GIE |
1237 decfsz PRODL,F ; row loop finished ? | |
604 | 1238 bra TFT_box3 ; NO - continue |
0 | 1239 |
582 | 1240 incf PRODH,F ; column count ++ |
628 | 1241 movf win_bargraph,W ; get width of active bargraph part |
1242 cpfseq PRODH ; current column == end of active bargraph ? | |
604 | 1243 bra TFT_box4 ; NO - just loop |
628 | 1244 clrf win_color1 ; YES - switch to black |
604 | 1245 clrf win_color2 ; - ... |
0 | 1246 TFT_box4: |
628 | 1247 movf win_width+0,W ; get total bargraph width |
1248 xorwf PRODH,W ; all columns done? | |
1249 bnz TFT_box2 ; NO - loop | |
0 | 1250 |
582 | 1251 movlw 0x00 ; NOP, to stop window mode |
1252 rcall TFT_CmdWrite | |
0 | 1253 |
604 | 1254 ; reset bargraph mode... |
582 | 1255 setf win_bargraph |
1256 return | |
623 | 1257 |
608 | 1258 TFT_box_display2: |
628 | 1259 ; Screen 2 |
608 | 1260 movff win_color1,PRODH |
1261 movff win_color2,PRODL | |
1262 rcall convert_for_display2 | |
631 | 1263 clrf PRODH ; column counter |
623 | 1264 TFT_box2_display2: ; loop height times |
608 | 1265 movff win_height,PRODL |
623 | 1266 TFT_box3_display2: ; loop width times |
608 | 1267 movff win_color5,PORTH |
623 | 1268 bcf tft_nwr |
1269 bsf tft_nwr ; upper | |
608 | 1270 movff win_color4,PORTH |
1271 bcf tft_nwr | |
623 | 1272 bsf tft_nwr ; high |
608 | 1273 movff win_color3,PORTH |
1274 bcf tft_nwr | |
623 | 1275 bsf tft_nwr ; low |
608 | 1276 |
1277 movff win_color5,PORTH | |
1278 bcf tft_nwr | |
623 | 1279 bsf tft_nwr ; upper |
608 | 1280 movff win_color4,PORTH |
1281 bcf tft_nwr | |
623 | 1282 bsf tft_nwr ; high |
608 | 1283 movff win_color3,PORTH |
1284 bcf tft_nwr | |
623 | 1285 bsf tft_nwr ; low |
1286 decfsz PRODL,F ; row loop finished? | |
1287 bra TFT_box3_display2 ; NO - loop | |
1288 incf PRODH,F ; YES - column count ++ | |
1289 movf win_bargraph,W ; - get bargraph width | |
1290 cpfseq PRODH ; - current column = bargraph ? | |
1291 bra TFT_box4_display2 ; NO | |
1292 clrf win_color5 ; YES - switch to black | |
1293 clrf win_color4 ; - ... | |
1294 clrf win_color3 ; - ... | |
608 | 1295 TFT_box4_display2: |
623 | 1296 movf win_width+0,W ; get width |
1297 cpfseq PRODH ; width loop finished ? | |
1298 bra TFT_box2_display2 ; NO - loop | |
1299 setf win_bargraph ; YES - reset bargraph mode | |
1300 return ; - done | |
0 | 1301 |
628 | 1302 TFT_box_display3: |
1303 ; Screen 3 | |
1304 TFT_box2_display3: ; loop height times | |
1305 movff win_height,PRODL | |
1306 TFT_box3_display3: ; loop width times | |
1307 movff win_color1,PORTH | |
1308 bcf tft_nwr | |
1309 bsf tft_nwr ; upper | |
1310 movff win_color2,PORTH | |
1311 bcf tft_nwr | |
1312 bsf tft_nwr ; high | |
1313 movff win_color1,PORTH | |
1314 bcf tft_nwr | |
1315 bsf tft_nwr ; low | |
1316 movff win_color2,PORTH | |
1317 bcf tft_nwr | |
1318 bsf tft_nwr ; upper | |
1319 decfsz PRODL,F ; row loop finished? | |
1320 bra TFT_box3_display3 ; NO - loop | |
1321 incf PRODH,F ; YES - column count ++ | |
1322 movf win_bargraph,W ; - get bargraph width | |
1323 cpfseq PRODH ; - current column = bargraph ? | |
1324 bra TFT_box4_display3 ; NO | |
1325 clrf win_color1 ; Yes - switch to black | |
1326 clrf win_color2 ; - ... | |
1327 TFT_box4_display3: | |
1328 movf win_width+0,W ; get width | |
1329 cpfseq PRODH ; width loop finished ? | |
1330 bra TFT_box2_display3 ; NO - loop | |
1331 setf win_bargraph ; YES - reset bargraph mode | |
1332 return | |
1333 | |
0 | 1334 |
634 | 1335 ;----------------------------------------------------------------------------- |
1336 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB b'RRRRRGGGGGGBBBBB' | |
1337 ; WREG win_color1 win_color2 | |
582 | 1338 global TFT_set_color |
0 | 1339 TFT_set_color: |
631 | 1340 movwf tft_temp1 ; get 8 bit RGB b'RRRGGGBB' into tft_temp1... |
634 | 1341 movwf tft_temp2 ; ... and tft_temp2 |
0 | 1342 |
604 | 1343 ; mask bit 7,6,5,4,3,2 |
0 | 1344 movlw b'00000011' |
1345 andwf tft_temp2,F | |
1346 | |
1347 movlw b'00000000' | |
1348 dcfsnz tft_temp2,F | |
1349 movlw b'01010000' | |
1350 dcfsnz tft_temp2,F | |
1351 movlw b'10100000' | |
1352 dcfsnz tft_temp2,F | |
1353 movlw b'11111000' | |
604 | 1354 movwf tft_temp3 ; blue done |
0 | 1355 |
604 | 1356 movff tft_temp1,tft_temp2 ; copy |
1357 ; mask bit 7,6,5,1,0 | |
0 | 1358 movlw b'00011100' |
1359 andwf tft_temp2,F | |
1360 rrncf tft_temp2,F | |
1361 rrncf tft_temp2,F | |
1362 | |
1363 movlw b'00000000' | |
1364 dcfsnz tft_temp2,F | |
1365 movlw b'00000100' | |
1366 dcfsnz tft_temp2,F | |
1367 movlw b'00001000' | |
1368 dcfsnz tft_temp2,F | |
1369 movlw b'00001100' | |
1370 dcfsnz tft_temp2,F | |
1371 movlw b'00010000' | |
1372 dcfsnz tft_temp2,F | |
1373 movlw b'00010100' | |
1374 dcfsnz tft_temp2,F | |
1375 movlw b'00100000' | |
1376 dcfsnz tft_temp2,F | |
1377 movlw b'00111111' | |
582 | 1378 movwf tft_temp4 |
0 | 1379 |
1380 rrcf tft_temp4,F | |
1381 rrcf tft_temp3,F | |
1382 | |
1383 rrcf tft_temp4,F | |
1384 rrcf tft_temp3,F | |
1385 | |
1386 rrcf tft_temp4,F | |
604 | 1387 rrcf tft_temp3,W ; tft_temp3 (b'GGGBBBBB') done |
1388 movwf win_color2 ; set color registers... | |
0 | 1389 |
604 | 1390 movff tft_temp1,tft_temp2 ; copy |
0 | 1391 clrf tft_temp1 |
1392 | |
1393 rrcf tft_temp4,F | |
1394 rrcf tft_temp1,F | |
1395 | |
1396 rrcf tft_temp4,F | |
1397 rrcf tft_temp1,F | |
1398 | |
1399 rrcf tft_temp4,F | |
604 | 1400 rrcf tft_temp1,F ; green done |
0 | 1401 |
604 | 1402 ; mask bit 4,3,2,1,0 |
0 | 1403 movlw b'11100000' |
1404 andwf tft_temp2,F | |
1405 | |
1406 rrncf tft_temp2,F | |
1407 rrncf tft_temp2,F | |
1408 rrncf tft_temp2,F | |
1409 rrncf tft_temp2,F | |
1410 rrncf tft_temp2,F | |
1411 | |
1412 movlw b'00000000' | |
1413 dcfsnz tft_temp2,F | |
1414 movlw b'00000100' | |
1415 dcfsnz tft_temp2,F | |
1416 movlw b'00001000' | |
1417 dcfsnz tft_temp2,F | |
1418 movlw b'00001100' | |
1419 dcfsnz tft_temp2,F | |
1420 movlw b'00010000' | |
1421 dcfsnz tft_temp2,F | |
1422 movlw b'00010100' | |
1423 dcfsnz tft_temp2,F | |
1424 movlw b'00100000' | |
1425 dcfsnz tft_temp2,F | |
1426 movlw b'00111111' | |
582 | 1427 movwf tft_temp4 |
0 | 1428 |
1429 rrcf tft_temp4,F | |
1430 rrcf tft_temp1,F | |
1431 | |
1432 rrcf tft_temp4,F | |
604 | 1433 rrcf tft_temp1,F |
0 | 1434 |
1435 rrcf tft_temp4,F | |
1436 rrcf tft_temp1,F | |
1437 | |
1438 rrcf tft_temp4,F | |
1439 rrcf tft_temp1,F | |
1440 | |
1441 rrcf tft_temp4,F | |
604 | 1442 rrcf tft_temp1,W ; red done |
1443 movwf win_color1 ; set color registers | |
0 | 1444 return |
623 | 1445 |
1446 | |
608 | 1447 global convert_for_display2 |
623 | 1448 convert_for_display2: ; convert 16 bit RGB b'RRRRRGGG GGGBBBBB' into 24 bit RGB b'RRRRRR00 GGGGGG00 BBBBBB00' |
1449 ; PRODH PRODL win_color5 win_color4 win_color3 | |
1450 ; Red | |
1451 movff PRODH,win_color5 ; = RRRRRGGG | |
1452 bcf win_color5,2 ; = RRRRR0GG | |
1453 btfsc win_color5,7 | |
1454 bsf win_color5,2 ; = RRRRR1GG the lower two bits are ignored by the screen | |
1455 ; Blue | |
1456 movff PRODL,win_color3 | |
1457 rrcf win_color3,F ; = UGGGBBBB and the LSB-blue into carry | |
1458 swapf win_color3,F ; = BBBBUGGG | |
1459 bcf win_color3,3 ; = BBBB0GGG | |
608 | 1460 btfsc STATUS,C |
623 | 1461 bsf win_color3,3 ; = BBBB1GGG |
1462 bcf win_color3,2 ; = BBBBB0GG | |
1463 btfsc win_color3,7 | |
1464 bsf win_color3,2 ; = BBBBB1GG | |
1465 ; Green | |
1466 rrcf PRODH,F | |
1467 rrcf PRODL,F | |
1468 rrcf PRODH,F | |
1469 rrcf PRODL,F | |
1470 rrcf PRODH,F | |
1471 rrcf PRODL,F ; = GGGGGGBB the lower two bits are ignored by the screen | |
1472 movff PRODL,win_color4 | |
608 | 1473 return |
623 | 1474 |
0 | 1475 |
634 | 1476 ;----------------------------------------------------------------------------- |
0 | 1477 |
604 | 1478 IFDEF _screendump |
1479 | |
623 | 1480 ;----------------------------------------------------------------------------- |
1481 ; Dump screen contents to the UART | |
1482 ; | |
604 | 1483 global TFT_dump_screen_check |
1484 TFT_dump_screen_check: | |
1485 btfss vusb_in ; USB (still) plugged in? | |
623 | 1486 bcf screen_dump_avail ; NO - disable screen dump function |
631 | 1487 |
1488 SERIAL_CC_RECEIVE WREG ; try to read a byte from RS232 | |
623 | 1489 btfsc rs232_rx_timeout ; anything received? |
631 | 1490 return ; NO - done |
1491 xorlw "l" ; YES - exclusive-or with coding of screen dump command | |
1492 tstfsz WREG ; - screen dump command received? | |
604 | 1493 return ; NO - return |
631 | 1494 ;bra TFT_dump_screen ; YES - serve screen dump request |
623 | 1495 |
631 | 1496 global TFT_dump_screen |
623 | 1497 TFT_dump_screen: |
1498 btfsc screen_type2 ; is this an OSTC with a screen of type 2? | |
631 | 1499 return ; YES - not supported, abort |
623 | 1500 bsf block_sensor_interrupt ; NO - disable sensor interrupts |
631 | 1501 SERIAL_LC_SEND 'l' ; - send command acknowledge |
1502 | |
604 | 1503 |
582 | 1504 ;---- Send DISPLAY box command for the full screen window ------------------- |
604 | 1505 Index_out 0x50 ; window horizontal start address |
582 | 1506 Parameter_out 0x00, 0x00 ; 0-239 |
604 | 1507 Index_out 0x51 ; window horizontal end address |
582 | 1508 Parameter_out 0x00, 0xEF ; 0-239 |
604 | 1509 Index_out 0x52 ; window vertical start address |
582 | 1510 Parameter_out 0x00, 0x00 ; 0-319 |
604 | 1511 Index_out 0x53 ; window vertical end address |
582 | 1512 Parameter_out 0x01, 0x3F ; 0-319 |
0 | 1513 |
582 | 1514 clrf ds_column |
1515 rcall dump_screen_pixel_reset | |
0 | 1516 dump_screen_1: |
582 | 1517 btg LEDr ; LED activity toggle |
631 | 1518 ; dump even column |
604 | 1519 movlw .240 ; 240 lines, once |
582 | 1520 movwf ds_line |
0 | 1521 dump_screen_2: |
604 | 1522 Index_out 0x20 ; frame memory horizontal address |
582 | 1523 movff ds_line,WREG ; d'0' ... d'239' |
604 | 1524 mullw .1 ; copy row to PRODH:L |
582 | 1525 rcall TFT_DataWrite_PROD |
0 | 1526 |
623 | 1527 movff ds_column,WREG ; initialize X position |
1528 mullw .2 ; ds_column x 2 -> PRODH:PRODL | |
604 | 1529 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
0 | 1530 |
582 | 1531 rcall TFT_DataRead_PROD ; read pixel |
1532 rcall dump_screen_pixel | |
0 | 1533 |
582 | 1534 decfsz ds_line,F |
1535 bra dump_screen_2 | |
1536 rcall dump_screen_pixel_flush | |
0 | 1537 |
631 | 1538 ; dump odd column |
604 | 1539 movlw .240 ; 240 lines, twice |
582 | 1540 movwf ds_line |
0 | 1541 dump_screen_3: |
604 | 1542 Index_out 0x20 ; frame memory horizontal address |
582 | 1543 movff ds_line,WREG ; d'0' ... d'239' |
623 | 1544 mullw .1 ; copy row to PRODH:L |
582 | 1545 rcall TFT_DataWrite_PROD |
0 | 1546 |
623 | 1547 movff ds_column,WREG ; initialize X position |
1548 mullw .2 ; ds_column x 2 -> PRODH:PRODL | |
1549 INCI PROD ; PROD++ | |
604 | 1550 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
0 | 1551 |
582 | 1552 rcall TFT_DataRead_PROD ; read pixel |
631 | 1553 rcall dump_screen_pixel ; compress and send pixel |
0 | 1554 |
582 | 1555 decfsz ds_line,F |
1556 bra dump_screen_3 | |
1557 rcall dump_screen_pixel_flush | |
0 | 1558 |
582 | 1559 incf ds_column,F |
1560 movlw .160 | |
1561 cpfseq ds_column | |
1562 bra dump_screen_1 | |
0 | 1563 |
623 | 1564 bcf block_sensor_interrupt ; re-enable sensor interrupts |
604 | 1565 clrf RCREG1 ; clear receive buffer |
1566 bcf RCSTA1,CREN ; clear receiver status | |
631 | 1567 bsf RCSTA1,CREN ; ... |
623 | 1568 bsf screen_dump_avail ; enable screen dump function |
582 | 1569 return |
0 | 1570 |
623 | 1571 ;----------------------------------------------------------------------------- |
0 | 1572 ; Pixel compression |
1573 ; | |
604 | 1574 ; Input : PRODH:L = pixel |
0 | 1575 ; Output: Compressed stream on output. |
1576 ; Compressed format: | |
604 | 1577 ; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128) |
1578 ; 11cccccc : WHITE pixel, repeated cccccc+1 times (1.. 64) | |
1579 ; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1.. 64) | |
623 | 1580 ; |
0 | 1581 dump_screen_pixel: |
604 | 1582 movf PRODH,W ; compare pixel-high |
582 | 1583 xorwf ds_pixel+1,W |
604 | 1584 bnz dump_screen_pixel_1 ; different -> dump |
0 | 1585 |
604 | 1586 movf PRODL,W ; compare pixel-low |
582 | 1587 xorwf ds_pixel+0,W |
604 | 1588 bnz dump_screen_pixel_1 ; different -> dump |
0 | 1589 |
604 | 1590 incf ds_count,F ; same color: just increment |
582 | 1591 return |
0 | 1592 |
604 | 1593 dump_screen_pixel_1: ; send (pixel,count) tuple |
1594 movf ds_count,W ; is count zero ? | |
1595 bz dump_screen_pixel_2 ; YES - skip sending | |
0 | 1596 |
604 | 1597 movf ds_pixel+1,W ; is this a BLACK pixel ? |
582 | 1598 iorwf ds_pixel+0,W |
604 | 1599 bz dump_screen_pix_black ; YES |
0 | 1600 |
604 | 1601 movf ds_pixel+1,W ; is this a white pixel ? |
582 | 1602 andwf ds_pixel+0,W |
1603 incf WREG | |
604 | 1604 bz dump_screen_pix_white ; YES |
0 | 1605 |
582 | 1606 ; No: write the pixel itself... |
604 | 1607 movlw .64 ; max color pixel on a single byte |
1608 cpfsgt ds_count ; skip if count > 64 | |
582 | 1609 movf ds_count,W ; W <- min(64,count) |
1610 subwf ds_count,F ; ds_count <- ds_count-W | |
604 | 1611 decf WREG ; save as 0..63 |
1612 iorlw b'10000000' ; mark as a color pixel | |
0 | 1613 |
631 | 1614 SERIAL_CC_SEND WREG ; send byte in WREG |
1615 SERIAL_CC_SEND ds_pixel+1 ; send bytes in ds_pixel, high byte first | |
1616 SERIAL_CC_SEND ds_pixel+0 ; low byte last | |
1617 | |
582 | 1618 bra dump_screen_pixel_1 |
0 | 1619 |
1620 dump_screen_pixel_2: | |
604 | 1621 movff PRODH,ds_pixel+1 ; save new pixel color |
582 | 1622 movff PRODL,ds_pixel+0 |
1623 movlw 1 | |
604 | 1624 movwf ds_count ; and set count=1 |
582 | 1625 return |
0 | 1626 |
1627 dump_screen_pix_black: | |
604 | 1628 movlw .128 ; max black pixel on a single byte |
1629 cpfsgt ds_count ; skip if count > 128 | |
582 | 1630 movf ds_count,W ; W <- min(128,count) |
1631 subwf ds_count,F ; ds_count <- ds_count-W | |
604 | 1632 decf WREG ; save as 0..127 |
623 | 1633 |
0 | 1634 dump_screen_pix_3: |
631 | 1635 SERIAL_CC_SEND WREG ; send byte in WREG |
604 | 1636 bra dump_screen_pixel_1 ; more to dump ? |
0 | 1637 |
1638 dump_screen_pix_white: | |
604 | 1639 movlw .64 ; max white pixel on a single byte |
1640 cpfsgt ds_count ; skip if count > 64 | |
582 | 1641 movf ds_count,W ; W <- min(64,count) |
1642 subwf ds_count,F ; ds_count <- ds_count-W | |
631 | 1643 decf WREG ; save as 0..63 |
604 | 1644 iorlw b'11000000' ; mark as a compressed white |
631 | 1645 bra dump_screen_pix_3 ; send pixel |
0 | 1646 |
1647 dump_screen_pixel_flush: | |
582 | 1648 clrf PRODH |
1649 clrf PRODL | |
604 | 1650 rcall dump_screen_pixel_1 ; send it |
0 | 1651 dump_screen_pixel_reset: |
604 | 1652 clrf ds_count ; clear count |
582 | 1653 return |
0 | 1654 |
623 | 1655 ENDIF ; _screendump |
1656 | |
634 | 1657 ;----------------------------------------------------------------------------- |
604 | 1658 |
582 | 1659 END |