Mercurial > public > hwos_code
annotate src/tft.asm @ 246:f345a55c92e0
minor docu update
author | heinrichsweikamp |
---|---|
date | Thu, 05 Mar 2015 10:36:56 +0100 |
parents | 31088352ee32 |
children | 653a3ab08062 |
rev | line source |
---|---|
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 | |
246 clrf PORTH ; Data Lower | |
247 | |
248 movlw d'10' | |
249 movwf tft_temp3 | |
250 TFT_ClearScreen2: | |
251 movlw d'30' | |
252 movwf tft_temp2 | |
253 TFT_ClearScreen3: | |
254 clrf tft_temp1 ; 30*10*256=76800 Pixels -> Clear complete 240*320 | |
255 TFT_ClearScreen4: | |
256 WR_L | |
257 WR_H ; Tick | |
258 decfsz tft_temp1,F | |
259 bra TFT_ClearScreen4 | |
260 decfsz tft_temp2,F | |
261 bra TFT_ClearScreen3 | |
262 decfsz tft_temp3,F | |
263 bra TFT_ClearScreen2 | |
264 return | |
265 | |
266 ;============================================================================= | |
267 ; | |
268 global TFT_DisplayOff | |
269 TFT_DisplayOff: | |
270 clrf CCPR1L ; PWM OFF | |
271 clrf PORTA | |
272 clrf PORTH | |
273 RD_L ; LOW | |
274 nop | |
275 RS_L ; LOW | |
276 bcf tft_nwr | |
277 nop | |
278 bcf tft_cs | |
279 nop | |
280 bcf tft_nreset | |
281 WAITMS d'1' | |
282 bsf tft_power ; inverted... | |
283 bcf lightsen_power ; power-down light sensor | |
284 return | |
285 | |
286 ; ----------------------------- | |
287 ; TFT boot | |
288 ; ----------------------------- | |
289 global TFT_boot | |
290 TFT_boot: | |
291 clrf PORTA | |
292 clrf PORTH | |
293 RD_L ; LOW | |
294 bcf tft_nwr | |
295 nop | |
296 bcf tft_cs | |
297 nop | |
298 bcf tft_nreset | |
299 WAITMS d'1' | |
300 bcf tft_power ; inverted... | |
301 WAITMS d'1' | |
302 | |
303 RD_H ; Keep high | |
304 WR_H ; | |
305 NCS_L ; Not CS | |
306 | |
307 WAITMS d'2' | |
308 bsf tft_nreset | |
309 WAITMS d'150' | |
310 bsf lightsen_power ; Supply power to light sensor | |
311 | |
312 ; Data Transfer Synchronization | |
313 Parameter_out 0x00, 0x00 | |
314 Parameter_out 0x00, 0x00 | |
315 | |
316 ; Init through config table... | |
317 movlw LOW display0_config_table | |
318 movwf TBLPTRL | |
319 movlw HIGH display0_config_table | |
320 movwf TBLPTRH | |
321 movlw UPPER display0_config_table | |
322 movwf TBLPTRU | |
323 rcall display0_init_loop | |
324 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
325 Index_out 0x03 |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
326 btfsc flip_screen ; 180° rotation ? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
327 bra TFT_boot2 ; Yes |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
328 Parameter_out 0x50, 0x20 |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
329 bra TFT_boot3 |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
330 TFT_boot2: |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
331 Parameter_out 0x50, 0x10 |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
332 TFT_boot3: |
0 | 333 Index_out 0x22 |
334 ; WAITMS d'81' ; 46 | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
152
diff
changeset
|
335 rcall TFT_ClearScreen |
0 | 336 Index_out 0x07 |
337 Parameter_out 0x01, 0x00 | |
338 return | |
339 | |
340 | |
341 display0_config_table: | |
342 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
343 db 0xA4,0x00,0x01,0xFF,.002,0x00 | |
344 db 0x09,0x00,0x01,0x92,0x04,0x00 | |
345 db 0x93,0x04,0x02,0x94,0x00,0x02 | |
346 db 0x07,0x00,0x00,0x10,0x04,0x30 | |
347 db 0x11,0x02,0x37,0x12,0x11,0x8D | |
348 db 0x13,0x11,0x00,0x01,0x01,0x00 | |
349 db 0x02,0x02,0x00,0x03,0x50,0x20 | |
350 db 0x0A,0x00,0x08,0x0D,0x00,0x00 | |
351 db 0x0E,0x00,0x30,0xFF,.151,0x00 | |
352 db 0x12,0x11,0xBD,0x20,0x00,0x00 | |
353 db 0x21,0x00,0x00,0x30,0x06,0x02 | |
354 db 0x31,0x56,0x0D,0x32,0x05,0x07 | |
355 db 0x33,0x06,0x09,0x34,0x00,0x00 | |
356 db 0x35,0x09,0x06,0x36,0x57,0x05 | |
357 db 0x37,0x0D,0x06,0x38,0x02,0x06 | |
358 db 0x39,0x00,0x00,0xFF,0x00,0x00 | |
359 | |
360 display0_init_loop: | |
361 TBLRD*+ | |
362 movlw 0xFF | |
363 cpfseq TABLAT | |
364 bra display0_config_write ; Write Config pair to Display | |
365 ; Delay ms or quit (return) | |
366 TBLRD*+ | |
367 tstfsz TABLAT ; End of config? | |
368 bra $+4 ; No | |
369 return ; Done. | |
370 movf TABLAT,W | |
371 call WAITMSX ; Wait WREG milliseconds | |
372 TBLRD*+ ; Dummy read (Third byte of delay command) | |
373 bra display0_init_loop ; Loop | |
374 | |
375 display0_config_write: ; With command in WREG | |
376 movf TABLAT,W | |
377 rcall TFT_CmdWrite ; Write command | |
378 TBLRD*+ ; Get config0 | |
379 movff TABLAT,PORTA | |
380 TBLRD*+ ; Get config1 | |
381 movf TABLAT,W | |
382 rcall TFT_DataWrite ; Write config | |
383 bra display0_init_loop ; Loop | |
384 | |
385 | |
386 ;============================================================================= | |
387 ; Smooth lighting-up of the display: | |
388 ; | |
389 ; Trashes: WREG, PRODL | |
390 ; Typical usage: | |
391 ; clrf CCPR1L ; Backlight off | |
392 ; [draw splash screen] | |
393 ; call TFT_DisplayFadeIn | |
394 ; | |
395 global TFT_Display_FadeIn | |
396 TFT_Display_FadeIn: | |
397 movlw CCP1CON_VALUE ; See ostc3.inc | |
398 movwf CCP1CON | |
399 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor! | |
400 clrf CCPR1L ; Backlight off - to be sure | |
401 movff max_CCPR1L,PRODL | |
402 TFT_Display_FadeIn_0: | |
403 incf CCPR1L,F ; Duty cycle | |
404 WAITMS d'2' | |
405 decfsz PRODL,F | |
406 bra TFT_Display_FadeIn_0 | |
407 bcf tft_is_dimming ; dimming done. | |
408 return | |
409 | |
410 ;============================================================================= | |
411 ; Smooth lighting-off of the display: | |
412 ; Trashes: WREG, PRODL | |
413 global TFT_Display_FadeOut | |
414 TFT_Display_FadeOut: | |
415 movff max_CCPR1L,PRODL | |
416 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor! | |
417 TFT_Display_FadeOut_0: | |
418 movff PRODL,CCPR1L ; Duty cycle | |
419 WAITMS d'1' | |
420 decfsz PRODL,F | |
421 bra TFT_Display_FadeOut_0 | |
422 clrf CCPR1L | |
423 return | |
424 | |
425 ;============================================================================= | |
426 | |
427 global box_std_block, box_black_block, box_color_block | |
428 | |
429 box_std_block: ; Use white color | |
430 setf WREG | |
431 bra box_common | |
432 box_black_block: ; Use black color | |
433 clrf WREG | |
434 box_common: | |
435 box_color_block: | |
436 rcall TFT_set_color | |
437 VARARGS_BEGIN | |
438 VARARGS_GET8 win_top | |
439 VARARGS_GET8 win_height | |
440 VARARGS_GET8 win_leftx2 | |
441 VARARGS_GET8 win_width | |
442 VARARGS_END | |
443 bra TFT_box | |
444 | |
445 ;----------------------------------------------------------------------------- | |
446 | |
447 global box_frame_std, box_frame_common, box_frame_color, box_frame_color16 | |
448 | |
449 box_frame_std: | |
450 setf WREG | |
451 rcall TFT_set_color | |
452 | |
453 box_frame_common: | |
454 VARARGS_BEGIN | |
455 VARARGS_GET8 win_top | |
456 VARARGS_GET8 win_height | |
457 VARARGS_GET8 win_leftx2 | |
458 VARARGS_GET8 win_width | |
459 VARARGS_END | |
460 bra TFT_frame | |
461 | |
462 box_frame_color: | |
463 rcall TFT_set_color | |
464 box_frame_color16: | |
465 bra box_frame_common | |
466 | |
467 ;============================================================================= | |
468 ; Init for half_pixel_write | |
469 ; Set column register on TFT device, and current color. | |
470 ; Inputs: win_leftx2 | |
471 ; Outputs: win_color:2 | |
472 ; Trashed: WREG, PROD | |
473 global init_pixel_write | |
474 init_pixel_write: | |
475 movff win_leftx2,WREG | |
476 mullw 2 | |
477 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
478 setf WREG | |
479 bra TFT_set_color | |
480 | |
481 ;----------------------------------------------------------------------------- | |
482 ; Writes two half-pixels at position (win_top,win_leftx2) | |
483 ; Inputs: win_leftx2, win_top, win_color:2 | |
484 ; Trashed: WREG, PROD | |
485 global pixel_write | |
486 pixel_write: | |
487 movff win_leftx2,WREG | |
488 mullw 2 ; win_leftx2 x 2 -> PRODH:PRODL | |
489 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
490 rcall half_pixel_write ; Write this half-one. | |
491 | |
492 movff win_leftx2,WREG ; Address of next one | |
493 mullw 2 | |
494 infsnz PRODL ; +1 | |
495 incf PRODH | |
496 rcall pixel_write_col320 | |
497 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because | |
498 ; of the autoincrement going vertical | |
499 | |
500 global pixel_write_col320 | |
501 pixel_write_col320: | |
151 | 502 btfss flip_screen ; 180° rotation? |
503 bra pixel_write_noflip_H ; No | |
504 | |
505 movf PRODL,W ; 16bits 319 - PROD --> PROD | |
506 sublw LOW(.319) ; 319-W --> W | |
507 movwf PRODL | |
508 movf PRODH,W | |
509 btfss STATUS,C ; Borrow = /CARRY | |
510 incf WREG | |
511 sublw HIGH(.319) | |
512 movwf PRODH | |
513 | |
514 pixel_write_noflip_H: | |
0 | 515 Index_out 0x21 ; Frame Memory Vertical Address |
516 bra TFT_DataWrite_PROD | |
517 | |
518 ;----------------------------------------------------------------------------- | |
519 ; Writes one half-pixel at position (win_top,win_leftx2). | |
520 ; Inputs: win_leftx2, win_top, win_color:2 | |
521 ; Trashed: WREG, PROD | |
522 global half_pixel_write | |
523 half_pixel_write: | |
524 movff win_top,WREG ; d'0' ... d'239' | |
525 ; Variant with Y position in WREG. | |
526 half_pixel_write_1: | |
151 | 527 btfss flip_screen ; 180° rotation? |
528 sublw .239 ; 239-Y --> Y | |
529 mullw 1 ; Copy row to PRODL (PRODH=0) | |
0 | 530 |
531 Index_out 0x20 ; Frame Memory Horizontal Address | |
532 rcall TFT_DataWrite_PROD | |
533 | |
534 Index_out 0x22 ; Frame Memory Data Write start | |
535 RS_H ; Data | |
536 movff win_color1,PORTA ; Upper | |
537 movff win_color2,PORTH ; Lower | |
538 WR_L | |
539 WR_H ; Tick | |
540 return | |
541 | |
542 ;----------------------------------------------------------------------------- | |
543 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height). | |
544 ; Inputs: win_leftx2, win_top, win_height, win_color:2 | |
545 ; Trashed: WREG, PROD, TABLAT, TBLPTRL | |
546 global half_vertical_line | |
547 half_vertical_line: | |
548 clrf TABLAT ; Loop index. | |
549 | |
550 half_vertical_line_loop: | |
551 movff win_leftx2,WREG ; Init X position. | |
552 mullw 2 | |
553 movf TABLAT,W ; Get loop index | |
554 andlw 1 ; Just low bit | |
555 xorwf PRODL,F ; And use it to jitter current X position | |
556 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
557 | |
558 movff win_height,WREG ; Index reached height (Bank0 read) ? | |
559 xorwf TABLAT,W | |
560 btfsc STATUS,Z ; Equals ? | |
561 return ; Yes: done. | |
562 movff win_top,WREG ; Y = top + index (Bank0 read) | |
563 addwf TABLAT,W | |
564 rcall half_pixel_write_1 | |
565 incf TABLAT,F ; index++ | |
566 bra half_vertical_line_loop | |
567 | |
568 ;----------------------------------------------------------------------------- | |
569 ; Writes a horizontal line of half-pixel at position (win_top,win_leftx2,win_width). | |
570 ; Inputs: win_leftx2, win_top, win_width, win_color:2 | |
571 ; Trashed: WREG, PROD, TABLAT, TBLPTRL | |
572 global half_horizontal_line | |
573 half_horizontal_line: | |
574 clrf TABLAT ; Loop index. | |
575 | |
576 half_horizontal_line_loop: | |
577 movff win_leftx2,WREG ; Init X position. | |
578 mullw 2 | |
579 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
580 movff win_width,WREG ; Index reached height (Bank0 read) ? | |
581 xorwf TABLAT,W | |
582 btfsc STATUS,Z ; Equals ? | |
583 return ; Yes: done. | |
584 movff win_top,WREG ; Y = top + index (Bank0 read) | |
585 addwf TABLAT,W | |
586 rcall half_pixel_write_1 | |
587 incf TABLAT,F ; index++ | |
588 bra half_horizontal_line_loop | |
589 | |
590 | |
591 ;----------------------------------------------------------------------------- | |
592 ; TFT Data Cmd via W | |
593 ; | |
594 global TFT_DataWrite_PROD | |
595 TFT_DataWrite_PROD: | |
596 ; RD_H ; Keep high | |
597 RS_H ; Data | |
598 movff PRODH,PORTA ; Move high byte to PORTA | |
599 movff PRODL,PORTH ; Move low byte to PORTH | |
600 WR_L | |
601 WR_H ; Tick | |
602 return | |
603 | |
604 TFT_DataRead_PROD: | |
605 Index_out 0x22 ; Frame Memory Data Read start | |
606 setf TRISA ; PortA as input. | |
607 setf TRISH ; PortH as input. | |
608 RS_H ; Data | |
609 WR_H ; Not write | |
610 RD_L ; Read! | |
611 nop | |
612 nop | |
613 nop | |
614 RD_H ; Tick | |
615 nop | |
616 RD_L ; Read! | |
617 nop | |
618 nop | |
619 nop | |
620 movff PORTA,PRODH | |
621 movff PORTH,PRODL | |
622 RD_H ; Tick | |
623 nop | |
624 clrf TRISA ; PortA as output | |
625 clrf TRISH ; PortH as output | |
626 return | |
627 | |
628 | |
629 | |
630 ;============================================================================= | |
631 ; Output TFT Window Address commands. | |
632 ; Inputs : win_top, win_leftx2, win_height, win_width. | |
633 ; Output : PortA/PortH commands. | |
634 ; Trashed: PROD | |
635 ; | |
636 global TFT_box_write | |
637 TFT_box_write: | |
638 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD | |
639 mullw 2 | |
640 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
641 global TFT_box_write_16bit_win_left |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
642 TFT_box_write_16bit_win_left: ; With column in PRODL:PRODH |
151 | 643 btfsc flip_screen ; 180° rotation ? |
644 bra DISP_box_flip_H ; Yes | |
645 | |
0 | 646 ;---- Normal horizontal window --------------------------------------- |
647 Index_out 0x52 ; Window Vertical Start Address | |
648 rcall TFT_DataWrite_PROD ; Output left | |
649 Index_out 0x21 ; Frame Memory Vertical Address | |
650 rcall TFT_DataWrite_PROD ; Output left | |
651 | |
652 movff win_width+0,WREG ; right = left + width - 1 | |
653 addwf PRODL,F | |
654 movff win_width+1,WREG | |
655 addwfc PRODH,F | |
656 decf PRODL,F ; decrement result | |
657 btfss STATUS,C | |
658 decf PRODH,F | |
659 | |
660 Index_out 0x53 ; Window Vertical End Address | |
661 rcall TFT_DataWrite_PROD | |
151 | 662 bra DISP_box_noflip_H |
0 | 663 |
151 | 664 ;---- Flipped horizontal window -------------------------------------- |
665 DISP_box_flip_H: | |
666 movf PRODL,W ; 16bits 319 - PROD --> PROD | |
667 sublw LOW(.319) ; 319-W --> W | |
668 movwf PRODL | |
669 movf PRODH,W | |
670 btfss STATUS,C ; Borrow = /CARRY | |
671 incf WREG | |
672 sublw HIGH(.319) | |
673 movwf PRODH | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
674 |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
675 Index_out 0x53 ; Window Vertical Start Address |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
676 rcall TFT_DataWrite_PROD ; Output left |
151 | 677 Index_out 0x21 ; Frame Memory Vertical Address |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
678 rcall TFT_DataWrite_PROD ; Output left |
151 | 679 |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
680 movff win_width+0,WREG ; 16bits PROD - width --> PROD |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
681 subwf PRODL,F ; PRODL - WREG --> PRODL |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
682 movff win_width+1,WREG |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
683 subwfb PRODH,F |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
684 infsnz PRODL ; PROD+1 --> PROD |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
685 incf PRODH |
151 | 686 |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
687 Index_out 0x52 ; Window Vertical End Address |
151 | 688 rcall TFT_DataWrite_PROD |
689 | |
690 DISP_box_noflip_H: | |
691 btfss flip_screen ; 180° rotation ? | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
692 bra TFT_box_noflip_V ; No. |
151 | 693 |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
694 ;---- Flipped vertical window ----------------------------------------- |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
695 movff win_top,PRODH ; top --> PRODH (first byte) |
151 | 696 movff win_height,WREG |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
697 addwf PRODH,W |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
698 decf WREG |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
699 movwf PRODL ; top+height-1 --> PRODL (second byte) |
151 | 700 |
701 Index_out 0x50 ; Window Horizontal Start Address | |
702 movf PRODH,W | |
703 rcall TFT_DataWrite ; Lower (and tick) | |
704 | |
705 Index_out 0x51 ; Window Horizontal End Address | |
706 movf PRODL,W | |
707 rcall TFT_DataWrite ; Lower (and tick) | |
708 | |
709 Index_out 0x20 ; Frame Memory Horizontal Address | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
710 movf PRODH,W |
151 | 711 rcall TFT_DataWrite ; Lower (and tick) |
712 return | |
713 | |
714 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
715 TFT_box_noflip_V: |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
151
diff
changeset
|
716 ;---- Normal vertical window ---------------------------------------- |
0 | 717 movff win_top,PRODL |
718 movff win_height,WREG | |
719 addwf PRODL,W | |
720 sublw .240 ; 240 - top - height | |
721 movwf PRODH ; First byte | |
722 | |
723 movf PRODL,W | |
151 | 724 sublw .239 ; 239-top |
0 | 725 movwf PRODL ; --> second byte. |
726 | |
727 Index_out 0x50 ; Window Horizontal Start Address | |
728 movf PRODH,W | |
729 rcall TFT_DataWrite ; Lower (and tick) | |
730 | |
731 Index_out 0x51 ; Window Horizontal End Address | |
732 movf PRODL,W | |
733 rcall TFT_DataWrite ; Lower (and tick) | |
734 | |
735 Index_out 0x20 ; Frame Memory Horizontal Address | |
736 movf PRODL,W | |
737 rcall TFT_DataWrite ; Lower (and tick) | |
738 return | |
739 | |
740 | |
741 ;============================================================================= | |
742 ; TFT_frame : draw a frame around current box with current color. | |
743 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
744 ; Outputs: (none) | |
745 ; Trashed: WREG, PROD, aa_start:2, aa_end:2 | |
746 global TFT_frame | |
747 TFT_frame: | |
748 movff win_top,save_top ; Backup everything. | |
749 movff win_height,save_height | |
750 movff win_leftx2,save_left | |
751 movff win_width,save_width | |
752 | |
753 ;---- TOP line ----------------------------------------------------------- | |
754 movlw 1 ; row ~ height=1 | |
755 movff WREG,win_height | |
756 rcall TFT_box | |
757 | |
758 ;---- BOTTOM line -------------------------------------------------------- | |
759 movff save_top,PRODL ; Get back top, | |
760 movff save_height,WREG ; and height | |
761 addwf PRODL,W ; top+height | |
762 decf WREG ; top+height-1 | |
763 movff WREG,win_top ; top+height-1 --> top | |
764 rcall TFT_box | |
765 | |
766 ;---- LEFT column -------------------------------------------------------- | |
767 movff save_top,win_top ; Restore top/height. | |
768 movff save_height,win_height | |
769 movlw 1 ; column ~ width=1 | |
770 movff WREG,win_width | |
771 rcall TFT_box | |
772 | |
773 ;---- RIGHT column ------------------------------------------------------- | |
774 movff save_left,WREG | |
775 movff save_width,PRODL | |
776 addwf PRODL,W | |
777 decf WREG | |
778 movff WREG,win_leftx2 | |
779 rcall TFT_box | |
780 | |
781 ;---- Restore everything ------------------------------------------------- | |
782 movff save_left,win_leftx2 | |
783 movff save_width,win_width | |
784 return | |
785 | |
786 ;============================================================================= | |
787 ; TFT_box : fills current box with current color. | |
788 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
789 ; Outputs: (none) | |
790 ; Trashed: WREG, PROD | |
791 global TFT_box | |
792 | |
793 TFT_box: | |
794 ;---- Define Window ------------------------------------------------------ | |
795 movf win_width,W | |
796 bcf STATUS,C | |
797 rlcf WREG | |
798 movwf win_width+0 | |
799 movlw 0 | |
800 rlcf WREG | |
801 movwf win_width+1 | |
83 | 802 rcall TFT_box_write ; Setup box |
0 | 803 |
83 | 804 global TFT_box_16bit_win_left |
805 TFT_box_16bit_win_left: | |
0 | 806 rrcf win_width+1,W ; width /= 2 |
807 rrcf win_width+0,W | |
808 movwf win_width | |
809 | |
810 ;---- Fill Window -------------------------------------------------------- | |
811 Index_out 0x22 ; Frame Memory Data Write start | |
812 | |
813 clrf PRODH ; Column counter. | |
814 RS_H ; Data | |
815 | |
816 TFT_box2: ; Loop height times | |
817 movff win_height,PRODL | |
818 | |
819 TFT_box3: ; loop width times | |
820 movff win_color1,PORTA ; Upper | |
821 movff win_color2,PORTH ; Lower | |
822 WR_L | |
823 WR_H ; Tick | |
824 | |
825 movff win_color1,PORTA ; Upper | |
826 movff win_color2,PORTH ; Lower | |
827 WR_L | |
828 WR_H ; Tick | |
829 | |
830 decfsz PRODL,F ; row loop finished ? | |
831 bra TFT_box3 ; No: continue. | |
832 | |
833 incf PRODH,F ; column count ++ | |
834 | |
835 movff win_bargraph,WREG ; current column == bargraph ? | |
836 cpfseq PRODH | |
837 bra TFT_box4 ; No: just loop. | |
838 | |
839 clrf WREG ; Yes: switch to black | |
840 movff WREG,win_color1 | |
841 movff WREG,win_color2 | |
842 TFT_box4: | |
843 | |
844 movff win_width+0,WREG ; compare ? | |
845 xorwf PRODH,W | |
846 bnz TFT_box2 ; Loop not finished. | |
847 | |
848 movlw 0x00 ; NOP, to stop window mode | |
849 rcall TFT_CmdWrite | |
850 | |
851 setf WREG ; Reset bargraph mode... | |
852 movff WREG,win_bargraph | |
853 | |
854 return | |
855 | |
856 ;============================================================================= | |
857 ;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGGGGGBBBBB' | |
858 global TFT_set_color | |
859 | |
860 TFT_set_color: | |
861 movwf tft_temp1 ; Get 8Bit RGB b'RRRGGGBB' | |
862 movwf tft_temp2 ; Copy | |
863 | |
864 ; Mask Bit 7,6,5,4,3,2 | |
865 movlw b'00000011' | |
866 andwf tft_temp2,F | |
867 | |
868 movlw b'00000000' | |
869 dcfsnz tft_temp2,F | |
870 movlw b'01010000' | |
871 dcfsnz tft_temp2,F | |
872 movlw b'10100000' | |
873 dcfsnz tft_temp2,F | |
874 movlw b'11111000' | |
875 movwf tft_temp3 ; Blue done. | |
876 | |
877 movff tft_temp1, tft_temp2 ; Copy | |
878 ; Mask Bit 7,6,5,1,0 | |
879 movlw b'00011100' | |
880 andwf tft_temp2,F | |
881 rrncf tft_temp2,F | |
882 rrncf tft_temp2,F | |
883 | |
884 movlw b'00000000' | |
885 dcfsnz tft_temp2,F | |
886 movlw b'00000100' | |
887 dcfsnz tft_temp2,F | |
888 movlw b'00001000' | |
889 dcfsnz tft_temp2,F | |
890 movlw b'00001100' | |
891 dcfsnz tft_temp2,F | |
892 movlw b'00010000' | |
893 dcfsnz tft_temp2,F | |
894 movlw b'00010100' | |
895 dcfsnz tft_temp2,F | |
896 movlw b'00100000' | |
897 dcfsnz tft_temp2,F | |
898 movlw b'00111111' | |
899 movwf tft_temp4 | |
900 | |
901 rrcf tft_temp4,F | |
902 rrcf tft_temp3,F | |
903 | |
904 rrcf tft_temp4,F | |
905 rrcf tft_temp3,F | |
906 | |
907 rrcf tft_temp4,F | |
908 rrcf tft_temp3,F ; tft_temp3 (b'GGGBBBBB') done. | |
909 | |
910 movff tft_temp1, tft_temp2 ; Copy | |
911 clrf tft_temp1 | |
912 | |
913 rrcf tft_temp4,F | |
914 rrcf tft_temp1,F | |
915 | |
916 rrcf tft_temp4,F | |
917 rrcf tft_temp1,F | |
918 | |
919 rrcf tft_temp4,F | |
920 rrcf tft_temp1,F ; Green done. | |
921 | |
922 ; Mask Bit 4,3,2,1,0 | |
923 movlw b'11100000' | |
924 andwf tft_temp2,F | |
925 | |
926 rrncf tft_temp2,F | |
927 rrncf tft_temp2,F | |
928 rrncf tft_temp2,F | |
929 rrncf tft_temp2,F | |
930 rrncf tft_temp2,F | |
931 | |
932 movlw b'00000000' | |
933 dcfsnz tft_temp2,F | |
934 movlw b'00000100' | |
935 dcfsnz tft_temp2,F | |
936 movlw b'00001000' | |
937 dcfsnz tft_temp2,F | |
938 movlw b'00001100' | |
939 dcfsnz tft_temp2,F | |
940 movlw b'00010000' | |
941 dcfsnz tft_temp2,F | |
942 movlw b'00010100' | |
943 dcfsnz tft_temp2,F | |
944 movlw b'00100000' | |
945 dcfsnz tft_temp2,F | |
946 movlw b'00111111' | |
947 movwf tft_temp4 | |
948 | |
949 rrcf tft_temp4,F | |
950 rrcf tft_temp1,F | |
951 | |
952 rrcf tft_temp4,F | |
953 rrcf tft_temp1,F | |
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 ; Red done. | |
963 | |
964 movff tft_temp1,win_color1 | |
965 movff tft_temp3,win_color2 ; Set Bank0 Color registers... | |
966 return | |
967 | |
968 ;============================================================================= | |
969 ; Dump screen contents to the UART | |
970 | |
971 global TFT_dump_screen | |
972 TFT_dump_screen: | |
973 bsf no_sensor_int | |
974 movlw 'l' | |
975 movwf TXREG ; Send command echo. | |
976 call rs232_wait_tx ; wait for UART | |
977 ;---- Send DISPLAY box command for the full screen window ------------------- | |
978 Index_out 0x50 ; Window Horizontal Start Address | |
979 Parameter_out 0x00, 0x00 ; 0-239 | |
980 Index_out 0x51 ; Window Horizontal End Address | |
981 Parameter_out 0x00, 0xEF ; 0-239 | |
982 Index_out 0x52 ; Window Vertical Start Address | |
983 Parameter_out 0x00, 0x00 ; 0-319 | |
984 Index_out 0x53 ; Window Vertical End Address | |
985 Parameter_out 0x01, 0x3F ; 0-319 | |
986 | |
987 clrf ds_column | |
988 rcall dump_screen_pixel_reset | |
989 dump_screen_1: | |
990 btg LEDr ; LED activity toggle | |
991 ; Dump even column | |
992 movlw .240 ; 240 lines, once. | |
993 movwf ds_line | |
994 dump_screen_2: | |
995 Index_out 0x20 ; Frame Memory Horizontal Address | |
996 movff ds_line,WREG ; d'0' ... d'239' | |
997 mullw 1 ; Copy row to PRODH:L | |
998 rcall TFT_DataWrite_PROD | |
999 | |
1000 movff ds_column,WREG ; Init X position. | |
1001 mullw 2 | |
1002 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
1003 | |
1004 rcall TFT_DataRead_PROD ; read pixel | |
1005 rcall dump_screen_pixel | |
1006 | |
1007 decfsz ds_line,F | |
1008 bra dump_screen_2 | |
1009 rcall dump_screen_pixel_flush | |
1010 | |
1011 ; Dump odd column | |
1012 movlw .240 ; 240 lines, twice. | |
1013 movwf ds_line | |
1014 dump_screen_3: | |
1015 Index_out 0x20 ; Frame Memory Horizontal Address | |
1016 movff ds_line,WREG ; d'0' ... d'239' | |
1017 mullw 1 ; Copy row to PRODH:L | |
1018 rcall TFT_DataWrite_PROD | |
1019 | |
1020 movff ds_column,WREG ; Init X position. | |
1021 mullw 2 | |
1022 movlw .1 | |
1023 addwf PRODL,F | |
1024 movlw 0 | |
1025 addwfc PRODH,F ; +1 | |
1026 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319) | |
1027 | |
1028 rcall TFT_DataRead_PROD ; read pixel | |
1029 rcall dump_screen_pixel | |
1030 | |
1031 decfsz ds_line,F | |
1032 bra dump_screen_3 | |
1033 rcall dump_screen_pixel_flush | |
1034 | |
1035 incf ds_column,F | |
1036 movlw .160 | |
1037 cpfseq ds_column | |
1038 bra dump_screen_1 | |
1039 | |
1040 bcf no_sensor_int | |
1041 clrf RCREG1 ; Clear receive buffer | |
1042 bcf RCSTA1,CREN ; Clear receiver status | |
1043 bsf RCSTA1,CREN | |
1044 bsf enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
1045 return | |
1046 | |
1047 | |
1048 ;============================================================================= | |
1049 ; Pixel compression | |
1050 ; | |
1051 ; Input: PRODH:L = pixel. | |
1052 ; Output: Compressed stream on output. | |
1053 ; Compressed format: | |
1054 ; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128). | |
1055 ; 11cccccc : WHITE pixel, repeated cccccc+1 times (1..64). | |
1056 ; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1..64). | |
1057 ; | |
1058 dump_screen_pixel: | |
1059 movf PRODH,W ; Compare pixel-high | |
1060 xorwf ds_pixel+1,W | |
1061 bnz dump_screen_pixel_1 ; Different -> dump. | |
1062 | |
1063 movf PRODL,W ; Compare pixel-low | |
1064 xorwf ds_pixel+0,W | |
1065 bnz dump_screen_pixel_1 ; Different -> dump. | |
1066 | |
1067 incf ds_count,F ; Same color: just increment. | |
1068 return | |
1069 | |
1070 dump_screen_pixel_1: ; Send (pixel,count) tuple | |
1071 movf ds_count,W ; Is count zero ? | |
1072 bz dump_screen_pixel_2 ; Yes: skip sending. | |
1073 | |
1074 movf ds_pixel+1,W ; This is a BLACK pixel ? | |
1075 iorwf ds_pixel+0,W | |
1076 bz dump_screen_pix_black ; YES. | |
1077 | |
1078 movf ds_pixel+1,W ; This is a white pixel ? | |
1079 andwf ds_pixel+0,W | |
1080 incf WREG | |
1081 bz dump_screen_pix_white ; YES. | |
1082 | |
1083 ; No: write the pixel itself... | |
1084 movlw .64 ; Max color pixel on a single byte. | |
1085 cpfsgt ds_count ; Skip if count > 64 | |
1086 movf ds_count,W ; W <- min(64,count) | |
1087 subwf ds_count,F ; ds_count <- ds_count-W | |
1088 decf WREG ; Save as 0..63 | |
1089 iorlw b'10000000' ; MARK as a color pixel. | |
1090 | |
1091 movwf TXREG | |
1092 call rs232_wait_tx ; wait for UART | |
1093 movff ds_pixel+1,TXREG | |
1094 call rs232_wait_tx ; wait for UART | |
1095 movff ds_pixel+0,TXREG | |
1096 call rs232_wait_tx ; wait for UART | |
1097 bra dump_screen_pixel_1 | |
1098 | |
1099 dump_screen_pixel_2: | |
1100 movff PRODH,ds_pixel+1 ; Save new pixel color | |
1101 movff PRODL,ds_pixel+0 | |
1102 movlw 1 | |
1103 movwf ds_count ; And set count=1. | |
1104 return | |
1105 | |
1106 dump_screen_pix_black: | |
1107 movlw .128 ; Max black pixel on a single byte. | |
1108 cpfsgt ds_count ; Skip if count > 128 | |
1109 movf ds_count,W ; W <- min(128,count) | |
1110 subwf ds_count,F ; ds_count <- ds_count-W | |
1111 decf WREG ; Save as 0..127 | |
1112 dump_screen_pix_3: | |
1113 movwf TXREG | |
1114 call rs232_wait_tx | |
1115 bra dump_screen_pixel_1 ; More to dump ? | |
1116 | |
1117 dump_screen_pix_white: | |
1118 movlw .64 ; Max white pixel on a single byte. | |
1119 cpfsgt ds_count ; Skip if count > 64 | |
1120 movf ds_count,W ; W <- min(64,count) | |
1121 subwf ds_count,F ; ds_count <- ds_count-W | |
1122 decf WREG ; Save as 0..63 | |
1123 iorlw b'11000000' ; MARK as a compressed white. | |
1124 bra dump_screen_pix_3 | |
1125 | |
1126 dump_screen_pixel_flush: | |
1127 clrf PRODH | |
1128 clrf PRODL | |
1129 rcall dump_screen_pixel_1 ; Send it | |
1130 dump_screen_pixel_reset: | |
1131 clrf ds_count ; But clear count. | |
1132 return | |
1133 | |
1134 end |