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
|
|
94 DISPLAYTEXT .106 ; Gas List
|
|
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
|
|
129 movff wait_temp, EEADR ; Gas %He - Set address in internal EEPROM
|
|
130 incf EEADR,F ; Gas %He - Set address in internal EEPROM
|
|
131 call read_eeprom ; Read He value from EEPROM
|
|
132 movff EEDATA,lo ; Move EEDATA -> lo
|
|
133 movf lo,f ; Move lo -> f
|
|
134 movlw d'0' ; Move 0 -> WREG
|
|
135 cpfsgt lo ; He > 0?
|
|
136 bra menu_diluentsetup_Nx ; NO check o2
|
|
137
|
|
138 ; YES Write TX 15/55
|
|
139 call gassetup_write_Tx
|
|
140 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
|
|
141 call read_eeprom ; O2 value
|
|
142 movff EEDATA,lo
|
|
143 output_8
|
|
144 PUTC '/'
|
|
145 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM
|
|
146 call read_eeprom ; He value
|
|
147 movff EEDATA,lo
|
|
148 output_8
|
|
149 bra menu_diluentsetup_list0
|
|
150
|
|
151 ; New v1.44se
|
|
152 menu_diluentsetup_Nx:
|
|
153 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM
|
|
154 call read_eeprom ; Read O2 value from EEPROM
|
|
155 movff EEDATA,lo ; Move EEDATA -> lo
|
|
156 movf lo,f ; Move lo -> f
|
|
157 movlw d'21' ; Move 21 -> WREG
|
|
158 cpfsgt lo ; o2 > 21%
|
|
159 bra menu_diluentsetup_Air ; NO AIR
|
|
160 movlw d'100' ; Move 100 -> WREG
|
|
161 cpfslt lo ; o2 < 100%
|
|
162 bra menu_diluentsetup_O2 ; NO write O2
|
|
163
|
|
164 ; YES Write NX 32
|
|
165 call gassetup_write_Nx
|
|
166 output_8
|
|
167 bra menu_diluentsetup_list0
|
|
168
|
|
169 menu_diluentsetup_O2:
|
|
170 STRCAT TXT_O2_3
|
|
171 output_8
|
|
172 bra menu_diluentsetup_list0
|
|
173
|
|
174 menu_diluentsetup_Air:
|
|
175 cpfseq lo ; o2 = 21%
|
|
176 call menu_gassetup_Err
|
|
177
|
|
178 STRCAT TXT_AIR4
|
|
179 output_8
|
|
180 bra menu_diluentsetup_list0
|
|
181
|
|
182 menu_diluentsetup_Err:
|
|
183 STRCAT TXT_ERR4
|
|
184 output_8
|
|
185
|
|
186 menu_diluentsetup_list0:
|
|
187 call word_processor
|
|
188
|
|
189 incf decodata+0,F
|
|
190 movlw d'5'
|
|
191 cpfseq decodata+0
|
|
192 goto menu_diluentsetup_list
|
|
193
|
|
194 DISPLAYTEXT .11 ; Exit
|
|
195 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
196 call PLED_menu_cursor
|
640
|
197 clrf EEADRH
|
639
|
198
|
|
199 menu_diluentsetup_loop:
|
|
200 call check_switches_logbook
|
|
201
|
|
202 btfsc menubit3
|
|
203 bra menu_diluentsetup_list2 ; move cursor
|
|
204
|
|
205 btfsc menubit2
|
|
206 bra do_diluentsetup_list ; call gas-specific submenu
|
|
207
|
|
208 btfsc onesecupdate
|
|
209 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
|
|
210
|
|
211 bcf onesecupdate ; 1 sec. functions done
|
|
212
|
|
213 btfsc sleepmode
|
|
214 bra menu_const_ppO2
|
|
215
|
|
216 bra menu_diluentsetup_loop
|
|
217
|
|
218 menu_diluentsetup_list2:
|
|
219 incf menupos,F
|
|
220 movlw d'7'
|
|
221 cpfseq menupos ; =7?
|
|
222 bra menu_diluentsetup_list3 ; No
|
|
223 movlw d'1'
|
|
224 movwf menupos
|
|
225
|
|
226 menu_diluentsetup_list3:
|
|
227 clrf timeout_counter2
|
|
228 call PLED_menu_cursor
|
|
229
|
|
230 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
231
|
|
232 bcf menubit3 ; clear flag
|
|
233 bra menu_diluentsetup_loop
|
|
234
|
|
235
|
|
236 do_diluentsetup_list:
|
|
237 dcfsnz menupos,F
|
|
238 bra diluent_list_edit_gas1
|
|
239 dcfsnz menupos,F
|
|
240 bra diluent_list_edit_gas1
|
|
241 dcfsnz menupos,F
|
|
242 bra diluent_list_edit_gas1
|
|
243 dcfsnz menupos,F
|
|
244 bra diluent_list_edit_gas1
|
|
245 dcfsnz menupos,F
|
|
246 bra diluent_list_edit_gas1
|
|
247 bra menu_const_ppO2 ; Exit List
|
|
248
|
|
249 diluent_list_edit_gas1:
|
|
250 diluent_list_edit_gas2:
|
|
251 diluent_list_edit_gas3:
|
|
252 diluent_list_edit_gas4:
|
|
253 diluent_list_edit_gas5:
|
|
254 bra menu_const_ppO2 ; Exit List
|
|
255
|
|
256 ; ***
|
|
257
|
|
258
|
|
259
|
|
260
|
|
261
|
|
262
|
|
263
|
|
264 menu_const_ppO2_setpoints: ; Setpoint menu
|
|
265 movlw d'1'
|
|
266 movwf menupos
|
0
|
267
|
|
268 bcf menubit4
|
|
269 clrf decodata+0 ; Here: # of SP
|
|
270 bcf first_FA ; Here: =1: -, =0: +
|
|
271 bcf second_FA ; Here: =1: 1, =0: 10 steps
|
|
272
|
|
273 menu_const_ppO20:
|
|
274 call PLED_ClearScreen
|
|
275 call PLED_topline_box
|
|
276
|
|
277 WIN_INVERT .1 ; Init new Wordprocessor
|
|
278 DISPLAYTEXT .111 ; Constant ppO2 Setup
|
|
279 WIN_INVERT .0 ; Init new Wordprocessor
|
|
280
|
|
281
|
|
282 menu_const_ppO21:
|
|
283 WIN_LEFT .20
|
|
284 WIN_TOP .35
|
|
285 lfsr FSR2,letter
|
|
286 OUTPUTTEXT .112 ; SP#
|
|
287 movff decodata+0,lo
|
|
288 incf lo,F
|
|
289 bsf leftbind
|
|
290 output_99
|
123
|
291 STRCAT " ("
|
0
|
292
|
|
293 OUTPUTTEXT d'192' ; Dil.
|
123
|
294 PUTC ' '
|
0
|
295
|
640
|
296 movlw .1
|
|
297 movwf EEADRH
|
|
298 addlw d'96' ; = address for O2 ratio
|
0
|
299 movwf EEADR
|
|
300 call read_eeprom ; Read O2 ratio
|
640
|
301 movff EEDATA, lo ; O2 ratio
|
0
|
302 bsf leftbind
|
|
303 output_99
|
123
|
304 PUTC '/'
|
640
|
305 addlw d'97' ; = address for He ratio
|
0
|
306 movwf EEADR
|
|
307 call read_eeprom ; Read He ratio
|
640
|
308 movff EEDATA,lo ; And copy into hold register
|
|
309 clrf EEADRH
|
0
|
310 bsf leftbind
|
|
311 output_99
|
123
|
312 STRCAT_PRINT ")"
|
0
|
313
|
|
314
|
|
315 WIN_LEFT .20
|
|
316 WIN_TOP .65
|
|
317
|
|
318 lfsr FSR2,letter
|
|
319 OUTPUTTEXT .97 ; "Current: "
|
|
320 movf decodata+0,W
|
|
321 addlw d'36' ; offset in eeprom
|
|
322 movwf EEADR
|
|
323 call read_eeprom ; ppO2 value
|
|
324 movff EEDATA,lo
|
|
325 clrf hi
|
|
326 bsf leftbind
|
|
327 output_16dp d'3'
|
|
328 bcf leftbind
|
445
|
329 STRCAT_PRINT TXT_BAR4
|
0
|
330
|
|
331 WIN_LEFT .20
|
|
332 WIN_TOP .95
|
|
333
|
|
334 lfsr FSR2,letter
|
|
335 OUTPUTTEXT d'190' ; ppO2 +
|
|
336 call word_processor
|
|
337
|
|
338 WIN_LEFT .20
|
|
339 WIN_TOP .125
|
|
340
|
|
341 lfsr FSR2,letter
|
|
342 OUTPUTTEXT d'191' ; ppO2 -
|
|
343 call word_processor
|
|
344
|
|
345 WIN_LEFT .20
|
|
346 WIN_TOP .155
|
|
347
|
|
348 lfsr FSR2,letter
|
|
349 OUTPUTTEXT .89 ; "Default: "
|
123
|
350 STRCAT_PRINT "1.00"
|
0
|
351
|
|
352 DISPLAYTEXT .11 ; Exit
|
|
353 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
576
|
354 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
|
0
|
355 call PLED_menu_cursor
|
|
356
|
|
357 menu_const_ppO2_loop:
|
|
358 call check_switches_logbook
|
|
359
|
|
360 btfsc menubit3
|
575
|
361 bra menu_const_ppO22 ; move cursor
|
0
|
362
|
|
363 btfsc menubit2
|
575
|
364 bra do_menu_const_ppO2 ; call submenu
|
0
|
365
|
|
366 btfsc onesecupdate
|
575
|
367 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
|
0
|
368
|
|
369 bcf onesecupdate ; 1 sec. functions done
|
|
370
|
|
371 btfsc sleepmode
|
575
|
372 bra exit_menu_const_ppO2
|
0
|
373
|
575
|
374 bra menu_const_ppO2_loop
|
0
|
375
|
|
376 menu_const_ppO22:
|
|
377 incf menupos,F
|
|
378
|
|
379 movlw d'2'
|
|
380 cpfseq menupos ; =2?
|
|
381 bra menu_const_ppO22a ; No
|
|
382 incf menupos,F ; Skip pos. 2
|
|
383
|
|
384 menu_const_ppO22a:
|
|
385 movlw d'7'
|
|
386 cpfseq menupos ; =7?
|
|
387 bra menu_const_ppO23 ; No
|
|
388 movlw d'1'
|
|
389 movwf menupos
|
|
390
|
|
391 menu_const_ppO23:
|
576
|
392 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
|
0
|
393 call PLED_menu_cursor
|
|
394 bra menu_const_ppO2_loop
|
|
395
|
|
396 do_menu_const_ppO2:
|
|
397 dcfsnz menupos,F
|
|
398 bra next_ppO2
|
|
399 dcfsnz menupos,F
|
|
400 bra change_ppo2_plus
|
|
401 dcfsnz menupos,F
|
|
402 bra change_ppo2_plus
|
|
403 dcfsnz menupos,F
|
|
404 bra change_ppo2_minus
|
|
405 dcfsnz menupos,F
|
|
406 bra change_ppo2_reset
|
|
407 movlw d'2'
|
|
408 movwf menupos
|
639
|
409 bra menu_const_ppO2_return
|
0
|
410
|
|
411 change_ppo2_plus:
|
|
412 movf decodata+0,W ; read current value
|
|
413 addlw d'36' ; offset in memory
|
|
414 movwf EEADR
|
|
415 call read_eeprom ; Low-value
|
|
416 movff EEDATA,lo
|
|
417
|
|
418 incf lo,F ; increase depth
|
|
419 movlw d'251'
|
|
420 cpfseq lo
|
|
421 bra change_ppo2_plus2
|
|
422 movlw d'250'
|
|
423 movwf lo
|
|
424 change_ppo2_plus2:
|
|
425 movff lo,EEDATA ; write result
|
|
426 call write_eeprom ; save result in EEPROM
|
|
427 movlw d'3'
|
|
428 movwf menupos
|
|
429 bra menu_const_ppO21
|
|
430
|
|
431 change_ppo2_minus:
|
|
432 movf decodata+0,W ; read current value
|
|
433 addlw d'36' ; offset in memory
|
|
434 movwf EEADR
|
|
435 call read_eeprom ; Low-value
|
|
436 movff EEDATA,lo
|
|
437
|
|
438 decf lo,F ; decrease depth
|
|
439 movlw d'255'
|
|
440 cpfseq lo
|
|
441 bra change_ppo2_minus2
|
|
442 movlw d'0'
|
|
443 movwf lo
|
|
444
|
|
445 change_ppo2_minus2:
|
|
446 movff lo,EEDATA ; write result
|
|
447 call write_eeprom ; save result in EEPROM
|
|
448
|
|
449 movlw d'4'
|
|
450 movwf menupos
|
576
|
451 bra menu_const_ppO21
|
0
|
452
|
|
453 change_ppo2_reset: ; reset to 1.00Bar
|
|
454 movf decodata+0,W ; read current value
|
|
455 addlw d'36' ; offset in memory
|
|
456 movwf EEADR
|
|
457 movlw d'100'
|
|
458 movwf EEDATA
|
|
459 call write_eeprom ; save result in EEPROM
|
|
460 movlw d'5'
|
|
461 movwf menupos
|
|
462 bra menu_const_ppO21
|
|
463
|
|
464 next_ppO2:
|
|
465 incf decodata+0,F
|
|
466 movlw d'3'
|
|
467 cpfseq decodata+0 ; =3?
|
|
468 bra next_ppO22
|
|
469 clrf decodata+0 ; yes, so reset to zero
|
|
470 next_ppO22:
|
|
471 movlw d'1'
|
|
472 movwf menupos
|
576
|
473 bra menu_const_ppO21 |