annotate src/tft.inc @ 71:4f83366fb943

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