annotate src/tft.asm @ 444:d93d75ae01bf

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