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