comparison 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
comparison
equal deleted inserted replaced
655:c7b7b8a358cd 656:8af5aefbcdaf
70 ;============================================================================= 70 ;=============================================================================
71 71
72 global TFT_ClearScreen 72 global TFT_ClearScreen
73 TFT_ClearScreen: 73 TFT_ClearScreen:
74 btfsc screen_type4 ; screen type 4? 74 btfsc screen_type4 ; screen type 4?
75 bra TFT_ClearScreen_display4; YES
76 btfsc screen_type5 ; screen type 5?
75 bra TFT_ClearScreen_display4; YES 77 bra TFT_ClearScreen_display4; YES
76 btfsc screen_type3 ; screen type 3? 78 btfsc screen_type3 ; screen type 3?
77 bra TFT_ClearScreen_display3; YES 79 bra TFT_ClearScreen_display3; YES
78 btfsc screen_type2 ; screen type 2? 80 btfsc screen_type2 ; screen type 2?
79 bra TFT_ClearScreen_display2; YES 81 bra TFT_ClearScreen_display2; YES
371 bra TFT_boot_screen3 ; YES 373 bra TFT_boot_screen3 ; YES
372 374
373 btfsc screen_type4 ; display type 4 ? 375 btfsc screen_type4 ; display type 4 ?
374 bra TFT_boot_screen4 ; YES 376 bra TFT_boot_screen4 ; YES
375 377
378 btfsc screen_type5 ; display type 5 ?
379 bra TFT_boot_screen5 ; YES
380
381
376 ; Data Transfer Synchronization 382 ; Data Transfer Synchronization
377 Parameter_out 0x00, 0x00 383 Parameter_out 0x00, 0x00
378 Parameter_out 0x00, 0x00 384 Parameter_out 0x00, 0x00
379 385
380 btfsc screen_type2 ; display type 2 ? 386 btfsc screen_type2 ; display type 2 ?
545 ; Screen 3 gets another byte from the table 551 ; Screen 3 gets another byte from the table
546 TBLRD*+ ; get configuration 552 TBLRD*+ ; get configuration
547 movf TABLAT,W 553 movf TABLAT,W
548 rcall TFT_DataWrite ; write configuration 554 rcall TFT_DataWrite ; write configuration
549 bra display1_init_loop ; loop 555 bra display1_init_loop ; loop
550 556
551 TFT_boot_screen4: 557 TFT_boot_screen4:
552 movlw 0xB0 558 movlw 0x11
553 rcall TFT_CmdWrite 559 rcall TFT_CmdWrite
554 movlw 0x00 560 WAITMS d'120'
555 rcall TFT_DataWrite 561
556 movlw 0xC4 562 movlw 0x36 ; x/y mirror, see page 125 of ST7789V datasheet
563 rcall TFT_CmdWrite
564 movlw 0x80 ; 0x80 (flipped orientation)
565 btfss flip_screen ; 180° rotation?
566 movlw 0x40 ; NO, 0x40 (normal orientation)
557 rcall TFT_DataWrite 567 rcall TFT_DataWrite
558 568
559 movlw 0xB1 569 movlw LOW display4_config_table
560 rcall TFT_CmdWrite 570 movwf TBLPTRL
561 movlw 0xC0 571 movlw HIGH display4_config_table
562 rcall TFT_DataWrite 572 movwf TBLPTRH
573 movlw UPPER display4_config_table
574 movwf TBLPTRU
575 bra display45_init_loop ; use common loop
563 576
564 movlw 0x3A 577 TFT_boot_screen5:
565 rcall TFT_CmdWrite 578 movlw 0x11
566 movlw 0x55 579 rcall TFT_CmdWrite
580 WAITMS d'120'
581
582 movlw 0x36
583 rcall TFT_CmdWrite
584 movlw b'11001000' ; 0xC8 (flipped orientation)
585 btfss flip_screen ; 180° rotation?
586 movlw b'00001000' ; NO, 0x08 (normal orientation)
567 rcall TFT_DataWrite 587 rcall TFT_DataWrite
568 588
569 movlw 0x36 ; x/y mirror, see page 125 of ST7789V datasheet 589 movlw LOW display5_config_table
570 rcall TFT_CmdWrite 590 movwf TBLPTRL
571 movlw 0x40 ; 0x40 (normal orientation) 591 movlw HIGH display5_config_table
572 rcall TFT_DataWrite 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
573 612
574 movlw 0xB0 613 display45_init_loop2:
575 rcall TFT_CmdWrite 614 movlw 0x21
576 movlw 0x00 615 rcall TFT_CmdWrite
577 rcall TFT_DataWrite 616 WAITMS d'60'
617 movlw 0x29
618 rcall TFT_CmdWrite
619 WAITMS d'120'
620 rcall TFT_ClearScreen
621 return ; done TFT_boot
622
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
578 637
579 movlw 0xB2 638 display5_config_table:
580 call TFT_CmdWrite 639 ; Reg, Dat0, Dat1, Dat2, ... 0xFF for command end, 0xFF 0xFF for init end
581 movlw 0x0C 640 db 0x13,0xFF,0xEF,0x01,0x01,0x00,0xFF,0xED
582 rcall TFT_DataWrite 641 db 0x64,0x03,0x12,0x81,0xFF,0xE8,0x85,0x00
583 movlw 0x0C 642 db 0x7A,0xFF,0xCB,0x39,0x2C,0x00,0x35,0x06
584 rcall TFT_DataWrite 643 db 0xFF,0xEA,0x00,0x00,0xFF,0xC0,0x20,0xFF
585 movlw 0x00 644 db 0xC1,0x13,0xFF,0xC5,0x39,0x27,0xFF,0xC7
586 rcall TFT_DataWrite 645 db 0xA6,0xFF,0x36,0x08,0xFF,0x3A,0x55,0xFF
587 movlw 0x33 646 db 0xB1,0x00,0x0B,0xFF,0xB6,0x08,0x82,0x27
588 rcall TFT_DataWrite 647 db 0xFF,0xF2,0x00,0xFF,0x26,0x01,0xFF,0xFF
589 movlw 0x33
590 rcall TFT_DataWrite
591 648
592 movlw 0xB7
593 rcall TFT_CmdWrite
594 movlw 0x75
595 rcall TFT_DataWrite
596
597 movlw 0xBB
598 rcall TFT_CmdWrite
599 movlw 0x20
600 rcall TFT_DataWrite
601
602 movlw 0xC0
603 rcall TFT_CmdWrite
604 movlw 0x2C
605 rcall TFT_DataWrite
606
607 movlw 0xC2
608 rcall TFT_CmdWrite
609 movlw 0x01
610 rcall TFT_DataWrite
611
612 movlw 0xC3
613 rcall TFT_CmdWrite
614 movlw 0x19
615 rcall TFT_DataWrite
616
617 movlw 0xC4
618 rcall TFT_CmdWrite
619 movlw 0x20
620 rcall TFT_DataWrite
621
622 movlw 0xC6
623 rcall TFT_CmdWrite
624 movlw 0x0F
625 rcall TFT_DataWrite
626
627 movlw 0xD0
628 rcall TFT_CmdWrite
629 movlw 0xA7
630 rcall TFT_DataWrite
631 movlw 0xA1
632 rcall TFT_DataWrite
633
634 movlw 0xBB
635 rcall TFT_CmdWrite
636 movlw 0x35
637 rcall TFT_DataWrite
638
639 movlw 0xC0
640 rcall TFT_CmdWrite
641 movlw 0x2C
642 rcall TFT_DataWrite
643
644 movlw 0xC2
645 rcall TFT_CmdWrite
646 movlw 0x01
647 rcall TFT_DataWrite
648
649 movlw 0xC3
650 rcall TFT_CmdWrite
651 movlw 0x11
652 rcall TFT_DataWrite
653
654 movlw 0xC4
655 rcall TFT_CmdWrite
656 movlw 0x20
657 rcall TFT_DataWrite
658
659 movlw 0xC6
660 rcall TFT_CmdWrite
661 movlw 0x0F
662 rcall TFT_DataWrite
663
664 movlw 0xD0
665 rcall TFT_CmdWrite
666 movlw 0xA7
667 rcall TFT_DataWrite
668 movlw 0xA1
669 rcall TFT_DataWrite
670
671 movlw 0xBB
672 rcall TFT_CmdWrite
673 movlw 0x35
674 rcall TFT_DataWrite
675
676 movlw 0xC0
677 rcall TFT_CmdWrite
678 movlw 0x2C
679 rcall TFT_DataWrite
680
681 movlw 0x2C
682 rcall TFT_CmdWrite
683 movlw 0x01
684 rcall TFT_DataWrite
685
686 movlw 0xC3
687 rcall TFT_CmdWrite
688 movlw 0x11
689 rcall TFT_DataWrite
690
691 movlw 0xC4
692 rcall TFT_CmdWrite
693 movlw 0x20
694 rcall TFT_DataWrite
695
696 movlw 0xC6
697 rcall TFT_CmdWrite
698 movlw 0x0F
699 rcall TFT_DataWrite
700
701 movlw 0xD0
702 rcall TFT_CmdWrite
703 movlw 0xA4
704 rcall TFT_DataWrite
705 movlw 0xA1
706 rcall TFT_DataWrite
707 ; gamma
708 movlw 0x11
709 rcall TFT_CmdWrite
710
711 movlw 0x21
712 rcall TFT_CmdWrite
713 WAITMS d'60'
714
715 movlw 0x29
716 rcall TFT_CmdWrite
717 WAITMS d'50'
718 rcall TFT_ClearScreen
719 ; ToDo: Flip....
720 return ; done TFT_boot
721
722 649
723 global TFT_CmdWrite 650 global TFT_CmdWrite
724 TFT_CmdWrite: 651 TFT_CmdWrite:
725 RS_L ; command 652 RS_L ; command
726 ; btfsc screen_type2 653 ; btfsc screen_type2
936 863
937 global pixel_write_col320 864 global pixel_write_col320
938 pixel_write_col320: 865 pixel_write_col320:
939 btfsc screen_type4 ; display type 4 ? 866 btfsc screen_type4 ; display type 4 ?
940 bra pixel_write_col320_d4 ; YES 867 bra pixel_write_col320_d4 ; YES
868 btfsc screen_type5 ; display type 5 ?
869 bra pixel_write_col320_d4 ; YES
941 btfsc screen_type3 ; display type 3 ? 870 btfsc screen_type3 ; display type 3 ?
942 bra pixel_write_col320_d3 ; YES 871 bra pixel_write_col320_d3 ; YES
943 btfsc screen_type2 ; display type 2 ? 872 btfsc screen_type2 ; display type 2 ?
944 bra pixel_write_col320_d2 ; YES 873 bra pixel_write_col320_d2 ; YES
945 btfsc screen_type1 ; display type 1 ? 874 btfsc screen_type1 ; display type 1 ?
992 movlw 0x21 ; start address vertical (.0 - .319) 921 movlw 0x21 ; start address vertical (.0 - .319)
993 rcall TFT_CmdWrite 922 rcall TFT_CmdWrite
994 bra TFT_DataWrite_PROD ; and return... 923 bra TFT_DataWrite_PROD ; and return...
995 924
996 pixel_write_col320_d4: 925 pixel_write_col320_d4:
997 movlw 0x2A 926 movlw 0x2B
998 rcall TFT_CmdWrite 927 rcall TFT_CmdWrite
999 rcall TFT_DataWrite_PROD 928 movf PRODH,W
929 rcall TFT_DataWrite
930 movf PRODL,W
931 rcall TFT_DataWrite
1000 incf PRODL,F 932 incf PRODL,F
1001 movlw .0 933 movlw .0
1002 addwfc PRODH,F ; +1 934 addwfc PRODH,F ; +1
1003 bra TFT_DataWrite_PROD ; and return... 935 movf PRODH,W
1004 936 rcall TFT_DataWrite
937 movf PRODL,W
938 bra TFT_DataWrite ; and return
939
1005 ;----------------------------------------------------------------------------- 940 ;-----------------------------------------------------------------------------
1006 ; Write one half-pixel at position (win_top,win_leftx2). 941 ; Write one half-pixel at position (win_top,win_leftx2).
1007 ; Inputs: win_leftx2, win_top, win_color_1/_2 942 ; Inputs: win_leftx2, win_top, win_color_1/_2
1008 ; Trashed: WREG, PROD 943 ; Trashed: WREG, PROD
1009 ; 944 ;
1012 movf win_top,W ; d'0' ... d'239' 947 movf win_top,W ; d'0' ... d'239'
1013 ; Variant with Y position in WREG 948 ; Variant with Y position in WREG
1014 half_pixel_write_1: 949 half_pixel_write_1:
1015 btfsc screen_type4 ; display type 4 ? 950 btfsc screen_type4 ; display type 4 ?
1016 bra half_pixel_write_1_display4 ; YES 951 bra half_pixel_write_1_display4 ; YES
1017 btfsc screen_type3 ; display type 3 ? 952 btfsc screen_type5 ; display type 5 ?
953 bra half_pixel_write_1_display4 ; YES
954 btfsc screen_type3 ; display type 3 ?
1018 bra half_pixel_write_1_display3 ; YES 955 bra half_pixel_write_1_display3 ; YES
1019 btfsc screen_type2 ; display type 2 ? 956 btfsc screen_type2 ; display type 2 ?
1020 bra half_pixel_write_1_display2 ; YES 957 bra half_pixel_write_1_display2 ; YES
1021 958
1022 half_pixel_write_1_display1: 959 half_pixel_write_1_display1:
1107 return ; done 1044 return ; done
1108 1045
1109 half_pixel_write_1_display4: 1046 half_pixel_write_1_display4:
1110 mullw 1 ; copy row to PRODL (PRODH=0) 1047 mullw 1 ; copy row to PRODL (PRODH=0)
1111 ; Row address start 1048 ; Row address start
1112 movlw 0x2B 1049 movlw 0x2A
1113 rcall TFT_CmdWrite 1050 rcall TFT_CmdWrite
1114 movlw 0x00 1051 movlw 0x00
1115 rcall TFT_DataWrite 1052 rcall TFT_DataWrite
1116 movf PRODL,W 1053 movf PRODL,W
1117 rcall TFT_DataWrite 1054 rcall TFT_DataWrite
1265 movf win_leftx2,W ; compute left = 2 * leftx2 --> PROD 1202 movf win_leftx2,W ; compute left = 2 * leftx2 --> PROD
1266 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL 1203 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL
1267 1204
1268 btfsc screen_type4 ; screen type 4 ? 1205 btfsc screen_type4 ; screen type 4 ?
1269 bra TFT_box_write_display4 ; YES 1206 bra TFT_box_write_display4 ; YES
1207 btfsc screen_type5 ; screen type 5 ?
1208 bra TFT_box_write_display4 ; YES
1270 btfsc screen_type3 ; screen type 3 ? 1209 btfsc screen_type3 ; screen type 3 ?
1271 bra TFT_box_write_display3 ; YES 1210 bra TFT_box_write_display3 ; YES
1272 btfsc screen_type2 ; screen type 2 ? 1211 btfsc screen_type2 ; screen type 2 ?
1273 bra TFT_box_write_display2 ; YES 1212 bra TFT_box_write_display2 ; YES
1274 btfsc screen_type1 ; screen type 1 ? 1213 btfsc screen_type1 ; screen type 1 ?
1585 1524
1586 ;---- Fill Window -------------------------------------------------------- 1525 ;---- Fill Window --------------------------------------------------------
1587 movlw 0x22 ; frame memory data write start 1526 movlw 0x22 ; frame memory data write start
1588 btfsc screen_type4 1527 btfsc screen_type4
1589 movlw 0x2C ; Start Writing Data to GRAM (Display 4) 1528 movlw 0x2C ; Start Writing Data to GRAM (Display 4)
1529 btfsc screen_type5
1530 movlw 0x2C ; Start Writing Data to GRAM (Display 4)
1590 rcall TFT_CmdWrite 1531 rcall TFT_CmdWrite
1591 1532
1592 clrf PRODH ; column counter 1533 clrf PRODH ; column counter
1593 RS_H ; data 1534 RS_H ; data
1594 1535
1595 btfsc screen_type4 ; display type 4 ? 1536 btfsc screen_type4 ; display type 4 ?
1537 bra TFT_box_display4 ; YES
1538 btfsc screen_type5 ; display type 5 ?
1596 bra TFT_box_display4 ; YES 1539 bra TFT_box_display4 ; YES
1597 btfsc screen_type3 ; display type 3 ? 1540 btfsc screen_type3 ; display type 3 ?
1598 bra TFT_box_display3 ; YES 1541 bra TFT_box_display3 ; YES
1599 btfsc screen_type2 ; display type 2 ? 1542 btfsc screen_type2 ; display type 2 ?
1600 bra TFT_box_display2 ; YES 1543 bra TFT_box_display2 ; YES