annotate src/tft.inc @ 1:e4e662746c02

init2
author heinrichsweikamp
date Wed, 24 Apr 2013 19:39:39 +0200
parents 11d4fc797f74
children ec4d8503ec45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File tft.inc
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Declaring interfaces to the TFT screen and its Oxxx controler
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code.
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
13 ; TFT public subroutines
heinrichsweikamp
parents:
diff changeset
14 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
15
heinrichsweikamp
parents:
diff changeset
16 ; Writes two half-pixels at position (win_top,win_leftx2)
heinrichsweikamp
parents:
diff changeset
17 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
18 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
19 extern pixel_write
heinrichsweikamp
parents:
diff changeset
20
heinrichsweikamp
parents:
diff changeset
21 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
22 ; Writes one half-pixel at position (win_top,win_leftx2).
heinrichsweikamp
parents:
diff changeset
23 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
24 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
25 extern half_pixel_write
heinrichsweikamp
parents:
diff changeset
26
heinrichsweikamp
parents:
diff changeset
27 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
28 ; TFT_frame : draw a frame around current box with current color.
heinrichsweikamp
parents:
diff changeset
29 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
30 ; Outputs: (none)
heinrichsweikamp
parents:
diff changeset
31 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1
heinrichsweikamp
parents:
diff changeset
32 extern TFT_frame
heinrichsweikamp
parents:
diff changeset
33
heinrichsweikamp
parents:
diff changeset
34 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
35 extern TFT_DisplayOff ; Power-off everything (need a boot next)
heinrichsweikamp
parents:
diff changeset
36 extern TFT_boot ; Initialize screen hardware
heinrichsweikamp
parents:
diff changeset
37 extern TFT_Display_FadeIn ; Smooth lighting
heinrichsweikamp
parents:
diff changeset
38 extern TFT_Display_FadeOut ; Smooth darkening
heinrichsweikamp
parents:
diff changeset
39 extern TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
40 extern TFT_box_write
heinrichsweikamp
parents:
diff changeset
41 extern TFT_box
heinrichsweikamp
parents:
diff changeset
42 extern TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
43 extern TFT_set_color
heinrichsweikamp
parents:
diff changeset
44 extern init_pixel_write
heinrichsweikamp
parents:
diff changeset
45 extern pixel_write
heinrichsweikamp
parents:
diff changeset
46 extern pixel_write_col320
heinrichsweikamp
parents:
diff changeset
47 extern half_vertical_line
heinrichsweikamp
parents:
diff changeset
48 extern half_horizontal_line
heinrichsweikamp
parents:
diff changeset
49 extern TFT_dump_screen
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
52 ; Macro to encode standard colors.
heinrichsweikamp
parents:
diff changeset
53 ; TODO: User preferences... Maybe.
heinrichsweikamp
parents:
diff changeset
54 TFT_STD_COLOR macro
heinrichsweikamp
parents:
diff changeset
55 setf WREG ; Default to white
heinrichsweikamp
parents:
diff changeset
56 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
57 endm
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 TFT_MASK_COLOR macro
heinrichsweikamp
parents:
diff changeset
60 movlw color_greenish ; Default to OSTC mask-green
heinrichsweikamp
parents:
diff changeset
61 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
62 endm
heinrichsweikamp
parents:
diff changeset
63
heinrichsweikamp
parents:
diff changeset
64 TFT_ATTENTION_COLOR macro
heinrichsweikamp
parents:
diff changeset
65 movlw color_yellow ; Default to OSTC yelow
heinrichsweikamp
parents:
diff changeset
66 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
67 endm
heinrichsweikamp
parents:
diff changeset
68
heinrichsweikamp
parents:
diff changeset
69 TFT_WARNINGS_COLOR macro
heinrichsweikamp
parents:
diff changeset
70 movlw color_red ; Default to OSTC red
heinrichsweikamp
parents:
diff changeset
71 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
72 endm
heinrichsweikamp
parents:
diff changeset
73
heinrichsweikamp
parents:
diff changeset
74 ;TFT_DISABLED_COLOR macro
heinrichsweikamp
parents:
diff changeset
75 ; movlw color_grey ; Default to OSTC grey (dark blue)
heinrichsweikamp
parents:
diff changeset
76 ; call TFT_set_color
heinrichsweikamp
parents:
diff changeset
77 ; endm
heinrichsweikamp
parents:
diff changeset
78
heinrichsweikamp
parents:
diff changeset
79 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
80 ; Low level macros (for aa_wordprocessor and color_processor).
heinrichsweikamp
parents:
diff changeset
81 ;
heinrichsweikamp
parents:
diff changeset
82 extern TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
83 Index_out macro low_b
heinrichsweikamp
parents:
diff changeset
84 movlw low_b
heinrichsweikamp
parents:
diff changeset
85 call TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
86 endm
heinrichsweikamp
parents:
diff changeset
87
heinrichsweikamp
parents:
diff changeset
88 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
89 ; A shortcut for TFT_box and TFT_frame call sequences.
heinrichsweikamp
parents:
diff changeset
90 ;
heinrichsweikamp
parents:
diff changeset
91 extern box_frame_std, box_frame_common, box_frame_color, box_frame_color16
heinrichsweikamp
parents:
diff changeset
92 extern box_std_block, box_black_block, box_color_block
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 ; Erase a given screen area.
heinrichsweikamp
parents:
diff changeset
95 WIN_BOX_BLACK macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
96 call box_black_block
heinrichsweikamp
parents:
diff changeset
97 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
98 endm
heinrichsweikamp
parents:
diff changeset
99
heinrichsweikamp
parents:
diff changeset
100 ; Fill a given screen area with standard color (White).
heinrichsweikamp
parents:
diff changeset
101 WIN_BOX_STD macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
102 call box_std_block
heinrichsweikamp
parents:
diff changeset
103 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
104 endm
heinrichsweikamp
parents:
diff changeset
105
heinrichsweikamp
parents:
diff changeset
106 ; Fill a given screen area with color from WREG (8bits rrrgggbb)
heinrichsweikamp
parents:
diff changeset
107 WIN_BOX_COLOR macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
108 call box_color_block
heinrichsweikamp
parents:
diff changeset
109 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
110 endm
heinrichsweikamp
parents:
diff changeset
111
heinrichsweikamp
parents:
diff changeset
112 ; Draw a frame in standard color (White).
heinrichsweikamp
parents:
diff changeset
113 WIN_FRAME_STD macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
114 call box_frame_std
heinrichsweikamp
parents:
diff changeset
115 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
116 endm
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 ; Draw a frame with color from WREG (8bits rrrgggbb)
heinrichsweikamp
parents:
diff changeset
119 WIN_FRAME_COLOR macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
120 call box_frame_color
heinrichsweikamp
parents:
diff changeset
121 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
122 endm
heinrichsweikamp
parents:
diff changeset
123
heinrichsweikamp
parents:
diff changeset
124 ; Draw a frame with color from win_color (16bits in TFT format)
heinrichsweikamp
parents:
diff changeset
125 WIN_FRAME_COLOR16 macro top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
126 call box_frame_color16
heinrichsweikamp
parents:
diff changeset
127 db top, (bottom)-(top)+1, left, (right)-(left)+1
heinrichsweikamp
parents:
diff changeset
128 endm
heinrichsweikamp
parents:
diff changeset
129
heinrichsweikamp
parents:
diff changeset
130 WIN_FONT macro win_font_input
heinrichsweikamp
parents:
diff changeset
131 movlw win_font_input
heinrichsweikamp
parents:
diff changeset
132 movff WREG,win_font
heinrichsweikamp
parents:
diff changeset
133 endm
heinrichsweikamp
parents:
diff changeset
134
heinrichsweikamp
parents:
diff changeset
135 WIN_TOP macro win_top_input
heinrichsweikamp
parents:
diff changeset
136 movlw win_top_input
heinrichsweikamp
parents:
diff changeset
137 movff WREG,win_top
heinrichsweikamp
parents:
diff changeset
138 endm
heinrichsweikamp
parents:
diff changeset
139
heinrichsweikamp
parents:
diff changeset
140 WIN_HEIGHT macro h
heinrichsweikamp
parents:
diff changeset
141 movlw h
heinrichsweikamp
parents:
diff changeset
142 movff WREG,win_height
heinrichsweikamp
parents:
diff changeset
143 endm
heinrichsweikamp
parents:
diff changeset
144
heinrichsweikamp
parents:
diff changeset
145 WIN_LEFT macro win_left_input
heinrichsweikamp
parents:
diff changeset
146 movlw win_left_input
heinrichsweikamp
parents:
diff changeset
147 movff WREG,win_leftx2
heinrichsweikamp
parents:
diff changeset
148 endm
heinrichsweikamp
parents:
diff changeset
149
heinrichsweikamp
parents:
diff changeset
150 WIN_WIDTH macro w
heinrichsweikamp
parents:
diff changeset
151 movlw w
heinrichsweikamp
parents:
diff changeset
152 movff WREG,win_width
heinrichsweikamp
parents:
diff changeset
153 endm
heinrichsweikamp
parents:
diff changeset
154
heinrichsweikamp
parents:
diff changeset
155 WIN_INVERT macro win_invert_input
heinrichsweikamp
parents:
diff changeset
156 movlw win_invert_input
heinrichsweikamp
parents:
diff changeset
157 movff WREG,win_invert
heinrichsweikamp
parents:
diff changeset
158 endm
heinrichsweikamp
parents:
diff changeset
159
heinrichsweikamp
parents:
diff changeset
160 WIN_COLOR macro win_color_input
heinrichsweikamp
parents:
diff changeset
161 movlw win_color_input
heinrichsweikamp
parents:
diff changeset
162 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
163 endm
heinrichsweikamp
parents:
diff changeset
164
heinrichsweikamp
parents:
diff changeset
165 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
166 ; TFT_write_flash_image
heinrichsweikamp
parents:
diff changeset
167 ;
heinrichsweikamp
parents:
diff changeset
168 ; Inputs: cx, cy : Image center (in 0..160 x 0..240 range)
heinrichsweikamp
parents:
diff changeset
169 ; image : flash image header's address
heinrichsweikamp
parents:
diff changeset
170 ; Outputs: win_top, win_left, win_height, win_width
heinrichsweikamp
parents:
diff changeset
171 ; image copyed on screen.
heinrichsweikamp
parents:
diff changeset
172 ; Trashed: PROD, hi, lo
heinrichsweikamp
parents:
diff changeset
173 ;
heinrichsweikamp
parents:
diff changeset
174 extern TFT_write_flash_image
heinrichsweikamp
parents:
diff changeset
175 extern TFT_write_flash_image_addr
heinrichsweikamp
parents:
diff changeset
176 TFT_WRITE_FLASH_IMAGE macro cx, cy, image
heinrichsweikamp
parents:
diff changeset
177 If LOW(image) != 0
heinrichsweikamp
parents:
diff changeset
178 Error "Image "image" mis-aligned"
heinrichsweikamp
parents:
diff changeset
179 Endif
heinrichsweikamp
parents:
diff changeset
180 If (UPPER(image) & 0xF0) != 0x30
heinrichsweikamp
parents:
diff changeset
181 Error "Image "image" not in image flash memory"
heinrichsweikamp
parents:
diff changeset
182 Endif
heinrichsweikamp
parents:
diff changeset
183 If (cx < 0) || (cx > 160)
heinrichsweikamp
parents:
diff changeset
184 Error "Image center's X "cx" not in 0..160 range".
heinrichsweikamp
parents:
diff changeset
185 Endif
heinrichsweikamp
parents:
diff changeset
186 If (cy < 0) || (cy > 240)
heinrichsweikamp
parents:
diff changeset
187 Error "Image center's Y "cy" not in 0..240 range".
heinrichsweikamp
parents:
diff changeset
188 Endif
heinrichsweikamp
parents:
diff changeset
189 ; Once we know image is aligned, we can use the compact (4bytes)
heinrichsweikamp
parents:
diff changeset
190 ; 12bit registers to pass the address:
heinrichsweikamp
parents:
diff changeset
191 lfsr FSR2, ((image)>>8) & 0xFFF
heinrichsweikamp
parents:
diff changeset
192 WIN_LEFT cx
heinrichsweikamp
parents:
diff changeset
193 WIN_TOP cy
heinrichsweikamp
parents:
diff changeset
194 call TFT_write_flash_image
heinrichsweikamp
parents:
diff changeset
195 endm
heinrichsweikamp
parents:
diff changeset
196
heinrichsweikamp
parents:
diff changeset
197 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
198 ; TFT_write_prom_image
heinrichsweikamp
parents:
diff changeset
199 ;
heinrichsweikamp
parents:
diff changeset
200 TFT_WRITE_PROM_IMAGE macro icon
heinrichsweikamp
parents:
diff changeset
201 extern icon, color_image
heinrichsweikamp
parents:
diff changeset
202 movlw LOW(icon)
heinrichsweikamp
parents:
diff changeset
203 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
204 movlw HIGH(icon)
heinrichsweikamp
parents:
diff changeset
205 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
206 movlw UPPER(icon)
heinrichsweikamp
parents:
diff changeset
207 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
208 call color_image
heinrichsweikamp
parents:
diff changeset
209 endm
heinrichsweikamp
parents:
diff changeset
210
heinrichsweikamp
parents:
diff changeset
211 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
212 ; Macro to provides our own interface code.
heinrichsweikamp
parents:
diff changeset
213 ;
heinrichsweikamp
parents:
diff changeset
214 PIXEL_WRITE macro colRegister, rowRegister
heinrichsweikamp
parents:
diff changeset
215 movff colRegister,win_leftx2
heinrichsweikamp
parents:
diff changeset
216 movff rowRegister,win_top
heinrichsweikamp
parents:
diff changeset
217 call pixel_write
heinrichsweikamp
parents:
diff changeset
218 endm
heinrichsweikamp
parents:
diff changeset
219
heinrichsweikamp
parents:
diff changeset
220 INIT_PIXEL_WROTE macro colRegister
heinrichsweikamp
parents:
diff changeset
221 movff colRegister,win_leftx2
heinrichsweikamp
parents:
diff changeset
222 call init_pixel_write
heinrichsweikamp
parents:
diff changeset
223 endm
heinrichsweikamp
parents:
diff changeset
224
heinrichsweikamp
parents:
diff changeset
225 HALF_PIXEL_WRITE macro rowRegister
heinrichsweikamp
parents:
diff changeset
226 movff rowRegister,win_top
heinrichsweikamp
parents:
diff changeset
227 call half_pixel_write
heinrichsweikamp
parents:
diff changeset
228 endm
heinrichsweikamp
parents:
diff changeset
229