Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_ppO2.asm @ 677:683e7d821678
Set CF17 (ppo2_warning_low) low level to 0.16bar
author | heinrichsweikamp |
---|---|
date | Sun, 30 Dec 2012 20:17:31 +0100 |
parents | 8c01edcf57fc |
children | 6e456a6398e0 |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; Constant ppO2 Setup menu | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 08/04/04 | |
639 | 22 ; last updated: 120920 |
0 | 23 ; known bugs: |
24 ; ToDo: | |
639 | 25 ; |
647 | 26 ; New in 2.52 Diluents stored seperately in EEPROM Bank0 |
27 ; EEPROM BANK0 Byte96-97: | |
639 | 28 ; Diluent 1 (%O2,%He) |
647 | 29 ; EEPROM BANK0 Byte98-99: |
639 | 30 ; Diluent 2 (%O2,%He) |
647 | 31 ; EEPROM BANK0 Byte100-101: |
639 | 32 ; Diluent 3 (%O2,%He) |
647 | 33 ; EEPROM BANK0 Byte102-103: |
639 | 34 ; Diluent 4 (%O2,%He) |
647 | 35 ; EEPROM BANK0 Byte104-105: |
639 | 36 ; Diluent 5 (%O2,%He) |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
37 ; EEPROM BANK0 Byte106: |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
38 ; First Diluent (1-5) |
639 | 39 |
0 | 40 |
41 menu_const_ppO2: | |
42 movlw d'1' | |
43 movwf menupos | |
639 | 44 menu_const_ppO2_return: |
45 call PLED_ClearScreen | |
46 call PLED_ccr_setup_menu_mask | |
47 call refresh_cursor | |
48 call menu_pre_loop_common | |
49 | |
50 menu_const_ppO2_preloop: | |
51 call check_switches_menu | |
52 movlw d'3' | |
53 cpfseq menupos | |
54 bra menu_const_ppO2_preloop2 ; Returns | |
55 movlw d'6' | |
56 movwf menupos | |
57 call PLED_menu_cursor | |
58 | |
59 menu_const_ppO2_preloop2: | |
60 btfsc menubit2 | |
61 bra do_ccr_pre_menu ; call submenu | |
62 btfss menubit | |
63 goto restart ; exit menu, restart | |
64 btfsc onesecupdate | |
65 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag | |
66 bcf onesecupdate ; End of one second tasks | |
67 btfsc sleepmode | |
68 goto restart | |
69 bra menu_const_ppO2_preloop | |
70 | |
71 do_ccr_pre_menu: | |
72 dcfsnz menupos,F | |
73 goto menu_diluentsetup | |
74 dcfsnz menupos,F | |
75 goto menu_const_ppO2_setpoints | |
76 dcfsnz menupos,F | |
77 goto exit_menu_const_ppO2 ; exit... | |
78 dcfsnz menupos,F | |
79 goto exit_menu_const_ppO2 ; exit... | |
80 dcfsnz menupos,F | |
81 goto exit_menu_const_ppO2 ; exit... | |
82 exit_menu_const_ppO2: ; exit... | |
83 movlw d'2' | |
84 movwf menupos | |
85 goto more_menu2 | |
86 | |
87 menu_diluentsetup: | |
88 movlw d'1' | |
89 movwf menupos | |
90 | |
91 menu_diluentsetup_prelist: | |
92 call PLED_ClearScreen | |
93 call menu_pre_loop_common ; Clear some menu flags, timeout and switches | |
94 call PLED_topline_box | |
95 WIN_INVERT .1 ; Init new Wordprocessor | |
642 | 96 DISPLAYTEXT .231 ; Dil. Setup - Gaslist |
639 | 97 WIN_INVERT .0 ; Init new Wordprocessor |
98 clrf decodata+0 ; Here: # of gas 0-4 | |
99 clrf divemins+0 ; Here: # of Gas * 4 | |
100 movlw d'5' | |
101 movwf waitms_temp ; here: stores row for gas list | |
102 movlw d'94' | |
103 movwf wait_temp ; here: stores eeprom address for gas list | |
104 | |
105 menu_diluentsetup_list: | |
106 WIN_LEFT .20 | |
107 movlw d'2' | |
108 addwf wait_temp,F ; Increase eeprom address for gas list | |
109 movlw d'30' | |
110 addwf waitms_temp,F ; Increase row | |
111 movf waitms_temp,W ; Load row into WREG | |
112 movff WREG,win_top | |
113 lfsr FSR2,letter | |
640 | 114 PUTC TXT_DIL_C |
639 | 115 movff decodata+0,lo |
116 incf lo,F | |
117 bsf leftbind | |
118 output_99 | |
119 PUTC ':' | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
120 call word_processor |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
121 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
122 WIN_LEFT .40 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
123 movf waitms_temp,W ; Load row into WREG |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
124 movff WREG,win_top |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
125 lfsr FSR2,letter |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
126 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
127 movlw d'106' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
128 movwf EEADR |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
129 call read_eeprom ; Get current startgas 1-5 # into EEDATA |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
130 decf EEDATA,W ; 0-4 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
131 cpfseq decodata+0 ; =current displayed gas #? |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
132 bra menu_diluentsetup_Tx; no, do not display * |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
133 PUTC '*' ; display * |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
134 call word_processor |
639 | 135 |
136 menu_diluentsetup_Tx: | |
137 WIN_LEFT .48 | |
138 movf waitms_temp,W ; Load row into WREG | |
139 movff WREG,win_top | |
140 lfsr FSR2,letter | |
141 | |
642 | 142 incf wait_temp, W ; Gas %O2 |
143 movwf EEADR ; Gas %He - Set address in internal EEPROM | |
639 | 144 call read_eeprom ; Read He value from EEPROM |
145 movff EEDATA,lo ; Move EEDATA -> lo | |
146 movf lo,f ; Move lo -> f | |
147 movlw d'0' ; Move 0 -> WREG | |
148 cpfsgt lo ; He > 0? | |
149 bra menu_diluentsetup_Nx ; NO check o2 | |
150 | |
151 ; YES Write TX 15/55 | |
642 | 152 STRCAT TXT_TX3 |
639 | 153 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM |
154 call read_eeprom ; O2 value | |
155 movff EEDATA,lo | |
156 output_8 | |
157 PUTC '/' | |
158 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM | |
159 call read_eeprom ; He value | |
160 movff EEDATA,lo | |
161 output_8 | |
162 bra menu_diluentsetup_list0 | |
163 | |
164 ; New v1.44se | |
165 menu_diluentsetup_Nx: | |
166 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM | |
167 call read_eeprom ; Read O2 value from EEPROM | |
168 movff EEDATA,lo ; Move EEDATA -> lo | |
169 movf lo,f ; Move lo -> f | |
170 movlw d'21' ; Move 21 -> WREG | |
171 cpfsgt lo ; o2 > 21% | |
172 bra menu_diluentsetup_Air ; NO AIR | |
173 movlw d'100' ; Move 100 -> WREG | |
174 cpfslt lo ; o2 < 100% | |
175 bra menu_diluentsetup_O2 ; NO write O2 | |
176 | |
177 ; YES Write NX 32 | |
642 | 178 STRCAT TXT_NX3 |
639 | 179 output_8 |
180 bra menu_diluentsetup_list0 | |
181 | |
182 menu_diluentsetup_O2: | |
183 STRCAT TXT_O2_3 | |
184 output_8 | |
185 bra menu_diluentsetup_list0 | |
186 | |
187 menu_diluentsetup_Air: | |
188 cpfseq lo ; o2 = 21% | |
642 | 189 bra menu_diluentsetup_Err |
639 | 190 |
191 STRCAT TXT_AIR4 | |
192 output_8 | |
193 bra menu_diluentsetup_list0 | |
194 | |
195 menu_diluentsetup_Err: | |
196 STRCAT TXT_ERR4 | |
197 output_8 | |
198 | |
199 menu_diluentsetup_list0: | |
200 call word_processor | |
201 | |
202 incf decodata+0,F | |
203 movlw d'5' | |
204 cpfseq decodata+0 | |
205 goto menu_diluentsetup_list | |
206 | |
207 DISPLAYTEXT .11 ; Exit | |
208 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
209 call PLED_menu_cursor | |
210 | |
211 menu_diluentsetup_loop: | |
212 call check_switches_logbook | |
213 | |
214 btfsc menubit3 | |
215 bra menu_diluentsetup_list2 ; move cursor | |
216 | |
217 btfsc menubit2 | |
218 bra do_diluentsetup_list ; call gas-specific submenu | |
219 | |
220 btfsc onesecupdate | |
221 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag | |
222 | |
223 bcf onesecupdate ; 1 sec. functions done | |
224 | |
225 btfsc sleepmode | |
226 bra menu_const_ppO2 | |
227 | |
228 bra menu_diluentsetup_loop | |
229 | |
230 menu_diluentsetup_list2: | |
231 incf menupos,F | |
232 movlw d'7' | |
233 cpfseq menupos ; =7? | |
234 bra menu_diluentsetup_list3 ; No | |
235 movlw d'1' | |
236 movwf menupos | |
237 | |
238 menu_diluentsetup_list3: | |
239 clrf timeout_counter2 | |
240 call PLED_menu_cursor | |
241 | |
242 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
243 | |
244 bcf menubit3 ; clear flag | |
245 bra menu_diluentsetup_loop | |
246 | |
247 | |
248 do_diluentsetup_list: | |
249 dcfsnz menupos,F | |
250 bra diluent_list_edit_gas1 | |
251 dcfsnz menupos,F | |
642 | 252 bra diluent_list_edit_gas2 |
639 | 253 dcfsnz menupos,F |
642 | 254 bra diluent_list_edit_gas3 |
639 | 255 dcfsnz menupos,F |
642 | 256 bra diluent_list_edit_gas4 |
639 | 257 dcfsnz menupos,F |
642 | 258 bra diluent_list_edit_gas5 |
639 | 259 bra menu_const_ppO2 ; Exit List |
260 | |
261 diluent_list_edit_gas1: | |
642 | 262 movlw d'0' ; Diluent Number 0-4 |
263 movwf decodata+0 | |
264 movlw d'96' ; EEPROM address of %O2 | |
265 movwf divemins+0 | |
266 bra menu_diluentgas | |
639 | 267 diluent_list_edit_gas2: |
642 | 268 movlw d'1' ; Diluent Number 0-4 |
269 movwf decodata+0 | |
270 movlw d'98' ; EEPROM address of %O2 | |
271 movwf divemins+0 | |
272 bra menu_diluentgas | |
639 | 273 diluent_list_edit_gas3: |
642 | 274 movlw d'2' ; Diluent Number 0-4 |
275 movwf decodata+0 | |
276 movlw d'100' ; EEPROM address of %O2 | |
277 movwf divemins+0 | |
278 bra menu_diluentgas | |
639 | 279 diluent_list_edit_gas4: |
642 | 280 movlw d'3' ; Diluent Number 0-4 |
281 movwf decodata+0 | |
282 movlw d'102' ; EEPROM address of %O2 | |
283 movwf divemins+0 | |
284 bra menu_diluentgas | |
639 | 285 diluent_list_edit_gas5: |
642 | 286 movlw d'4' ; Diluent Number 0-4 |
287 movwf decodata+0 | |
288 movlw d'104' ; EEPROM address of %O2 | |
289 movwf divemins+0 | |
290 ; bra menu_diluentgas | |
291 menu_diluentgas: | |
292 movlw d'1' | |
293 movwf menupos | |
294 bcf menubit4 | |
295 bcf first_FA ; Here: =1: -, =0: + | |
296 | |
297 menu_diluentgas0: | |
298 call PLED_ClearScreen | |
299 WIN_LEFT .20 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
300 WIN_TOP .185 |
642 | 301 lfsr FSR2, letter |
302 OUTPUTTEXT .11 ; Exit | |
303 STRCAT_PRINT "" | |
304 | |
305 menu_diluentgas1: | |
306 call menu_pre_loop_common ; Clear some menu flags, timeout and switches | |
307 call diluent_title_bar2 ; Displays the title bar with the current Gas info | |
308 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
309 WIN_TOP .35 |
642 | 310 WIN_LEFT .20 |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
311 lfsr FSR2,letter |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
312 OUTPUTTEXT .88 ; First Gas? |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
313 PUTC ' ' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
314 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
315 movlw d'106' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
316 movwf EEADR |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
317 call read_eeprom ; Get current startgas 1-5 # into EEDATA |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
318 decf EEDATA,W ; 0-4 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
319 cpfseq decodata+0 ; =current displayed gas #? |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
320 bra menu_firstdil0 ; no, display three spaces |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
321 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
322 OUTPUTTEXT .96 ; Yes |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
323 bsf second_FA ; Is first gas |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
324 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
325 bra menu_firstdil1 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
326 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
327 menu_firstdil0: |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
328 bcf second_FA ; Is not first gas |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
329 STRCAT " " ; 3 spaces. |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
330 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
331 menu_firstdil1: |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
332 call word_processor |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
333 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
334 WIN_LEFT .20 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
335 WIN_TOP .65 |
642 | 336 STRCPY TXT_O2_4 |
337 movff divemins+0,EEADR | |
338 call read_eeprom ; O2 value | |
339 movff EEDATA,lo | |
340 output_8 | |
341 STRCAT_PRINT "% " | |
342 | |
343 ; Show MOD in m | |
344 WIN_LEFT .90 | |
345 lfsr FSR2, letter | |
346 OUTPUTTEXTH .297 ; MOD: | |
347 | |
348 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
349 mullw d'10' | |
350 movff PRODL,xA+0 | |
351 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10 | |
352 movff divemins+0,EEADR | |
353 call read_eeprom ; O2 value | |
354 movff EEDATA,xB+0 | |
355 clrf xB+1 | |
356 call div16x16 ; xA/xB=xC with xA as remainder | |
357 movlw d'10' | |
358 subwf xC+0,F ; Subtract 10m... | |
359 movff xC+0,lo | |
360 movlw d'0' | |
361 subwfb xC+1,F | |
362 movff xC+1,hi | |
363 | |
364 output_16 | |
365 STRCAT_PRINT TXT_METER3 | |
366 | |
367 WIN_LEFT .20 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
368 WIN_TOP .95 |
642 | 369 STRCPY TXT_HE4 |
370 incf divemins+0,W | |
371 movwf EEADR | |
372 call read_eeprom ; He value | |
373 movff EEDATA,lo | |
374 output_8 | |
375 STRCAT_PRINT "% " | |
376 | |
377 ; Show END in m | |
378 lfsr FSR2, letter | |
379 WIN_LEFT .90 | |
380 OUTPUTTEXTH .298 ; END: | |
381 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
382 mullw d'10' | |
383 movff PRODL,xA+0 | |
384 movff PRODH,xA+1 ; ppO2 in [0.01bar] * 10 | |
385 movff divemins+0,EEADR | |
386 call read_eeprom ; O2 value | |
387 movff EEDATA,xB+0 | |
388 clrf xB+1 | |
389 call div16x16 ; xA/xB=xC with xA as remainder | |
390 movlw d'10' | |
391 subwf xC+0,F ; Subtract 10m... | |
392 movff xC+0,lo | |
393 movlw d'0' | |
394 subwfb xC+1,F | |
395 movff xC+1,hi ; lo:hi holding MOD in meters | |
396 movlw d'10' | |
397 addwf lo,F | |
398 movlw d'0' | |
399 addwfc hi,F ; lo:hi holding MOD+10m | |
400 | |
401 incf divemins+0,W | |
402 movwf EEADR | |
403 call read_eeprom ; He value in % -> EEDATA | |
404 movlw d'100' | |
405 movwf xA+0 | |
406 movf EEDATA,W ; He value in % -> EEDATA | |
407 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
408 clrf xA+1 | |
409 movff lo,xB+0 | |
410 movff hi,xB+1 ; Copy MOD+10 | |
411 call mult16x16 ; xA*xB=xC | |
412 movff xC+0,xA+0 | |
413 movff xC+1,xA+1 | |
414 movlw d'100' | |
415 movwf xB+0 | |
416 clrf xB+1 | |
417 call div16x16 ; xA/xB=xC with xA as remainder | |
418 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | |
419 movlw d'10' | |
420 subwf xC+0,F ; Subtract 10m... | |
421 movff xC+0,lo | |
422 movlw d'0' | |
423 subwfb xC+1,F | |
424 movff xC+1,hi | |
425 output_16 | |
426 STRCAT_PRINT TXT_METER3 | |
427 | |
428 WIN_LEFT .20 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
429 WIN_TOP .125 |
642 | 430 STRCPY "+/-: " |
431 movlw '+' | |
432 btfsc first_FA | |
433 movlw '-' | |
434 movwf POSTINC2 | |
435 call word_processor | |
436 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
437 WIN_TOP .155 |
642 | 438 lfsr FSR2,letter |
439 OUTPUTTEXT .89 ; Default: | |
440 movlw .21 | |
441 movwf lo ; Default always Air | |
442 output_8 | |
443 PUTC '/' | |
444 clrf lo ; Default He value | |
445 output_8 | |
446 STRCAT_PRINT " " | |
447 | |
448 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
449 call PLED_menu_cursor | |
450 | |
451 diluentgassetup_loop: | |
452 call check_switches_logbook | |
453 | |
454 btfsc menubit3 | |
455 bra diluentgassetup2 ; move cursor | |
456 | |
457 btfsc menubit2 | |
458 bra do_diluentgassetup ; call submenu | |
459 | |
460 btfsc onesecupdate | |
461 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag | |
462 | |
463 bcf onesecupdate ; 1 sec. functions done | |
464 | |
465 btfsc sleepmode | |
466 bra exit_menu_const_ppO2 | |
467 | |
468 bra diluentgassetup_loop | |
469 | |
470 diluentgassetup2: | |
471 incf menupos,F | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
472 movlw d'7' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
473 cpfseq menupos ; =7? |
642 | 474 bra diluentgassetup3 ; No |
475 movlw d'1' | |
476 movwf menupos | |
477 | |
478 diluentgassetup3: | |
479 clrf timeout_counter2 | |
480 call PLED_menu_cursor | |
481 | |
482 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
483 | |
484 bcf menubit3 ; clear flag | |
485 bra diluentgassetup_loop | |
486 | |
487 do_diluentgassetup: | |
488 dcfsnz menupos,F | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
489 bra make_first_diluent |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
490 dcfsnz menupos,F |
642 | 491 bra adjust_o2_diluent |
492 dcfsnz menupos,F | |
493 bra adjust_he_diluent | |
494 dcfsnz menupos,F | |
495 bra toggle_plus_minus_diluentsetup | |
496 dcfsnz menupos,F | |
497 bra restore_gas_diluent | |
498 exit_diluentgassetup: ; exit... | |
499 movff decodata+0,menupos | |
500 incf menupos,F | |
501 bra menu_diluentsetup_prelist | |
502 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
503 make_first_diluent: |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
504 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
505 incf EEDATA,F ; current gas (1-5) into EEDATA |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
506 movlw d'106' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
507 movwf EEADR |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
508 call write_eeprom ; store in internal EEPROM |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
509 movlw d'1' |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
510 movwf menupos |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
511 bra menu_diluentgas1 ; return |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
512 |
642 | 513 toggle_plus_minus_diluentsetup: |
514 btg first_FA | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
515 movlw d'4' |
642 | 516 movwf menupos |
517 bra menu_diluentgas1 ; return | |
518 | |
519 adjust_o2_diluent: | |
520 movff divemins+0,EEADR ; read current value | |
521 call read_eeprom ; Low-value | |
522 movff EEDATA,lo | |
523 | |
524 btfsc first_FA ; Minus? | |
525 bra adjust_o2_1_diluent ; yes, minus! | |
526 | |
527 incf lo,F ; increase O2 | |
528 movlw d'101' | |
529 cpfseq lo | |
530 bra adjust_o2_2_diluent | |
531 movlw d'4' ; LOWER O2 Limit | |
532 movwf lo | |
533 bra adjust_o2_2_diluent | |
534 | |
535 adjust_o2_1_diluent: | |
536 decf lo,F ; decrease O2 | |
537 movlw d'3' | |
538 cpfseq lo | |
539 bra adjust_o2_2_diluent | |
540 | |
541 incf divemins+0,W | |
542 movwf EEADR | |
543 call read_eeprom ; read He value | |
544 | |
545 movlw d'100' | |
546 movwf lo | |
547 movf EEDATA,W ; He value | |
548 subwf lo,F ; lo=100% - He% | |
549 | |
550 adjust_o2_2_diluent: ; test if O2+He>100... | |
551 incf divemins+0,W | |
552 movwf EEADR | |
553 call read_eeprom ; read He value | |
554 movf EEDATA,W ; He value | |
555 addwf lo,W ; add O2 value | |
556 movwf hi ; store in temp | |
557 movlw d'101' | |
558 cpfseq hi ; O2 and He > 100? | |
559 bra adjust_o2_3_diluent ; No! | |
560 | |
561 movlw d'4' ; LOWER O2 Limit | |
562 movwf lo | |
563 | |
564 adjust_o2_3_diluent: | |
565 movff divemins+0,EEADR ; save current value | |
566 movff lo,EEDATA | |
567 call write_eeprom ; Low-value | |
568 | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
569 movlw d'2' |
642 | 570 movwf menupos |
571 bra menu_diluentgas1 ; return | |
572 | |
573 adjust_he_diluent: | |
574 incf divemins+0,W | |
652 | 575 movwf EEADR ; read current value (He) |
642 | 576 call read_eeprom ; Low-value |
577 movff EEDATA,lo | |
578 | |
579 btfsc first_FA ; Minus? | |
580 bra adjust_he_1_diluent ; yes, minus! | |
581 | |
582 incf lo,F | |
652 | 583 movlw d'99' ; He limited to (useless) 99% |
642 | 584 cpfseq lo |
585 bra adjust_he_2_diluent | |
586 clrf lo | |
587 bra adjust_he_2_diluent | |
588 | |
589 adjust_he_1_diluent: | |
590 decf lo,F ; decrease He | |
591 movlw d'255' | |
592 cpfseq lo | |
593 bra adjust_he_2_diluent | |
652 | 594 clrf lo ; limit to zero |
642 | 595 |
652 | 596 adjust_he_2_diluent: ; test if O2+He>100... |
597 movff divemins+0,EEADR; read current O2 value | |
598 call read_eeprom ; Low-value | |
599 movf EEDATA,W | |
600 addwf lo,W ; add He value | |
642 | 601 movwf hi ; store in temp |
602 movlw d'101' | |
652 | 603 cpfseq hi ; O2 and He > 100? |
604 bra adjust_he_3_diluent ; No! | |
642 | 605 ; clrf lo ; Yes, clear He to zero |
606 decf lo,F ; reduce He again = unchanged after operation | |
607 | |
608 adjust_he_3_diluent: | |
652 | 609 incf divemins+0,W ; save current value |
642 | 610 movwf EEADR |
611 movff lo,EEDATA | |
652 | 612 call write_eeprom ; Low-value |
642 | 613 |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
614 movlw d'3' |
642 | 615 movwf menupos |
652 | 616 bra menu_diluentgas1; |
642 | 617 |
618 restore_gas_diluent: | |
619 movff divemins+0,EEADR ; save Default value (O2) | |
620 movlw .21 ; Always Air | |
621 movwf EEDATA | |
622 call write_eeprom | |
623 incf EEADR,F ; Point to He | |
624 clrf EEDATA | |
625 call write_eeprom | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
626 movlw d'5' |
642 | 627 movwf menupos |
628 bra menu_diluentgas1 | |
629 | |
630 | |
631 diluent_title_bar2: | |
632 call PLED_topline_box | |
633 WIN_INVERT .1 ; Init new Wordprocessor | |
634 WIN_TOP .2 | |
635 WIN_LEFT .30 | |
636 lfsr FSR2,letter | |
637 STRCAT TXT_DIL5 ; Dil.# | |
638 movff decodata+0,lo | |
639 incf lo,F | |
640 bsf leftbind | |
641 output_99 | |
642 STRCAT_PRINT ": " | |
643 | |
644 WIN_TOP .2 | |
645 WIN_LEFT .80 | |
646 lfsr FSR2,letter | |
647 | |
648 ;He check | |
649 incf divemins+0,W | |
650 movwf EEADR | |
651 call read_eeprom ; He value | |
652 movff EEDATA,lo ; Move EEData -> lo | |
653 movf lo,f ; Move lo -> f | |
654 movlw d'0' ; Move 0 -> WREG | |
655 cpfsgt lo ; He > 0? | |
656 bra diluent_title_bar3 ; NO check o2 | |
657 | |
658 ; YES Write TX 15/55 | |
659 STRCAT TXT_TX3 | |
660 movff divemins+0,EEADR | |
661 call read_eeprom ; O2 value | |
662 movff EEDATA,lo | |
663 output_8 ; Write O2 | |
664 PUTC '/' | |
665 incf divemins+0,W | |
666 movwf EEADR | |
667 call read_eeprom ; He value | |
668 movff EEDATA,lo | |
669 output_8 ; Write He | |
670 bra diluent_title_bar7 | |
671 | |
672 ; New v1.44se | |
673 diluent_title_bar3: ; O2 Check | |
674 movff divemins+0,EEADR | |
675 call read_eeprom ; O2 value | |
676 movff EEDATA,lo | |
677 movf lo,f ; Move lo -> f | |
678 movlw d'21' ; Move 21 -> WREG | |
679 cpfseq lo ; o2 = 21 | |
680 cpfsgt lo ; o2 > 21% | |
681 bra diluent_title_bar5 ; NO AIR | |
682 movlw d'100' ; Move 100 -> WREG | |
683 cpfslt lo ; o2 < 100% | |
684 bra diluent_title_bar4 ; NO write O2 | |
685 | |
686 ; YES Write NX 32 | |
687 STRCAT TXT_NX3 | |
688 output_8 | |
689 bra diluent_title_bar7 | |
690 | |
691 ; New v1.44se | |
692 diluent_title_bar4: | |
693 STRCAT TXT_O2_3 | |
694 output_8 | |
695 bra diluent_title_bar7 | |
696 | |
697 ; New v1.44se | |
698 diluent_title_bar5: | |
699 cpfseq lo ; o2 = 21% | |
700 bra diluent_title_bar6 | |
701 | |
702 STRCAT TXT_AIR4 | |
703 output_8 | |
704 bra diluent_title_bar7 | |
705 | |
706 ; New v1.44se | |
707 diluent_title_bar6: ; ERROR | |
708 STRCAT TXT_ERR4 | |
709 output_8 | |
710 ;bra diluent_title_bar7 | |
711 | |
712 diluent_title_bar7: | |
713 STRCAT_PRINT "" | |
714 WIN_INVERT .0 ; Init new Wordprocessor | |
715 return | |
716 | |
639 | 717 |
718 ; *** | |
719 | |
720 | |
721 | |
722 | |
723 | |
724 | |
725 | |
726 menu_const_ppO2_setpoints: ; Setpoint menu | |
727 movlw d'1' | |
728 movwf menupos | |
0 | 729 |
730 bcf menubit4 | |
731 clrf decodata+0 ; Here: # of SP | |
732 bcf first_FA ; Here: =1: -, =0: + | |
733 bcf second_FA ; Here: =1: 1, =0: 10 steps | |
734 | |
735 menu_const_ppO20: | |
736 call PLED_ClearScreen | |
737 call PLED_topline_box | |
738 | |
739 WIN_INVERT .1 ; Init new Wordprocessor | |
740 DISPLAYTEXT .111 ; Constant ppO2 Setup | |
741 WIN_INVERT .0 ; Init new Wordprocessor | |
742 | |
743 | |
744 menu_const_ppO21: | |
745 WIN_LEFT .20 | |
746 WIN_TOP .35 | |
747 lfsr FSR2,letter | |
748 OUTPUTTEXT .112 ; SP# | |
749 movff decodata+0,lo | |
750 incf lo,F | |
751 bsf leftbind | |
752 output_99 | |
123 | 753 STRCAT " (" |
0 | 754 |
755 OUTPUTTEXT d'192' ; Dil. | |
123 | 756 PUTC ' ' |
0 | 757 |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
758 rcall get_first_diluent ; Read first diluent into lo(O2) and hi(He) |
0 | 759 bsf leftbind |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
760 output_99 ; O2 |
123 | 761 PUTC '/' |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
762 movff hi,lo |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
763 output_99 ; He |
123 | 764 STRCAT_PRINT ")" |
0 | 765 |
766 WIN_LEFT .20 | |
767 WIN_TOP .65 | |
768 | |
769 lfsr FSR2,letter | |
770 OUTPUTTEXT .97 ; "Current: " | |
771 movf decodata+0,W | |
772 addlw d'36' ; offset in eeprom | |
773 movwf EEADR | |
774 call read_eeprom ; ppO2 value | |
775 movff EEDATA,lo | |
776 clrf hi | |
777 bsf leftbind | |
778 output_16dp d'3' | |
779 bcf leftbind | |
445 | 780 STRCAT_PRINT TXT_BAR4 |
0 | 781 |
782 WIN_LEFT .20 | |
783 WIN_TOP .95 | |
784 | |
785 lfsr FSR2,letter | |
786 OUTPUTTEXT d'190' ; ppO2 + | |
787 call word_processor | |
788 | |
789 WIN_LEFT .20 | |
790 WIN_TOP .125 | |
791 | |
792 lfsr FSR2,letter | |
793 OUTPUTTEXT d'191' ; ppO2 - | |
794 call word_processor | |
795 | |
796 WIN_LEFT .20 | |
797 WIN_TOP .155 | |
798 | |
799 lfsr FSR2,letter | |
800 OUTPUTTEXT .89 ; "Default: " | |
123 | 801 STRCAT_PRINT "1.00" |
0 | 802 |
803 DISPLAYTEXT .11 ; Exit | |
804 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
576 | 805 call menu_pre_loop_common ; Clear some menu flags, timeout and switches |
0 | 806 call PLED_menu_cursor |
807 | |
808 menu_const_ppO2_loop: | |
809 call check_switches_logbook | |
810 | |
811 btfsc menubit3 | |
575 | 812 bra menu_const_ppO22 ; move cursor |
0 | 813 |
814 btfsc menubit2 | |
575 | 815 bra do_menu_const_ppO2 ; call submenu |
0 | 816 |
817 btfsc onesecupdate | |
575 | 818 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag |
0 | 819 |
820 bcf onesecupdate ; 1 sec. functions done | |
821 | |
822 btfsc sleepmode | |
575 | 823 bra exit_menu_const_ppO2 |
0 | 824 |
575 | 825 bra menu_const_ppO2_loop |
0 | 826 |
827 menu_const_ppO22: | |
828 incf menupos,F | |
829 | |
830 movlw d'2' | |
831 cpfseq menupos ; =2? | |
832 bra menu_const_ppO22a ; No | |
833 incf menupos,F ; Skip pos. 2 | |
834 | |
835 menu_const_ppO22a: | |
836 movlw d'7' | |
837 cpfseq menupos ; =7? | |
838 bra menu_const_ppO23 ; No | |
839 movlw d'1' | |
840 movwf menupos | |
841 | |
842 menu_const_ppO23: | |
576 | 843 call menu_pre_loop_common ; Clear some menu flags, timeout and switches |
0 | 844 call PLED_menu_cursor |
845 bra menu_const_ppO2_loop | |
846 | |
847 do_menu_const_ppO2: | |
848 dcfsnz menupos,F | |
849 bra next_ppO2 | |
850 dcfsnz menupos,F | |
851 bra change_ppo2_plus | |
852 dcfsnz menupos,F | |
853 bra change_ppo2_plus | |
854 dcfsnz menupos,F | |
855 bra change_ppo2_minus | |
856 dcfsnz menupos,F | |
857 bra change_ppo2_reset | |
858 movlw d'2' | |
859 movwf menupos | |
639 | 860 bra menu_const_ppO2_return |
0 | 861 |
862 change_ppo2_plus: | |
863 movf decodata+0,W ; read current value | |
864 addlw d'36' ; offset in memory | |
865 movwf EEADR | |
866 call read_eeprom ; Low-value | |
867 movff EEDATA,lo | |
868 | |
869 incf lo,F ; increase depth | |
870 movlw d'251' | |
871 cpfseq lo | |
872 bra change_ppo2_plus2 | |
873 movlw d'250' | |
874 movwf lo | |
875 change_ppo2_plus2: | |
876 movff lo,EEDATA ; write result | |
877 call write_eeprom ; save result in EEPROM | |
878 movlw d'3' | |
879 movwf menupos | |
880 bra menu_const_ppO21 | |
881 | |
882 change_ppo2_minus: | |
883 movf decodata+0,W ; read current value | |
884 addlw d'36' ; offset in memory | |
885 movwf EEADR | |
886 call read_eeprom ; Low-value | |
887 movff EEDATA,lo | |
888 | |
889 decf lo,F ; decrease depth | |
890 movlw d'255' | |
891 cpfseq lo | |
892 bra change_ppo2_minus2 | |
893 movlw d'0' | |
894 movwf lo | |
895 | |
896 change_ppo2_minus2: | |
897 movff lo,EEDATA ; write result | |
898 call write_eeprom ; save result in EEPROM | |
899 | |
900 movlw d'4' | |
901 movwf menupos | |
576 | 902 bra menu_const_ppO21 |
0 | 903 |
904 change_ppo2_reset: ; reset to 1.00Bar | |
905 movf decodata+0,W ; read current value | |
906 addlw d'36' ; offset in memory | |
907 movwf EEADR | |
908 movlw d'100' | |
909 movwf EEDATA | |
910 call write_eeprom ; save result in EEPROM | |
911 movlw d'5' | |
912 movwf menupos | |
913 bra menu_const_ppO21 | |
914 | |
915 next_ppO2: | |
916 incf decodata+0,F | |
917 movlw d'3' | |
918 cpfseq decodata+0 ; =3? | |
919 bra next_ppO22 | |
920 clrf decodata+0 ; yes, so reset to zero | |
921 next_ppO22: | |
922 movlw d'1' | |
923 movwf menupos | |
655
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
924 bra menu_const_ppO21 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
925 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
926 get_first_diluent: ; Read first diluent into lo(O2) and hi(He) |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
927 read_int_eeprom d'106' ; Read First Diluent (1-5) |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
928 decf EEDATA,W ; WREG: 0-4 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
929 mullw .2 ; PRODL: 0-8 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
930 movlw .96 ; Base address for O2 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
931 addwf PRODL,W |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
932 movwf EEADR |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
933 call read_eeprom ; Read O2 |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
934 movff EEDATA,lo |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
935 incf EEADR,F |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
936 call read_eeprom ; Read He |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
937 movff EEDATA,hi |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
938 return |
8c01edcf57fc
Allow any diluent to be "First gas" in CCR modes
heinrichsweikamp
parents:
652
diff
changeset
|
939 |