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