Mercurial > public > hwos_code
comparison src/menu_processor.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | b7eb98dbd800 |
children | ca4556fb60b9 |
comparison
equal
deleted
inserted
replaced
581:f5de1ff88814 | 582:b455b31ce022 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File menu_processor.asm REFACTORED VERSION V2.91 | 3 ; File menu_processor.asm REFACTORED VERSION V2.98 |
4 ; | 4 ; |
5 ; Routines to handle all hwOS graphic/text menus. | 5 ; Routines to handle all hwOS graphic/text menus. |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling. | 10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling. |
11 ; But need a font with lower/upper alpha chars... | 11 ; But need a font with lower/upper alpha chars... |
12 | 12 |
13 #include "convert.inc" | 13 #include "convert.inc" |
14 #include "hwos.inc" | 14 #include "hwos.inc" |
15 #include "strings.inc" | 15 #include "strings.inc" |
16 #include "tft.inc" | 16 #include "tft.inc" |
22 #include "tft_outputs.inc" | 22 #include "tft_outputs.inc" |
23 #include "eeprom_rs232.inc" | 23 #include "eeprom_rs232.inc" |
24 #include "adc_lightsensor.inc" | 24 #include "adc_lightsensor.inc" |
25 | 25 |
26 | 26 |
27 ;NOTE: should be identic in .inc and .asm ! | 27 ;NOTE: should be identical in .inc and .asm ! |
28 #define MENU_LINES_MAX .7 ; Number of lines per screen? | 28 #define MENU_LINES_MAX .7 ; Number of lines per screen? |
29 #define MENU_TITLE_FONT WIN_STD ; Font should contains lower/UPPER alpha | 29 #define MENU_TITLE_FONT WIN_STD ; Font should contains lower/UPPER alpha |
30 #define MENU_LINE_FONT WIN_SMALL ; Font should contains lower/UPPER alpha | 30 #define MENU_LINE_FONT WIN_SMALL ; Font should contains lower/UPPER alpha |
31 #define MENU_LEFT .20 ; Position of first menu item | 31 #define MENU_LEFT .20 ; Position of first menu item |
32 #define MENU_HEIGHT .27 ; Spacing between menu lines. | 32 #define MENU_HEIGHT .27 ; Spacing between menu lines. |
33 #define MENU_VCENTER .125 ; Position on screen. | 33 #define MENU_VCENTER .125 ; Position on screen. |
34 #define MENU_LINE_MAX_LENGTH .20 ; Length in characters | 34 #define MENU_LINE_MAX_LENGTH .20 ; Length in characters |
35 #define option_item proc_item | |
35 | 36 |
36 ; Other needed references | 37 ; Other needed references |
37 extern aa_wordprocessor,option_inc,option_draw,comm_mode | 38 extern aa_wordprocessor |
38 | 39 extern option_inc |
39 | 40 extern option_draw |
40 ;============================================================================= | 41 extern comm_mode |
41 ; Temporary data. | 42 extern TFT_clear_divemode_menu |
42 | 43 extern TFT_divemask_color |
43 CBLOCK tmp+0x20 ; Reserved space for options.asm | 44 extern rtc_set_rtc |
44 menu_flags ; Various flags for menu: | 45 extern divemode_option0_return |
45 ; bit 0 :dynamic menu | 46 extern TFT_fillup_with_spaces |
46 menu_item ; Index of the current item. | 47 |
47 start_item ; Index of the first item (scrolling) | 48 |
48 item_max ; Number of items in menu. | 49 basic CODE |
49 selected_item ; Index of the current item. | 50 |
50 value_type ; Type for vertical menu. | |
51 dynamic_item:3 ; Callback addr | |
52 menu_block:3 ; Address of the menu block (ie. item 0) | |
53 menu_title:3 ; text or proc for dynamic menu. | |
54 menu_center ; centering for line menu. | |
55 proc_item:3 ; Address of the current proc. | |
56 text_item:2 ; Address of the current text. | |
57 ; Reserved to tmp+0x35 | |
58 ENDC | |
59 | |
60 #define option_item proc_item | |
61 | |
62 basic CODE | |
63 ;============================================================================= | 51 ;============================================================================= |
64 ; menu handler. | 52 ; menu handler. |
65 ; | 53 ; |
66 ; Input: TBLPTR = addr of menu block. | 54 ; Input: TBLPTR = addr of menu block. |
67 global menu_processor | 55 global menu_processor |
68 menu_processor: | 56 menu_processor: |
69 banksel common ; Bank1 | 57 banksel common ; Bank1 |
70 btfss divemode ; Not in divemode | 58 btfss divemode ; Not in divemode |
71 call speed_fastest ; Make it quick ! | 59 call speed_fastest ; Make it quick ! |
72 | 60 ;---- Read menu block ------------------------------------------------ |
73 ;---- Read menu block ------------------------------------------------ | 61 VARARGS_BEGIN ; Read inline PROM data |
74 VARARGS_BEGIN ; Read inline PROM data | 62 clrf STKPTR ; Never return, anyway... |
75 clrf STKPTR ; Never return, anyway... | 63 VARARGS_GET8 item_max ; Get number of items |
76 VARARGS_GET8 item_max ; Get number of items | 64 VARARGS_GET8 menu_flags ; Get flags |
77 VARARGS_GET8 menu_flags ; Get flags | 65 VARARGS_GET24 menu_title ; Get pointer to menu title |
78 VARARGS_GET24 menu_title ; Get pointer to menu title | 66 VARARGS_GET8 menu_center ; Vertical position |
79 VARARGS_GET8 menu_center ; Vertical position | 67 movff TBLPTRL, menu_block+0 ; Save base address for menu_read_item |
80 movff TBLPTRL, menu_block+0 ; Save base address for menu_read_item | 68 movff TBLPTRH, menu_block+1 |
81 movff TBLPTRH, menu_block+1 | 69 movff TBLPTRU, menu_block+2 |
82 movff TBLPTRU, menu_block+2 | 70 btfss divemode ; In divemode? |
83 | 71 bra menu_processor0 ; No |
84 btfss divemode ; In divemode? | |
85 bra menu_processor0 ; No | |
86 | |
87 ; Required for menus with less entries then the calling menu but not so nice when setting up gas 6.... mH | 72 ; Required for menus with less entries then the calling menu but not so nice when setting up gas 6.... mH |
88 extern TFT_clear_divemode_menu | 73 movlw .1 |
89 movlw .1 | 74 cpfsgt menupos1 ; only if menupos1 = 1... |
90 cpfsgt menupos ; only if menupos=1... | 75 call TFT_clear_divemode_menu ; ... Clear the menu! |
91 call TFT_clear_divemode_menu ; ... Clear the menu! | 76 ; Draw one frame around the divemode menu |
92 | 77 call TFT_divemask_color |
93 ; Draw one frame around the divemode menu | 78 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right |
94 extern TFT_divemask_color | 79 call TFT_standard_color |
95 call TFT_divemask_color | 80 |
96 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right | 81 bra menu_processor1 ; Yes, skip some lines here |
97 call TFT_standard_color | |
98 | |
99 bra menu_processor1 ; Yes, skip some lines here | |
100 | 82 |
101 menu_processor0: | 83 menu_processor0: |
102 ;---- draw menu title ------------------------------------------------ | 84 ;---- draw menu title ------------------------------------------------ |
103 clrf CCP1CON ; stop PWM | 85 clrf CCP1CON ; stop PWM |
104 bcf PORTC,2 ; Pull PWM out to GND | 86 bcf PORTC,2 ; Pull PWM out to GND |
105 call TFT_ClearScreen | 87 call TFT_ClearScreen |
106 rcall menu_processor_title | 88 rcall menu_processor_title |
107 rcall menu_processor_bottom_line | 89 rcall menu_processor_bottom_line |
108 | 90 |
109 menu_processor1: | 91 menu_processor1: |
110 movlw FT_SMALL | 92 movlw FT_SMALL |
111 movff WREG, win_font | 93 movff WREG, win_font |
112 | 94 |
113 ;---- Select menu type ----------------------------------------------- | 95 ;---- Select menu type ----------------------------------------------- |
114 bra menu_vertical | 96 bra menu_vertical |
115 | 97 |
116 global menu_processor_bottom_line | 98 global menu_processor_bottom_line |
117 menu_processor_bottom_line: | 99 menu_processor_bottom_line: |
118 ;---- Draw bottomline ------------------------------------------------ | 100 ;---- Draw bottom line ----------------------------------------------- |
119 TEXT_TINY .5, .240-.16, tNext | 101 TEXT_TINY .5, .240-.16, tNext |
120 TEXT_TINY .160-.6*.6, .240-.16, tEnter | 102 TEXT_TINY .160-.6*.6, .240-.16, tEnter |
121 | 103 WIN_COLOR color_greenish |
122 WIN_COLOR color_greenish | 104 ; Serial and Firmware Version |
123 ; Serial and Firmware Version | 105 WIN_TINY .57,.240-.16 |
124 WIN_TINY .57,.240-.16 | 106 STRCPY "#" |
125 STRCPY "#" | 107 call TFT_cat_serial |
126 call TFT_cat_serial | 108 STRCAT " v" |
127 STRCAT " v" | 109 call TFT_cat_firmware |
128 call TFT_cat_firmware | 110 STRCAT_PRINT "" |
129 STRCAT_PRINT "" | 111 call TFT_standard_color |
130 call TFT_standard_color | 112 bcf win_invert |
131 bcf win_invert | 113 return |
132 return | |
133 | 114 |
134 ;============================================================================= | 115 ;============================================================================= |
135 ; (re-)draw menu title. | 116 ; (re-)draw menu title. |
136 ; | 117 ; |
137 menu_processor_title: | 118 menu_processor_title: |
138 WIN_BOX_BLACK .2,.23,.0,.159 ; Clear Menu title | 119 WIN_BOX_BLACK .2,.23,.0,.159 ; Clear Menu title |
139 MENU_TITLE_FONT .0, .2 ; Menu title positionning | 120 MENU_TITLE_FONT .0, .2 ; Menu title positioning |
140 | 121 btfss menu_flags,0 ; Static or dynamic title ? |
141 btfss menu_flags,0 ; Static or dynmic title ? | 122 bra menu_processor_static_title |
142 bra menu_processor_static_title | 123 rcall menu_processor_call_title ; add gas, detail and color. |
143 | 124 bra menu_processor_title_1 |
144 rcall menu_processor_call_title ; add gas, detail and color. | 125 |
145 bra menu_processor_title_1 | 126 menu_processor_static_title: |
146 | 127 movff menu_title+0,FSR1L ; Just copy string. |
147 menu_processor_static_title: | 128 movff menu_title+1,FSR1H |
148 movff menu_title+0,FSR1L ; Just copy string. | 129 call strcpy_text |
149 movff menu_title+1,FSR1H | |
150 call strcpy_text | |
151 | 130 |
152 menu_processor_title_1: | 131 menu_processor_title_1: |
153 WIN_COLOR color_greenish | 132 WIN_COLOR color_greenish |
154 movf FSR2L,W ; Get title length | 133 movf FSR2L,W ; Get title length |
155 mullw .9 ; Convert to half pixels | 134 mullw .9 ; Convert to half pixels |
156 bcf STATUS,C ; Clear carry | 135 bcf STATUS,C ; Clear carry |
157 rrcf PRODL ; /2 | 136 rrcf PRODL ; /2 |
158 movf PRODL,W ; Back to WREG | 137 movf PRODL,W ; Back to WREG |
159 sublw .80 ; 80 - width | 138 sublw .80 ; 80 - width |
160 movwf win_leftx2 ; Aligned to center. | 139 movwf win_leftx2 ; Aligned to center. |
161 | 140 movlw .0 |
162 movlw .0 | 141 movff WREG,buffer+.17 ; limit to 17chars (Std font max.) |
163 movff WREG,buffer+.17 ; limit to 17chars (Std font max.) | 142 call aa_wordprocessor |
164 | 143 call TFT_standard_color |
165 call aa_wordprocessor | 144 return |
166 call TFT_standard_color | |
167 return | |
168 | 145 |
169 ;============================================================================= | 146 ;============================================================================= |
170 ; Call dynamic proc for menu title: | 147 ; Call dynamic proc for menu title: |
171 | 148 |
172 menu_processor_call_title: | 149 menu_processor_call_title: |
173 movff menu_title+2,PCLATU ; Just execute computed goto. | 150 movff menu_title+2,PCLATU ; Just execute computed goto. |
174 movff menu_title+1,PCLATH | 151 movff menu_title+1,PCLATH |
175 movf menu_title+0,W | 152 movf menu_title+0,W |
176 movwf PCL | 153 movwf PCL |
177 | 154 |
178 ;============================================================================= | 155 ;============================================================================= |
179 ; Restart with first icon/line selected. | 156 ; Restart with first icon/line selected. |
180 global menu_processor_reset | 157 global menu_processor_reset |
181 menu_processor_reset: | 158 menu_processor_reset: |
182 banksel common | 159 banksel menustack |
183 lfsr FSR2,menustack | 160 lfsr FSR2,menustack |
184 clrf POSTINC2 | 161 clrf POSTINC2 |
185 clrf POSTINC2 | 162 clrf POSTINC2 |
186 clrf POSTINC2 | 163 clrf POSTINC2 |
187 clrf POSTINC2 | 164 clrf POSTINC2 |
188 clrf POSTINC2 | 165 clrf POSTINC2 |
189 clrf selected_item | 166 banksel common |
190 return | 167 clrf selected_item |
191 | 168 return |
192 global menu_processor_pop | 169 |
170 global menu_processor_pop | |
193 menu_processor_pop: | 171 menu_processor_pop: |
194 movff menustack+0,selected_item | 172 movff menustack+0,selected_item |
195 movff menustack+1,menustack+0 | 173 movff menustack+1,menustack+0 |
196 movff menustack+2,menustack+1 | 174 movff menustack+2,menustack+1 |
197 movff menustack+3,menustack+2 | 175 movff menustack+3,menustack+2 |
198 movff menustack+4,menustack+3 | 176 movff menustack+4,menustack+3 |
199 return | 177 return |
178 | |
179 global menu_processor_double_pop | |
180 menu_processor_double_pop: | |
181 movff menustack+1,selected_item | |
182 movff menustack+2,menustack+0 | |
183 movff menustack+3,menustack+1 | |
184 movff menustack+4,menustack+2 | |
185 return | |
200 | 186 |
201 menu_processor_push: | 187 menu_processor_push: |
202 movff menustack+3,menustack+4 | 188 movff menustack+3,menustack+4 |
203 movff menustack+2,menustack+3 | 189 movff menustack+2,menustack+3 |
204 movff menustack+1,menustack+2 | 190 movff menustack+1,menustack+2 |
205 movff menustack+0,menustack+1 | 191 movff menustack+0,menustack+1 |
206 movff selected_item,menustack+0 | 192 movff selected_item,menustack+0 |
207 clrf selected_item | 193 clrf selected_item |
208 return | 194 return |
209 | 195 |
210 ;---- Execute menu selection ------------------------------------------------- | 196 ;---- Execute menu selection ------------------------------------------------- |
211 do_menu_item: | 197 do_menu_item: |
212 bcf switch_right ; Avoid loops. | 198 bcf switch_right ; Avoid loops. |
213 call speed_normal ; Back to normal speed. | 199 call speed_normal ; Back to normal speed. |
214 | 200 movf selected_item,W ; Reread proc address from table. |
215 movf selected_item,W ; Reread proc address from table. | 201 rcall menu_read_item ; (destroy PROD) |
216 rcall menu_read_item ; (destroy PROD) | 202 movff selected_item,PRODL ; Pass along selected line |
217 | 203 rcall menu_processor_push ; Remember where we get from. (clears selected_item) |
218 movff selected_item,PRODL ; Pass along selected line | 204 movff proc_item+2,PCLATU ; Then execute computed goto. |
219 | 205 movff proc_item+1,PCLATH |
220 rcall menu_processor_push ; Remember where we get from. (clears selected_item) | 206 movf proc_item+0,W |
221 | 207 movwf PCL |
222 movff proc_item+2,PCLATU ; Then execute computed goto. | |
223 movff proc_item+1,PCLATH | |
224 movf proc_item+0,W | |
225 movwf PCL | |
226 | 208 |
227 ;============================================================================= | 209 ;============================================================================= |
228 ; Get current item from table. | 210 ; Get current item from table. |
229 ; | 211 ; |
230 ; Input : Item number in WREG, menu_block. | 212 ; Input : Item number in WREG, menu_block. |
231 ; | 213 ; |
232 ; Output: icon_large, text_item, proc_item 16bits pointers. | 214 ; Output: icon_large, text_item, proc_item 16bits pointers. |
233 ; | 215 ; |
234 ; Trashed: PROD, WREG | 216 ; Trashed: PROD, WREG |
235 menu_read_item: | 217 menu_read_item: |
236 mullw .10 ; 10 bytes per item. | 218 mullw .10 ; 10 bytes per item. |
237 movf PRODL,W ; Then do a 24bits add | 219 movf PRODL,W ; Then do a 24bits add |
238 addwf menu_block+0,W ; with menu_block, and | 220 addwf menu_block+0,W ; with menu_block, and |
239 movwf TBLPTRL ; setup TBLPTR | 221 movwf TBLPTRL ; setup TBLPTR |
240 movf PRODH,W | 222 movf PRODH,W |
241 addwfc menu_block+1,W | 223 addwfc menu_block+1,W |
242 movwf TBLPTRH | 224 movwf TBLPTRH |
243 movlw 0 | 225 movlw 0 |
244 addwfc menu_block+2,W | 226 addwfc menu_block+2,W |
245 movwf TBLPTRU | 227 movwf TBLPTRU |
246 | 228 VARARGS_GET8 value_type ; Read 10 bytes of item data |
247 VARARGS_GET8 value_type ; Read 10 bytes of item data | 229 VARARGS_GET24 dynamic_item |
248 VARARGS_GET24 dynamic_item | 230 VARARGS_GET24 proc_item |
249 VARARGS_GET24 proc_item | 231 VARARGS_GET8 WREG ; Skip dummy byte |
250 VARARGS_GET8 WREG ; Skip dummy byte | 232 VARARGS_GET16 text_item |
251 VARARGS_GET16 text_item | 233 |
252 | 234 return |
253 return | |
254 | 235 |
255 ;============================================================================= | 236 ;============================================================================= |
256 ; Vertical menu : set of line/value to choose from. | 237 ; Vertical menu : set of line/value to choose from. |
257 ; Entry point to update lines already shown. | 238 ; Entry point to update lines already shown. |
258 ; | 239 ; |
259 global menu_vertical | 240 global menu_vertical |
260 menu_vertical: | 241 menu_vertical: |
261 btfss divemode ; Not in divemode | 242 btfss divemode ; Not in divemode |
262 clrf timeout_counter2 ; Reset timeout | 243 clrf timeout_counter2 ; Reset timeout |
263 | 244 |
264 menu_vertical_2: | 245 menu_vertical_2: |
265 rcall menu_draw_lines ; Always re-draw whole menu | 246 rcall menu_draw_lines ; Always re-draw whole menu |
266 | 247 movlw CCP1CON_VALUE ; See hwos.inc |
267 movlw CCP1CON_VALUE ; See hwos.inc | 248 btfss divemode ; Not in divemode |
268 btfss divemode ; Not in divemode | 249 movwf CCP1CON ; Power-on backlight |
269 movwf CCP1CON ; Power-on backlight | |
270 | 250 |
271 menu_vertical_1: | 251 menu_vertical_1: |
272 movf selected_item,W ; Get current item data | 252 movf selected_item,W ; Get current item data |
273 rcall menu_read_item | 253 rcall menu_read_item |
274 movf proc_item+0,W ; Check if pro address is NULL ? | 254 movf proc_item+0,W ; Check if pro address is NULL ? |
275 iorwf proc_item+1,W | 255 iorwf proc_item+1,W |
276 bz next_line_menu ; YES: not selectable ! | 256 bz next_line_menu ; YES: not selectable ! |
277 | 257 btfss divemode ; Not in divemode |
278 btfss divemode ; Not in divemode | 258 rcall menu_draw_selected_line |
279 rcall menu_draw_selected_line | 259 btfsc in_color_menu ; =1: In the color scheme menu |
280 | 260 call TFT_show_color_schemes ; Yes, update the color schemes |
281 btfsc in_color_menu ; =1: In the color scheme menu | 261 btfss settime_setdate ; In the Set Time or Set Date menu? |
282 call TFT_show_color_schemes ; Yes, update the color schemes | 262 bra menu_line_loop_pre2 ; no, skip all following |
283 | 263 movff month,lo ; new month |
284 extern rtc_set_rtc | 264 dcfsnz lo,F |
285 btfss settime_setdate ; In the Set Time or Set Date menu? | 265 movlw .31 |
286 bra menu_line_loop_pre2 ; no, skip all following | 266 dcfsnz lo,F |
287 | 267 movlw .28 |
288 movff month,lo ; new month | 268 dcfsnz lo,F |
289 dcfsnz lo,F | 269 movlw .31 |
290 movlw .31 | 270 dcfsnz lo,F |
291 dcfsnz lo,F | 271 movlw .30 |
292 movlw .28 | 272 dcfsnz lo,F |
293 dcfsnz lo,F | 273 movlw .31 |
294 movlw .31 | 274 dcfsnz lo,F |
295 dcfsnz lo,F | 275 movlw .30 |
296 movlw .30 | 276 dcfsnz lo,F |
297 dcfsnz lo,F | 277 movlw .31 |
298 movlw .31 | 278 dcfsnz lo,F |
299 dcfsnz lo,F | 279 movlw .31 |
300 movlw .30 | 280 dcfsnz lo,F |
301 dcfsnz lo,F | 281 movlw .30 |
302 movlw .31 | 282 dcfsnz lo,F |
303 dcfsnz lo,F | 283 movlw .31 |
304 movlw .31 | 284 dcfsnz lo,F |
305 dcfsnz lo,F | 285 movlw .30 |
306 movlw .30 | 286 dcfsnz lo,F |
307 dcfsnz lo,F | 287 movlw .31 |
308 movlw .31 | 288 cpfsgt day ; day ok? |
309 dcfsnz lo,F | 289 bra menu_line_loop_pre1 ; OK! |
310 movlw .30 | 290 movlw .1 ; not OK, set to 1st |
311 dcfsnz lo,F | 291 movwf day |
312 movlw .31 | |
313 cpfsgt day ; day ok? | |
314 bra menu_line_loop_pre1 ; OK! | |
315 movlw .1 ; not OK, set to 1st | |
316 movwf day | |
317 | 292 |
318 menu_line_loop_pre1: | 293 menu_line_loop_pre1: |
319 btfsc switch_right ; Enter pressed? | 294 btfsc switch_right ; Enter pressed? |
320 call rtc_set_rtc ; Yes, update mins,sec,hours,day,month and year to rtc module | 295 call rtc_set_rtc ; Yes, update mins,sec,hours,day,month and year to RTC module |
321 call TFT_show_time_date_menu ; Update clock | 296 call TFT_show_time_date_menu ; Update clock |
322 | 297 |
323 menu_line_loop_pre2: | 298 menu_line_loop_pre2: |
324 bcf switch_right | 299 bcf switch_right |
325 bcf switch_left | 300 bcf switch_left |
326 btfss divemode ; Not in Divemode | 301 btfss divemode ; Not in divemode |
327 call speed_normal | 302 call speed_normal |
328 | 303 |
329 menu_line_loop_pre3: | 304 menu_line_loop_pre3: |
330 extern divemode_option0_return | 305 btfsc divemode ; In divemode? |
331 btfsc divemode ; In divemode? | 306 goto divemode_option0_return ; Yes, return to it |
332 goto divemode_option0_return ; Yes, return to it | |
333 | 307 |
334 menu_line_loop: | 308 menu_line_loop: |
335 btfsc switch_right | 309 btfsc switch_right |
336 bra do_line_menu ; Type dependent | 310 bra do_line_menu ; Type dependent |
337 btfsc switch_left | 311 btfsc switch_left |
338 bra next_line_menu | 312 bra next_line_menu |
339 | 313 btfss quarter_second_update ; 1/4 second? |
340 btfss quarter_second_update ; 1/4 second? | 314 bra menu_line_loop1 ; Not yet... |
341 bra menu_line_loop1 ; Not yet... | 315 btfsc menu_show_sensors2 ; In the "Calibrate" menu? |
342 | 316 call TFT_menu_calibrate ; Yes, update mV data |
343 btfsc menu_show_sensors2 ; In the "Calibrate" menu? | 317 bcf quarter_second_update ; Clear flag |
344 call TFT_menu_calibrate ; Yes, update mV data | |
345 bcf quarter_second_update ; Clear flag | |
346 | 318 |
347 menu_line_loop1: | 319 menu_line_loop1: |
348 btfss onesecupdate ; New second | 320 btfss onesecupdate ; New second |
349 bra menu_line_loop2 ; not yet... | 321 bra menu_line_loop2 ; not yet... |
350 | 322 call timeout_surfmode ; timeout on timeout_counter2 |
351 call timeout_surfmode ; timeout | 323 call set_dive_modes ; check, if divemode must be entered |
352 call set_dive_modes ; check, if divemode must be entered | 324 call get_battery_voltage ; gets battery voltage |
353 call get_battery_voltage ; gets battery voltage | 325 btfsc settime_setdate ; In the Set Time or Set Date menu? |
354 | 326 call TFT_show_time_date_menu ; Yes, update clock |
355 btfsc settime_setdate ; In the Set Time or Set Date menu? | 327 bcf onesecupdate ; one second updates done |
356 call TFT_show_time_date_menu ; Yes, update clock | |
357 | |
358 ; DELETE - menu has been deleted ## memory | |
359 ; btfsc menu_show_sensors ; In the "Sensors" menu? | |
360 ; call TFT_menu_hud ; Yes, update HUD data | |
361 | |
362 bcf onesecupdate ; one second updates done | |
363 | 328 |
364 menu_line_loop2: | 329 menu_line_loop2: |
365 btfsc sleepmode ; Timeout? | 330 btfsc sleepmode ; Timeout? |
366 goto restart ; Yes, back to surfacemode | 331 goto restart ; Yes, back to surfacemode |
367 btfsc divemode | 332 btfsc divemode |
368 goto restart ; Enter Divemode if required | 333 goto restart ; Enter divemode if required |
369 | 334 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) |
370 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 335 bra menu_line_loop3 |
371 bra menu_line_loop3 | 336 btfsc vusb_in ; USB plugged in? |
372 btfsc vusb_in ; USB plugged in? | 337 call comm_mode ; Start COMM mode |
373 call comm_mode ; Start COMM mode | 338 bra menu_line_loop4 |
374 bra menu_line_loop4 | |
375 menu_line_loop3: | 339 menu_line_loop3: |
376 btfss vusb_in ; USB (still) plugged in? | 340 btfss vusb_in ; USB (still) plugged in? |
377 bcf enable_screen_dumps ; No, clear flag | 341 bcf enable_screen_dumps ; No, clear flag |
378 call rs232_get_byte | 342 call rs232_get_byte |
379 btfsc rs232_recieve_overflow | 343 btfsc rs232_receive_overflow |
380 bra menu_line_loop4 | 344 bra menu_line_loop4 |
381 movlw "l" | 345 movlw "l" |
382 cpfseq RCREG1 | 346 cpfseq RCREG1 |
383 bra menu_line_loop4 | 347 bra menu_line_loop4 |
384 call TFT_dump_screen ; Dump the screen contents | 348 call TFT_dump_screen ; Dump the screen contents |
385 menu_line_loop4: | 349 menu_line_loop4: |
386 | 350 bra menu_line_loop |
387 bra menu_line_loop | |
388 | 351 |
389 ;---- Move to menu's next line | 352 ;---- Move to menu's next line |
390 next_line_menu: | 353 next_line_menu: |
391 btfss divemode ; not in divemode | 354 btfss divemode ; not in divemode |
392 call speed_fastest | 355 call speed_fastest |
393 bcf switch_left ; Avoid looping. | 356 bcf switch_left ; Avoid looping. |
394 | 357 incf selected_item,F ; Select next item. |
395 incf selected_item,F ; Select next item. | 358 movf selected_item,W ; Index == max ? |
396 movf selected_item,W ; Index == max ? | 359 cpfseq item_max |
397 cpfseq item_max | 360 bra menu_vertical_1 ; NO: redraw cursor. |
398 bra menu_vertical_1 ; NO: redraw cursor. | 361 clrf selected_item ; YES: restart for item 0. |
399 | 362 bra menu_vertical_1 ; Then redraw cursor. |
400 clrf selected_item ; YES: restart for item 0. | 363 |
401 bra menu_vertical_1 ; Then redraw cursor. | 364 global do_line_menu |
402 | |
403 global do_line_menu | |
404 do_line_menu: | 365 do_line_menu: |
405 btfss divemode ; not in divemode | 366 btfss divemode ; not in divemode |
406 call speed_fastest | 367 call speed_fastest |
407 ; bcf switch_right ; Avoid looping. | 368 ; bcf switch_right ; Avoid looping. |
408 | 369 decf menupos1,W ; menu_processor needs 0-5... |
409 decf menupos,W ; menu_processor needs 0-5... | 370 btfsc divemode ; only in divemode |
410 btfsc divemode ; only in divemode | 371 movwf selected_item |
411 movwf selected_item | 372 movf selected_item,W ; Read selected descriptor |
412 | 373 rcall menu_read_item |
413 movf selected_item,W ; Read selected descriptor | 374 movf value_type,W ; Switch on data type |
414 rcall menu_read_item | 375 bz menu_do_line_call ; CALL |
415 | 376 dcfsnz WREG |
416 movf value_type,W ; Switch on data type | 377 bra menu_do_line_call ; STRING: do as call |
417 bz menu_do_line_call ; CALL | 378 dcfsnz WREG |
418 dcfsnz WREG | 379 bra menu_do_line_option ; OPTION |
419 bra menu_do_line_call ; STRING: do as call | 380 dcfsnz WREG |
420 dcfsnz WREG | 381 bra menu_do_line_call ; DYNAMIC: do as call |
421 bra menu_do_line_option ; OPTION | 382 bra menu_line_loop_pre3 ; else do nothing... |
422 dcfsnz WREG | |
423 bra menu_do_line_call ; DYNAMIC: do as call | |
424 bra menu_line_loop_pre3 ; else do nothing... | |
425 | 383 |
426 ;---- CALL | 384 ;---- CALL |
427 menu_do_line_call: | 385 menu_do_line_call: |
428 rcall do_menu_item ; Same as icon menu: calculated goto. | 386 rcall do_menu_item ; Same as icon menu: calculated goto. |
429 rcall menu_processor_pop ; Back to same line, | 387 rcall menu_processor_pop ; Back to same line, |
430 bra menu_vertical ; Then continue into menu... | 388 bra menu_vertical ; Then continue into menu... |
431 | 389 |
432 ;---- Call option specific increment subroutine | 390 ;---- Call option specific increment subroutine |
433 menu_do_line_option: | 391 menu_do_line_option: |
434 movff option_item+0,FSR0L ; Get option handle | 392 movff option_item+0,FSR0L ; Get option handle |
435 movff option_item+1,FSR0H | 393 movff option_item+1,FSR0H |
436 call option_inc ; increment | 394 call option_inc ; increment |
437 | 395 movff selected_item,PRODL ; Pass selection to callback. |
438 movff selected_item,PRODL ; Pass selection to callback. | 396 rcall menu_text_call |
439 rcall menu_text_call | 397 bra menu_vertical_2 ; redraw all lines... |
440 bra menu_vertical_2 ; redraw all lines... | |
441 | 398 |
442 ;----------------------------------------------------------------------------- | 399 ;----------------------------------------------------------------------------- |
443 | 400 |
444 menu_draw_lines_divemode: | 401 menu_draw_lines_divemode: |
445 movlw dm_menu_item1_row | 402 movlw dm_menu_item1_row |
446 movff WREG,win_top | 403 movff WREG,win_top |
447 movlw dm_menu_item1_column | 404 movlw dm_menu_item1_column |
448 movff WREG,win_leftx2 | 405 movff WREG,win_leftx2 |
449 clrf start_item | 406 clrf start_item |
450 movff item_max,menupos4 ; Copy item_max for divemode cursor routine | 407 movff item_max,menupos4 ; Copy item_max for divemode cursor routine |
451 bra menu_draw_lines_2 | 408 bra menu_draw_lines_2 |
452 | 409 |
453 menu_draw_lines: | 410 menu_draw_lines: |
454 btfsc divemode ; in divemode? | 411 btfsc divemode ; in divemode? |
455 bra menu_draw_lines_divemode; Yes | 412 bra menu_draw_lines_divemode ; Yes |
456 | 413 btfsc menu_flags,0 ; Dynamic title ? |
457 btfsc menu_flags,0 ; Dynamic title ? | 414 rcall menu_processor_title ; YES: redraw it then. |
458 rcall menu_processor_title ; YES: redraw it then. | 415 MENU_LINE_FONT MENU_LEFT, 0 ; Init start position/font |
459 | 416 movff menu_center,win_top ; computed in menu block. |
460 MENU_LINE_FONT MENU_LEFT, 0 ; Init start position/font | 417 |
461 movff menu_center,win_top ; computed in menu block. | 418 ; Does the menu have more than 6 lines ? |
462 | 419 movf item_max,W |
463 ; Does the menu have more than 6 lines ? | 420 addlw -(MENU_LINES_MAX+1) ; (max - 7) |
464 movf item_max,W | 421 bnn menu_draw_long_menu ; bra if (max >= 7) |
465 addlw -(MENU_LINES_MAX+1) ; (max - 7) | 422 clrf start_item |
466 bnn menu_draw_long_menu ; bra if (max >= 7) | 423 bra menu_draw_lines_2 |
467 | |
468 clrf start_item | |
469 bra menu_draw_lines_2 | |
470 | 424 |
471 menu_draw_long_menu: | 425 menu_draw_long_menu: |
472 movf selected_item,W ; Start at selected-6 | 426 movf selected_item,W ; Start at selected-6 |
473 addlw -(MENU_LINES_MAX-1) | 427 addlw -(MENU_LINES_MAX-1) |
474 btfsc STATUS,N ; This is <0 ? | 428 btfsc STATUS,N ; This is <0 ? |
475 clrf WREG ; YES: start from top instead. | 429 clrf WREG ; YES: start from top instead. |
476 movwf start_item | 430 movwf start_item |
477 | 431 |
478 menu_draw_lines_2: | 432 menu_draw_lines_2: |
479 movff start_item, menu_item | 433 movff start_item, menu_item |
480 | 434 |
481 menu_draw_lines_1: | 435 menu_draw_lines_1: |
482 call TFT_standard_color ; Restore color after disabled lines. | 436 call TFT_standard_color ; Restore color after disabled lines. |
483 | 437 movf menu_item,W |
484 movf menu_item,W | 438 rcall menu_read_item |
485 rcall menu_read_item | 439 movf value_type,W ; Switch on data type |
486 | 440 bz menu_draw_line_call |
487 movf value_type,W ; Switch on data type | 441 dcfsnz WREG |
488 bz menu_draw_line_call | 442 bra menu_draw_line_string |
489 dcfsnz WREG | 443 dcfsnz WREG |
490 bra menu_draw_line_string | 444 bra menu_draw_line_option |
491 dcfsnz WREG | 445 dcfsnz WREG |
492 bra menu_draw_line_option | 446 bra menu_draw_line_dynamic |
493 dcfsnz WREG | 447 bra menu_draw_line_none |
494 bra menu_draw_line_dynamic | |
495 bra menu_draw_line_none | |
496 | 448 |
497 menu_draw_line_string: | 449 menu_draw_line_string: |
498 movff text_item+0,TBLPTRL ; Read not-translated string from PROM. | 450 movff text_item+0,TBLPTRL ; Read not-translated string from PROM. |
499 movff text_item+1,TBLPTRH | 451 movff text_item+1,TBLPTRH |
500 call strcpy_prom ; Copy in buffer | 452 call strcpy_prom ; Copy in buffer |
501 bra menu_draw_line_none | 453 bra menu_draw_line_none |
502 | 454 |
503 menu_draw_line_call: | 455 menu_draw_line_call: |
504 movff text_item+0,FSR1L ; Read string from PROM. | 456 movff text_item+0,FSR1L ; Read string from PROM. |
505 movff text_item+1,FSR1H | 457 movff text_item+1,FSR1H |
506 call strcpy_text ; Copy in buffer | 458 call strcpy_text ; Copy in buffer |
507 | 459 bra menu_draw_line_none |
508 bra menu_draw_line_none | 460 |
509 | |
510 menu_draw_line_option: | 461 menu_draw_line_option: |
511 movff text_item+0,FSR1L ; Read string from PROM. | 462 movff text_item+0,FSR1L ; Read string from PROM. |
512 movff text_item+1,FSR1H | 463 movff text_item+1,FSR1H |
513 call strcpy_text ; Copy in buffer | 464 call strcpy_text ; Copy in buffer |
514 | 465 movff option_item+0,FSR0L ; Retrieve option handle. |
515 movff option_item+0,FSR0L ; Retrieve option handle. | 466 movff option_item+1,FSR0H |
516 movff option_item+1,FSR0H | 467 btfss settime_setdate ; Not in Time/Date menu... |
517 btfss settime_setdate ; Not in Time/Date menu... | 468 call option_draw |
518 call option_draw | 469 bra menu_draw_line_none |
519 bra menu_draw_line_none | |
520 | 470 |
521 menu_draw_line_dynamic: | 471 menu_draw_line_dynamic: |
522 lfsr FSR2,buffer | 472 lfsr FSR2,buffer |
523 movff menu_item,PRODL ; Pass item to callback. | 473 movff menu_item,PRODL ; Pass item to callback. |
524 rcall menu_text_call ; Push return address. | 474 rcall menu_text_call ; Push return address. |
525 bra menu_draw_line_none | 475 bra menu_draw_line_none |
526 | 476 |
527 ; Computed goto to pointer inside dynamic_item: | 477 ; Computed goto to pointer inside dynamic_item: |
528 menu_text_call: | 478 menu_text_call: |
529 movf dynamic_item+0,W ; Check if callback is NULL | 479 movf dynamic_item+0,W ; Check if callback is NULL |
530 iorwf dynamic_item+1,W | 480 iorwf dynamic_item+1,W |
531 iorwf dynamic_item+2,W | 481 iorwf dynamic_item+2,W |
532 btfsc STATUS,Z | 482 btfsc STATUS,Z |
533 return ; YES: don't call it. | 483 return ; YES: don't call it. |
534 | 484 movff dynamic_item+2,PCLATU ; Prepare... |
535 movff dynamic_item+2,PCLATU ; Prepare... | 485 movff dynamic_item+1,PCLATH |
536 movff dynamic_item+1,PCLATH | 486 movf dynamic_item+0,W |
537 movf dynamic_item+0,W | 487 movwf PCL ; And jump ! |
538 movwf PCL ; And jump ! | |
539 | 488 |
540 menu_draw_line_none: | 489 menu_draw_line_none: |
541 extern TFT_fillup_with_spaces | 490 btfsc divemode ; In divemode? |
542 | 491 bra menu_draw_line_none_divemode ; Yes |
543 btfsc divemode ; In divemode? | 492 movlw MENU_LINE_MAX_LENGTH |
544 bra menu_draw_line_none_divemode ; Yes | 493 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) |
545 | 494 clrf WREG |
546 movlw MENU_LINE_MAX_LENGTH | 495 movff WREG,buffer+MENU_LINE_MAX_LENGTH ; No - make sure won't be longer than MENU_LINE_MAX_LENGTH ch |
547 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | 496 call aa_wordprocessor |
548 clrf WREG | 497 movlw MENU_HEIGHT ; No, Move to next line |
549 movff WREG,buffer+MENU_LINE_MAX_LENGTH;No ; Make sure won't be longer than MENU_LINE_MAX_LENGTH ch | 498 addwf win_top,F |
550 call aa_wordprocessor | 499 incf menu_item,F ; inc loop counter |
551 movlw MENU_HEIGHT ; No, Move to next line | 500 movf start_item,W ; First line (scrolled) |
552 addwf win_top,F | 501 subwf menu_item,W ; current - first |
553 incf menu_item,F ; inc loop counter | 502 xorlw MENU_LINES_MAX ; Already done 6 lines ? |
554 | 503 btfsc STATUS,Z |
555 movf start_item,W ; First line (scrolled) | 504 return ; YES |
556 subwf menu_item,W ; current - first | |
557 xorlw MENU_LINES_MAX ; Already done 6 lines ? | |
558 btfsc STATUS,Z | |
559 return ; YES | |
560 menu_draw_line_none2: | 505 menu_draw_line_none2: |
561 movf menu_item,W ; Done item_max lines ? | 506 movf menu_item,W ; Done item_max lines ? |
562 xorwf item_max,W | 507 xorwf item_max,W |
563 btfss STATUS,Z | 508 btfss STATUS,Z |
564 bra menu_draw_lines_1 ; No: loop... | 509 bra menu_draw_lines_1 ; No: loop... |
565 return | 510 return |
566 | 511 |
567 menu_draw_line_none_divemode: | 512 menu_draw_line_none_divemode: |
568 movlw .10 | 513 movlw .10 |
569 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | 514 call TFT_fillup_with_spaces ; Fill up FSR2 with spaces (Total string length in #WREG) |
570 clrf WREG | 515 clrf WREG |
571 movff WREG,buffer+.10 | 516 movff WREG,buffer+.10 |
572 | 517 call aa_wordprocessor ; Draw the line! |
573 call aa_wordprocessor ; Draw the line! | 518 banksel common |
574 | 519 bcf win_invert ; Reset invert flag |
575 banksel common | 520 banksel win_top |
576 bcf win_invert ; Reset invert flag | 521 movlw .24 ; divemode menu spacing |
577 banksel win_top | 522 addwf win_top,F |
578 | 523 incf menu_item,F ; inc loop counter |
579 movlw .24 ; Divemode menu spacing | 524 movlw .3 |
580 addwf win_top,F | 525 cpfseq menu_item ; At pos 4? |
581 incf menu_item,F ; inc loop counter | 526 bra menu_draw_line_none2 ; No |
582 | 527 movlw dm_menu_item4_row |
583 movlw .3 | 528 movff WREG,win_top ; Reset row |
584 cpfseq menu_item ; At pos 4? | 529 movlw dm_menu_item4_column |
585 bra menu_draw_line_none2 ; No | 530 movff WREG,win_leftx2 ; New column |
586 | 531 bra menu_draw_line_none2 ; Done. |
587 movlw dm_menu_item4_row | |
588 movff WREG,win_top ; Reset row | |
589 movlw dm_menu_item4_column | |
590 movff WREG,win_leftx2 ; New column | |
591 bra menu_draw_line_none2 ; Done. | |
592 | 532 |
593 ;----------------------------------------------------------------------------- | 533 ;----------------------------------------------------------------------------- |
594 ; Put a mark in front of the current line | 534 ; Put a mark in front of the current line |
595 menu_draw_selected_line: | 535 menu_draw_selected_line: |
596 clrf timeout_counter2 ; Reset timeout | 536 clrf timeout_counter2 ; Reset timeout |
597 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; Clear left column | 537 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; Clear left column |
598 | 538 call TFT_standard_color |
599 call TFT_standard_color | 539 WIN_SMALL MENU_LEFT-8, 0 ; Arrow symbol only in small font |
600 WIN_SMALL MENU_LEFT-8, 0 ; Arrow symbol only in small font | 540 movf start_item,W ; First line (scrolled) |
601 movf start_item,W ; First line (scrolled) | 541 subwf selected_item,W ; selected - first |
602 subwf selected_item,W ; selected - first | 542 mullw MENU_HEIGHT ; 30 pixel by line |
603 mullw MENU_HEIGHT ; 30 pixel by line | 543 movf PRODL,W ; result |
604 movf PRODL,W ; result | 544 addwf menu_center,W ; added to first line |
605 addwf menu_center,W ; added to first line | 545 movwf win_top ; and stored to pos. |
606 movwf win_top ; and stored to pos. | 546 STRCPY_PRINT "\xb7" ; print cursor |
607 STRCPY_PRINT "\xb7" ; print cursor | 547 return |
608 | 548 |
609 return | 549 END |
610 | |
611 END |