0
|
1 ;=============================================================================
|
|
2 ;
|
604
|
3 ; File tft.inc V2.99c
|
0
|
4 ;
|
|
5 ; Declaring interfaces to the TFT screen and its Oxxx controler
|
|
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 ;=============================================================================
|
|
13 ; TFT public subroutines
|
|
14 ;=============================================================================
|
|
15
|
|
16 ; Writes two half-pixels at position (win_top,win_leftx2)
|
604
|
17 ; Inputs : win_leftx2, win_top, win_color:2
|
|
18 ; Outputs: (none)
|
0
|
19 ; Trashed: WREG, PROD
|
604
|
20 extern pixel_write
|
0
|
21
|
|
22 ;-----------------------------------------------------------------------------
|
604
|
23 ; Writes one half-pixel at position (win_top,win_leftx2)
|
|
24 ; Inputs : win_leftx2, win_top, win_color:2
|
|
25 ; Outputs: (none)
|
0
|
26 ; Trashed: WREG, PROD
|
604
|
27 extern half_pixel_write
|
0
|
28
|
|
29 ;-----------------------------------------------------------------------------
|
604
|
30 ; Draws a frame around current box with current color
|
|
31 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2
|
0
|
32 ; Outputs: (none)
|
|
33 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1
|
604
|
34 extern TFT_frame
|
0
|
35
|
|
36 ;-----------------------------------------------------------------------------
|
604
|
37 extern TFT_DisplayOff ; Power-off everything (need a boot next)
|
|
38 extern TFT_boot ; Initialize screen hardware
|
|
39 extern TFT_Display_FadeIn ; Smooth lighting
|
|
40 extern TFT_Display_FadeOut ; Smooth darkening
|
|
41 extern TFT_ClearScreen
|
|
42 extern TFT_box_write
|
|
43 extern TFT_box_write_16bit_win_left ; With column in PRODL:PRODH
|
|
44 extern TFT_box
|
|
45 extern TFT_box_16bit_win_left ; With column in PRODL:PRODH
|
|
46 extern TFT_DataWrite_PROD
|
|
47 extern TFT_set_color
|
434
|
48 ; extern init_pixel_write
|
0
|
49 extern pixel_write
|
|
50 extern pixel_write_col320
|
|
51 extern half_vertical_line
|
604
|
52 extern half_horizontal_line
|
|
53
|
|
54 IFDEF _screendump
|
|
55 extern TFT_dump_screen
|
|
56 extern TFT_dump_screen_check
|
|
57 ENDIF
|
0
|
58
|
|
59 ;=============================================================================
|
604
|
60 ; Low level macros (for aa_wordprocessor and color_processor)
|
0
|
61 ;
|
604
|
62 extern TFT_CmdWrite
|
|
63 Index_out macro low_b
|
|
64 movlw low_b
|
|
65 call TFT_CmdWrite
|
|
66 endm
|
0
|
67
|
|
68 ;=============================================================================
|
604
|
69 ; A shortcut for TFT_box and TFT_frame call sequences
|
0
|
70 ;
|
604
|
71 extern box_frame_std, box_frame_common, box_frame_color, box_frame_color16
|
|
72 extern box_std_block, box_black_block, box_color_block
|
0
|
73
|
604
|
74 ; Erase a given screen area
|
|
75 WIN_BOX_BLACK macro top, bottom, left, right
|
|
76 call box_black_block
|
|
77 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
78 endm
|
0
|
79
|
604
|
80 ; Fill a given screen area with standard color (white)
|
|
81 WIN_BOX_STD macro top, bottom, left, right
|
|
82 call box_std_block
|
|
83 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
84 endm
|
0
|
85
|
604
|
86 ; Fill a given screen area with color from WREG (8 bits rrrgggbb)
|
|
87 WIN_BOX_COLOR macro top, bottom, left, right
|
|
88 call box_color_block
|
|
89 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
90 endm
|
0
|
91
|
604
|
92 ; Draw a frame in standard color (white)
|
|
93 WIN_FRAME_STD macro top, bottom, left, right
|
|
94 call box_frame_std
|
|
95 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
96 endm
|
0
|
97
|
604
|
98 ; Draw a frame with color from WREG (8 bits rrrgggbb)
|
|
99 WIN_FRAME_COLOR macro top, bottom, left, right
|
|
100 call box_frame_color
|
|
101 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
102 endm
|
0
|
103
|
604
|
104 ; Draw a frame with color from win_color (16 bits in TFT format)
|
|
105 WIN_FRAME_COLOR16 macro top, bottom, left, right
|
|
106 call box_frame_color16
|
|
107 db top, (bottom)-(top)+1, left, (right)-(left)+1
|
|
108 endm
|
0
|
109
|
604
|
110 WIN_FONT macro win_font_input
|
|
111 movlw win_font_input
|
|
112 movff WREG,win_font
|
|
113 endm
|
|
114
|
|
115 WIN_TOP macro win_top_input
|
|
116 movlw win_top_input
|
|
117 movff WREG,win_top
|
|
118 endm
|
0
|
119
|
604
|
120 WIN_HEIGHT macro h
|
|
121 movlw h
|
|
122 movff WREG,win_height
|
|
123 endm
|
|
124
|
|
125 WIN_LEFT macro win_left_input
|
|
126 movlw win_left_input
|
|
127 movff WREG,win_leftx2
|
|
128 endm
|
0
|
129
|
604
|
130 WIN_WIDTH macro w
|
|
131 movlw w
|
|
132 movff WREG,win_width
|
|
133 endm
|
|
134
|
|
135 WIN_COLOR macro win_color_input
|
|
136 movlw win_color_input
|
|
137 call TFT_set_color
|
|
138 endm
|
0
|
139
|
604
|
140 ;;=============================================================================
|
|
141 ;; TFT_write_flash_image
|
|
142 ;;
|
|
143 ;; Inputs : cx, cy : Image center (in 0..160 x 0..240 range)
|
|
144 ;; image : flash image header's address
|
|
145 ;; Outputs: win_top, win_left, win_height, win_width
|
|
146 ;; image copyed on screen.
|
|
147 ;; Trashed: PROD, hi, lo
|
|
148 ;;
|
|
149 ;; extern TFT_write_flash_image
|
|
150 ;; extern TFT_write_flash_image_addr
|
|
151 ;TFT_WRITE_FLASH_IMAGE macro cx, cy, image
|
|
152 ; If LOW(image) != 0
|
|
153 ; Error "Image "image" mis-aligned"
|
|
154 ; Endif
|
|
155 ; If (UPPER(image) & 0xF0) != 0x30
|
|
156 ; Error "Image "image" not in image flash memory"
|
|
157 ; Endif
|
|
158 ; If (cx < 0) || (cx > 160)
|
|
159 ; Error "Image center's X "cx" not in 0..160 range".
|
|
160 ; Endif
|
|
161 ; If (cy < 0) || (cy > 240)
|
|
162 ; Error "Image center's Y "cy" not in 0..240 range".
|
|
163 ; Endif
|
|
164 ; ; Once we know image is aligned, we can use the compact (4 bytes)
|
|
165 ; ; 12 bit registers to pass the address:
|
|
166 ; lfsr FSR2, ((image)>>8) & 0xFFF
|
|
167 ; WIN_LEFT cx
|
|
168 ; WIN_TOP cy
|
|
169 ; call TFT_write_flash_image
|
|
170 ; endm
|
0
|
171
|
|
172 ;=============================================================================
|
|
173 ; TFT_write_prom_image
|
604
|
174
|
|
175 ; image referenced by a label
|
|
176 TFT_WRITE_PROM_IMAGE_BY_LABEL macro image_label
|
|
177 extern image_label
|
|
178 movlw LOW (image_label)
|
|
179 movwf TBLPTRL
|
|
180 movlw HIGH (image_label)
|
|
181 movwf TBLPTRH
|
|
182 movlw UPPER (image_label)
|
|
183 movwf TBLPTRU
|
|
184 extern color_image
|
|
185 call color_image
|
|
186 endm
|
|
187
|
|
188 ; image referenced by an address
|
|
189 TFT_WRITE_PROM_IMAGE_BY_ADDR macro image_address
|
|
190 movlw LOW (image_address)
|
|
191 movwf TBLPTRL
|
|
192 movlw HIGH (image_address & 0xFFFF)
|
|
193 movwf TBLPTRH
|
|
194 movlw UPPER (image_address)
|
|
195 movwf TBLPTRU
|
|
196 extern color_image
|
|
197 call color_image
|
|
198 endm
|
|
199
|
|
200 ; custom colors referenced by label
|
|
201 TFT_WRITE_PROM_IMAGE_CUST_COLOR macro colors_label
|
|
202 movlw LOW (colors_label)
|
|
203 movwf TBLPTRL
|
|
204 movlw HIGH (colors_label)
|
|
205 movwf TBLPTRH
|
|
206 movlw UPPER (colors_label)
|
|
207 movwf TBLPTRU
|
|
208 extern get_colors
|
|
209 call get_colors
|
|
210 bsf use_custom_colors ; will suppress read-in of the colors that come with the image
|
|
211 endm
|
0
|
212
|
|
213 ;=============================================================================
|
604
|
214 ; Macro to provide our own interface code
|
0
|
215 ;
|
604
|
216 PIXEL_WRITE macro colRegister, rowRegister
|
|
217 movff colRegister,win_leftx2
|
|
218 movff rowRegister,win_top
|
|
219 call pixel_write
|
|
220 endm
|
0
|
221
|
604
|
222 ;INIT_PIXEL_WRITE macro colRegister
|
|
223 ; movff colRegister,win_leftx2
|
|
224 ; call init_pixel_write
|
|
225 ; endm
|
0
|
226
|
604
|
227 HALF_PIXEL_WRITE macro rowRegister
|
|
228 movff rowRegister,win_top
|
|
229 call half_pixel_write
|
|
230 endm
|