Mercurial > public > hwos_code
comparison src/tft.asm @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | 185ba2f91f59 |
children | 2737ddc643bb |
comparison
equal
deleted
inserted
replaced
633:690c48db7b5b | 634:4050675965ea |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File tft.asm combined next generation V3.08.8 | 3 ; File tft.asm combined next generation V3.09.4n |
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 ;============================================================================= |
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. | 10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. |
11 | 11 |
12 #include "hwos.inc" | 12 #include "hwos.inc" |
13 #include "wait.inc" | 13 #include "wait.inc" |
14 #include "varargs.inc" | 14 #include "varargs.inc" |
15 #include "external_flash.inc" | |
16 #include "tft_outputs.inc" | 15 #include "tft_outputs.inc" |
17 #include "eeprom_rs232.inc" | 16 #include "eeprom_rs232.inc" |
18 | 17 |
19 ;============================================================================= | 18 ;----------------------------------------------------------------------------- |
20 ; Basic bit-level macros | 19 ; Basic bit-level macros |
21 | 20 |
22 RD_H macro | 21 RD_H macro |
23 bsf tft_rd,0 | 22 bsf tft_rd,0 |
24 endm | 23 endm |
49 | 48 |
50 WR_L macro | 49 WR_L macro |
51 bcf tft_nwr,0 | 50 bcf tft_nwr,0 |
52 endm | 51 endm |
53 | 52 |
54 ;============================================================================= | 53 ;----------------------------------------------------------------------------- |
55 ; Byte-level macros | 54 ; Byte-level macros |
56 | 55 |
57 Index_out macro low_b | 56 Index_out macro low_b |
58 movlw low_b | 57 movlw low_b |
59 rcall TFT_CmdWrite | 58 rcall TFT_CmdWrite |
64 movwf PORTA ; upper | 63 movwf PORTA ; upper |
65 movlw low_b | 64 movlw low_b |
66 rcall TFT_DataWrite | 65 rcall TFT_DataWrite |
67 endm | 66 endm |
68 | 67 |
69 | 68 ;============================================================================= |
70 tft CODE | 69 tft CODE |
71 | 70 ;============================================================================= |
72 ;;============================================================================= | |
73 | 71 |
74 global TFT_ClearScreen | 72 global TFT_ClearScreen |
75 TFT_ClearScreen: | 73 TFT_ClearScreen: |
76 btfsc screen_type2 ; screen type 2? | 74 btfsc screen_type2 ; screen type 2? |
77 bra TFT_ClearScreen_display2; YES | 75 bra TFT_ClearScreen_display2; YES |
219 rcall TFT_CmdWrite | 217 rcall TFT_CmdWrite |
220 | 218 |
221 movlw .107 ; 107 x 240 x 6 = 154080 ticks (153600 would be enough) | 219 movlw .107 ; 107 x 240 x 6 = 154080 ticks (153600 would be enough) |
222 bra TFT_ClearScreen_display2_loop0 | 220 bra TFT_ClearScreen_display2_loop0 |
223 | 221 |
224 | |
225 ;============================================================================= | |
226 | 222 |
227 global TFT_DisplayOff | 223 global TFT_DisplayOff |
228 TFT_DisplayOff: | 224 TFT_DisplayOff: |
229 bcf lightsen_power ; power-down light sensor | 225 bcf lightsen_power ; power-down light sensor |
230 btfsc screen_type3 ; screen type 3 ? | 226 btfsc screen_type3 ; screen type 3 ? |
477 TBLRD*+ ; get configuration | 473 TBLRD*+ ; get configuration |
478 movf TABLAT,W | 474 movf TABLAT,W |
479 rcall TFT_DataWrite ; write configuration | 475 rcall TFT_DataWrite ; write configuration |
480 bra display1_init_loop ; loop | 476 bra display1_init_loop ; loop |
481 | 477 |
482 ;============================================================================= | |
483 | 478 |
484 global TFT_CmdWrite | 479 global TFT_CmdWrite |
485 TFT_CmdWrite: | 480 TFT_CmdWrite: |
486 RS_L ; command | 481 RS_L ; command |
487 ; btfsc screen_type2 | 482 ; btfsc screen_type2 |
515 ; WR_L | 510 ; WR_L |
516 ; WR_H ; tick | 511 ; WR_H ; tick |
517 ; return | 512 ; return |
518 | 513 |
519 | 514 |
520 ;============================================================================= | 515 ;----------------------------------------------------------------------------- |
521 ; Smooth lighting-up of the display: | 516 ; Smooth lighting-up of the display: |
522 ; | 517 ; |
523 ; Trashes: WREG, PRODL | 518 ; Trashes: WREG, PRODL |
524 ; Typical usage: | 519 ; Typical usage: |
525 ; clrf CCPR1L ; backlight off | 520 ; clrf CCPR1L ; backlight off |
526 ; [draw splash screen] | 521 ; [draw splash screen] |
527 ; call TFT_DisplayFadeIn | 522 ; call TFT_DisplayFadeIn |
528 | 523 ; |
529 global TFT_Display_FadeIn | 524 global TFT_Display_FadeIn |
530 TFT_Display_FadeIn: | 525 TFT_Display_FadeIn: |
531 movlw CCP1CON_VALUE ; get configuration | 526 movlw CCP1CON_VALUE ; get configuration |
532 movwf CCP1CON ; set configuration | 527 movwf CCP1CON ; set configuration |
533 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor | 528 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor |
534 btfsc screen_type3 | 529 btfsc screen_type3 |
535 bra TFT_Display_FadeIn_1 | 530 bra TFT_Display_FadeIn_1 |
536 clrf CCPR1L ; backlight off - to be sure | 531 clrf CCPR1L ; backlight off - to be sure |
537 movff max_CCPR1L,PRODL | 532 movff max_CCPR1L,PRODL |
538 TFT_Display_FadeIn_0: | 533 TFT_Display_FadeIn_0: |
539 incf CCPR1L,F ; duty cycle | 534 incf CCPR1L,F ; duty cycle |
540 WAITMS d'2' | 535 WAITMS d'2' |
544 return | 539 return |
545 TFT_Display_FadeIn_1: | 540 TFT_Display_FadeIn_1: |
546 setf CCPR1L | 541 setf CCPR1L |
547 return | 542 return |
548 | 543 |
549 ;============================================================================= | 544 ;----------------------------------------------------------------------------- |
550 ; Smooth lighting-off of the display: | 545 ; Smooth lighting-off of the display: |
551 ; Trashes: WREG, PRODL | 546 ; Trashes: WREG, PRODL |
552 | 547 ; |
553 global TFT_Display_FadeOut | 548 global TFT_Display_FadeOut |
554 TFT_Display_FadeOut: | 549 TFT_Display_FadeOut: |
555 movff max_CCPR1L,PRODL | 550 movff max_CCPR1L,PRODL |
556 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor | 551 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor |
557 btfsc screen_type3 | 552 btfsc screen_type3 |
563 bra TFT_Display_FadeOut_0 | 558 bra TFT_Display_FadeOut_0 |
564 TFT_Display_FadeOut_1: | 559 TFT_Display_FadeOut_1: |
565 clrf CCPR1L | 560 clrf CCPR1L |
566 return | 561 return |
567 | 562 |
568 ;============================================================================= | 563 ;----------------------------------------------------------------------------- |
569 ; OLED brightness control | 564 ; OLED brightness control |
565 ; | |
570 TFT_display3_high: ; 0x01F8F8 | 566 TFT_display3_high: ; 0x01F8F8 |
571 movlw LOW (0x01F8F8 ) | 567 movlw LOW (0x01F8F8 ) |
572 movwf TBLPTRL | 568 movwf TBLPTRL |
573 movlw HIGH (0x01F8F8 & 0xFFFF) | 569 movlw HIGH (0x01F8F8 & 0xFFFF) |
574 movwf TBLPTRH | 570 movwf TBLPTRH |
592 movwf TBLPTRH | 588 movwf TBLPTRH |
593 movlw UPPER (0x01F8D4 ) | 589 movlw UPPER (0x01F8D4 ) |
594 movwf TBLPTRU | 590 movwf TBLPTRU |
595 bra display1_init_loop ; and return | 591 bra display1_init_loop ; and return |
596 | 592 |
597 ;============================================================================= | 593 |
598 | 594 ;----------------------------------------------------------------------------- |
599 global box_std_block, box_black_block, box_color_block | 595 ; colored (filled) Boxes |
596 ; | |
597 global box_std_block, box_black_block, box_color_block, box_color | |
600 | 598 |
601 box_std_block: ; use white color | 599 box_std_block: ; use white color |
602 setf WREG | 600 setf WREG |
603 bra box_common | 601 bra box_color_block |
604 box_black_block: ; use black color | 602 box_black_block: ; use black color |
605 clrf WREG | 603 clrf WREG |
606 box_common: | 604 box_color_block: ; use color from WREG |
607 box_color_block: | |
608 rcall TFT_set_color | 605 rcall TFT_set_color |
609 VARARGS_BEGIN | 606 VARARGS_BEGIN |
610 VARARGS_GET8 win_top | 607 VARARGS_GET8 win_top |
611 VARARGS_GET8 win_height | 608 VARARGS_GET8 win_height |
612 VARARGS_GET8 win_leftx2 | 609 VARARGS_GET8 win_leftx2 |
613 VARARGS_GET8 win_width | 610 VARARGS_GET8 win_width |
614 VARARGS_END | 611 VARARGS_END |
615 bra TFT_box | 612 bra TFT_box |
616 | 613 |
617 ;----------------------------------------------------------------------------- | 614 box_color: ; use color from WREG and pre-set coordinates |
618 | 615 rcall TFT_set_color |
619 global box_frame_std, box_frame_common, box_frame_color, box_frame_color16 | 616 bra TFT_box |
620 | 617 |
621 box_frame_std: | 618 |
619 ;----------------------------------------------------------------------------- | |
620 ; colored Frames | |
621 ; | |
622 global box_frame_std, box_frame_color | |
623 | |
624 box_frame_std: ; use white color | |
622 setf WREG | 625 setf WREG |
626 box_frame_color: ; use color from WREG | |
623 rcall TFT_set_color | 627 rcall TFT_set_color |
624 box_frame_common: | |
625 VARARGS_BEGIN | 628 VARARGS_BEGIN |
626 VARARGS_GET8 win_top | 629 VARARGS_GET8 win_top |
627 VARARGS_GET8 win_height | 630 VARARGS_GET8 win_height |
628 VARARGS_GET8 win_leftx2 | 631 VARARGS_GET8 win_leftx2 |
629 VARARGS_GET8 win_width | 632 VARARGS_GET8 win_width |
630 VARARGS_END | 633 VARARGS_END |
631 bra TFT_frame | 634 bra TFT_frame |
632 box_frame_color: | 635 |
633 rcall TFT_set_color | 636 |
634 box_frame_color16: | 637 ; ;----------------------------------------------------------------------------- |
635 bra box_frame_common | 638 ; ; Init for half_pixel_write |
636 | 639 ; ; Set column register on TFT device, and current color. |
637 ;;============================================================================= | 640 ; ; Inputs: win_leftx2 |
638 ;; Init for half_pixel_write | 641 ; ; Outputs: win_color_1/_2 |
639 ;; Set column register on TFT device, and current color. | 642 ; ; Trashed: WREG, PROD |
640 ;; Inputs: win_leftx2 | 643 ; ; |
641 ;; Outputs: win_color:2 | 644 ; ; global init_pixel_write |
642 ;; Trashed: WREG, PROD | 645 ; ;init_pixel_write: |
643 ; | 646 ; ; movf win_leftx2,W |
644 ; global init_pixel_write | 647 ; ; mullw 2 |
645 ;init_pixel_write: | 648 ; ; rcall pixel_write_col320 ; start address vertical (.0 - .319) |
646 ; movf win_leftx2,W | 649 ; ; setf WREG |
647 ; mullw 2 | 650 ; ; bra TFT_set_color |
648 ; rcall pixel_write_col320 ; start address vertical (.0 - .319) | 651 |
649 ; setf WREG | 652 |
650 ; bra TFT_set_color | 653 ;----------------------------------------------------------------------------- |
651 | 654 ; Draw two half-pixels at position (win_top,win_leftx2) |
652 ;----------------------------------------------------------------------------- | 655 ; Inputs: win_leftx2, win_top, win_color_1/_2 |
653 ; Writes two half-pixels at position (win_top,win_leftx2) | |
654 ; Inputs: win_leftx2, win_top, win_color:2 | |
655 ; Trashed: WREG, PROD | 656 ; Trashed: WREG, PROD |
656 | 657 ; |
657 global pixel_write | 658 global pixel_write |
658 pixel_write: | 659 pixel_write: |
659 movf win_leftx2,W | 660 movf win_leftx2,W |
660 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL | 661 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
661 rcall pixel_write_col320 ; start address vertical (.0 - .319) | 662 rcall pixel_write_col320 ; start address vertical (.0 - .319) |
724 movlw 0x21 ; start address vertical (.0 - .319) | 725 movlw 0x21 ; start address vertical (.0 - .319) |
725 rcall TFT_CmdWrite | 726 rcall TFT_CmdWrite |
726 bra TFT_DataWrite_PROD ; and return... | 727 bra TFT_DataWrite_PROD ; and return... |
727 | 728 |
728 ;----------------------------------------------------------------------------- | 729 ;----------------------------------------------------------------------------- |
729 ; Writes one half-pixel at position (win_top,win_leftx2). | 730 ; Write one half-pixel at position (win_top,win_leftx2). |
730 ; Inputs: win_leftx2, win_top, win_color:2 | 731 ; Inputs: win_leftx2, win_top, win_color_1/_2 |
731 ; Trashed: WREG, PROD | 732 ; Trashed: WREG, PROD |
732 | 733 ; |
733 global half_pixel_write | 734 global half_pixel_write |
734 half_pixel_write: | 735 half_pixel_write: |
735 movf win_top,W ; d'0' ... d'239' | 736 movf win_top,W ; d'0' ... d'239' |
736 ; Variant with Y position in WREG | 737 ; Variant with Y position in WREG |
737 half_pixel_write_1: | 738 half_pixel_write_1: |
815 WR_L | 816 WR_L |
816 WR_H ; tick | 817 WR_H ; tick |
817 return ; done | 818 return ; done |
818 | 819 |
819 ;----------------------------------------------------------------------------- | 820 ;----------------------------------------------------------------------------- |
820 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height). | 821 ; Draw a vertical line of half-pixel at position (win_top,win_leftx2,win_height). |
821 ; Inputs: win_leftx2, win_top, win_height, win_color:2 | 822 ; Inputs: win_leftx2, win_top, win_height, win_color_1/_2 |
822 ; Trashed: WREG, PROD, TABLAT, TBLPTRL | 823 ; Trashed: WREG, PROD, TABLAT, TBLPTRL |
823 | 824 ; |
824 global half_vertical_line | 825 global half_vertical_line |
825 half_vertical_line: | 826 half_vertical_line: |
826 clrf TABLAT ; loop index | 827 clrf TABLAT ; loop index |
827 | 828 |
828 half_vertical_line_loop: | 829 half_vertical_line_loop: |
842 rcall half_pixel_write_1 | 843 rcall half_pixel_write_1 |
843 incf TABLAT,F ; index++ | 844 incf TABLAT,F ; index++ |
844 bra half_vertical_line_loop | 845 bra half_vertical_line_loop |
845 | 846 |
846 ;----------------------------------------------------------------------------- | 847 ;----------------------------------------------------------------------------- |
847 ; Writes a horizontal line of half-pixel at position (win_top,win_leftx2,win_width). | 848 ; Draw a horizontal line of half-pixel at position (win_top,win_leftx2,win_width). |
848 ; Inputs: win_leftx2, win_top, win_width, win_color:2 | 849 ; Inputs: win_leftx2, win_top, win_width, win_color_1/_2 |
849 ; Trashed: WREG, PROD, TABLAT, TBLPTRL | 850 ; Trashed: WREG, PROD, TABLAT, TBLPTRL |
850 | 851 ; |
851 global half_horizontal_line | 852 global half_horizontal_line |
852 half_horizontal_line: | 853 half_horizontal_line: |
853 clrf TABLAT ; loop index | 854 clrf TABLAT ; loop index |
854 | 855 |
855 half_horizontal_line_loop: | 856 half_horizontal_line_loop: |
866 incf TABLAT,F ; index++ | 867 incf TABLAT,F ; index++ |
867 bra half_horizontal_line_loop | 868 bra half_horizontal_line_loop |
868 | 869 |
869 | 870 |
870 ;----------------------------------------------------------------------------- | 871 ;----------------------------------------------------------------------------- |
871 ; TFT Data Command via W | 872 ; TFT Data Command |
872 | 873 ; |
873 global TFT_DataWrite_PROD | |
874 TFT_DataWrite_PROD: | 874 TFT_DataWrite_PROD: |
875 ; RD_H ; keep high | 875 ; RD_H ; keep high |
876 RS_H ; data | 876 RS_H ; data |
877 btfsc screen_type2 ; screen type 2 ? | 877 btfsc screen_type2 ; screen type 2 ? |
878 bra TFT_DataWrite_PROD_display2 ; YES | 878 bra TFT_DataWrite_PROD_display2 ; YES |
926 nop | 926 nop |
927 clrf TRISA ; port A as output | 927 clrf TRISA ; port A as output |
928 clrf TRISH ; port H as output | 928 clrf TRISH ; port H as output |
929 return | 929 return |
930 | 930 |
931 ;============================================================================= | 931 ;----------------------------------------------------------------------------- |
932 ; Output TFT Window Address commands | 932 ; Output TFT Window Address commands |
933 ; Inputs : win_top, win_leftx2, win_height, win_width | 933 ; Inputs : win_top, win_leftx2, win_height, win_width |
934 ; Output : PortA/PortH commands | 934 ; Output : PortA/PortH commands |
935 ; Trashed: PROD | 935 ; Trashed: PROD |
936 | 936 ; |
937 global TFT_box_write | 937 global TFT_box_write |
938 TFT_box_write: | 938 TFT_box_write: |
939 movf win_leftx2,W ; compute left = 2 * leftx2 --> PROD | 939 movf win_leftx2,W ; compute left = 2 * leftx2 --> PROD |
940 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL | 940 mullw .2 ; win_leftx2 x 2 -> PRODH:PRODL |
941 | 941 |
942 btfsc screen_type2 ; screen type 2 ? | 942 btfsc screen_type2 ; screen type 2 ? |
943 bra TFT_box_write_display2 ; YES | 943 bra TFT_box_write_display2 ; YES |
944 btfsc screen_type3 ; screen type 3 ? | 944 btfsc screen_type3 ; screen type 3 ? |
945 bra TFT_box_write_display3 ; YES | 945 bra TFT_box_write_display3 ; YES |
946 | 946 btfsc screen_type1 ; screen type 1 ? |
947 global TFT_box_write_16bit_win_left | 947 bra TFT_box_write_display1 ; YES |
948 TFT_box_write_16bit_win_left: ; with column in PRODL:PRODH | 948 |
949 btfsc screen_type1 ; screen type 1 ? | |
950 bra TFT_box_write_16bit_win_left_d1 ; YES | |
951 ; screen type 0 | 949 ; screen type 0 |
952 btfsc flip_screen ; 180° rotation? | 950 TFT_box_write_display0: |
953 bra TFT_box_flip_H ; YES | 951 btfsc flip_screen ; 180° rotation? |
954 bra TFT_box_write_16bit_win_left_com ; NO | 952 bra TFT_box_do_flip_H ; YES |
955 TFT_box_write_16bit_win_left_d1: ; Display1 | 953 bra TFT_box_no_flip_H ; NO |
956 btfss flip_screen ; 180° rotation? | 954 |
957 bra TFT_box_flip_H ; NO | 955 ; screen type 1 |
958 TFT_box_write_16bit_win_left_com: ; YES for screen type 1, NO for type 0 | 956 TFT_box_write_display1: |
957 btfss flip_screen ; 180° rotation? | |
958 bra TFT_box_do_flip_H ; NO | |
959 ;bra TFT_box_no_flip_H ; YES | |
960 | |
959 ;---- Normal horizontal window --------------------------------------- | 961 ;---- Normal horizontal window --------------------------------------- |
962 TFT_box_no_flip_H: | |
960 Index_out 0x52 ; window vertical start address | 963 Index_out 0x52 ; window vertical start address |
961 rcall TFT_DataWrite_PROD ; output left | 964 rcall TFT_DataWrite_PROD ; output left |
962 Index_out 0x21 ; frame memory vertical address | 965 Index_out 0x21 ; frame memory vertical address |
963 rcall TFT_DataWrite_PROD ; output left | 966 rcall TFT_DataWrite_PROD ; output left |
964 | 967 |
970 btfss STATUS,C | 973 btfss STATUS,C |
971 decf PRODH,F | 974 decf PRODH,F |
972 | 975 |
973 Index_out 0x53 ; window vertical end address | 976 Index_out 0x53 ; window vertical end address |
974 rcall TFT_DataWrite_PROD | 977 rcall TFT_DataWrite_PROD |
975 bra TFT_box_noflip_H | 978 bra TFT_box_common_H |
976 | 979 |
977 ;---- Flipped horizontal window -------------------------------------- | 980 ;---- Flipped horizontal window -------------------------------------- |
978 TFT_box_flip_H: | 981 TFT_box_do_flip_H: |
979 ; calculate new coordinate | 982 ; calculate new coordinate |
980 movf PRODL,W ; 16 bits 319 - PROD --> PROD | 983 movf PRODL,W ; 16 bits 319 - PROD --> PROD |
981 sublw LOW .319 ; 319 - WREG --> WREG | 984 sublw LOW .319 ; 319 - WREG --> WREG |
982 movwf PRODL | 985 movwf PRODL |
983 movf PRODH,W | 986 movf PRODH,W |
999 INCI PROD ; PROD++ | 1002 INCI PROD ; PROD++ |
1000 | 1003 |
1001 Index_out 0x52 ; window vertical end address | 1004 Index_out 0x52 ; window vertical end address |
1002 rcall TFT_DataWrite_PROD | 1005 rcall TFT_DataWrite_PROD |
1003 | 1006 |
1004 TFT_box_noflip_H: | 1007 TFT_box_common_H: |
1005 btfss flip_screen ; 180° rotation ? | 1008 btfss flip_screen ; 180° rotation ? |
1006 bra TFT_box_noflip_V ; NO | 1009 bra TFT_box_no_flip_V ; NO |
1010 ;bra TFT_box_do_flip_V ; YES | |
1007 | 1011 |
1008 ;---- Flipped vertical window ----------------------------------------- | 1012 ;---- Flipped vertical window ----------------------------------------- |
1013 TFT_box_do_flip_V: | |
1009 ; calculate new coordinate | 1014 ; calculate new coordinate |
1010 movff win_top,PRODH ; top --> PRODH (first byte) | 1015 movff win_top,PRODH ; top --> PRODH (first byte) |
1011 movf win_height,W | 1016 movf win_height,W |
1012 addwf PRODH,W | 1017 addwf PRODH,W |
1013 decf WREG | 1018 decf WREG |
1023 | 1028 |
1024 Index_out 0x20 ; frame memory horizontal address | 1029 Index_out 0x20 ; frame memory horizontal address |
1025 movf PRODH,W | 1030 movf PRODH,W |
1026 bra TFT_DataWrite ; lower (and tick) and return | 1031 bra TFT_DataWrite ; lower (and tick) and return |
1027 | 1032 |
1028 TFT_box_noflip_V: | |
1029 ;---- Normal vertical window ---------------------------------------- | 1033 ;---- Normal vertical window ---------------------------------------- |
1034 TFT_box_no_flip_V: | |
1030 movff win_top,PRODL | 1035 movff win_top,PRODL |
1031 movf win_height,W | 1036 movf win_height,W |
1032 addwf PRODL,W | 1037 addwf PRODL,W |
1033 sublw .240 ; 240 - top - height | 1038 sublw .240 ; 240 - top - height |
1034 movwf PRODH ; first byte | 1039 movwf PRODH ; first byte |
1118 movf win_width+0,W ; right = left + width - 1 | 1123 movf win_width+0,W ; right = left + width - 1 |
1119 addwf PRODL,F | 1124 addwf PRODL,F |
1120 movf win_width+1,W | 1125 movf win_width+1,W |
1121 addwfc PRODH,F | 1126 addwfc PRODH,F |
1122 decf PRODL,F ; decrement result | 1127 decf PRODL,F ; decrement result |
1123 btfss STATUS,C | 1128 btfss STATUS,C |
1124 decf PRODH,F | 1129 decf PRODH,F |
1125 | 1130 |
1126 Index_out 0x36 ; write and the right border | 1131 Index_out 0x36 ; write and the right border |
1127 rcall TFT_DataWrite_PROD | 1132 rcall TFT_DataWrite_PROD |
1128 | 1133 |
1141 clrf PRODH ; start pixel V coord == top. | 1146 clrf PRODH ; start pixel V coord == top. |
1142 Index_out 0x20 | 1147 Index_out 0x20 |
1143 bra TFT_DataWrite_PROD ; and return... | 1148 bra TFT_DataWrite_PROD ; and return... |
1144 | 1149 |
1145 | 1150 |
1146 ;============================================================================= | 1151 ;----------------------------------------------------------------------------- |
1147 ; TFT_frame : draw a frame around current box with current color | 1152 ; TFT_frame : draw a frame around current box with current color |
1148 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | 1153 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
1149 ; Outputs: (none) | 1154 ; Outputs: (none) |
1150 ; Trashed: WREG, PROD, aa_start:2, aa_end:2 | 1155 ; Trashed: WREG, PROD, aa_start:2, aa_end:2 |
1151 | 1156 ; |
1152 global TFT_frame | 1157 global TFT_frame |
1153 TFT_frame: | 1158 TFT_frame: |
1154 movff win_top,tft_save_top ; backup everything | 1159 movff win_top,tft_save_top ; backup everything |
1155 movff win_height,tft_save_height | 1160 movff win_height,tft_save_height |
1156 movff win_leftx2,tft_save_left | 1161 movff win_leftx2,tft_save_left |
1187 ;---- Restore everything ------------------------------------------------- | 1192 ;---- Restore everything ------------------------------------------------- |
1188 movff tft_save_left,win_leftx2 | 1193 movff tft_save_left,win_leftx2 |
1189 movff tft_save_width,win_width+0 | 1194 movff tft_save_width,win_width+0 |
1190 return | 1195 return |
1191 | 1196 |
1192 ;============================================================================= | 1197 ;----------------------------------------------------------------------------- |
1193 ; TFT_box: fills current box with current color | 1198 ; TFT_box: fills current box with current color |
1194 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | 1199 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
1195 ; Outputs: (none) | 1200 ; Outputs: (none) |
1196 ; Trashed: WREG, PROD | 1201 ; Trashed: WREG, PROD |
1197 | 1202 ; |
1198 global TFT_box | 1203 global TFT_box |
1199 TFT_box: | 1204 TFT_box: |
1200 ;---- Define Window ------------------------------------------------------ | 1205 ;---- Define Window ------------------------------------------------------ |
1201 bcf STATUS,C | 1206 bcf STATUS,C |
1202 rlcf win_width+0,F | 1207 rlcf win_width+0,F |
1222 | 1227 |
1223 TFT_box3: ; loop width times | 1228 TFT_box3: ; loop width times |
1224 bcf INTCON,GIE | 1229 bcf INTCON,GIE |
1225 movff win_color1,PORTA ; upper | 1230 movff win_color1,PORTA ; upper |
1226 movff win_color2,PORTH ; lower | 1231 movff win_color2,PORTH ; lower |
1227 WR_L | 1232 WR_L ; tick |
1228 WR_H ; tick | 1233 WR_H ; ... |
1229 WR_L | 1234 WR_L ; tick |
1230 WR_H ; tick | 1235 WR_H ; ... |
1231 bsf INTCON,GIE | 1236 bsf INTCON,GIE |
1232 decfsz PRODL,F ; row loop finished ? | 1237 decfsz PRODL,F ; row loop finished ? |
1233 bra TFT_box3 ; NO - continue | 1238 bra TFT_box3 ; NO - continue |
1234 | 1239 |
1235 incf PRODH,F ; column count ++ | 1240 incf PRODH,F ; column count ++ |
1324 cpfseq PRODH ; width loop finished ? | 1329 cpfseq PRODH ; width loop finished ? |
1325 bra TFT_box2_display3 ; NO - loop | 1330 bra TFT_box2_display3 ; NO - loop |
1326 setf win_bargraph ; YES - reset bargraph mode | 1331 setf win_bargraph ; YES - reset bargraph mode |
1327 return | 1332 return |
1328 | 1333 |
1329 ;============================================================================= | 1334 |
1330 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB b'RRRRRGGGGGGBBBBB' | 1335 ;----------------------------------------------------------------------------- |
1331 | 1336 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB b'RRRRRGGGGGGBBBBB' |
1337 ; WREG win_color1 win_color2 | |
1332 global TFT_set_color | 1338 global TFT_set_color |
1333 TFT_set_color: | 1339 TFT_set_color: |
1334 movwf tft_temp1 ; get 8 bit RGB b'RRRGGGBB' into tft_temp1... | 1340 movwf tft_temp1 ; get 8 bit RGB b'RRRGGGBB' into tft_temp1... |
1335 movwf tft_temp2 ; ... and tft_temp2 | 1341 movwf tft_temp2 ; ... and tft_temp2 |
1336 | 1342 |
1337 ; mask bit 7,6,5,4,3,2 | 1343 ; mask bit 7,6,5,4,3,2 |
1338 movlw b'00000011' | 1344 movlw b'00000011' |
1339 andwf tft_temp2,F | 1345 andwf tft_temp2,F |
1340 | 1346 |
1465 rrcf PRODL,F ; = GGGGGGBB the lower two bits are ignored by the screen | 1471 rrcf PRODL,F ; = GGGGGGBB the lower two bits are ignored by the screen |
1466 movff PRODL,win_color4 | 1472 movff PRODL,win_color4 |
1467 return | 1473 return |
1468 | 1474 |
1469 | 1475 |
1470 ;============================================================================= | 1476 ;----------------------------------------------------------------------------- |
1471 | 1477 |
1472 IFDEF _screendump | 1478 IFDEF _screendump |
1473 | 1479 |
1474 ;----------------------------------------------------------------------------- | 1480 ;----------------------------------------------------------------------------- |
1475 ; Dump screen contents to the UART | 1481 ; Dump screen contents to the UART |
1647 clrf ds_count ; clear count | 1653 clrf ds_count ; clear count |
1648 return | 1654 return |
1649 | 1655 |
1650 ENDIF ; _screendump | 1656 ENDIF ; _screendump |
1651 | 1657 |
1652 ;============================================================================= | 1658 ;----------------------------------------------------------------------------- |
1653 | 1659 |
1654 END | 1660 END |