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