annotate src/menu_processor.asm @ 53:2825f1d2262f

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