Mercurial > public > hwos_code
comparison src/tft.inc @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
author | heinrichsweikamp |
---|---|
date | Thu, 22 Nov 2018 19:47:26 +0100 |
parents | b7eb98dbd800 |
children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
603:00b24fb4324d | 604:ca4556fb60b9 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File tft.inc | 3 ; File tft.inc V2.99c |
4 ; | 4 ; |
5 ; Declaring interfaces to the TFT screen and its Oxxx controler | 5 ; Declaring interfaces to the TFT screen and its Oxxx controler |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
12 ;============================================================================= | 12 ;============================================================================= |
13 ; TFT public subroutines | 13 ; TFT public subroutines |
14 ;============================================================================= | 14 ;============================================================================= |
15 | 15 |
16 ; Writes two half-pixels at position (win_top,win_leftx2) | 16 ; Writes two half-pixels at position (win_top,win_leftx2) |
17 ; Inputs: win_leftx2, win_top, win_color:2 | 17 ; Inputs : win_leftx2, win_top, win_color:2 |
18 ; Outputs: (none) | |
18 ; Trashed: WREG, PROD | 19 ; Trashed: WREG, PROD |
19 extern pixel_write | 20 extern pixel_write |
20 | 21 |
21 ;----------------------------------------------------------------------------- | 22 ;----------------------------------------------------------------------------- |
22 ; Writes one half-pixel at position (win_top,win_leftx2). | 23 ; Writes one half-pixel at position (win_top,win_leftx2) |
23 ; Inputs: win_leftx2, win_top, win_color:2 | 24 ; Inputs : win_leftx2, win_top, win_color:2 |
25 ; Outputs: (none) | |
24 ; Trashed: WREG, PROD | 26 ; Trashed: WREG, PROD |
25 extern half_pixel_write | 27 extern half_pixel_write |
26 | 28 |
27 ;----------------------------------------------------------------------------- | 29 ;----------------------------------------------------------------------------- |
28 ; TFT_frame : draw a frame around current box with current color. | 30 ; Draws a frame around current box with current color |
29 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | 31 ; Inputs : win_top, win_leftx2, win_height, win_width, win_color1, win_color2 |
30 ; Outputs: (none) | 32 ; Outputs: (none) |
31 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1 | 33 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1 |
32 extern TFT_frame | 34 extern TFT_frame |
33 | 35 |
34 ;----------------------------------------------------------------------------- | 36 ;----------------------------------------------------------------------------- |
35 extern TFT_DisplayOff ; Power-off everything (need a boot next) | 37 extern TFT_DisplayOff ; Power-off everything (need a boot next) |
36 extern TFT_boot ; Initialize screen hardware | 38 extern TFT_boot ; Initialize screen hardware |
37 extern TFT_Display_FadeIn ; Smooth lighting | 39 extern TFT_Display_FadeIn ; Smooth lighting |
38 extern TFT_Display_FadeOut ; Smooth darkening | 40 extern TFT_Display_FadeOut ; Smooth darkening |
39 extern TFT_ClearScreen | 41 extern TFT_ClearScreen |
40 extern TFT_box_write | 42 extern TFT_box_write |
41 extern TFT_box_write_16bit_win_left; With column in PRODL:PRODH | 43 extern TFT_box_write_16bit_win_left ; With column in PRODL:PRODH |
42 extern TFT_box | 44 extern TFT_box |
43 extern TFT_box_16bit_win_left ; With column in PRODL:PRODH | 45 extern TFT_box_16bit_win_left ; With column in PRODL:PRODH |
44 extern TFT_DataWrite_PROD | 46 extern TFT_DataWrite_PROD |
45 extern TFT_set_color | 47 extern TFT_set_color |
46 ; extern init_pixel_write | 48 ; extern init_pixel_write |
47 extern pixel_write | 49 extern pixel_write |
48 extern pixel_write_col320 | 50 extern pixel_write_col320 |
49 extern half_vertical_line | 51 extern half_vertical_line |
50 extern half_horizontal_line | 52 extern half_horizontal_line |
51 extern TFT_dump_screen | 53 |
52 | 54 IFDEF _screendump |
53 ;============================================================================= | 55 extern TFT_dump_screen |
54 ; Low level macros (for aa_wordprocessor and color_processor). | 56 extern TFT_dump_screen_check |
55 ; | 57 ENDIF |
56 extern TFT_CmdWrite | 58 |
57 Index_out macro low_b | 59 ;============================================================================= |
58 movlw low_b | 60 ; Low level macros (for aa_wordprocessor and color_processor) |
59 call TFT_CmdWrite | 61 ; |
60 endm | 62 extern TFT_CmdWrite |
61 | 63 Index_out macro low_b |
62 ;============================================================================= | 64 movlw low_b |
63 ; A shortcut for TFT_box and TFT_frame call sequences. | 65 call TFT_CmdWrite |
64 ; | 66 endm |
65 extern box_frame_std, box_frame_common, box_frame_color, box_frame_color16 | 67 |
66 extern box_std_block, box_black_block, box_color_block | 68 ;============================================================================= |
67 | 69 ; A shortcut for TFT_box and TFT_frame call sequences |
68 ; Erase a given screen area. | 70 ; |
69 WIN_BOX_BLACK macro top, bottom, left, right | 71 extern box_frame_std, box_frame_common, box_frame_color, box_frame_color16 |
70 call box_black_block | 72 extern box_std_block, box_black_block, box_color_block |
71 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 73 |
72 endm | 74 ; Erase a given screen area |
73 | 75 WIN_BOX_BLACK macro top, bottom, left, right |
74 ; Fill a given screen area with standard color (White). | 76 call box_black_block |
75 WIN_BOX_STD macro top, bottom, left, right | 77 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
76 call box_std_block | 78 endm |
77 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 79 |
78 endm | 80 ; Fill a given screen area with standard color (white) |
79 | 81 WIN_BOX_STD macro top, bottom, left, right |
80 ; Fill a given screen area with color from WREG (8bits rrrgggbb) | 82 call box_std_block |
81 WIN_BOX_COLOR macro top, bottom, left, right | 83 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
82 call box_color_block | 84 endm |
83 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 85 |
84 endm | 86 ; Fill a given screen area with color from WREG (8 bits rrrgggbb) |
85 | 87 WIN_BOX_COLOR macro top, bottom, left, right |
86 ; Draw a frame in standard color (White). | 88 call box_color_block |
87 WIN_FRAME_STD macro top, bottom, left, right | 89 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
88 call box_frame_std | 90 endm |
89 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 91 |
90 endm | 92 ; Draw a frame in standard color (white) |
91 | 93 WIN_FRAME_STD macro top, bottom, left, right |
92 ; Draw a frame with color from WREG (8bits rrrgggbb) | 94 call box_frame_std |
93 WIN_FRAME_COLOR macro top, bottom, left, right | 95 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
94 call box_frame_color | 96 endm |
95 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 97 |
96 endm | 98 ; Draw a frame with color from WREG (8 bits rrrgggbb) |
97 | 99 WIN_FRAME_COLOR macro top, bottom, left, right |
98 ; Draw a frame with color from win_color (16bits in TFT format) | 100 call box_frame_color |
99 WIN_FRAME_COLOR16 macro top, bottom, left, right | 101 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
100 call box_frame_color16 | 102 endm |
101 db top, (bottom)-(top)+1, left, (right)-(left)+1 | 103 |
102 endm | 104 ; Draw a frame with color from win_color (16 bits in TFT format) |
103 | 105 WIN_FRAME_COLOR16 macro top, bottom, left, right |
104 WIN_FONT macro win_font_input | 106 call box_frame_color16 |
105 movlw win_font_input | 107 db top, (bottom)-(top)+1, left, (right)-(left)+1 |
106 movff WREG,win_font | 108 endm |
107 endm | 109 |
108 | 110 WIN_FONT macro win_font_input |
109 WIN_TOP macro win_top_input | 111 movlw win_font_input |
110 movlw win_top_input | 112 movff WREG,win_font |
111 movff WREG,win_top | 113 endm |
112 endm | 114 |
113 | 115 WIN_TOP macro win_top_input |
114 WIN_HEIGHT macro h | 116 movlw win_top_input |
115 movlw h | 117 movff WREG,win_top |
116 movff WREG,win_height | 118 endm |
117 endm | 119 |
118 | 120 WIN_HEIGHT macro h |
119 WIN_LEFT macro win_left_input | 121 movlw h |
120 movlw win_left_input | 122 movff WREG,win_height |
121 movff WREG,win_leftx2 | 123 endm |
122 endm | 124 |
123 | 125 WIN_LEFT macro win_left_input |
124 WIN_WIDTH macro w | 126 movlw win_left_input |
125 movlw w | 127 movff WREG,win_leftx2 |
126 movff WREG,win_width | 128 endm |
127 endm | 129 |
128 | 130 WIN_WIDTH macro w |
129 WIN_COLOR macro win_color_input | 131 movlw w |
130 movlw win_color_input | 132 movff WREG,win_width |
131 call TFT_set_color | 133 endm |
132 endm | 134 |
133 | 135 WIN_COLOR macro win_color_input |
134 ;============================================================================= | 136 movlw win_color_input |
135 ; TFT_write_flash_image | 137 call TFT_set_color |
136 ; | 138 endm |
137 ; Inputs: cx, cy : Image center (in 0..160 x 0..240 range) | 139 |
138 ; image : flash image header's address | 140 ;;============================================================================= |
139 ; Outputs: win_top, win_left, win_height, win_width | 141 ;; TFT_write_flash_image |
140 ; image copyed on screen. | 142 ;; |
141 ; Trashed: PROD, hi, lo | 143 ;; Inputs : cx, cy : Image center (in 0..160 x 0..240 range) |
142 ; | 144 ;; image : flash image header's address |
143 ; extern TFT_write_flash_image | 145 ;; Outputs: win_top, win_left, win_height, win_width |
144 ; extern TFT_write_flash_image_addr | 146 ;; image copyed on screen. |
145 TFT_WRITE_FLASH_IMAGE macro cx, cy, image | 147 ;; Trashed: PROD, hi, lo |
146 If LOW(image) != 0 | 148 ;; |
147 Error "Image "image" mis-aligned" | 149 ;; extern TFT_write_flash_image |
148 Endif | 150 ;; extern TFT_write_flash_image_addr |
149 If (UPPER(image) & 0xF0) != 0x30 | 151 ;TFT_WRITE_FLASH_IMAGE macro cx, cy, image |
150 Error "Image "image" not in image flash memory" | 152 ; If LOW(image) != 0 |
151 Endif | 153 ; Error "Image "image" mis-aligned" |
152 If (cx < 0) || (cx > 160) | 154 ; Endif |
153 Error "Image center's X "cx" not in 0..160 range". | 155 ; If (UPPER(image) & 0xF0) != 0x30 |
154 Endif | 156 ; Error "Image "image" not in image flash memory" |
155 If (cy < 0) || (cy > 240) | 157 ; Endif |
156 Error "Image center's Y "cy" not in 0..240 range". | 158 ; If (cx < 0) || (cx > 160) |
157 Endif | 159 ; Error "Image center's X "cx" not in 0..160 range". |
158 ; Once we know image is aligned, we can use the compact (4bytes) | 160 ; Endif |
159 ; 12bit registers to pass the address: | 161 ; If (cy < 0) || (cy > 240) |
160 lfsr FSR2, ((image)>>8) & 0xFFF | 162 ; Error "Image center's Y "cy" not in 0..240 range". |
161 WIN_LEFT cx | 163 ; Endif |
162 WIN_TOP cy | 164 ; ; Once we know image is aligned, we can use the compact (4 bytes) |
163 call TFT_write_flash_image | 165 ; ; 12 bit registers to pass the address: |
164 endm | 166 ; lfsr FSR2, ((image)>>8) & 0xFFF |
167 ; WIN_LEFT cx | |
168 ; WIN_TOP cy | |
169 ; call TFT_write_flash_image | |
170 ; endm | |
165 | 171 |
166 ;============================================================================= | 172 ;============================================================================= |
167 ; TFT_write_prom_image | 173 ; TFT_write_prom_image |
168 ; | 174 |
169 TFT_WRITE_PROM_IMAGE macro icon | 175 ; image referenced by a label |
170 extern icon, color_image | 176 TFT_WRITE_PROM_IMAGE_BY_LABEL macro image_label |
171 movlw LOW(icon) | 177 extern image_label |
172 movwf TBLPTRL | 178 movlw LOW (image_label) |
173 movlw HIGH(icon) | 179 movwf TBLPTRL |
174 movwf TBLPTRH | 180 movlw HIGH (image_label) |
175 movlw UPPER(icon) | 181 movwf TBLPTRH |
176 movwf TBLPTRU | 182 movlw UPPER (image_label) |
177 call color_image | 183 movwf TBLPTRU |
178 endm | 184 extern color_image |
179 | 185 call color_image |
180 ;============================================================================= | 186 endm |
181 ; Macro to provides our own interface code. | 187 |
182 ; | 188 ; image referenced by an address |
183 PIXEL_WRITE macro colRegister, rowRegister | 189 TFT_WRITE_PROM_IMAGE_BY_ADDR macro image_address |
184 movff colRegister,win_leftx2 | 190 movlw LOW (image_address) |
185 movff rowRegister,win_top | 191 movwf TBLPTRL |
186 call pixel_write | 192 movlw HIGH (image_address & 0xFFFF) |
187 endm | 193 movwf TBLPTRH |
188 | 194 movlw UPPER (image_address) |
189 ;INIT_PIXEL_WRITE macro colRegister | 195 movwf TBLPTRU |
190 ; movff colRegister,win_leftx2 | 196 extern color_image |
191 ; call init_pixel_write | 197 call color_image |
192 ; endm | 198 endm |
193 | 199 |
194 HALF_PIXEL_WRITE macro rowRegister | 200 ; custom colors referenced by label |
195 movff rowRegister,win_top | 201 TFT_WRITE_PROM_IMAGE_CUST_COLOR macro colors_label |
196 call half_pixel_write | 202 movlw LOW (colors_label) |
197 endm | 203 movwf TBLPTRL |
198 | 204 movlw HIGH (colors_label) |
205 movwf TBLPTRH | |
206 movlw UPPER (colors_label) | |
207 movwf TBLPTRU | |
208 extern get_colors | |
209 call get_colors | |
210 bsf use_custom_colors ; will suppress read-in of the colors that come with the image | |
211 endm | |
212 | |
213 ;============================================================================= | |
214 ; Macro to provide our own interface code | |
215 ; | |
216 PIXEL_WRITE macro colRegister, rowRegister | |
217 movff colRegister,win_leftx2 | |
218 movff rowRegister,win_top | |
219 call pixel_write | |
220 endm | |
221 | |
222 ;INIT_PIXEL_WRITE macro colRegister | |
223 ; movff colRegister,win_leftx2 | |
224 ; call init_pixel_write | |
225 ; endm | |
226 | |
227 HALF_PIXEL_WRITE macro rowRegister | |
228 movff rowRegister,win_top | |
229 call half_pixel_write | |
230 endm |