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