Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode_menu.asm @ 103:fe195f766014
Codesize optimized valconv.asm
author | JeanDo |
---|---|
date | Tue, 14 Dec 2010 11:14:32 +0100 |
parents | 39d325b2a5f9 |
children | 2a2606e9db5f |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Underwater Menu (Set Gas, Decoplan, etc.) | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 11/11/05 | |
21 ; last updated: 090305 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 | |
26 test_switches_divemode: | |
27 ; checks switches in divemode | |
28 btfsc switch_left | |
29 bra test_switches_divemode2 | |
30 | |
31 btfss switch_right | |
32 return | |
33 | |
34 bcf switch_left ; Left button pressed! | |
35 bcf switch_right | |
36 | |
37 bcf select_bailoutgas ; Clear Flag for Bailout list | |
38 bsf premenu ; Set Flag for premenu | |
39 bcf menubit | |
40 clrf timeout_counter3 ; timeout_divemenu | |
41 | |
42 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
43 bra test_switches_divemode1 ; Yes! | |
44 | |
45 test_switches_divemode0: | |
46 WIN_INVERT .1 | |
47 DISPLAYTEXT .4 ;Menu? | |
48 WIN_INVERT .0 | |
49 return | |
50 | |
51 test_switches_divemode1: | |
52 DISPLAYTEXT .141 ;Quit? | |
53 return | |
54 | |
55 test_switches_divemode2: | |
56 bcf switch_left ; Also reactivate left button if there was a right press without prior left press | |
57 bcf switch_right ; enable right button again | |
58 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
59 btfsc premenu |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
60 bra test_switches_divemode2_2 |
0 | 61 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
62 bsf toggle_customview ; Toggle customview (Cleared in divemode.asm) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
63 btfsc standalone_simulator ; Standalone Simualtor active? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
64 bra divemode_menu_simulator ; Yes, Show simulator menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
65 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
66 test_switches_divemode2_2: |
0 | 67 btfss FLAG_apnoe_mode ; In Apnoe mode? |
68 bra test_switches_divemode2a; No! | |
69 | |
70 ; Yes, so quit Apnoe mode at once... | |
71 bcf divemode ; Clear Divemode flag... | |
72 bcf premenu ; clear premenu flag | |
73 return | |
74 | |
75 test_switches_divemode2a: | |
76 bsf menubit ; Enter Divemode-Menu! | |
77 bcf premenu ; clear premenu flag | |
78 call PLED_clear_divemode_menu ; Clear dive mode menu area | |
79 call PLED_divemode_menu_mask_first ; Write Divemode menu1 mask | |
80 bcf display_set_simulator ; Clear Simulator-Menu flag | |
81 movlw d'1' | |
82 movwf menupos ; reset cursor in divemode menu | |
83 call PLED_divemenu_cursor ; show cursor | |
84 bcf switch_right | |
85 bcf switch_left ; Left button pressed! | |
86 return | |
87 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
88 reset_stopwatch: |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
89 btfsc lock_stopwatch_reset ; Reset locked? |
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
90 return ; Yes, do not reset (now)... |
0 | 91 ; Maker Set, also reset average Depth.... |
92 clrf average_depth_hold+0 | |
93 clrf average_depth_hold+1 | |
94 clrf average_depth_hold+2 | |
95 clrf average_depth_hold+3 ; Clear average depth register | |
96 movlw d'2' | |
97 movwf average_divesecs+0 | |
98 clrf average_divesecs+1 | |
99 call calc_average_depth | |
100 return | |
101 | |
102 test_switches_divemode_menu: | |
103 btfsc switch_left | |
104 bra test_switches_divemode_menu3 | |
105 btfss switch_right | |
106 return | |
107 | |
108 btfsc display_see_deco ; Is the Decoplan displayed? | |
109 bra divemenu_see_decoplan2 ; Yes, exit menu on left button press | |
110 | |
111 bcf switch_right ; Left button pressed | |
112 clrf timeout_counter3 ; timout_divemenu! | |
113 incf menupos,F | |
114 | |
115 ; Following routine configures the number of menu entries for the different modes | |
116 movlw d'6' ; number of available gases+1, ; number of menu options+1 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
117 btfsc display_set_gas ; Are we in the "Gaslist" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
118 movlw d'7' ; Yes, Number of entries for this menu+1 = 7 |
0 | 119 btfsc display_set_setpoint ; In SetPoint Menu? |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
120 movlw d'5' ; Number of entries for this menu+1 = 5 |
0 | 121 cpfseq menupos ; =limit? |
122 bra test_switches_divemode_menu1; No! | |
123 movlw d'1' ; Yes, reset to position 1! | |
124 movwf menupos | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
125 |
0 | 126 test_switches_divemode_menu1: |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
127 ; Finally, check if menuposition 3 should be skipped (No customview with function displayed) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
128 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
129 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
130 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
131 btfsc display_set_xgas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
132 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
133 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
134 movlw d'3' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
135 cpfseq menupos ; At position 3? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
136 bra test_switches_divemode_menu1a; No |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
137 btfss menu3_active ; Menu position 3 has functionality? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
138 incf menupos,F ; No, +1, skip to menuos=4 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
139 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
140 test_switches_divemode_menu1a: |
0 | 141 call PLED_divemenu_cursor ; update cursor |
142 return | |
143 | |
144 test_switches_divemode_menu3: | |
145 bcf switch_left | |
146 bcf switch_right | |
147 bsf menubit ; Enter Divemode-Menu! | |
148 bcf premenu ; clear premenu flag | |
149 clrf timeout_counter3 | |
150 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
151 ; btfsc display_see_l_tissue ; Is the leading tissue info screen active |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
152 ; bra divemenu_see_leading_tissue2; Yes, quit menu |
0 | 153 |
154 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? | |
155 bra divemenu_set_gas2 ; Yes, so set gas and exit menu | |
156 | |
157 btfsc display_see_deco ; Is the Decoplan displayed? | |
158 bra divemenu_see_decoplan2 ; Yes, exit menu on right button press | |
159 | |
160 btfsc display_set_graphs ; Is the Graph displayed? | |
161 bra divemode_set_graphs2 ; Yes, exit menu on right button press | |
162 | |
163 btfsc display_set_xgas ; Are we in the "Set Gas" menu? | |
164 bra divemenu_set_xgas2 ; Yes, so configure gas or set menu and exit menu | |
165 | |
166 btfsc display_set_simulator ; Are we in the Divemode Simulator menu? | |
167 goto divemode_menu_simulator2 ; Yes, so adjust depth or set and exit | |
168 | |
169 ; Options for Menu 1 | |
170 dcfsnz menupos,F | |
73
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
171 bra divemenu_set_gas ; Set gas sub-menu |
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
172 dcfsnz menupos,F |
0 | 173 bra divemenu_see_decoplan ; display the full decoplan |
174 dcfsnz menupos,F | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
175 bra divemode_menu3 ; Customview-function |
0 | 176 dcfsnz menupos,F |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
177 bra divemode_toggle_brightness ; Toggle OLED-Brightness |
0 | 178 dcfsnz menupos,F |
179 bra timeout_divemenu2 ; Quit divemode menu | |
180 return | |
181 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
182 divemode_menu3: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
183 movff menupos3,temp1 ; copy |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
184 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
185 bra toggle_stopwatch ; Toggle Stopwatch/Average register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
186 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
187 bra set_marker ; Set Marker |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
188 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
189 bra divemode_menu3_nothing ; clock... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
190 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
191 bra divemode_menu3_nothing ; leading tissue... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
192 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
193 divemode_menu3_nothing: |
0 | 194 bra timeout_divemenu2 ; Quit divemode menu |
195 return | |
196 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
197 set_marker: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
198 movlw d'6' ; Type of Alarm (Manual Marker) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
199 movwf AlarmType ; Copy to Alarm Register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
200 bsf event_occured ; Set Event Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
201 bra timeout_divemenu2 ; quit menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
202 |
0 | 203 toggle_stopwatch: |
204 btg stopwatch_active ; Toggle Flag | |
205 | |
206 btfss stopwatch_active ; Show Stopwatch? | |
207 bra toggle_stopwatch2 ; No, remove outputs | |
208 | |
209 clrf average_depth_hold+0 | |
210 clrf average_depth_hold+1 | |
211 clrf average_depth_hold+2 | |
212 clrf average_depth_hold+3 ; Clear average depth register | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
213 movlw d'3' |
0 | 214 movwf average_divesecs+0 |
215 clrf average_divesecs+1 | |
216 call calc_average_depth | |
217 bra timeout_divemenu2 ; quit menu! | |
218 | |
219 toggle_stopwatch2: | |
87 | 220 call PLED_clear_customview_divemode ; Remove Stopwatch Outputs |
0 | 221 bra timeout_divemenu2 ; quit menu! |
222 | |
223 divemode_toggle_brightness: | |
224 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
225 tstfsz EEDATA ; Was dimmed? | |
226 bra divemode_toggle_brightness1 ; Yes... | |
227 | |
228 call PLED_brightness_low | |
229 movlw d'1' | |
230 movwf EEDATA ; Copy to EEDATA | |
231 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
232 bra divemode_toggle_brightness3 | |
233 | |
234 divemode_toggle_brightness1: | |
235 call PLED_brightness_full | |
236 movlw d'0' | |
237 movwf EEDATA ; Copy to EEDATA | |
238 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
239 | |
240 divemode_toggle_brightness3: | |
241 ; Now, redraw all outputs (All modes) | |
242 call PLED_active_gas_divemode ; Display gas, if required | |
243 call PLED_temp_divemode ; Displays temperature | |
244 call PLED_depth ; Displays new depth... | |
245 call PLED_max_pressure ; ...and max. depth | |
246 | |
247 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
248 bra timeout_divemenu2 ; quit menu! | |
249 btfsc gauge_mode ; Ignore in Gauge mode | |
250 bra timeout_divemenu2 ; quit menu! | |
251 | |
252 ; Redraw Outputs in Deco modes | |
253 btfsc dekostop_active | |
254 call PLED_display_deko_mask ; clear nostop time, display decodata | |
255 btfss dekostop_active | |
256 call PLED_display_ndl_mask ; Clear deco data, display nostop time | |
257 bra timeout_divemenu2 ; quit menu! | |
258 | |
259 divemode_set_xgas: ; Set the extra gas... | |
260 bsf display_set_xgas ; Set Flag | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
261 bcf display_set_gas ; Clear Flag |
0 | 262 call PLED_clear_divemode_menu ; Clear Menu |
263 | |
264 movff char_I_O2_ratio, EEDATA ; Reset Gas6 to current gas | |
265 write_int_eeprom d'24' | |
266 movff char_I_He_ratio, EEDATA | |
267 write_int_eeprom d'25' | |
268 | |
269 call PLED_divemode_set_xgas ; Show mask | |
270 | |
271 movlw d'1' | |
272 movwf menupos ; reset cursor | |
273 call PLED_divemenu_cursor ; update cursor | |
274 return | |
275 | |
276 divemode_menu_simulator: | |
277 bsf menubit ; Enter Divemode-Menu! | |
278 bcf premenu ; clear premenu flag | |
279 bcf switch_right | |
280 bcf switch_left ; Left button pressed! | |
281 bsf display_set_simulator ; Set Flag | |
282 call PLED_clear_divemode_menu ; Clear Menu | |
283 call PLED_divemode_simulator_mask; Show mask | |
284 movlw d'1' | |
285 movwf menupos ; reset cursor | |
286 call PLED_divemenu_cursor ; update cursor | |
287 return | |
288 | |
289 divemode_menu_simulator2: | |
290 dcfsnz menupos,F | |
291 bra timeout_divemenu2 ; quit underwater menu! | |
292 dcfsnz menupos,F | |
293 bra divemode_menu_simulator_p1 ; Adjust +1m | |
294 dcfsnz menupos,F | |
295 bra divemode_menu_simulator_m1 ; Adjust -1m | |
296 dcfsnz menupos,F | |
297 bra divemode_menu_simulator_p10 ; Adjust +10m | |
298 dcfsnz menupos,F | |
299 bra divemode_menu_simulator_m10 ; Adjust -10m | |
300 bra timeout_divemenu2 ; quit underwater menu! | |
301 | |
302 divemode_menu_simulator_common: | |
303 call PLED_divemode_simulator_mask ; Redraw Simualtor mask | |
304 | |
305 ; Check limits (140m and 0m) | |
306 movlw LOW d'15000' | |
307 movwf sub_a+0 | |
308 movlw HIGH d'15000' | |
309 movwf sub_a+1 | |
310 movff sim_pressure+0,sub_b+0 | |
311 movff sim_pressure+1,sub_b+1 | |
312 call sub16 ; sub_c = sub_a - sub_b | |
313 btfss neg_flag | |
314 bra divemode_menu_simulator_common2 | |
315 ; Too deep, limit to 140m | |
316 movlw LOW d'15000' | |
317 movwf sim_pressure+0 | |
318 movlw HIGH d'15000' | |
319 movwf sim_pressure+1 | |
320 return | |
321 | |
322 divemode_menu_simulator_common2: | |
323 movlw LOW d'1000' | |
324 movwf sub_a+0 | |
325 movlw HIGH d'1000' | |
326 movwf sub_a+1 | |
327 movff sim_pressure+0,sub_b+0 | |
328 movff sim_pressure+1,sub_b+1 | |
329 call sub16 ; sub_c = sub_a - sub_b | |
330 btfsc neg_flag | |
331 return | |
332 ; Too shallow, limit to 1m | |
333 movlw LOW d'1000' | |
334 movwf sim_pressure+0 | |
335 movlw HIGH d'1000' | |
336 movwf sim_pressure+1 | |
337 return | |
338 | |
339 divemode_menu_simulator_m10: | |
340 movlw LOW d'1000' | |
341 subwf sim_pressure+0,F | |
342 movlw HIGH d'1000' | |
343 subwfb sim_pressure+1,F | |
344 movlw d'5' | |
345 movwf menupos ; reset cursor | |
346 bra divemode_menu_simulator_common | |
347 | |
348 divemode_menu_simulator_p10: | |
349 movlw LOW d'1000' | |
350 addwf sim_pressure+0,F | |
351 movlw HIGH d'1000' | |
352 addwfc sim_pressure+1,F | |
353 movlw d'4' | |
354 movwf menupos ; reset cursor | |
355 bra divemode_menu_simulator_common | |
356 | |
357 divemode_menu_simulator_p1: | |
358 movlw d'100' | |
359 addwf sim_pressure+0,F | |
360 movlw d'0' | |
361 addwfc sim_pressure+1,F | |
362 movlw d'2' | |
363 movwf menupos ; reset cursor | |
364 bra divemode_menu_simulator_common | |
365 | |
366 divemode_menu_simulator_m1: | |
367 movlw d'100' | |
368 subwf sim_pressure+0,F | |
369 movlw d'0' | |
370 subwfb sim_pressure+1,F | |
371 movlw d'3' | |
372 movwf menupos ; reset cursor | |
373 bra divemode_menu_simulator_common | |
374 | |
375 divemode_set_graphs: | |
376 bsf display_set_graphs ; set flag | |
377 call PLED_clear_divemode_menu ; Clear Menu | |
378 call deco_main_calc_desaturation_time ; calculate desaturation time | |
379 movlb b'00000001' ; select ram bank 1 | |
380 call PLED_saturation_graph_divemode ; Display saturation graph | |
381 return | |
382 | |
383 divemode_set_graphs2: | |
384 bcf display_set_graphs ; clear flag | |
385 bra timeout_divemenu2 ; quit menu! | |
386 | |
387 divemenu_see_decoplan: | |
388 bsf display_see_deco ; set flag | |
64 | 389 call PLED_clear_divemode_menu ; Clear Menu |
0 | 390 |
391 read_int_eeprom d'34' | |
392 movlw d'3' | |
393 cpfsgt EEDATA ; in multi-gf mode? Z16 GF OC=4 and Z16 GF CC=5 | |
68 | 394 bra divemenu_see_decoplan1 ; No, standard ZH-L16 |
0 | 395 |
396 bsf multi_gf_display ; Yes, display the multi-gf table screen | |
64 | 397 bcf last_ceiling_gf_shown ; Clear flag |
0 | 398 |
68 | 399 ; movff char_O_deco_status,deco_status ; |
400 ; tstfsz deco_status ; deco_status=0 if decompression calculation done | |
401 ; return ; calculation not yet finished! | |
0 | 402 |
64 | 403 call PLED_decoplan_gf_page1 ; Display the new screen |
0 | 404 return |
405 | |
406 divemenu_see_decoplan1: | |
407 | |
408 movff char_O_deco_status,deco_status ; | |
409 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
410 return ; calculation not yet finished! | |
411 | |
412 call PLED_decoplan ; display the Decoplan | |
413 return | |
414 | |
415 divemenu_see_decoplan2: | |
64 | 416 btfsc multi_gf_display ; Next Page in Multi-GF Screen? |
417 bra divemenu_see_decoplan2_nextgf ; Yes! | |
418 ; No, remove outputs! | |
419 divemenu_see_decoplan2_0: | |
0 | 420 bcf display_see_deco ; clear flag |
421 bra timeout_divemenu2 ; quit menu! | |
422 | |
64 | 423 divemenu_see_decoplan2_nextgf: |
424 incf temp8,F | |
425 btfsc last_ceiling_gf_shown ; last ceiling shown? | |
426 bra divemenu_see_decoplan2_0 ; All done, clear and return | |
427 | |
428 clrf timeout_counter3 ; Clear timeout Divemode menu | |
68 | 429 bra timeout_divemenu3x ; Display next page |
64 | 430 |
0 | 431 divemenu_set_xgas2: |
432 dcfsnz menupos,F | |
433 bra divemenu_set_xgas2_exit ; Use the gas6 configured and exit | |
434 dcfsnz menupos,F | |
435 bra divemenu_set_xgas2_o2plus ; Adjust O2+ | |
436 dcfsnz menupos,F | |
437 bra divemenu_set_xgas2_o2minus ; Adjust O2- | |
438 dcfsnz menupos,F | |
439 bra divemenu_set_xgas2_heplus ; Adjust He+ | |
440 dcfsnz menupos,F | |
441 bra divemenu_set_xgas2_heminus ; Adjust He- | |
442 return | |
443 | |
444 divemenu_set_xgas2_heminus: | |
445 read_int_eeprom d'25' ; He value | |
446 movff EEDATA,lo | |
447 decf lo,F ; decrease He | |
448 movlw d'255' | |
449 cpfseq lo | |
450 bra divemenu_set_xgas2_heminus2 | |
451 incf lo,F ; limit to min=0 | |
452 divemenu_set_xgas2_heminus2: | |
453 movff lo, EEDATA | |
454 write_int_eeprom d'25' ; He Value | |
455 | |
456 call PLED_divemode_set_xgas ; Redraw menu | |
457 movlw d'5' | |
458 movwf menupos ; reset cursor | |
459 return | |
460 | |
461 divemenu_set_xgas2_heplus: | |
462 read_int_eeprom d'25' ; He value | |
463 movff EEDATA,lo | |
464 incf lo,F ; increase He | |
465 movlw d'101' | |
466 cpfseq lo | |
467 bra divemenu_set_xgas2_heplus2 | |
468 movlw d'4' ; O2 Limit | |
469 movwf lo | |
470 divemenu_set_xgas2_heplus2: ; test if O2+He>100... | |
471 read_int_eeprom d'24' ; O2 value | |
472 movf EEDATA,W | |
473 addwf lo,W ; add He value | |
474 movwf hi ; store in temp | |
475 movlw d'101' | |
476 cpfseq hi ; O2 and He > 100? | |
477 bra divemenu_set_xgas2_heplus3 ; No! | |
478 decf lo,F ; reduce He again = unchanged after operation | |
479 divemenu_set_xgas2_heplus3: ; save current value | |
480 movff lo, EEDATA | |
481 write_int_eeprom d'25' ; He Value | |
482 | |
483 call PLED_divemode_set_xgas ; Redraw menu | |
484 movlw d'4' | |
485 movwf menupos ; reset cursor | |
486 return | |
487 | |
488 divemenu_set_xgas2_o2minus: | |
489 read_int_eeprom d'24' ; O2 value | |
490 movff EEDATA,lo | |
491 decf lo,F ; decrease O2 | |
492 movlw d'3' ; Limit-1 | |
493 cpfseq lo | |
494 bra divemenu_set_xgas2_o2minus2 | |
495 incf lo,F ; limit to min=9 | |
496 divemenu_set_xgas2_o2minus2: | |
497 movff lo, EEDATA | |
498 write_int_eeprom d'24' ; O2 Value | |
499 | |
500 call PLED_divemode_set_xgas ; Redraw menu | |
501 movlw d'3' | |
502 movwf menupos ; reset cursor | |
503 return | |
504 | |
505 divemenu_set_xgas2_o2plus: | |
506 read_int_eeprom d'24' ; O2 value | |
507 movff EEDATA,lo | |
508 incf lo,F ; increase O2 | |
509 movlw d'101' | |
510 cpfseq lo | |
511 bra divemenu_set_xgas2_o2plus2 | |
512 movlw d'5' ; O2 limit | |
513 movwf lo | |
514 divemenu_set_xgas2_o2plus2: ; test if O2+He>100... | |
515 read_int_eeprom d'25' ; He value | |
516 movf EEDATA,W | |
517 addwf lo,W ; add O2 value | |
518 movwf hi ; store in temp | |
519 movlw d'101' | |
520 cpfseq hi ; O2 and He > 100? | |
521 bra divemenu_set_xgas2_o2plus3 ; No! | |
522 decf lo,F ; reduce O2 again = unchanged after operation | |
523 divemenu_set_xgas2_o2plus3: ; save current value | |
524 movff lo, EEDATA | |
525 write_int_eeprom d'24' ; O2 Value | |
526 | |
527 call PLED_divemode_set_xgas ; Redraw menu | |
528 movlw d'2' | |
529 movwf menupos ; reset cursor | |
530 return | |
531 | |
532 divemenu_set_xgas2_exit: | |
533 read_int_eeprom d'25' ; Read He ratio | |
534 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
535 | |
536 read_int_eeprom d'24' ; Read O2 ratio | |
537 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
538 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
539 bsf STATUS,C ; | |
540 movlw d'100' ; 100% | |
541 subfwb wait_temp,W ; minus He | |
542 subfwb EEDATA,F ; minus O2 | |
543 movff EEDATA, char_I_N2_ratio ; = N2! | |
544 bsf manual_gas_changed ; set event flag | |
545 bsf event_occured ; set global event flag | |
99 | 546 bsf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
547 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
548 movff lo,char_I_const_ppO2 |
0 | 549 bra timeout_divemenu2 ; quit underwater menu! |
550 | |
551 divemenu_set_gas: | |
552 btfsc FLAG_const_ppO2_mode ; in ppO2 mode? | |
17 | 553 bra divemenu_set_setpoint ; Yes, display SetPoint list |
0 | 554 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
555 divemenu_set_gas_2: |
0 | 556 bsf display_set_gas ; set flag |
557 call PLED_clear_divemode_menu ; Clear Menu | |
558 call PLED_gas_list ; Display all 5 gases | |
559 movlw d'1' | |
560 movwf menupos ; reset cursor | |
561 call PLED_divemenu_cursor ; update cursor | |
562 return | |
563 | |
564 divemenu_set_setpoint: | |
565 bsf display_set_setpoint ; set flag | |
566 bsf display_set_gas ; set flag | |
567 | |
568 call PLED_clear_divemode_menu ; Clear Menu | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
569 call PLED_splist_start ; Display SetPoints |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
570 DISPLAYTEXT d'137' ; Bailout (as a sub-menu) |
0 | 571 movlw d'1' |
572 movwf menupos ; reset cursor | |
573 call PLED_divemenu_cursor ; update cursor | |
574 return | |
575 | |
576 | |
577 divemenu_set_gas2: | |
578 btfsc select_bailoutgas ; Are we in the Bailout list? | |
579 bra divemenu_set_gas2a ; Yes, choose gas | |
580 | |
581 btfss FLAG_const_ppO2_mode ; are we in ppO2 mode? | |
582 bra divemenu_set_gas2a ; no, choose gas | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
583 ; Yes, so select SP 1-3 |
3 | 584 bcf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
585 call PLED_show_ppO2_clear ; Clear ppO2 value |
3 | 586 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
587 divemenu_set_gas1: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
588 movlw d'4' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
589 cpfseq menupos ; At the "Bailout" position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
590 bra divemenu_set_gas1b ; No, select SetPoint 1-3 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
591 bsf select_bailoutgas ; Set Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
592 bcf display_set_setpoint ; Clear Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
593 bra divemenu_set_gas_2 ; Configure the extra gas / Select Bailout |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
594 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
595 divemenu_set_gas1b: |
0 | 596 movlw d'35' ; offset in memory |
597 addwf menupos,W ; add SP number 0-2 | |
598 movwf EEADR | |
599 call read_eeprom ; Read SetPoint | |
600 movff EEDATA, char_I_const_ppO2 ; Use SetPoint | |
4 | 601 movff EEDATA, ppO2_setpoint_store ; Store also in this byte... |
0 | 602 |
603 divemenu_set_gas1a: | |
604 bcf display_set_setpoint ; Clear Display Flag | |
605 bsf stored_gas_changed ; set event flag | |
606 bsf event_occured ; set global event flag | |
607 bra timeout_divemenu2 ; quit menu! | |
608 | |
609 divemenu_set_gas2a: | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
610 movlw d'6' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
611 cpfseq menupos ; At the "Gas 6.." position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
612 bra divemenu_set_gas2b ; No, select Gas1-5 (Stored in Menupos) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
613 bra divemode_set_xgas ; Configure the extra gas |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
614 divemenu_set_gas2b: |
3 | 615 bsf is_bailout ;=1: CC mode, but bailout active! |
0 | 616 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
617 movff lo,char_I_const_ppO2 | |
618 | |
619 bcf display_set_gas ; clear flag | |
620 movff menupos,active_gas ; copy into active gas register | |
621 decf menupos,W ; # of selected gas (0-4) | |
622 mullw d'4' ; times 4... | |
623 movf PRODL,W ; | |
624 addlw d'7' ; +7 = address for He ratio | |
625 movwf EEADR | |
626 call read_eeprom ; Read He ratio | |
627 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
628 | |
629 decf menupos,W ; # of selected gas (0-4) | |
630 mullw d'4' ; times 4... | |
631 movf PRODL,W ; | |
632 addlw d'6' ; +6 = address for O2 ratio | |
633 movwf EEADR | |
634 call read_eeprom ; Read O2 ratio | |
635 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
636 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
637 bsf STATUS,C ; | |
638 movlw d'100' ; 100% | |
639 subfwb wait_temp,W ; minus He | |
640 subfwb EEDATA,F ; minus O2 | |
641 movff EEDATA, char_I_N2_ratio ; = N2! | |
642 bsf stored_gas_changed ; set event flag | |
643 bsf event_occured ; set global event flag | |
644 bra timeout_divemenu2 ; quit menu! | |
645 | |
646 timeout_divemenu: | |
647 btfss menubit ; is the Dive mode menu displayed? | |
648 return ; No | |
649 | |
650 | |
651 btfsc display_set_simulator ; Is the Simulator Mask active? | |
652 bra timeout_divemenu6 ; Yes, update Simulator mask | |
653 | |
654 btfss display_see_deco ; Is the decoplan active? | |
655 bra timeout_divemenu1 ; No, skip updating the decoplan | |
656 | |
657 btfsc multi_gf_display ; display the multi-gf table screen? | |
658 bra timeout_divemenu3 ; Yes... | |
659 | |
660 movff char_O_deco_status,deco_status ; | |
66 | 661 tstfsz deco_status ; deco_status=0 if decompression calculation done |
662 bra timeout_divemenu1 ; No, skip updating the decoplan | |
0 | 663 |
66 | 664 call PLED_decoplan ; update the Decoplan |
0 | 665 |
666 timeout_divemenu1: | |
667 incf timeout_counter3,F ; increase timeout_counter3 | |
668 GETCUSTOM8 d'10' ; loads timeout_divemenu into WREG | |
669 cpfsgt timeout_counter3 ; ... longer then timeout_divemenu | |
670 return ; No! | |
671 timeout_divemenu2: ; quit divemode menu | |
66 | 672 btfss multi_gf_display ; Was the Multi-GF Table displayed? |
673 bra timeout_divemenu2a ; No, normal OLED rebuild | |
0 | 674 |
675 ; Restore some outputs | |
66 | 676 clrf temp8 ; Page 0-1 of deco list |
0 | 677 btfsc dekostop_active |
66 | 678 call PLED_display_deko_mask ; clear nostop time, display decodata |
0 | 679 btfss dekostop_active |
66 | 680 call PLED_display_ndl_mask ; Clear deco data, display nostop time |
0 | 681 |
682 timeout_divemenu2a: | |
66 | 683 bcf multi_gf_display ; Do not display the multi-gf table screen |
0 | 684 bcf menubit |
685 bcf premenu ; Yes, clear flags and menu, display dive time and mask again | |
66 | 686 call PLED_active_gas_divemode; Display gas, if required |
0 | 687 call PLED_clear_divemode_menu; Clear dive mode menu |
688 call PLED_divemode_mask ; Display mask | |
689 call PLED_divemins ; Display (new) divetime! | |
87 | 690 btfss dekostop_active |
691 call PLED_display_ndl_mask | |
692 btfsc dekostop_active | |
693 call PLED_display_deko_mask | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
694 call customview_mask ; Redraw current customview mask |
0 | 695 clrf timeout_counter3 ; Also clear timeout |
696 bcf display_see_deco ; clear all display flags | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
697 ; bcf display_see_l_tissue |
0 | 698 bcf display_set_gas |
699 bcf display_set_graphs | |
700 bcf display_set_xgas | |
701 bcf display_set_setpoint | |
702 bcf display_set_simulator | |
703 bcf switch_left ; and debounce switches | |
704 bcf switch_right | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
705 bsf lock_stopwatch_reset ; Lock the stopwatch reset for at least one second (Cleared in "calc_average_depth:") |
0 | 706 return |
707 | |
708 timeout_divemenu3: | |
64 | 709 movff char_O_deco_status,deco_status ; |
710 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
0 | 711 bra timeout_divemenu1 ; No, skip updating the decoplan |
68 | 712 timeout_divemenu3x: |
64 | 713 call PLED_decoplan_gf_page_current ; Re-Draw Current page of GF Decoplan |
0 | 714 bra timeout_divemenu1 ; Check timeout |
715 | |
716 timeout_divemenu6: | |
717 ; Update Simulator Mask | |
718 call PLED_divemode_simulator_mask; Show mask | |
719 call PLED_divemenu_cursor ; update cursor | |
720 bra timeout_divemenu1 ; Check timeout | |
721 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
722 ;timeout_divemenu7: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
723 ; ; Update Leading tissue infos |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
724 ; call PLED_show_leading_tissue ; Update infos about leading tissue |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
725 ; bra timeout_divemenu1 ; Check timeout |