annotate src/tft.inc @ 327:ca5df826437a new_screen_layout

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