annotate src/tft.asm @ 585:00ad4ffd915b

CNS Fix2
author heinrichsweikamp
date Wed, 28 Feb 2018 16:24:18 +0100
parents b455b31ce022
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
3 ; File tft.asm ## V2.97
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Managing the TFT screen
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code.
heinrichsweikamp
parents:
diff changeset
11
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 225
diff changeset
12 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
13 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "varargs.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
20 ; Basic bit-level macros
heinrichsweikamp
parents:
diff changeset
21
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
22 RD_H macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
23 bsf tft_rd,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
24 endm
0
heinrichsweikamp
parents:
diff changeset
25
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
26 RD_L macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
27 bcf tft_rd,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
28 endm
0
heinrichsweikamp
parents:
diff changeset
29
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
30 RS_H macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
31 bsf tft_rs,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
32 endm
0
heinrichsweikamp
parents:
diff changeset
33
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
34 RS_L macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
35 bcf tft_rs,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
36 endm
0
heinrichsweikamp
parents:
diff changeset
37
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
38 NCS_H macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
39 bsf tft_cs,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
40 endm
0
heinrichsweikamp
parents:
diff changeset
41
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
42 NCS_L macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
43 bcf tft_cs,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
44 endm
0
heinrichsweikamp
parents:
diff changeset
45
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
46 WR_H macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
47 bsf tft_nwr,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
48 endm
0
heinrichsweikamp
parents:
diff changeset
49
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
50 WR_L macro
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
51 bcf tft_nwr,0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
52 endm
0
heinrichsweikamp
parents:
diff changeset
53
heinrichsweikamp
parents:
diff changeset
54 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
55 ; Byte-level macros
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
56
0
heinrichsweikamp
parents:
diff changeset
57 Index_out macro low_b
heinrichsweikamp
parents:
diff changeset
58 movlw low_b
heinrichsweikamp
parents:
diff changeset
59 rcall TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
60 endm
heinrichsweikamp
parents:
diff changeset
61
heinrichsweikamp
parents:
diff changeset
62 Parameter_out macro high_b, low_b
heinrichsweikamp
parents:
diff changeset
63 movlw high_b
heinrichsweikamp
parents:
diff changeset
64 movwf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
65 movlw low_b
heinrichsweikamp
parents:
diff changeset
66 rcall TFT_DataWrite
heinrichsweikamp
parents:
diff changeset
67 endm
heinrichsweikamp
parents:
diff changeset
68
heinrichsweikamp
parents:
diff changeset
69
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
70 basic CODE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
71
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
72 ;;=============================================================================
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
73 ;; TFT_write_flash_image
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
74 ;;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
75 ;; Inputs: FSR2 = EEPROM address / 256
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
76 ;; win_left, win_top : image CENTER position
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
77 ;; Outputs: win_height, win_width.
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
78 ;; image copied on screen.
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
79 ;; Trashed: PROD, hi, lo
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
80 ;;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
81 ; global TFT_write_flash_image
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
82 ;TFT_write_flash_image:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
83 ; ; Get back the full 24bit EEPROM address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
84 ; clrf ext_flash_address+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
85 ; movff FSR2L,ext_flash_address+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
86 ; movf FSR2H,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
87 ; iorlw 0x30
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
88 ; movwf ext_flash_address+2
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
89 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
90 ; ; Read header: width and height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
91 ; global TFT_write_flash_image_addr
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
92 ;TFT_write_flash_image_addr:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
93 ; call ext_flash_read_block_start
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
94 ; movff SSP2BUF,win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
95 ; movwf SSP2BUF ; Write to buffer to initiate new read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
96 ; btfss SSP2STAT, BF ; Next byte ready ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
97 ; bra $-2 ; NO: wait...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
98 ; movff SSP2BUF,win_width+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
99 ; movwf SSP2BUF ; Write to buffer to initiate new read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
100 ; btfss SSP2STAT, BF ; Next byte ready ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
101 ; bra $-2 ; NO: wait...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
102 ; movff SSP2BUF,win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
103 ; movwf SSP2BUF ; Write to buffer to initiate new read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
104 ; btfss SSP2STAT, BF ; Next byte ready ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
105 ; bra $-2 ; NO: wait...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
106 ; movff SSP2BUF,WREG ; drop 4th byte.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
107 ; movwf SSP2BUF ; Write to buffer to initiate new read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
108 ; btfss SSP2STAT, BF ; Next byte ready ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
109 ; bra $-2 ; NO: wait...
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
110 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
111 ; ; Sanity check on header to avoid badly uploaded images.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
112 ; iorwf WREG ; Check height < 256
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
113 ; bnz TFT_write_flash_image_failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
114 ; movf win_width+1,W ; Check width < 512
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
115 ; andlw 0xFE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
116 ; bnz TFT_write_flash_image_failed
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
117 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
118 ; ; Center image on win_top, win_left values
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
119 ; bcf STATUS,C ; Clear carry
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
120 ; rrcf win_height,W ; And get height/2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
121 ; subwf win_top,F ; top -= height/2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
122 ; rrcf win_width+1,W ; Get 9th bit into carry
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
123 ; rrcf win_width+0,W ; Get width/2 (in 0..320 range)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
124 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
125 ; rrcf WREG,W ; Get width/2 in 0..160 range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
126 ; subwf win_leftx2,F ; left -= width/2
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
127 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
128 ; rcall TFT_box_write ; Inputs : win_top, win_leftx2, win_height, win_width(in 1..320 range)
0
heinrichsweikamp
parents:
diff changeset
129 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
130 ; ; Compute number of pixels to move (result on 17 bits !)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
131 ; clrf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
132 ; movf win_width+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
133 ; mulwf win_height ; Result in PRODL:H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
134 ; movf win_width+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
135 ; bz TFT_write_flash_image_1 ; width > 8bits ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
136 ; movf win_height,W ; YES: add extra
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
137 ; addwf PRODH,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
138 ; rlcf TBLPTRU ; And carry into upper register.
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
139 ;TFT_write_flash_image_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
140 ; incf PRODH,F ; pre-condition nested loops
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
141 ; incf TBLPTRU,F
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
142 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
143 ; ; Write pixels
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
144 ; Index_out 0x22 ; Frame Memory Data Write start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
145 ; RS_H ; Data
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
146 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
147 ;TFT_write_flash_image_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
148 ; btfss SSP2STAT, BF ; Buffer full?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
149 ; bra $-2 ; NO: wait...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
150 ; movff SSP2BUF,PORTH ; Read lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
151 ; movwf SSP2BUF ; Write to buffer to initiate new read
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
152 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
153 ; btfss SSP2STAT, BF ; Buffer full?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
154 ; bra $-2 ; NO: wait...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
155 ; movff SSP2BUF,PORTA ; And read hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
156 ; movwf SSP2BUF ; Write to buffer to initiate new read
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
157 ; WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
158 ; WR_H ; Write 1 Pixel
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
159 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
160 ; decfsz PRODL,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
161 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
162 ; decfsz PRODH,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
163 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
164 ; decfsz TBLPTRU,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
165 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
166 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
167 ; btfss SSP2STAT, BF ; Buffer full?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
168 ; bra $-2 ; No, wait
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
169 ; movf SSP2BUF,W ; Read dummy byte
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
170 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
171 ; bsf flash_ncs ; CS=1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
172 ; movlw 0x00 ; NOP, to stop window mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
173 ; bra TFT_CmdWrite ; This routine "returns"
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
174 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
175 ; ;---- Draw a 4x4 red square in place of missing images...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
176 ;TFT_write_flash_image_failed:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
177 ; movlw -1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
178 ; addwf win_leftx2,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
179 ; movlw -2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
180 ; addwf win_top,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
181 ; movlw 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
182 ; movwf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
183 ; clrf win_width+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
184 ; movlw 4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
185 ; movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
186 ; movlw color_red
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
187 ; rcall TFT_set_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
188 ; goto TFT_box
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
189 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
190 ;;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
191
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
192 global TFT_CmdWrite
0
heinrichsweikamp
parents:
diff changeset
193 TFT_CmdWrite:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
194 RS_L ; Command
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
195 clrf PORTA ; Upper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
196 bcf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
197 movwf PORTH ; Lower
0
heinrichsweikamp
parents:
diff changeset
198 WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
199 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
200 bsf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
201 return
0
heinrichsweikamp
parents:
diff changeset
202
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
203 global TFT_DataWrite
0
heinrichsweikamp
parents:
diff changeset
204 TFT_DataWrite:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
205 RS_H ; Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
206 bcf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
207 movwf PORTH ; Lower
0
heinrichsweikamp
parents:
diff changeset
208 WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
209 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
210 bsf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
211 return
heinrichsweikamp
parents:
diff changeset
212
heinrichsweikamp
parents:
diff changeset
213 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
214
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
215 global TFT_ClearScreen
0
heinrichsweikamp
parents:
diff changeset
216 TFT_ClearScreen:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
217 Index_out 0x50 ; Window Horizontal Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
218 Parameter_out 0x00, 0x00 ; 0-239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
219 Index_out 0x51 ; Window Horizontal End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
220 Parameter_out 0x00, 0xEF ; 0-239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
221 Index_out 0x52 ; Window Vertical Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
222 Parameter_out 0x00, 0x00 ; 0-319
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
223 Index_out 0x53 ; Window Vertical End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
224 Parameter_out 0x01, 0x3F ; 0-319
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
225 Index_out 0x20 ; Frame Memory Horizontal Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
226 Parameter_out 0x00, 0x00 ; 0-239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
227 Index_out 0x21 ; Frame Memory Vertical Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
228 Parameter_out 0x01, 0x3F ; 0-319
0
heinrichsweikamp
parents:
diff changeset
229
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
230 Index_out 0x22 ; Frame Memory Data Write start
0
heinrichsweikamp
parents:
diff changeset
231
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
232 RD_H ; Not Read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
233 RS_H ; Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
234 NCS_L ; Not CS
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
235 clrf PORTH ; Data Lower
0
heinrichsweikamp
parents:
diff changeset
236
heinrichsweikamp
parents:
diff changeset
237 movlw d'10'
heinrichsweikamp
parents:
diff changeset
238 movwf tft_temp3
heinrichsweikamp
parents:
diff changeset
239 TFT_ClearScreen2:
heinrichsweikamp
parents:
diff changeset
240 movlw d'30'
heinrichsweikamp
parents:
diff changeset
241 movwf tft_temp2
heinrichsweikamp
parents:
diff changeset
242 TFT_ClearScreen3:
heinrichsweikamp
parents:
diff changeset
243 clrf tft_temp1 ; 30*10*256=76800 Pixels -> Clear complete 240*320
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
244 bcf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
245 TFT_ClearScreen4:
heinrichsweikamp
parents:
diff changeset
246 WR_L
heinrichsweikamp
parents:
diff changeset
247 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
248 decfsz tft_temp1,F
heinrichsweikamp
parents:
diff changeset
249 bra TFT_ClearScreen4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
250 bsf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
251 decfsz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
252 bra TFT_ClearScreen3
heinrichsweikamp
parents:
diff changeset
253 decfsz tft_temp3,F
heinrichsweikamp
parents:
diff changeset
254 bra TFT_ClearScreen2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
255
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
256 movlw 0x00 ; NOP, to stop window mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
257 bra TFT_CmdWrite ; And return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
258
0
heinrichsweikamp
parents:
diff changeset
259
heinrichsweikamp
parents:
diff changeset
260 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
261
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
262 global TFT_DisplayOff
0
heinrichsweikamp
parents:
diff changeset
263 TFT_DisplayOff:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
264 clrf CCPR1L ; PWM OFF
0
heinrichsweikamp
parents:
diff changeset
265 clrf PORTA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
266 clrf PORTH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
267 RD_L ; LOW
0
heinrichsweikamp
parents:
diff changeset
268 nop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
269 RS_L ; LOW
0
heinrichsweikamp
parents:
diff changeset
270 bcf tft_nwr
heinrichsweikamp
parents:
diff changeset
271 nop
heinrichsweikamp
parents:
diff changeset
272 bcf tft_cs
heinrichsweikamp
parents:
diff changeset
273 nop
heinrichsweikamp
parents:
diff changeset
274 bcf tft_nreset
heinrichsweikamp
parents:
diff changeset
275 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
276 bsf tft_power ; inverted...
heinrichsweikamp
parents:
diff changeset
277 bcf lightsen_power ; power-down light sensor
heinrichsweikamp
parents:
diff changeset
278 return
heinrichsweikamp
parents:
diff changeset
279
heinrichsweikamp
parents:
diff changeset
280 ; -----------------------------
heinrichsweikamp
parents:
diff changeset
281 ; TFT boot
heinrichsweikamp
parents:
diff changeset
282 ; -----------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
283
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
284 global TFT_boot
0
heinrichsweikamp
parents:
diff changeset
285 TFT_boot:
heinrichsweikamp
parents:
diff changeset
286 clrf PORTA
heinrichsweikamp
parents:
diff changeset
287 clrf PORTH
heinrichsweikamp
parents:
diff changeset
288 RD_L ; LOW
heinrichsweikamp
parents:
diff changeset
289 bcf tft_nwr
heinrichsweikamp
parents:
diff changeset
290 nop
heinrichsweikamp
parents:
diff changeset
291 bcf tft_cs
heinrichsweikamp
parents:
diff changeset
292 nop
heinrichsweikamp
parents:
diff changeset
293 bcf tft_nreset
heinrichsweikamp
parents:
diff changeset
294 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
295 bcf tft_power ; inverted...
heinrichsweikamp
parents:
diff changeset
296 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
297
heinrichsweikamp
parents:
diff changeset
298 RD_H ; Keep high
heinrichsweikamp
parents:
diff changeset
299 WR_H ;
heinrichsweikamp
parents:
diff changeset
300 NCS_L ; Not CS
heinrichsweikamp
parents:
diff changeset
301
heinrichsweikamp
parents:
diff changeset
302 WAITMS d'2'
heinrichsweikamp
parents:
diff changeset
303 bsf tft_nreset
461
4927ba3bd3b5 repeated init (For screen 2 issues)
heinrichsweikamp
parents: 441
diff changeset
304 WAITMS d'5'
4927ba3bd3b5 repeated init (For screen 2 issues)
heinrichsweikamp
parents: 441
diff changeset
305 bcf tft_nreset
4927ba3bd3b5 repeated init (For screen 2 issues)
heinrichsweikamp
parents: 441
diff changeset
306 WAITMS d'5'
4927ba3bd3b5 repeated init (For screen 2 issues)
heinrichsweikamp
parents: 441
diff changeset
307 bsf tft_nreset
0
heinrichsweikamp
parents:
diff changeset
308 WAITMS d'150'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
309 bsf lightsen_power ; Supply power to light sensor
0
heinrichsweikamp
parents:
diff changeset
310
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
311 ; Data Transfer Synchronization
0
heinrichsweikamp
parents:
diff changeset
312 Parameter_out 0x00, 0x00
heinrichsweikamp
parents:
diff changeset
313 Parameter_out 0x00, 0x00
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
314
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 436
diff changeset
315 ; Get screentype from Bootloader-Info
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
316 movlw 0x7B
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
317 movwf TBLPTRL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
318 movlw 0xF7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
319 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
320 movlw 0x01
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
321 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
322 TBLRD*+ ; Reads .110 for cR and USB OSTC3, .0 for BLE (2 and 3), and .2 for display1 OSTC
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 436
diff changeset
323 movlw 0x02
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 436
diff changeset
324 cpfseq TABLAT
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
325 bra TFT_boot_0 ; Display0
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
326
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
327 TFT_boot_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
328 ; Init through config table...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
329 movlw 0x74
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
330 movwf TBLPTRL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
331 movlw 0xF7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
332 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
333 movlw 0x01
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
334 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
335 bsf screen_type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
336 bra TFT_boot_com
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
337
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 436
diff changeset
338 TFT_boot_0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
339 ; Init through config table...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
340 movlw LOW display0_config_table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
341 movwf TBLPTRL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
342 movlw HIGH display0_config_table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
343 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
344 movlw UPPER display0_config_table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
345 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
346 bcf screen_type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
347
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
348 TFT_boot_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
349 rcall display0_init_loop
0
heinrichsweikamp
parents:
diff changeset
350
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
351 Index_out 0x03
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
352 btfsc flip_screen ; 180° rotation ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
353 bra TFT_boot2 ; Yes
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
354
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
355 btfss screen_type ; display1?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
356 bra TFT_boot1a ; no
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
357 Parameter_out 0x10, 0x00 ; display1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
358 bra TFT_boot3
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
359 TFT_boot1a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
360 Parameter_out 0x50, 0x20 ; display0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
361 bra TFT_boot3
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 151
diff changeset
362 TFT_boot2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
363 btfss screen_type ; display1?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
364 bra TFT_boot2a ; no
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
365 Parameter_out 0x10, 0x30 ; display1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
366 bra TFT_boot3
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
367 TFT_boot2a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
368 Parameter_out 0x50, 0x10 ; display0
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 151
diff changeset
369 TFT_boot3:
0
heinrichsweikamp
parents:
diff changeset
370 Index_out 0x22
225
31088352ee32 BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents: 152
diff changeset
371 rcall TFT_ClearScreen
0
heinrichsweikamp
parents:
diff changeset
372 Index_out 0x07
312
b2f6a4b01e64 Config table for alternative display
heinrichsweikamp
parents: 275
diff changeset
373 Parameter_out 0x01, 0x33
0
heinrichsweikamp
parents:
diff changeset
374 return
heinrichsweikamp
parents:
diff changeset
375
heinrichsweikamp
parents:
diff changeset
376 display0_config_table:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
377 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
378 db 0xA4,0x00,0x01,0xFF,.002,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
379 db 0x09,0x00,0x01,0x92,0x04,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
380 db 0x93,0x04,0x02,0x94,0x00,0x02
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
381 db 0x07,0x00,0x00,0x10,0x04,0x30
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
382 db 0x11,0x02,0x37,0x12,0x11,0x8D
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
383 db 0x13,0x11,0x00,0x01,0x01,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
384 db 0x02,0x02,0x00,0x03,0x50,0x20
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
385 db 0x0A,0x00,0x08,0x0D,0x00,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
386 db 0x0E,0x00,0x30,0xFF,.151,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
387 db 0x12,0x11,0xBD,0x20,0x00,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
388 db 0x21,0x00,0x00,0x30,0x06,0x02
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
389 db 0x31,0x56,0x0D,0x32,0x05,0x07
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
390 db 0x33,0x06,0x09,0x34,0x00,0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
391 db 0x35,0x09,0x06,0x36,0x57,0x05
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
392 db 0x37,0x0D,0x06,0x38,0x02,0x06
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
393 db 0x39,0x00,0x00,0xFF,0x00,0x00
0
heinrichsweikamp
parents:
diff changeset
394
heinrichsweikamp
parents:
diff changeset
395 display0_init_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
396 TBLRD*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
397 movlw 0xFF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
398 cpfseq TABLAT
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
399 bra display0_config_write ; Write Config pair to Display
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
400 ; Delay ms or quit (return)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
401 TBLRD*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
402 tstfsz TABLAT ; End of config?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
403 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
404 return ; Done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
405 movf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
406 call WAITMSX ; Wait WREG milliseconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
407 TBLRD*+ ; Dummy read (Third byte of delay command)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
408 bra display0_init_loop ; Loop
0
heinrichsweikamp
parents:
diff changeset
409
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
410 display0_config_write: ; With command in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
411 movf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
412 rcall TFT_CmdWrite ; Write command
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
413 TBLRD*+ ; Get config0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
414 movff TABLAT,PORTA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
415 TBLRD*+ ; Get config1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
416 movf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
417 rcall TFT_DataWrite ; Write config
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
418 bra display0_init_loop ; Loop
0
heinrichsweikamp
parents:
diff changeset
419
heinrichsweikamp
parents:
diff changeset
420
heinrichsweikamp
parents:
diff changeset
421 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
422 ; Smooth lighting-up of the display:
heinrichsweikamp
parents:
diff changeset
423 ;
heinrichsweikamp
parents:
diff changeset
424 ; Trashes: WREG, PRODL
heinrichsweikamp
parents:
diff changeset
425 ; Typical usage:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
426 ; clrf CCPR1L ; Backlight off
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
427 ; [draw splash screen]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
428 ; call TFT_DisplayFadeIn
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
429
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
430 global TFT_Display_FadeIn
0
heinrichsweikamp
parents:
diff changeset
431 TFT_Display_FadeIn:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
432 movlw CCP1CON_VALUE ; See hwos.inc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
433 movwf CCP1CON
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
434 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
435 clrf CCPR1L ; Backlight off - to be sure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
436 movff max_CCPR1L,PRODL
0
heinrichsweikamp
parents:
diff changeset
437 TFT_Display_FadeIn_0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
438 incf CCPR1L,F ; Duty cycle
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
439 WAITMS d'2'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
440 decfsz PRODL,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
441 bra TFT_Display_FadeIn_0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
442 bcf tft_is_dimming ; dimming done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
443 return
0
heinrichsweikamp
parents:
diff changeset
444
heinrichsweikamp
parents:
diff changeset
445 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
446 ; Smooth lighting-off of the display:
heinrichsweikamp
parents:
diff changeset
447 ; Trashes: WREG, PRODL
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
448
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
449 global TFT_Display_FadeOut
0
heinrichsweikamp
parents:
diff changeset
450 TFT_Display_FadeOut:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
451 movff max_CCPR1L,PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
452 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor!
0
heinrichsweikamp
parents:
diff changeset
453 TFT_Display_FadeOut_0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
454 movff PRODL,CCPR1L ; Duty cycle
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
455 WAITMS d'1'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
456 decfsz PRODL,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
457 bra TFT_Display_FadeOut_0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
458 clrf CCPR1L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
459 return
0
heinrichsweikamp
parents:
diff changeset
460
heinrichsweikamp
parents:
diff changeset
461 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
462
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
463 global box_std_block, box_black_block, box_color_block
0
heinrichsweikamp
parents:
diff changeset
464
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
465 box_std_block: ; Use white color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
466 setf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
467 bra box_common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
468 box_black_block: ; Use black color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
469 clrf WREG
0
heinrichsweikamp
parents:
diff changeset
470 box_common:
heinrichsweikamp
parents:
diff changeset
471 box_color_block:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
472 rcall TFT_set_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
473 VARARGS_BEGIN
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
474 VARARGS_GET8 win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
475 VARARGS_GET8 win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
476 VARARGS_GET8 win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
477 VARARGS_GET8 win_width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
478 VARARGS_END
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
479 bra TFT_box
0
heinrichsweikamp
parents:
diff changeset
480
heinrichsweikamp
parents:
diff changeset
481 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
482
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
483 global box_frame_std, box_frame_common, box_frame_color, box_frame_color16
0
heinrichsweikamp
parents:
diff changeset
484
heinrichsweikamp
parents:
diff changeset
485 box_frame_std:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
486 setf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
487 rcall TFT_set_color
0
heinrichsweikamp
parents:
diff changeset
488 box_frame_common:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
489 VARARGS_BEGIN
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
490 VARARGS_GET8 win_top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
491 VARARGS_GET8 win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
492 VARARGS_GET8 win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
493 VARARGS_GET8 win_width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
494 VARARGS_END
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
495 bra TFT_frame
0
heinrichsweikamp
parents:
diff changeset
496 box_frame_color:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
497 rcall TFT_set_color
0
heinrichsweikamp
parents:
diff changeset
498 box_frame_color16:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
499 bra box_frame_common
0
heinrichsweikamp
parents:
diff changeset
500
434
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
501 ;;=============================================================================
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
502 ;; Init for half_pixel_write
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
503 ;; Set column register on TFT device, and current color.
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
504 ;; Inputs: win_leftx2
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
505 ;; Outputs: win_color:2
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
506 ;; Trashed: WREG, PROD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
507 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
508 ; global init_pixel_write
434
a001f170a1f7 hunting a bug in the logbook (Day 3)
heinrichsweikamp
parents: 432
diff changeset
509 ;init_pixel_write:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
510 ; movf win_leftx2,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
511 ; mullw 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
512 ; rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
513 ; setf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
514 ; bra TFT_set_color
0
heinrichsweikamp
parents:
diff changeset
515
heinrichsweikamp
parents:
diff changeset
516 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
517 ; Writes two half-pixels at position (win_top,win_leftx2)
heinrichsweikamp
parents:
diff changeset
518 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
519 ; Trashed: WREG, PROD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
520
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
521 global pixel_write
0
heinrichsweikamp
parents:
diff changeset
522 pixel_write:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
523 movf win_leftx2,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
524 mullw 2 ; win_leftx2 x 2 -> PRODH:PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
525 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
526 rcall half_pixel_write ; Write this half-one.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
527 movf win_leftx2,W ; Address of next one
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
528 mullw 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
529 infsnz PRODL ; +1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
530 incf PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
531 rcall pixel_write_col320
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
532 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
533 ; of the auto-increment going vertical
0
heinrichsweikamp
parents:
diff changeset
534
heinrichsweikamp
parents:
diff changeset
535 global pixel_write_col320
heinrichsweikamp
parents:
diff changeset
536 pixel_write_col320:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
537 btfsc screen_type ; display1?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
538 bra pixel_write_col320_d1 ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
539 ; Display0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
540 btfss flip_screen ; 180° rotation?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
541 bra pixel_write_noflip_H ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
542 bra pixel_write_flip_H ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
543 pixel_write_col320_d1: ; Display1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
544 btfsc flip_screen ; 180° rotation?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
545 bra pixel_write_noflip_H ; Yes for d1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
546 pixel_write_flip_H: ; Flip d0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
547 movf PRODL,W ; 16bits 319 - PROD --> PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
548 sublw LOW(.319) ; 319-W --> W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
549 movwf PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
550 movf PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
551 btfss STATUS,C ; Borrow = /CARRY
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
552 incf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
553 sublw HIGH(.319)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
554 movwf PRODH
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
555
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
556 pixel_write_noflip_H:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
557 Index_out 0x21 ; Frame Memory Vertical Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
558 bra TFT_DataWrite_PROD ; and return...
0
heinrichsweikamp
parents:
diff changeset
559
heinrichsweikamp
parents:
diff changeset
560 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
561 ; Writes one half-pixel at position (win_top,win_leftx2).
heinrichsweikamp
parents:
diff changeset
562 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
563 ; Trashed: WREG, PROD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
564
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
565 global half_pixel_write
0
heinrichsweikamp
parents:
diff changeset
566 half_pixel_write:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
567 movf win_top,W ; d'0' ... d'239'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
568 ; Variant with Y position in WREG.
0
heinrichsweikamp
parents:
diff changeset
569 half_pixel_write_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
570 btfss flip_screen ; 180° rotation?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
571 sublw .239 ; 239-Y --> Y
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
572 mullw .1 ; Copy row to PRODL (PRODH=0)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
573 Index_out 0x20 ; Frame Memory Horizontal Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
574 rcall TFT_DataWrite_PROD
0
heinrichsweikamp
parents:
diff changeset
575
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
576 Index_out 0x22 ; Frame Memory Data Write start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
577 RS_H ; Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
578 bcf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
579 movff win_color1,PORTA ; Upper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
580 movff win_color2,PORTH ; Lower
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
581 WR_L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
582 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
583 bsf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
584 return
0
heinrichsweikamp
parents:
diff changeset
585
heinrichsweikamp
parents:
diff changeset
586 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
587 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height).
heinrichsweikamp
parents:
diff changeset
588 ; Inputs: win_leftx2, win_top, win_height, win_color:2
heinrichsweikamp
parents:
diff changeset
589 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
590
0
heinrichsweikamp
parents:
diff changeset
591 global half_vertical_line
heinrichsweikamp
parents:
diff changeset
592 half_vertical_line:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
593 clrf TABLAT ; Loop index.
0
heinrichsweikamp
parents:
diff changeset
594
heinrichsweikamp
parents:
diff changeset
595 half_vertical_line_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
596 movf win_leftx2,W ; Init X position.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
597 mullw .2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
598 movf TABLAT,W ; Get loop index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
599 andlw .1 ; Just low bit
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
600 xorwf PRODL,F ; And use it to jitter current X position
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
601 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
0
heinrichsweikamp
parents:
diff changeset
602
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
603 movf win_height,W ; Index reached height (Bank0 read) ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
604 xorwf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
605 btfsc STATUS,Z ; Equals ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
606 return ; Yes: done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
607 movf win_top,W ; Y = top + index (Bank0 read)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
608 addwf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
609 rcall half_pixel_write_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
610 incf TABLAT,F ; index++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
611 bra half_vertical_line_loop
0
heinrichsweikamp
parents:
diff changeset
612
heinrichsweikamp
parents:
diff changeset
613 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
614 ; Writes a horizontal line of half-pixel at position (win_top,win_leftx2,win_width).
heinrichsweikamp
parents:
diff changeset
615 ; Inputs: win_leftx2, win_top, win_width, win_color:2
heinrichsweikamp
parents:
diff changeset
616 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
617
0
heinrichsweikamp
parents:
diff changeset
618 global half_horizontal_line
heinrichsweikamp
parents:
diff changeset
619 half_horizontal_line:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
620 clrf TABLAT ; Loop index.
0
heinrichsweikamp
parents:
diff changeset
621
heinrichsweikamp
parents:
diff changeset
622 half_horizontal_line_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
623 movf win_leftx2,W ; Init X position.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
624 mullw .2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
625 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
626 movf win_width,W ; Index reached height (Bank0 read) ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
627 xorwf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
628 btfsc STATUS,Z ; Equals ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
629 return ; Yes: done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
630 movf win_top,W ; Y = top + index (Bank0 read)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
631 addwf TABLAT,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
632 rcall half_pixel_write_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
633 incf TABLAT,F ; index++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
634 bra half_horizontal_line_loop
0
heinrichsweikamp
parents:
diff changeset
635
heinrichsweikamp
parents:
diff changeset
636
heinrichsweikamp
parents:
diff changeset
637 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
638 ; TFT Data Cmd via W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
639
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
640 global TFT_DataWrite_PROD
0
heinrichsweikamp
parents:
diff changeset
641 TFT_DataWrite_PROD:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
642 ; RD_H ; Keep high
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
643 RS_H ; Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
644 bcf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
645 movff PRODH,PORTA ; Move high byte to PORTA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
646 movff PRODL,PORTH ; Move low byte to PORTH
0
heinrichsweikamp
parents:
diff changeset
647 WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
648 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
649 bsf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
650 return
heinrichsweikamp
parents:
diff changeset
651
heinrichsweikamp
parents:
diff changeset
652 TFT_DataRead_PROD:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
653 Index_out 0x22 ; Frame Memory Data Read start
360
5f142cff43f6 hardware support
heinrichsweikamp
parents: 312
diff changeset
654 TFT_CmdRead_PROD:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
655 setf TRISA ; PortA as input.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
656 setf TRISH ; PortH as input.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
657 RS_H ; Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
658 WR_H ; Not write
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
659 RD_L ; Read!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
660 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
661 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
662 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
663 RD_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
664 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
665 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
666 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
667 RD_L ; Read!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
668 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
669 ;nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
670 ;nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
671 movff PORTA,PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
672 movff PORTH,PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
673 RD_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
674 nop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
675 clrf TRISA ; PortA as output
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
676 clrf TRISH ; PortH as output
0
heinrichsweikamp
parents:
diff changeset
677 return
heinrichsweikamp
parents:
diff changeset
678
heinrichsweikamp
parents:
diff changeset
679 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
680 ; Output TFT Window Address commands.
heinrichsweikamp
parents:
diff changeset
681 ; Inputs : win_top, win_leftx2, win_height, win_width.
heinrichsweikamp
parents:
diff changeset
682 ; Output : PortA/PortH commands.
heinrichsweikamp
parents:
diff changeset
683 ; Trashed: PROD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
684
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
685 global TFT_box_write
0
heinrichsweikamp
parents:
diff changeset
686 TFT_box_write:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
687 movf win_leftx2,W ; Compute left = 2*leftx2 --> PROD
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
688 mullw 2
0
heinrichsweikamp
parents:
diff changeset
689
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
690 global TFT_box_write_16bit_win_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
691 TFT_box_write_16bit_win_left: ; With column in PRODL:PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
692 btfsc screen_type ; display1?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
693 bra TFT_box_write_16bit_win_left_d1 ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
694 ; Display0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
695 btfsc flip_screen ; 180° rotation?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
696 bra DISP_box_flip_H ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
697 bra TFT_box_write_16bit_win_left_com ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
698 TFT_box_write_16bit_win_left_d1: ; Display1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
699 btfss flip_screen ; 180° rotation?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
700 bra DISP_box_flip_H ; No for d1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
701 ; Yes for d1
361
631cbfea3757 1.85beta release
heinrichsweikamp
parents: 360
diff changeset
702 TFT_box_write_16bit_win_left_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
703 ;---- Normal horizontal window ---------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
704 Index_out 0x52 ; Window Vertical Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
705 rcall TFT_DataWrite_PROD ; Output left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
706 Index_out 0x21 ; Frame Memory Vertical Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
707 rcall TFT_DataWrite_PROD ; Output left
0
heinrichsweikamp
parents:
diff changeset
708
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
709 movf win_width+0,W ; right = left + width - 1
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
710 addwf PRODL,F
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
711 movf win_width+1,W
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
712 addwfc PRODH,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
713 decf PRODL,F ; decrement result
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
714 btfss STATUS,C
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
715 decf PRODH,F
0
heinrichsweikamp
parents:
diff changeset
716
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
717 Index_out 0x53 ; Window Vertical End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
718 rcall TFT_DataWrite_PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
719 bra DISP_box_noflip_H
0
heinrichsweikamp
parents:
diff changeset
720
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
721 ;---- Flipped horizontal window --------------------------------------
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
722 DISP_box_flip_H:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
723 movf PRODL,W ; 16bits 319 - PROD --> PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
724 sublw LOW(.319) ; 319-W --> W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
725 movwf PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
726 movf PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
727 btfss STATUS,C ; Borrow = /CARRY
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
728 incf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
729 sublw HIGH(.319)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
730 movwf PRODH
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 151
diff changeset
731
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
732 Index_out 0x53 ; Window Vertical Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
733 rcall TFT_DataWrite_PROD ; Output left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
734 Index_out 0x21 ; Frame Memory Vertical Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
735 rcall TFT_DataWrite_PROD ; Output left
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
736
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
737 movf win_width+0,W ; 16bits PROD - width --> PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
738 subwf PRODL,F ; PRODL - WREG --> PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
739 movf win_width+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
740 subwfb PRODH,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
741 infsnz PRODL ; PROD+1 --> PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
742 incf PRODH
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
743
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
744 Index_out 0x52 ; Window Vertical End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
745 rcall TFT_DataWrite_PROD
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
746
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
747 DISP_box_noflip_H:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
748 btfss flip_screen ; 180° rotation ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
749 bra TFT_box_noflip_V ; No.
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
750
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
751 ;---- Flipped vertical window -----------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
752 movff win_top,PRODH ; top --> PRODH (first byte)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
753 movf win_height,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
754 addwf PRODH,W
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
755 decf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
756 movwf PRODL ; top+height-1 --> PRODL (second byte)
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
757
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
758 Index_out 0x50 ; Window Horizontal Start Address
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
759 movf PRODH,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
760 rcall TFT_DataWrite ; Lower (and tick)
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
761
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
762 Index_out 0x51 ; Window Horizontal End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
763 movf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
764 rcall TFT_DataWrite ; Lower (and tick)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
765
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
766 Index_out 0x20 ; Frame Memory Horizontal Address
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
767 movf PRODH,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
768 bra TFT_DataWrite ; Lower (and tick) and return
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
769
152
19ad15f04f60 BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents: 151
diff changeset
770 TFT_box_noflip_V:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
771 ;---- Normal vertical window ----------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
772 movff win_top,PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
773 movf win_height,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
774 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
775 sublw .240 ; 240 - top - height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
776 movwf PRODH ; First byte
0
heinrichsweikamp
parents:
diff changeset
777
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
778 movf PRODL,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
779 sublw .239 ; 239-top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
780 movwf PRODL ; --> second byte.
0
heinrichsweikamp
parents:
diff changeset
781
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
782 Index_out 0x50 ; Window Horizontal Start Address
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
783 movf PRODH,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
784 rcall TFT_DataWrite ; Lower (and tick)
0
heinrichsweikamp
parents:
diff changeset
785
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
786 Index_out 0x51 ; Window Horizontal End Address
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
787 movf PRODL,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
788 rcall TFT_DataWrite ; Lower (and tick)
0
heinrichsweikamp
parents:
diff changeset
789
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
790 Index_out 0x20 ; Frame Memory Horizontal Address
432
929feb0da4f5 hunting a bug in the logbook (Day 2)
heinrichsweikamp
parents: 431
diff changeset
791 movf PRODL,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
792 bra TFT_DataWrite ; Lower (and tick) and return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
793
0
heinrichsweikamp
parents:
diff changeset
794
heinrichsweikamp
parents:
diff changeset
795 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
796 ; TFT_frame : draw a frame around current box with current color.
heinrichsweikamp
parents:
diff changeset
797 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
798 ; Outputs: (none)
heinrichsweikamp
parents:
diff changeset
799 ; Trashed: WREG, PROD, aa_start:2, aa_end:2
heinrichsweikamp
parents:
diff changeset
800
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
801 global TFT_frame
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
802 TFT_frame:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
803 movff win_top,save_top ; Backup everything.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
804 movff win_height,save_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
805 movff win_leftx2,save_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
806 movff win_width,save_width
0
heinrichsweikamp
parents:
diff changeset
807
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
808 ;---- TOP line -----------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
809 movlw .1 ; row ~ height=1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
810 movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
811 rcall TFT_box
0
heinrichsweikamp
parents:
diff changeset
812
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
813 ;---- BOTTOM line --------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
814 movff save_top,PRODL ; Get back top,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
815 movff save_height,WREG ; and height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
816 addwf PRODL,W ; top+height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
817 decf WREG ; top+height-1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
818 movwf win_top ; top+height-1 --> top
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
819 rcall TFT_box
0
heinrichsweikamp
parents:
diff changeset
820
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
821 ;---- LEFT column --------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
822 movff save_top,win_top ; Restore top/height.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
823 movff save_height,win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
824 movlw .1 ; column ~ width=1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
825 movwf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
826 rcall TFT_box
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
827
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
828 ;---- RIGHT column -------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
829 movff save_left,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
830 movff save_width,PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
831 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
832 decf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
833 movwf win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
834 rcall TFT_box
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
835
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
836 ;---- Restore everything -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
837 movff save_left,win_leftx2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
838 movff save_width,win_width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
839 return
0
heinrichsweikamp
parents:
diff changeset
840
heinrichsweikamp
parents:
diff changeset
841 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
842 ; TFT_box : fills current box with current color.
heinrichsweikamp
parents:
diff changeset
843 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
844 ; Outputs: (none)
heinrichsweikamp
parents:
diff changeset
845 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
846
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
847 global TFT_box
0
heinrichsweikamp
parents:
diff changeset
848 TFT_box:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
849 ;---- Define Window ------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
850 bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
851 rlcf win_width+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
852 rlcf win_width+1,F ; x2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
853 rcall TFT_box_write ; Setup box
0
heinrichsweikamp
parents:
diff changeset
854
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
855 global TFT_box_16bit_win_left
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
856 TFT_box_16bit_win_left:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
857 bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
858 rrcf win_width+1,F ; width /= 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
859 rrcf win_width+0,F
0
heinrichsweikamp
parents:
diff changeset
860
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
861 ;---- Fill Window --------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
862 Index_out 0x22 ; Frame Memory Data Write start
0
heinrichsweikamp
parents:
diff changeset
863
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
864 clrf PRODH ; Column counter.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
865 RS_H ; Data
0
heinrichsweikamp
parents:
diff changeset
866
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
867 TFT_box2: ; Loop height times
0
heinrichsweikamp
parents:
diff changeset
868 movff win_height,PRODL
heinrichsweikamp
parents:
diff changeset
869
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
870 TFT_box3: ; loop width times
436
95ee78f4a974 no screen reboot after logbook exit
heinrichsweikamp
parents: 434
diff changeset
871 bcf INTCON,GIE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
872 movff win_color1,PORTA ; Upper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
873 movff win_color2,PORTH ; Lower
0
heinrichsweikamp
parents:
diff changeset
874 WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
875 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
876
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
877 ; movff win_color1,PORTA ; Upper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
878 ; movff win_color2,PORTH ; Lower
0
heinrichsweikamp
parents:
diff changeset
879 WR_L
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
880 WR_H ; Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
881 bsf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
882 decfsz PRODL,F ; row loop finished ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
883 bra TFT_box3 ; No: continue.
0
heinrichsweikamp
parents:
diff changeset
884
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
885 incf PRODH,F ; column count ++
0
heinrichsweikamp
parents:
diff changeset
886
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
887 movf win_bargraph,W ; current column == bargraph ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
888 cpfseq PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
889 bra TFT_box4 ; No: just loop.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
890 ; Yes: switch to black
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
891 clrf win_color1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
892 clrf win_color2
0
heinrichsweikamp
parents:
diff changeset
893 TFT_box4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
894 movf win_width+0,W ; compare ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
895 xorwf PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
896 bnz TFT_box2 ; Loop not finished.
0
heinrichsweikamp
parents:
diff changeset
897
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
898 movlw 0x00 ; NOP, to stop window mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
899 rcall TFT_CmdWrite
0
heinrichsweikamp
parents:
diff changeset
900
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
901 ; Reset bargraph mode...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
902 setf win_bargraph
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
903 return
0
heinrichsweikamp
parents:
diff changeset
904
heinrichsweikamp
parents:
diff changeset
905 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
906 ;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGGGGGBBBBB'
heinrichsweikamp
parents:
diff changeset
907
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
908 global TFT_set_color
0
heinrichsweikamp
parents:
diff changeset
909 TFT_set_color:
heinrichsweikamp
parents:
diff changeset
910 movwf tft_temp1 ; Get 8Bit RGB b'RRRGGGBB'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
911 movwf tft_temp2 ; Copy
0
heinrichsweikamp
parents:
diff changeset
912
heinrichsweikamp
parents:
diff changeset
913 ; Mask Bit 7,6,5,4,3,2
heinrichsweikamp
parents:
diff changeset
914 movlw b'00000011'
heinrichsweikamp
parents:
diff changeset
915 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
916
heinrichsweikamp
parents:
diff changeset
917 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
918 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
919 movlw b'01010000'
heinrichsweikamp
parents:
diff changeset
920 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
921 movlw b'10100000'
heinrichsweikamp
parents:
diff changeset
922 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
923 movlw b'11111000'
heinrichsweikamp
parents:
diff changeset
924 movwf tft_temp3 ; Blue done.
heinrichsweikamp
parents:
diff changeset
925
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
926 movff tft_temp1,tft_temp2 ; Copy
0
heinrichsweikamp
parents:
diff changeset
927 ; Mask Bit 7,6,5,1,0
heinrichsweikamp
parents:
diff changeset
928 movlw b'00011100'
heinrichsweikamp
parents:
diff changeset
929 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
930 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
931 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
932
heinrichsweikamp
parents:
diff changeset
933 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
934 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
935 movlw b'00000100'
heinrichsweikamp
parents:
diff changeset
936 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
937 movlw b'00001000'
heinrichsweikamp
parents:
diff changeset
938 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
939 movlw b'00001100'
heinrichsweikamp
parents:
diff changeset
940 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
941 movlw b'00010000'
heinrichsweikamp
parents:
diff changeset
942 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
943 movlw b'00010100'
heinrichsweikamp
parents:
diff changeset
944 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
945 movlw b'00100000'
heinrichsweikamp
parents:
diff changeset
946 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
947 movlw b'00111111'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
948 movwf tft_temp4
0
heinrichsweikamp
parents:
diff changeset
949
heinrichsweikamp
parents:
diff changeset
950 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
951 rrcf tft_temp3,F
heinrichsweikamp
parents:
diff changeset
952
heinrichsweikamp
parents:
diff changeset
953 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
954 rrcf tft_temp3,F
heinrichsweikamp
parents:
diff changeset
955
heinrichsweikamp
parents:
diff changeset
956 rrcf tft_temp4,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
957 rrcf tft_temp3,W ; tft_temp3 (b'GGGBBBBB') done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
958 movwf win_color2 ; Set Color registers...
0
heinrichsweikamp
parents:
diff changeset
959
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
960 movff tft_temp1,tft_temp2 ; Copy
0
heinrichsweikamp
parents:
diff changeset
961 clrf tft_temp1
heinrichsweikamp
parents:
diff changeset
962
heinrichsweikamp
parents:
diff changeset
963 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
964 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
965
heinrichsweikamp
parents:
diff changeset
966 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
967 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
968
heinrichsweikamp
parents:
diff changeset
969 rrcf tft_temp4,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
970 rrcf tft_temp1,F ; Green done.
0
heinrichsweikamp
parents:
diff changeset
971
heinrichsweikamp
parents:
diff changeset
972 ; Mask Bit 4,3,2,1,0
heinrichsweikamp
parents:
diff changeset
973 movlw b'11100000'
heinrichsweikamp
parents:
diff changeset
974 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
975
heinrichsweikamp
parents:
diff changeset
976 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
977 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
978 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
979 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
980 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
981
heinrichsweikamp
parents:
diff changeset
982 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
983 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
984 movlw b'00000100'
heinrichsweikamp
parents:
diff changeset
985 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
986 movlw b'00001000'
heinrichsweikamp
parents:
diff changeset
987 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
988 movlw b'00001100'
heinrichsweikamp
parents:
diff changeset
989 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
990 movlw b'00010000'
heinrichsweikamp
parents:
diff changeset
991 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
992 movlw b'00010100'
heinrichsweikamp
parents:
diff changeset
993 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
994 movlw b'00100000'
heinrichsweikamp
parents:
diff changeset
995 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
996 movlw b'00111111'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
997 movwf tft_temp4
0
heinrichsweikamp
parents:
diff changeset
998
heinrichsweikamp
parents:
diff changeset
999 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
1000 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
1001
heinrichsweikamp
parents:
diff changeset
1002 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
1003 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
1004
heinrichsweikamp
parents:
diff changeset
1005 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
1006 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
1007
heinrichsweikamp
parents:
diff changeset
1008 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
1009 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
1010
heinrichsweikamp
parents:
diff changeset
1011 rrcf tft_temp4,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1012 rrcf tft_temp1,W ; Red done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1013 movwf win_color1 ; Set Color registers...
0
heinrichsweikamp
parents:
diff changeset
1014 return
heinrichsweikamp
parents:
diff changeset
1015
heinrichsweikamp
parents:
diff changeset
1016 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1017 ; Dump screen contents to the UART
heinrichsweikamp
parents:
diff changeset
1018
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1019 global TFT_dump_screen
0
heinrichsweikamp
parents:
diff changeset
1020 TFT_dump_screen:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1021 bsf no_sensor_int
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1022 movlw 'l'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1023 movwf TXREG ; Send command echo.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1024 call rs232_wait_tx ; wait for UART
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1025 ;---- Send DISPLAY box command for the full screen window -------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1026 Index_out 0x50 ; Window Horizontal Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1027 Parameter_out 0x00, 0x00 ; 0-239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1028 Index_out 0x51 ; Window Horizontal End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1029 Parameter_out 0x00, 0xEF ; 0-239
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1030 Index_out 0x52 ; Window Vertical Start Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1031 Parameter_out 0x00, 0x00 ; 0-319
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1032 Index_out 0x53 ; Window Vertical End Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1033 Parameter_out 0x01, 0x3F ; 0-319
0
heinrichsweikamp
parents:
diff changeset
1034
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1035 clrf ds_column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1036 rcall dump_screen_pixel_reset
0
heinrichsweikamp
parents:
diff changeset
1037 dump_screen_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1038 btg LEDr ; LED activity toggle
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1039 ; Dump even column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1040 movlw .240 ; 240 lines, once.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1041 movwf ds_line
0
heinrichsweikamp
parents:
diff changeset
1042 dump_screen_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1043 Index_out 0x20 ; Frame Memory Horizontal Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1044 movff ds_line,WREG ; d'0' ... d'239'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1045 mullw .1 ; Copy row to PRODH:L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1046 rcall TFT_DataWrite_PROD
0
heinrichsweikamp
parents:
diff changeset
1047
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1048 movff ds_column,WREG ; Init X position.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1049 mullw 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1050 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
0
heinrichsweikamp
parents:
diff changeset
1051
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1052 rcall TFT_DataRead_PROD ; read pixel
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1053 rcall dump_screen_pixel
0
heinrichsweikamp
parents:
diff changeset
1054
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1055 decfsz ds_line,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1056 bra dump_screen_2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1057 rcall dump_screen_pixel_flush
0
heinrichsweikamp
parents:
diff changeset
1058
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1059 ; Dump odd column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1060 movlw .240 ; 240 lines, twice.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1061 movwf ds_line
0
heinrichsweikamp
parents:
diff changeset
1062 dump_screen_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1063 Index_out 0x20 ; Frame Memory Horizontal Address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1064 movff ds_line,WREG ; d'0' ... d'239'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1065 mullw 1 ; Copy row to PRODH:L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1066 rcall TFT_DataWrite_PROD
0
heinrichsweikamp
parents:
diff changeset
1067
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1068 movff ds_column,WREG ; Init X position.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1069 mullw 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1070 movlw .1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1071 addwf PRODL,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1072 movlw 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1073 addwfc PRODH,F ; +1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1074 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
0
heinrichsweikamp
parents:
diff changeset
1075
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1076 rcall TFT_DataRead_PROD ; read pixel
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1077 rcall dump_screen_pixel
0
heinrichsweikamp
parents:
diff changeset
1078
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1079 decfsz ds_line,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1080 bra dump_screen_3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1081 rcall dump_screen_pixel_flush
0
heinrichsweikamp
parents:
diff changeset
1082
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1083 incf ds_column,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1084 movlw .160
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1085 cpfseq ds_column
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1086 bra dump_screen_1
0
heinrichsweikamp
parents:
diff changeset
1087
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1088 bcf no_sensor_int
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1089 clrf RCREG1 ; Clear receive buffer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1090 bcf RCSTA1,CREN ; Clear receiver status
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1091 bsf RCSTA1,CREN
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1092 bsf enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1093 return
0
heinrichsweikamp
parents:
diff changeset
1094
heinrichsweikamp
parents:
diff changeset
1095
heinrichsweikamp
parents:
diff changeset
1096 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1097 ; Pixel compression
heinrichsweikamp
parents:
diff changeset
1098 ;
heinrichsweikamp
parents:
diff changeset
1099 ; Input: PRODH:L = pixel.
heinrichsweikamp
parents:
diff changeset
1100 ; Output: Compressed stream on output.
heinrichsweikamp
parents:
diff changeset
1101 ; Compressed format:
heinrichsweikamp
parents:
diff changeset
1102 ; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128).
heinrichsweikamp
parents:
diff changeset
1103 ; 11cccccc : WHITE pixel, repeated cccccc+1 times (1..64).
heinrichsweikamp
parents:
diff changeset
1104 ; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1..64).
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1105
0
heinrichsweikamp
parents:
diff changeset
1106 dump_screen_pixel:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1107 movf PRODH,W ; Compare pixel-high
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1108 xorwf ds_pixel+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1109 bnz dump_screen_pixel_1 ; Different -> dump.
0
heinrichsweikamp
parents:
diff changeset
1110
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1111 movf PRODL,W ; Compare pixel-low
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1112 xorwf ds_pixel+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1113 bnz dump_screen_pixel_1 ; Different -> dump.
0
heinrichsweikamp
parents:
diff changeset
1114
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1115 incf ds_count,F ; Same color: just increment.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1116 return
0
heinrichsweikamp
parents:
diff changeset
1117
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1118 dump_screen_pixel_1: ; Send (pixel,count) tuple
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1119 movf ds_count,W ; Is count zero ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1120 bz dump_screen_pixel_2 ; Yes: skip sending.
0
heinrichsweikamp
parents:
diff changeset
1121
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1122 movf ds_pixel+1,W ; This is a BLACK pixel ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1123 iorwf ds_pixel+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1124 bz dump_screen_pix_black ; YES.
0
heinrichsweikamp
parents:
diff changeset
1125
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1126 movf ds_pixel+1,W ; This is a white pixel ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1127 andwf ds_pixel+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1128 incf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1129 bz dump_screen_pix_white ; YES.
0
heinrichsweikamp
parents:
diff changeset
1130
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1131 ; No: write the pixel itself...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1132 movlw .64 ; Max color pixel on a single byte.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1133 cpfsgt ds_count ; Skip if count > 64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1134 movf ds_count,W ; W <- min(64,count)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1135 subwf ds_count,F ; ds_count <- ds_count-W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1136 decf WREG ; Save as 0..63
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1137 iorlw b'10000000' ; MARK as a color pixel.
0
heinrichsweikamp
parents:
diff changeset
1138
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1139 movwf TXREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1140 call rs232_wait_tx ; wait for UART
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1141 movff ds_pixel+1,TXREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1142 call rs232_wait_tx ; wait for UART
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1143 movff ds_pixel+0,TXREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1144 call rs232_wait_tx ; wait for UART
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1145 bra dump_screen_pixel_1
0
heinrichsweikamp
parents:
diff changeset
1146
heinrichsweikamp
parents:
diff changeset
1147 dump_screen_pixel_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1148 movff PRODH,ds_pixel+1 ; Save new pixel color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1149 movff PRODL,ds_pixel+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1150 movlw 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1151 movwf ds_count ; And set count=1.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1152 return
0
heinrichsweikamp
parents:
diff changeset
1153
heinrichsweikamp
parents:
diff changeset
1154 dump_screen_pix_black:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1155 movlw .128 ; Max black pixel on a single byte.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1156 cpfsgt ds_count ; Skip if count > 128
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1157 movf ds_count,W ; W <- min(128,count)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1158 subwf ds_count,F ; ds_count <- ds_count-W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1159 decf WREG ; Save as 0..127
0
heinrichsweikamp
parents:
diff changeset
1160 dump_screen_pix_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1161 movwf TXREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1162 call rs232_wait_tx
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1163 bra dump_screen_pixel_1 ; More to dump ?
0
heinrichsweikamp
parents:
diff changeset
1164
heinrichsweikamp
parents:
diff changeset
1165 dump_screen_pix_white:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1166 movlw .64 ; Max white pixel on a single byte.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1167 cpfsgt ds_count ; Skip if count > 64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1168 movf ds_count,W ; W <- min(64,count)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1169 subwf ds_count,F ; ds_count <- ds_count-W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1170 decf WREG ; Save as 0..63
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1171 iorlw b'11000000' ; MARK as a compressed white.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1172 bra dump_screen_pix_3
0
heinrichsweikamp
parents:
diff changeset
1173
heinrichsweikamp
parents:
diff changeset
1174 dump_screen_pixel_flush:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1175 clrf PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1176 clrf PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1177 rcall dump_screen_pixel_1 ; Send it
0
heinrichsweikamp
parents:
diff changeset
1178 dump_screen_pixel_reset:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1179 clrf ds_count ; But clear count.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1180 return
0
heinrichsweikamp
parents:
diff changeset
1181
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 461
diff changeset
1182 END