Mercurial > public > hwos_code
comparison src/tft.asm @ 631:185ba2f91f59
3.09 beta 1 release
| author | heinrichsweikamp |
|---|---|
| date | Fri, 28 Feb 2020 15:45:07 +0100 |
| parents | cd58f7fc86db |
| children | 4050675965ea |
comparison
equal
deleted
inserted
replaced
| 630:4cd81bdbf15c | 631:185ba2f91f59 |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File tft.asm combined next generation V3.03.7 | 3 ; File tft.asm combined next generation V3.08.8 |
| 4 ; | 4 ; |
| 5 ; low-level Display Outputs | 5 ; low-level Display Outputs |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 188 return | 188 return |
| 189 | 189 |
| 190 TFT_ClearScreen_display3: | 190 TFT_ClearScreen_display3: |
| 191 movlw 0x35 ; vertical start address HIGH:LOW | 191 movlw 0x35 ; vertical start address HIGH:LOW |
| 192 rcall TFT_CmdWrite | 192 rcall TFT_CmdWrite |
| 193 mullw 0 | 193 mullw 0 |
| 194 rcall TFT_DataWrite_PROD | 194 rcall TFT_DataWrite_PROD |
| 195 | 195 |
| 196 movlw 0x36 ; vertical end address HIGH:LOW | 196 movlw 0x36 ; vertical end address HIGH:LOW |
| 197 rcall TFT_CmdWrite | 197 rcall TFT_CmdWrite |
| 198 movlw 0x01 | 198 movlw 0x01 |
| 225 ;============================================================================= | 225 ;============================================================================= |
| 226 | 226 |
| 227 global TFT_DisplayOff | 227 global TFT_DisplayOff |
| 228 TFT_DisplayOff: | 228 TFT_DisplayOff: |
| 229 bcf lightsen_power ; power-down light sensor | 229 bcf lightsen_power ; power-down light sensor |
| 230 btfsc screen_type3 | 230 btfsc screen_type3 ; screen type 3 ? |
| 231 bra TFT_DisplayOff_display3 ; screen needs special power-down sequence | 231 bra TFT_DisplayOff_display3 ; YES - screen needs special power-down sequence |
| 232 clrf CCP1CON ; stop PWM | 232 clrf CCP1CON ; NO - stop PWM |
| 233 bcf PORTC,2 ; pull PWM out to GND | 233 bcf PORTC,2 ; - pull PWM out to GND |
| 234 clrf PORTA | 234 clrf PORTA |
| 235 clrf PORTH | 235 clrf PORTH |
| 236 RD_L ; LOW | 236 RD_L ; LOW |
| 237 RS_L ; LOW | 237 RS_L ; LOW |
| 238 bcf tft_nwr | 238 bcf tft_nwr |
| 1049 movf PRODL,W | 1049 movf PRODL,W |
| 1050 bra TFT_DataWrite ; lower (and tick) and return | 1050 bra TFT_DataWrite ; lower (and tick) and return |
| 1051 | 1051 |
| 1052 | 1052 |
| 1053 TFT_box_write_display2: | 1053 TFT_box_write_display2: |
| 1054 ; setup left border | |
| 1054 movlw 0x06 | 1055 movlw 0x06 |
| 1055 rcall TFT_CmdWrite | 1056 rcall TFT_CmdWrite |
| 1056 movf PRODH,W | 1057 movf PRODH,W |
| 1057 rcall TFT_DataWrite | 1058 rcall TFT_DataWrite |
| 1058 movlw 0x07 | 1059 movlw 0x07 |
| 1062 | 1063 |
| 1063 movf win_width+0,W ; right = left + width - 1 | 1064 movf win_width+0,W ; right = left + width - 1 |
| 1064 addwf PRODL,F | 1065 addwf PRODL,F |
| 1065 movf win_width+1,W | 1066 movf win_width+1,W |
| 1066 addwfc PRODH,F | 1067 addwfc PRODH,F |
| 1067 decf PRODL,F,A ; decrement result | 1068 decf PRODL,F ; decrement result |
| 1068 btfss STATUS,C | 1069 btfss STATUS,C |
| 1069 decf PRODH,F,A | 1070 decf PRODH,F |
| 1070 | 1071 |
| 1072 ; setup right border | |
| 1071 movlw 0x08 | 1073 movlw 0x08 |
| 1072 rcall TFT_CmdWrite | 1074 rcall TFT_CmdWrite |
| 1073 movf PRODH,W | 1075 movf PRODH,W |
| 1074 rcall TFT_DataWrite | 1076 rcall TFT_DataWrite |
| 1075 movlw 0x09 | 1077 movlw 0x09 |
| 1104 bra TFT_DataWrite ; ... and return | 1106 bra TFT_DataWrite ; ... and return |
| 1105 | 1107 |
| 1106 TFT_box_write_display3: | 1108 TFT_box_write_display3: |
| 1107 ;---- Normal horizontal window --------------------------------------- | 1109 ;---- Normal horizontal window --------------------------------------- |
| 1108 ; Output 0x35 left, | 1110 ; Output 0x35 left, |
| 1109 ; 0x36 right == left + width - 1. | 1111 ; 0x36 right == left + width - 1. |
| 1110 | 1112 |
| 1111 Index_out 0x35 ; window vertical start address | 1113 Index_out 0x35 ; window vertical start address |
| 1112 rcall TFT_DataWrite_PROD ; output left | 1114 rcall TFT_DataWrite_PROD ; output left |
| 1113 Index_out 0x21 ; also the horizontal first pix coordinate | 1115 Index_out 0x21 ; also the horizontal first pix coordinate |
| 1114 rcall TFT_DataWrite_PROD ; output left | 1116 rcall TFT_DataWrite_PROD ; output left |
| 1115 | 1117 |
| 1116 movf win_width+0,W,ACCESS ; right = left + width - 1 | 1118 movf win_width+0,W ; right = left + width - 1 |
| 1117 addwf PRODL,F | 1119 addwf PRODL,F |
| 1118 movf win_width+1,W,ACCESS | 1120 movf win_width+1,W |
| 1119 addwfc PRODH,F | 1121 addwfc PRODH,F |
| 1120 decf PRODL,F,A ; decrement result | 1122 decf PRODL,F ; decrement result |
| 1121 btfss STATUS,C | 1123 btfss STATUS,C |
| 1122 decf PRODH,F,A | 1124 decf PRODH,F |
| 1123 | 1125 |
| 1124 Index_out 0x36 ; Write and the right border | 1126 Index_out 0x36 ; write and the right border |
| 1125 rcall TFT_DataWrite_PROD | 1127 rcall TFT_DataWrite_PROD |
| 1126 | 1128 |
| 1127 ;---- Normal vertical window ----------------------------------------- | 1129 ;---- Normal vertical window ----------------------------------------- |
| 1128 ; Output 0x37 (top) (bottom) | 1130 ; Output 0x37 (top) (bottom) |
| 1129 movff win_top,PRODH ; top --> PRODH (first byte) | 1131 movff win_top,PRODH ; top --> PRODH (first byte) |
| 1150 global TFT_frame | 1152 global TFT_frame |
| 1151 TFT_frame: | 1153 TFT_frame: |
| 1152 movff win_top,tft_save_top ; backup everything | 1154 movff win_top,tft_save_top ; backup everything |
| 1153 movff win_height,tft_save_height | 1155 movff win_height,tft_save_height |
| 1154 movff win_leftx2,tft_save_left | 1156 movff win_leftx2,tft_save_left |
| 1155 movff win_width,tft_save_width | 1157 movff win_width+0,tft_save_width |
| 1156 | 1158 |
| 1157 ;---- TOP line ----------------------------------------------------------- | 1159 ;---- TOP line ----------------------------------------------------------- |
| 1158 movlw .1 ; row ~ height = 1 | 1160 movlw .1 ; row ~ height = 1 |
| 1159 movwf win_height | 1161 movwf win_height |
| 1160 rcall TFT_box | 1162 rcall TFT_box |
| 1182 movwf win_leftx2 | 1184 movwf win_leftx2 |
| 1183 rcall TFT_box | 1185 rcall TFT_box |
| 1184 | 1186 |
| 1185 ;---- Restore everything ------------------------------------------------- | 1187 ;---- Restore everything ------------------------------------------------- |
| 1186 movff tft_save_left,win_leftx2 | 1188 movff tft_save_left,win_leftx2 |
| 1187 movff tft_save_width,win_width | 1189 movff tft_save_width,win_width+0 |
| 1188 return | 1190 return |
| 1189 | 1191 |
| 1190 ;============================================================================= | 1192 ;============================================================================= |
| 1191 ; TFT_box: fills current box with current color | 1193 ; TFT_box: fills current box with current color |
| 1192 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | 1194 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
| 1251 TFT_box_display2: | 1253 TFT_box_display2: |
| 1252 ; Screen 2 | 1254 ; Screen 2 |
| 1253 movff win_color1,PRODH | 1255 movff win_color1,PRODH |
| 1254 movff win_color2,PRODL | 1256 movff win_color2,PRODL |
| 1255 rcall convert_for_display2 | 1257 rcall convert_for_display2 |
| 1258 clrf PRODH ; column counter | |
| 1256 TFT_box2_display2: ; loop height times | 1259 TFT_box2_display2: ; loop height times |
| 1257 movff win_height,PRODL | 1260 movff win_height,PRODL |
| 1258 TFT_box3_display2: ; loop width times | 1261 TFT_box3_display2: ; loop width times |
| 1259 movff win_color5,PORTH | 1262 movff win_color5,PORTH |
| 1260 bcf tft_nwr | 1263 bcf tft_nwr |
| 1326 ;============================================================================= | 1329 ;============================================================================= |
| 1327 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB b'RRRRRGGGGGGBBBBB' | 1330 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB b'RRRRRGGGGGGBBBBB' |
| 1328 | 1331 |
| 1329 global TFT_set_color | 1332 global TFT_set_color |
| 1330 TFT_set_color: | 1333 TFT_set_color: |
| 1331 movwf tft_temp1 ; get 8 Bit RGB b'RRRGGGBB' | 1334 movwf tft_temp1 ; get 8 bit RGB b'RRRGGGBB' into tft_temp1... |
| 1332 movwf tft_temp2 ; copy | 1335 movwf tft_temp2 ; ... and tft_temp2 |
| 1333 | 1336 |
| 1334 ; mask bit 7,6,5,4,3,2 | 1337 ; mask bit 7,6,5,4,3,2 |
| 1335 movlw b'00000011' | 1338 movlw b'00000011' |
| 1336 andwf tft_temp2,F | 1339 andwf tft_temp2,F |
| 1337 | 1340 |
| 1470 | 1473 |
| 1471 ;----------------------------------------------------------------------------- | 1474 ;----------------------------------------------------------------------------- |
| 1472 ; Dump screen contents to the UART | 1475 ; Dump screen contents to the UART |
| 1473 ; | 1476 ; |
| 1474 global TFT_dump_screen_check | 1477 global TFT_dump_screen_check |
| 1475 global TFT_dump_screen | |
| 1476 TFT_dump_screen_check: | 1478 TFT_dump_screen_check: |
| 1477 return | 1479 return |
| 1478 btfss vusb_in ; USB (still) plugged in? | 1480 btfss vusb_in ; USB (still) plugged in? |
| 1479 bcf screen_dump_avail ; NO - disable screen dump function | 1481 bcf screen_dump_avail ; NO - disable screen dump function |
| 1480 call rs232_get_byte ; try to read data from RS232 | 1482 |
| 1483 SERIAL_CC_RECEIVE WREG ; try to read a byte from RS232 | |
| 1481 btfsc rs232_rx_timeout ; anything received? | 1484 btfsc rs232_rx_timeout ; anything received? |
| 1482 return ; NO - return | 1485 return ; NO - done |
| 1483 movlw "l" ; YES - load coding for screen dump command | 1486 xorlw "l" ; YES - exclusive-or with coding of screen dump command |
| 1484 cpfseq RCREG1 ; screen dump command received? | 1487 tstfsz WREG ; - screen dump command received? |
| 1485 return ; NO - return | 1488 return ; NO - return |
| 1486 | 1489 ;bra TFT_dump_screen ; YES - serve screen dump request |
| 1490 | |
| 1491 global TFT_dump_screen | |
| 1487 TFT_dump_screen: | 1492 TFT_dump_screen: |
| 1488 btfsc screen_type2 ; is this an OSTC with a screen of type 2? | 1493 btfsc screen_type2 ; is this an OSTC with a screen of type 2? |
| 1489 return ; YES - not supported | 1494 return ; YES - not supported, abort |
| 1490 bsf block_sensor_interrupt ; NO - disable sensor interrupts | 1495 bsf block_sensor_interrupt ; NO - disable sensor interrupts |
| 1491 movlw 'l' ; - prepare response | 1496 SERIAL_LC_SEND 'l' ; - send command acknowledge |
| 1492 movwf TXREG ; - send response | 1497 |
| 1493 call rs232_wait_tx ; - wait for UART | |
| 1494 | 1498 |
| 1495 ;---- Send DISPLAY box command for the full screen window ------------------- | 1499 ;---- Send DISPLAY box command for the full screen window ------------------- |
| 1496 Index_out 0x50 ; window horizontal start address | 1500 Index_out 0x50 ; window horizontal start address |
| 1497 Parameter_out 0x00, 0x00 ; 0-239 | 1501 Parameter_out 0x00, 0x00 ; 0-239 |
| 1498 Index_out 0x51 ; window horizontal end address | 1502 Index_out 0x51 ; window horizontal end address |
| 1504 | 1508 |
| 1505 clrf ds_column | 1509 clrf ds_column |
| 1506 rcall dump_screen_pixel_reset | 1510 rcall dump_screen_pixel_reset |
| 1507 dump_screen_1: | 1511 dump_screen_1: |
| 1508 btg LEDr ; LED activity toggle | 1512 btg LEDr ; LED activity toggle |
| 1509 ; Dump even column | 1513 ; dump even column |
| 1510 movlw .240 ; 240 lines, once | 1514 movlw .240 ; 240 lines, once |
| 1511 movwf ds_line | 1515 movwf ds_line |
| 1512 dump_screen_2: | 1516 dump_screen_2: |
| 1513 Index_out 0x20 ; frame memory horizontal address | 1517 Index_out 0x20 ; frame memory horizontal address |
| 1514 movff ds_line,WREG ; d'0' ... d'239' | 1518 movff ds_line,WREG ; d'0' ... d'239' |
| 1524 | 1528 |
| 1525 decfsz ds_line,F | 1529 decfsz ds_line,F |
| 1526 bra dump_screen_2 | 1530 bra dump_screen_2 |
| 1527 rcall dump_screen_pixel_flush | 1531 rcall dump_screen_pixel_flush |
| 1528 | 1532 |
| 1529 ; Dump odd column | 1533 ; dump odd column |
| 1530 movlw .240 ; 240 lines, twice | 1534 movlw .240 ; 240 lines, twice |
| 1531 movwf ds_line | 1535 movwf ds_line |
| 1532 dump_screen_3: | 1536 dump_screen_3: |
| 1533 Index_out 0x20 ; frame memory horizontal address | 1537 Index_out 0x20 ; frame memory horizontal address |
| 1534 movff ds_line,WREG ; d'0' ... d'239' | 1538 movff ds_line,WREG ; d'0' ... d'239' |
| 1539 mullw .2 ; ds_column x 2 -> PRODH:PRODL | 1543 mullw .2 ; ds_column x 2 -> PRODH:PRODL |
| 1540 INCI PROD ; PROD++ | 1544 INCI PROD ; PROD++ |
| 1541 rcall pixel_write_col320 ; start address vertical (.0 - .319) | 1545 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
| 1542 | 1546 |
| 1543 rcall TFT_DataRead_PROD ; read pixel | 1547 rcall TFT_DataRead_PROD ; read pixel |
| 1544 rcall dump_screen_pixel | 1548 rcall dump_screen_pixel ; compress and send pixel |
| 1545 | 1549 |
| 1546 decfsz ds_line,F | 1550 decfsz ds_line,F |
| 1547 bra dump_screen_3 | 1551 bra dump_screen_3 |
| 1548 rcall dump_screen_pixel_flush | 1552 rcall dump_screen_pixel_flush |
| 1549 | 1553 |
| 1553 bra dump_screen_1 | 1557 bra dump_screen_1 |
| 1554 | 1558 |
| 1555 bcf block_sensor_interrupt ; re-enable sensor interrupts | 1559 bcf block_sensor_interrupt ; re-enable sensor interrupts |
| 1556 clrf RCREG1 ; clear receive buffer | 1560 clrf RCREG1 ; clear receive buffer |
| 1557 bcf RCSTA1,CREN ; clear receiver status | 1561 bcf RCSTA1,CREN ; clear receiver status |
| 1558 bsf RCSTA1,CREN | 1562 bsf RCSTA1,CREN ; ... |
| 1559 bsf screen_dump_avail ; enable screen dump function | 1563 bsf screen_dump_avail ; enable screen dump function |
| 1560 return | 1564 return |
| 1561 | 1565 |
| 1562 ;----------------------------------------------------------------------------- | 1566 ;----------------------------------------------------------------------------- |
| 1563 ; Pixel compression | 1567 ; Pixel compression |
| 1600 movf ds_count,W ; W <- min(64,count) | 1604 movf ds_count,W ; W <- min(64,count) |
| 1601 subwf ds_count,F ; ds_count <- ds_count-W | 1605 subwf ds_count,F ; ds_count <- ds_count-W |
| 1602 decf WREG ; save as 0..63 | 1606 decf WREG ; save as 0..63 |
| 1603 iorlw b'10000000' ; mark as a color pixel | 1607 iorlw b'10000000' ; mark as a color pixel |
| 1604 | 1608 |
| 1605 movwf TXREG | 1609 SERIAL_CC_SEND WREG ; send byte in WREG |
| 1606 call rs232_wait_tx ; wait for UART | 1610 SERIAL_CC_SEND ds_pixel+1 ; send bytes in ds_pixel, high byte first |
| 1607 movff ds_pixel+1,TXREG | 1611 SERIAL_CC_SEND ds_pixel+0 ; low byte last |
| 1608 call rs232_wait_tx ; wait for UART | 1612 |
| 1609 movff ds_pixel+0,TXREG | |
| 1610 call rs232_wait_tx ; wait for UART | |
| 1611 bra dump_screen_pixel_1 | 1613 bra dump_screen_pixel_1 |
| 1612 | 1614 |
| 1613 dump_screen_pixel_2: | 1615 dump_screen_pixel_2: |
| 1614 movff PRODH,ds_pixel+1 ; save new pixel color | 1616 movff PRODH,ds_pixel+1 ; save new pixel color |
| 1615 movff PRODL,ds_pixel+0 | 1617 movff PRODL,ds_pixel+0 |
| 1623 movf ds_count,W ; W <- min(128,count) | 1625 movf ds_count,W ; W <- min(128,count) |
| 1624 subwf ds_count,F ; ds_count <- ds_count-W | 1626 subwf ds_count,F ; ds_count <- ds_count-W |
| 1625 decf WREG ; save as 0..127 | 1627 decf WREG ; save as 0..127 |
| 1626 | 1628 |
| 1627 dump_screen_pix_3: | 1629 dump_screen_pix_3: |
| 1628 movwf TXREG | 1630 SERIAL_CC_SEND WREG ; send byte in WREG |
| 1629 call rs232_wait_tx | |
| 1630 bra dump_screen_pixel_1 ; more to dump ? | 1631 bra dump_screen_pixel_1 ; more to dump ? |
| 1631 | 1632 |
| 1632 dump_screen_pix_white: | 1633 dump_screen_pix_white: |
| 1633 movlw .64 ; max white pixel on a single byte | 1634 movlw .64 ; max white pixel on a single byte |
| 1634 cpfsgt ds_count ; skip if count > 64 | 1635 cpfsgt ds_count ; skip if count > 64 |
| 1635 movf ds_count,W ; W <- min(64,count) | 1636 movf ds_count,W ; W <- min(64,count) |
| 1636 subwf ds_count,F ; ds_count <- ds_count-W | 1637 subwf ds_count,F ; ds_count <- ds_count-W |
| 1637 decf WREG ; Save as 0..63 | 1638 decf WREG ; save as 0..63 |
| 1638 iorlw b'11000000' ; mark as a compressed white | 1639 iorlw b'11000000' ; mark as a compressed white |
| 1639 bra dump_screen_pix_3 | 1640 bra dump_screen_pix_3 ; send pixel |
| 1640 | 1641 |
| 1641 dump_screen_pixel_flush: | 1642 dump_screen_pixel_flush: |
| 1642 clrf PRODH | 1643 clrf PRODH |
| 1643 clrf PRODL | 1644 clrf PRODL |
| 1644 rcall dump_screen_pixel_1 ; send it | 1645 rcall dump_screen_pixel_1 ; send it |
