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