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
|
|
114 PUTC TXT_GAS_C
|
|
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
|
|
197
|
|
198 menu_diluentsetup_loop:
|
|
199 call check_switches_logbook
|
|
200
|
|
201 btfsc menubit3
|
|
202 bra menu_diluentsetup_list2 ; move cursor
|
|
203
|
|
204 btfsc menubit2
|
|
205 bra do_diluentsetup_list ; call gas-specific submenu
|
|
206
|
|
207 btfsc onesecupdate
|
|
208 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
|
|
209
|
|
210 bcf onesecupdate ; 1 sec. functions done
|
|
211
|
|
212 btfsc sleepmode
|
|
213 bra menu_const_ppO2
|
|
214
|
|
215 bra menu_diluentsetup_loop
|
|
216
|
|
217 menu_diluentsetup_list2:
|
|
218 incf menupos,F
|
|
219 movlw d'7'
|
|
220 cpfseq menupos ; =7?
|
|
221 bra menu_diluentsetup_list3 ; No
|
|
222 movlw d'1'
|
|
223 movwf menupos
|
|
224
|
|
225 menu_diluentsetup_list3:
|
|
226 clrf timeout_counter2
|
|
227 call PLED_menu_cursor
|
|
228
|
|
229 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
230
|
|
231 bcf menubit3 ; clear flag
|
|
232 bra menu_diluentsetup_loop
|
|
233
|
|
234
|
|
235 do_diluentsetup_list:
|
|
236 dcfsnz menupos,F
|
|
237 bra diluent_list_edit_gas1
|
|
238 dcfsnz menupos,F
|
|
239 bra diluent_list_edit_gas1
|
|
240 dcfsnz menupos,F
|
|
241 bra diluent_list_edit_gas1
|
|
242 dcfsnz menupos,F
|
|
243 bra diluent_list_edit_gas1
|
|
244 dcfsnz menupos,F
|
|
245 bra diluent_list_edit_gas1
|
|
246 bra menu_const_ppO2 ; Exit List
|
|
247
|
|
248 diluent_list_edit_gas1:
|
|
249 diluent_list_edit_gas2:
|
|
250 diluent_list_edit_gas3:
|
|
251 diluent_list_edit_gas4:
|
|
252 diluent_list_edit_gas5:
|
|
253 bra menu_const_ppO2 ; Exit List
|
|
254
|
|
255 ; ***
|
|
256
|
|
257
|
|
258
|
|
259
|
|
260
|
|
261
|
|
262
|
|
263 menu_const_ppO2_setpoints: ; Setpoint menu
|
|
264 movlw d'1'
|
|
265 movwf menupos
|
0
|
266
|
|
267 bcf menubit4
|
|
268 clrf decodata+0 ; Here: # of SP
|
|
269 bcf first_FA ; Here: =1: -, =0: +
|
|
270 bcf second_FA ; Here: =1: 1, =0: 10 steps
|
|
271
|
|
272 menu_const_ppO20:
|
|
273 call PLED_ClearScreen
|
|
274 call PLED_topline_box
|
|
275
|
|
276 WIN_INVERT .1 ; Init new Wordprocessor
|
|
277 DISPLAYTEXT .111 ; Constant ppO2 Setup
|
|
278 WIN_INVERT .0 ; Init new Wordprocessor
|
|
279
|
|
280
|
|
281 menu_const_ppO21:
|
|
282 WIN_LEFT .20
|
|
283 WIN_TOP .35
|
|
284 lfsr FSR2,letter
|
|
285 OUTPUTTEXT .112 ; SP#
|
|
286 movff decodata+0,lo
|
|
287 incf lo,F
|
|
288 bsf leftbind
|
|
289 output_99
|
123
|
290 STRCAT " ("
|
0
|
291
|
|
292 OUTPUTTEXT d'192' ; Dil.
|
123
|
293 PUTC ' '
|
0
|
294
|
|
295 read_int_eeprom d'33' ; Read byte (stored in EEDATA)
|
|
296 movff EEDATA,active_gas ; Read start gas (1-5)
|
|
297
|
|
298 decf active_gas,W ; Gas 0-4
|
|
299 mullw d'4'
|
|
300 movf PRODL,W
|
|
301 addlw d'6' ; = address for O2 ratio
|
|
302 movwf EEADR
|
|
303 call read_eeprom ; Read O2 ratio
|
|
304 movff EEDATA, lo ; O2 ratio
|
|
305
|
|
306
|
|
307 bsf leftbind
|
|
308 output_99
|
|
309
|
123
|
310 PUTC '/'
|
0
|
311
|
|
312 decf active_gas,W ; Gas 0-4
|
|
313 mullw d'4'
|
|
314 movf PRODL,W
|
|
315 addlw d'7' ; = address for He ratio
|
|
316 movwf EEADR
|
|
317 call read_eeprom ; Read He ratio
|
|
318 movff EEDATA,lo ; And copy into hold register
|
|
319
|
|
320 bsf leftbind
|
|
321 output_99
|
123
|
322 STRCAT_PRINT ")"
|
0
|
323
|
|
324
|
|
325 WIN_LEFT .20
|
|
326 WIN_TOP .65
|
|
327
|
|
328 lfsr FSR2,letter
|
|
329 OUTPUTTEXT .97 ; "Current: "
|
|
330 movf decodata+0,W
|
|
331 addlw d'36' ; offset in eeprom
|
|
332 movwf EEADR
|
|
333 call read_eeprom ; ppO2 value
|
|
334 movff EEDATA,lo
|
|
335 clrf hi
|
|
336 bsf leftbind
|
|
337 output_16dp d'3'
|
|
338 bcf leftbind
|
445
|
339 STRCAT_PRINT TXT_BAR4
|
0
|
340
|
|
341 WIN_LEFT .20
|
|
342 WIN_TOP .95
|
|
343
|
|
344 lfsr FSR2,letter
|
|
345 OUTPUTTEXT d'190' ; ppO2 +
|
|
346 call word_processor
|
|
347
|
|
348 WIN_LEFT .20
|
|
349 WIN_TOP .125
|
|
350
|
|
351 lfsr FSR2,letter
|
|
352 OUTPUTTEXT d'191' ; ppO2 -
|
|
353 call word_processor
|
|
354
|
|
355 WIN_LEFT .20
|
|
356 WIN_TOP .155
|
|
357
|
|
358 lfsr FSR2,letter
|
|
359 OUTPUTTEXT .89 ; "Default: "
|
123
|
360 STRCAT_PRINT "1.00"
|
0
|
361
|
|
362 DISPLAYTEXT .11 ; Exit
|
|
363 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
576
|
364 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
|
0
|
365 call PLED_menu_cursor
|
|
366
|
|
367 menu_const_ppO2_loop:
|
|
368 call check_switches_logbook
|
|
369
|
|
370 btfsc menubit3
|
575
|
371 bra menu_const_ppO22 ; move cursor
|
0
|
372
|
|
373 btfsc menubit2
|
575
|
374 bra do_menu_const_ppO2 ; call submenu
|
0
|
375
|
|
376 btfsc onesecupdate
|
575
|
377 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
|
0
|
378
|
|
379 bcf onesecupdate ; 1 sec. functions done
|
|
380
|
|
381 btfsc sleepmode
|
575
|
382 bra exit_menu_const_ppO2
|
0
|
383
|
575
|
384 bra menu_const_ppO2_loop
|
0
|
385
|
|
386 menu_const_ppO22:
|
|
387 incf menupos,F
|
|
388
|
|
389 movlw d'2'
|
|
390 cpfseq menupos ; =2?
|
|
391 bra menu_const_ppO22a ; No
|
|
392 incf menupos,F ; Skip pos. 2
|
|
393
|
|
394 menu_const_ppO22a:
|
|
395 movlw d'7'
|
|
396 cpfseq menupos ; =7?
|
|
397 bra menu_const_ppO23 ; No
|
|
398 movlw d'1'
|
|
399 movwf menupos
|
|
400
|
|
401 menu_const_ppO23:
|
576
|
402 call menu_pre_loop_common ; Clear some menu flags, timeout and switches
|
0
|
403 call PLED_menu_cursor
|
|
404 bra menu_const_ppO2_loop
|
|
405
|
|
406 do_menu_const_ppO2:
|
|
407 dcfsnz menupos,F
|
|
408 bra next_ppO2
|
|
409 dcfsnz menupos,F
|
|
410 bra change_ppo2_plus
|
|
411 dcfsnz menupos,F
|
|
412 bra change_ppo2_plus
|
|
413 dcfsnz menupos,F
|
|
414 bra change_ppo2_minus
|
|
415 dcfsnz menupos,F
|
|
416 bra change_ppo2_reset
|
|
417 movlw d'2'
|
|
418 movwf menupos
|
639
|
419 bra menu_const_ppO2_return
|
0
|
420
|
|
421 change_ppo2_plus:
|
|
422 movf decodata+0,W ; read current value
|
|
423 addlw d'36' ; offset in memory
|
|
424 movwf EEADR
|
|
425 call read_eeprom ; Low-value
|
|
426 movff EEDATA,lo
|
|
427
|
|
428 incf lo,F ; increase depth
|
|
429 movlw d'251'
|
|
430 cpfseq lo
|
|
431 bra change_ppo2_plus2
|
|
432 movlw d'250'
|
|
433 movwf lo
|
|
434 change_ppo2_plus2:
|
|
435 movff lo,EEDATA ; write result
|
|
436 call write_eeprom ; save result in EEPROM
|
|
437 movlw d'3'
|
|
438 movwf menupos
|
|
439 bra menu_const_ppO21
|
|
440
|
|
441 change_ppo2_minus:
|
|
442 movf decodata+0,W ; read current value
|
|
443 addlw d'36' ; offset in memory
|
|
444 movwf EEADR
|
|
445 call read_eeprom ; Low-value
|
|
446 movff EEDATA,lo
|
|
447
|
|
448 decf lo,F ; decrease depth
|
|
449 movlw d'255'
|
|
450 cpfseq lo
|
|
451 bra change_ppo2_minus2
|
|
452 movlw d'0'
|
|
453 movwf lo
|
|
454
|
|
455 change_ppo2_minus2:
|
|
456 movff lo,EEDATA ; write result
|
|
457 call write_eeprom ; save result in EEPROM
|
|
458
|
|
459 movlw d'4'
|
|
460 movwf menupos
|
576
|
461 bra menu_const_ppO21
|
0
|
462
|
|
463 change_ppo2_reset: ; reset to 1.00Bar
|
|
464 movf decodata+0,W ; read current value
|
|
465 addlw d'36' ; offset in memory
|
|
466 movwf EEADR
|
|
467 movlw d'100'
|
|
468 movwf EEDATA
|
|
469 call write_eeprom ; save result in EEPROM
|
|
470 movlw d'5'
|
|
471 movwf menupos
|
|
472 bra menu_const_ppO21
|
|
473
|
|
474 next_ppO2:
|
|
475 incf decodata+0,F
|
|
476 movlw d'3'
|
|
477 cpfseq decodata+0 ; =3?
|
|
478 bra next_ppO22
|
|
479 clrf decodata+0 ; yes, so reset to zero
|
|
480 next_ppO22:
|
|
481 movlw d'1'
|
|
482 movwf menupos
|
576
|
483 bra menu_const_ppO21 |