annotate src/divemode.asm @ 564:54346c651b6a

bring digital S8 HUD back to life...
author heinrichsweikamp
date Mon, 05 Feb 2018 17:59:55 +0100
parents b7eb98dbd800
children b455b31ce022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3 ; File divemode.asm REFACTORED VERSION V2.96a
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Divemode
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-15 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
12 #include "hwos.inc" ; Mandatory header
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
14 #include "tft_outputs.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
15 #include "strings.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
16 #include "tft.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
17 #include "eeprom_rs232.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
18 #include "isr.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
19 #include "math.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
20 #include "wait.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
21 #include "customview.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
22 #include "start.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
23 #include "adc_lightsensor.inc"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
24 #include "ghostwriter.inc"
0
heinrichsweikamp
parents:
diff changeset
25 #include "i2c.inc"
113
heinrichsweikamp
parents: 111
diff changeset
26 #include "calibrate.inc"
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
27 #include "convert.inc"
0
heinrichsweikamp
parents:
diff changeset
28
heinrichsweikamp
parents:
diff changeset
29 gui CODE
heinrichsweikamp
parents:
diff changeset
30
heinrichsweikamp
parents:
diff changeset
31 global diveloop
heinrichsweikamp
parents:
diff changeset
32 diveloop:
heinrichsweikamp
parents:
diff changeset
33 banksel common
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
34 call speed_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
35 call diveloop_boot ; Boot tasks for all modes
0
heinrichsweikamp
parents:
diff changeset
36
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
37 ; Startup Tasks for all modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
38 call TFT_boot ; Initialize TFT (includes clear screen)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
39 bsf FLAG_TFT_divemode_mask ; Display mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
40 movff customview_divemode,menupos3; Reload last customview
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
41 call customview_mask ; Redraw last custom view
0
heinrichsweikamp
parents:
diff changeset
42
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
43 btfsc FLAG_apnoe_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
44 bsf realdive ; Set Realdive flag in Apnoe mode
0
heinrichsweikamp
parents:
diff changeset
45
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
46 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
47 bra diveloop_loop_start
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
48 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
49 bra diveloop_loop_start
0
heinrichsweikamp
parents:
diff changeset
50
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
51 bsf FLAG_TFT_display_ndl_mask ; display "NDL"
0
heinrichsweikamp
parents:
diff changeset
52
heinrichsweikamp
parents:
diff changeset
53 ; +@5 init
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
54 clrf WREG ; WAIT marker: display "---"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
55 movff WREG,char_I_sim_advance_time; bank safe clrf
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
56 movff WREG,int_O_alternate_ascenttime+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
57 bsf WREG,int_not_yet_computed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
58 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
59 movff WREG,int_O_alternate_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
60
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
61 diveloop_loop_start:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
62 btfsc FLAG_TFT_display_ndl_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
63 call TFT_display_ndl_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
64
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
65
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
66 diveloop_loop: ; The diveloop starts here
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
67 btfss quarter_second_update
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
68 bra diveloop_loop4a
0
heinrichsweikamp
parents:
diff changeset
69
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
70 ; tasks any 1/4 second, any mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
71 bcf quarter_second_update ; clear flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
72
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
73 movlw .6
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
74 cpfseq menupos3 ; in compass view?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
75 bra diveloop_loop4a ; No, done.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
76
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
77 btfsc alternative_divelayout ; In alternative layout mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
78 bra diveloop_loop4a ; Yes, done. No Compass.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
79
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
80 ; TFT Output routines
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
81 extern TFT_dive_compass_heading
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
82 call TFT_dive_compass_heading ; Yes, update compass heading value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
83 bsf FLAG_TFT_temp_divemode ; Redraw temperature (Is slighty affected from compass heading arrow)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
84 ; TFT Output routines
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
85
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
86 diveloop_loop4a:
0
heinrichsweikamp
parents:
diff changeset
87 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
88 bra diveloop_loop3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
89
0
heinrichsweikamp
parents:
diff changeset
90 ; tasks any new second...
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
91 bcf onesecupdate ; one seconds update, clear flag here in case it's set again in ISR before all tasks are done.
178
39f6c07ce2f6 BUGFIX: Average depth computation
heinrichsweikamp
parents: 176
diff changeset
92
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
93 ;bsf LEDg ; ### DEBUG - used to measure the time used by all deco code to see if there is enough margin each second ###
0
heinrichsweikamp
parents:
diff changeset
94
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
95 ; display depth based on full seconds interval (nicer blinking)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
96 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
97 rcall TFT_output4_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
98 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
99 rcall TFT_output4_alternative
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
100
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
101 btfsc FLAG_apnoe_mode ; Only in apnoe mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
102 bra diveloop_loop1b ; One Second Tasks in Apnoe mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
103
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
104 ; tasks any new second - only for deco modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
105 bsf FLAG_TFT_divemins ; Display (new) divetime!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
106 btfsc show_safety_stop ; Show the safety stop?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
107 bsf FLAG_TFT_show_safety_stop ; Yes, show/delete if done.
0
heinrichsweikamp
parents:
diff changeset
108
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
109 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
110 rcall TFT_output1_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
111 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
112 rcall TFT_output1_alternative
0
heinrichsweikamp
parents:
diff changeset
113
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
114 btfsc FLAG_ccr_mode ; In CCR mode...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
115 call check_dive_autosp ; ...check for Auto-SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
116
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
117 call calc_deko_divemode ; calculate decompression and set resulting display flags
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
118
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
119 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
120 rcall TFT_output2_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
121 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
122 rcall TFT_output2_alternative
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
123
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
124 call divemode_check_for_warnings ; Check for any warnings
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
125
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
126 bra diveloop_loop1x ; Common Tasks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
127
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
128
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
129 ; tasks any new second - only for apnoe mode
0
heinrichsweikamp
parents:
diff changeset
130 diveloop_loop1b:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
131 rcall divemode_apnoe_tasks ; 1 sec. Apnoe tasks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
132 call customview_second ; Do every-second tasks for the custom view area
0
heinrichsweikamp
parents:
diff changeset
133
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
134 ;bra diveloop_loop1x ; Common Tasks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
135
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
136 ; continue tasks any new second, any mode
0
heinrichsweikamp
parents:
diff changeset
137 diveloop_loop1x:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
138 rcall timeout_divemode ; ** menu timeout? ** This routine sets the required flags
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
139 rcall set_dive_modes ; tests if depth>threshold
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
140 rcall set_min_temp ; store min. temp if required (Future hardware will need this to be checked 1/second...)
0
heinrichsweikamp
parents:
diff changeset
141
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
142 btfsc oneminupdate ; one minute tasks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
143 rcall update_divemode60 ; Update clock, etc.
0
heinrichsweikamp
parents:
diff changeset
144
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
145 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
146 rcall TFT_output3_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
147 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
148 rcall TFT_output3_alternative
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
149
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
150 ;bcf LEDg ; ### DEBUG - used to measure the time used by all deco code to see if there is enough margin each second ###
0
heinrichsweikamp
parents:
diff changeset
151
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
152 ; tasks any round, any mode
0
heinrichsweikamp
parents:
diff changeset
153 diveloop_loop3:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
154 call test_switches_divemode ; Check switches in divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
155
0
heinrichsweikamp
parents:
diff changeset
156 global diveloop_loop4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
157 diveloop_loop4: ; Menu-Exit returns here...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
158 btfsc divemode_menu ; in the big divemode menu?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
159 bra diveloop_loop4b ; YES - no space for CCR/pSCR info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
160 btfsc menuview ; NO - in the small yellow menu?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
161 bra diveloop_loop4b ; YES - no space for CCR/pSCR info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
162 btfsc alternative_divelayout ; NO - in the alternative layout?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
163 bra diveloop_loop4b ; YES - no space for CCR/pSCR info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
164 call TFT_show_mode_divemode ; NO - (re)write CCR/pSCR mode info to display
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
165 diveloop_loop4b:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
166 btfsc toggle_customview ; Next view?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
167 call customview_toggle ; Yes, show next customview (and delete this flag)
0
heinrichsweikamp
parents:
diff changeset
168
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
169 btfsc store_sample ; store new sample?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
170 call store_dive_data ; Store profile data
0
heinrichsweikamp
parents:
diff changeset
171
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
172 btfss divemode ; Dive finished?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
173 goto ghostwriter_end_dive ; Dive finished!
0
heinrichsweikamp
parents:
diff changeset
174
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
175 btfsc divemode_gaschange ; Gas switch flag set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
176 call gas_switched_common ; Yes
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 69
diff changeset
177
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
178 btfsc toggle_gf ; =1: Toggle GF/aGF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
179 rcall divemodemode_togglegf ; Toggle aGF/GF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
180
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
181 btfsc pressure_refresh ; new pressure available?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
182 rcall set_max_depth ; update max. depth if required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
183 btfsc pressure_refresh ; new pressure available?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
184 bsf FLAG_TFT_depth ; Yes, update depth asap
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
185 bcf pressure_refresh ; clear flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
186
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
187 btfsc temp_changed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
188 bsf FLAG_TFT_temp_divemode ; Displays temperature
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
189
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
190 ; display depth based on as-fast-as-possible (no nice blinking)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
191 ;btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
192 ;rcall TFT_output4_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
193 ;btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
194 ;rcall TFT_output4_alternative
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
195
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
196 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
0
heinrichsweikamp
parents:
diff changeset
197 bra diveloop_loop5
heinrichsweikamp
parents:
diff changeset
198 bra diveloop_loop6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
199
0
heinrichsweikamp
parents:
diff changeset
200 diveloop_loop5:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
201 btfss vusb_in ; USB (still) plugged in?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
202 bcf enable_screen_dumps ; No, clear flag
0
heinrichsweikamp
parents:
diff changeset
203 call rs232_get_byte
heinrichsweikamp
parents:
diff changeset
204 btfsc rs232_recieve_overflow
heinrichsweikamp
parents:
diff changeset
205 bra diveloop_loop6
heinrichsweikamp
parents:
diff changeset
206 movlw "l"
heinrichsweikamp
parents:
diff changeset
207 cpfseq RCREG1
heinrichsweikamp
parents:
diff changeset
208 bra diveloop_loop6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
209 call TFT_dump_screen ; Dump the screen contents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
210
0
heinrichsweikamp
parents:
diff changeset
211 diveloop_loop6:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
212 bra diveloop_loop ; Loop the divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
213
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
214 ;--------------------------------------------------------------------------------------------------------
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
215
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
216 TFT_output1_normal: ; beginning of any new second - only for deco modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
217 btfsc FLAG_TFT_divemode_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
218 call TFT_divemode_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
219 btfsc FLAG_TFT_divemins
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
220 call TFT_divemins ; Display (new) divetime!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
221 call customview_second ; Do every-second tasks for the custom view area (In sync with the divetime) mH
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
222 btfsc FLAG_TFT_show_safety_stop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
223 call TFT_show_safety_stop ; Show safety stop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
224 btfsc FLAG_TFT_clear_safety_stop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
225 call TFT_clear_safety_stop ; Clear safety stop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
226 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
227
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
228 TFT_output1_alternative: ; beginning of any new second - only for deco modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
229 btfsc FLAG_TFT_divemins
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
230 call TFT_divemins_alternative ; Display (new) divetime!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
231 btfsc FLAG_TFT_divemode_mask_alt
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
232 call TFT_divemode_mask_alternative ; Alt. mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
233 call customview_alternative_second ; Do every-second tasks for the custom view area (In sync with the divetime) mH
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
234 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
235
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
236 TFT_output2_normal: ; any new second - only for deco modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
237 btfsc FLAG_TFT_display_ndl_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
238 call TFT_display_ndl_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
239 btfsc FLAG_TFT_display_ndl
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
240 call TFT_display_ndl
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
241 btfsc FLAG_TFT_display_deko_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
242 call TFT_display_deko_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
243 btfsc FLAG_TFT_display_deko
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
244 call TFT_display_deko
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
245 btfsc FLAG_TFT_display_tts
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
246 call TFT_display_tts
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
247 return
0
heinrichsweikamp
parents:
diff changeset
248
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
249 TFT_output2_alternative: ; any new second - only for deco modes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
250 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
251
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
252 TFT_output3_normal: ; tasks any new second, any mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
253 btfsc FLAG_TFT_max_depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
254 call TFT_max_depth ; use normal max. depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
255 btfsc FLAG_TFT_divemode_warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
256 call TFT_divemode_warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
257 btfsc FLAG_TFT_divemode_warning_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
258 call TFT_divemode_warning_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
259 btfsc FLAG_TFT_active_gas_divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
260 call TFT_active_gas_divemode ; Display gas/Setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
261 btfsc FLAG_TFT_dive_warning_text_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
262 call TFT_clear_warning_text ; clear complete warnings area
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
263 btfsc FLAG_TFT_dive_warning_text_clr2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
264 call TFT_clear_warning_text_2nd_row ; clear 2nd row of warnings
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
265 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
266
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
267 TFT_output3_alternative: ; tasks any new second, any mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
268 btfsc FLAG_TFT_max_depth_alt
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
269 call TFT_max_depth_alternative ; big max. depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
270 btfsc FLAG_TFT_dive_warning_text_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
271 call TFT_clear_warning_text ; clear complete warnings area (In alt mode only 2nd. row...)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
272 btfsc FLAG_TFT_big_deco_alt
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
273 call TFT_big_deco_alt ; Big deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
274 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
275
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
276 TFT_output4_normal: ; tasks any round, any mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
277 btfsc FLAG_TFT_depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
278 call TFT_depth ; Displays new depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
279 btfsc FLAG_TFT_temp_divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
280 call TFT_temp_divemode ; Update temperature
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
281 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
282
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
283 TFT_output4_alternative: ; tasks any round, any mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
284 btfsc FLAG_TFT_depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
285 call TFT_depth ; Displays new depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
286 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
287
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
288
0
heinrichsweikamp
parents:
diff changeset
289 ;--------------------------------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
290
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
291 divemode_apnoe_tasks: ; 1 sec. Apnoe tasks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
292 call TFT_display_apnoe_descent ; Yes, Show descent timer
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
293 call TFT_max_depth ; use normal max. depth
0
heinrichsweikamp
parents:
diff changeset
294
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
295 btfsc divemode2 ; Time running?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
296 bra divemode_apnoe_tasks2 ; New descent, reset data if flag is set
0
heinrichsweikamp
parents:
diff changeset
297
heinrichsweikamp
parents:
diff changeset
298 rcall apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
299 call TFT_display_apnoe_surface
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
300 call TFT_display_apnoe_last_max ; Show last max. depth
0
heinrichsweikamp
parents:
diff changeset
301 incf apnoe_surface_secs,F
heinrichsweikamp
parents:
diff changeset
302 movlw d'60'
heinrichsweikamp
parents:
diff changeset
303 cpfseq apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
304 bra divemode_apnoe_tasks1
heinrichsweikamp
parents:
diff changeset
305 clrf apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
306 incf apnoe_surface_mins,F
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 divemode_apnoe_tasks1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
309 bcf FLAG_active_descent ; Clear flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
310 btfsc divemode2 ; Time running?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
311 return ; Yes, return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
312 bsf FLAG_active_descent ; Set Flag
0
heinrichsweikamp
parents:
diff changeset
313 return
heinrichsweikamp
parents:
diff changeset
314
heinrichsweikamp
parents:
diff changeset
315 divemode_apnoe_tasks2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
316 btfss FLAG_active_descent ; Are we descending?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
317 return ; No, We are at the surface
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
318 rcall apnoe_calc_maxdepth ; Yes!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
319 call TFT_apnoe_clear_surface ; Clear Surface timer
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
320 clrf apnoe_timeout_counter ; Delete timeout
0
heinrichsweikamp
parents:
diff changeset
321 clrf apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
322 clrf apnoe_surface_mins
heinrichsweikamp
parents:
diff changeset
323 clrf apnoe_secs
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
324 clrf apnoe_mins ; Reset Descent time
0
heinrichsweikamp
parents:
diff changeset
325 movlw .0
heinrichsweikamp
parents:
diff changeset
326 movff WREG,max_pressure+0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
327 movff WREG,max_pressure+1 ; Reset Max. Depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
328 bcf FLAG_active_descent ; Clear flag
0
heinrichsweikamp
parents:
diff changeset
329 return
heinrichsweikamp
parents:
diff changeset
330
heinrichsweikamp
parents:
diff changeset
331 global apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
332 apnoe_calc_maxdepth:
heinrichsweikamp
parents:
diff changeset
333 movff apnoe_max_pressure+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
334 movff apnoe_max_pressure+1,sub_a+1
heinrichsweikamp
parents:
diff changeset
335 movff max_pressure+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
336 movff max_pressure+1,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
337 call subU16 ; sub_c = sub_a - sub_b
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
338 ; apnoe_max_pressure<max_pressure -> neg_flag=1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
339 ; max_pressure<=apnoe_max_pressure -> neg_flag=0
0
heinrichsweikamp
parents:
diff changeset
340 btfss neg_flag
heinrichsweikamp
parents:
diff changeset
341 return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
342 ;apnoe_max_pressure<max_pressure
0
heinrichsweikamp
parents:
diff changeset
343 movff max_pressure+0,apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
344 movff max_pressure+1,apnoe_max_pressure+1
heinrichsweikamp
parents:
diff changeset
345 return
heinrichsweikamp
parents:
diff changeset
346
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
347 ; --------------------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
348
heinrichsweikamp
parents:
diff changeset
349 calc_deko_divemode:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
350 rcall calc_deko_divemode2 ; all deco relevant code is now invoked every second
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
351 btfsc twosecupdate
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
352 bra calc_deko_divemode1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
353 bsf twosecupdate
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
354 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
355
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
356 calc_deko_divemode1: ; the following code is invoked every 2 seconds
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
357 bcf twosecupdate
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
358
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
359 call calc_average_depth ; calculate average depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
360 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
361 call set_reset_safety_stop ; Set flags for safety stop and/or reset safety stop
0
heinrichsweikamp
parents:
diff changeset
362 call TFT_debug_output
heinrichsweikamp
parents:
diff changeset
363
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
364 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
365 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
366 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
367 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
368
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
369 ; Check for a gas change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
370 goto check_gas_change ; Checks if a better gas should be selected (by user) and return...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
371
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
372
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
373 calc_deko_divemode2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
374 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
0
heinrichsweikamp
parents:
diff changeset
375 return
heinrichsweikamp
parents:
diff changeset
376
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
377 btfsc FLAG_ccr_mode ; In CCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
378 rcall calc_deko_divemode_sensor ; do sensor data acquisition if applicable by OSTC model
0
heinrichsweikamp
parents:
diff changeset
379
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
380 btfsc FLAG_pscr_mode ; In PSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
381 rcall calc_deko_divemode_sensor ; do sensor data acquisition if applicable by OSTC model
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
382
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
383 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; transfer ambient pressure to deco engine
0
heinrichsweikamp
parents:
diff changeset
384
195
bca0f054f023 allow auto-return from setpoint fallback
heinrichsweikamp
parents: 193
diff changeset
385
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
386 ; check deco engine state and switch between normal and alternative plan calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
387 ;
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
388 ; Remark: Any reconfigurations done here do only affect the ascent & deco calculation settings,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
389 ; not the settings for the calculations done on the real tissues. The later ones are only
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
390 ; altered in case of a gas change, or in case of a real bailout or switchback to setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
391 ; or sensor, respectively.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
392 ; In case of a gas change or real bailout/switchback, the settings for the deco calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
393 ; are also changed to match the settings for the real tissues. This is done on signal through
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
394 ; 'divemode_gaschange' and will also leave the deco engine status in state as if having done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
395 ; the alternative plan last.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
396
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
397 ; check state of ascent/deco calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
398 movff char_O_deco_status,lo ; get a working copy of char_O_deco_status into bank common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
399 movlw DECO_STATUS_MASK ; load bit mask covering the deco status bits
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
400 andwf lo,W ; mask out bits showing deco engine computations state
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
401 tstfsz WREG ; check if the last compute cycle has finished (bits 1 and 0 cleared)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
402 bra calc_deko_divemode2e ; NO - computations still in progress, needs more computation cycles
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
403 btfss lo,DECO_PLAN_FLAG ; YES - computation cycle finished, so check what has been computed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
404 bra calc_deko_divemode2b ; PLAN bit is cleared i.e. normal plan was done, may do alternative next
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
405
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
406 ; The PLAN bit is set, i.e. an alternative plan was computed in the last cycle, or the deco engine has
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
407 ; been restarted because of a gas change etc. --> Reconfigure to normal plan for next computation cycle.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
408
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
409 ; reset flags for special calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
410 bcf lo,DECO_PLAN_FLAG ; clear flag for alternative plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
411 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
412 bcf lo,DECO_VOLUME_FLAG ; clear flag for gas needs calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
413 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface
0
heinrichsweikamp
parents:
diff changeset
414
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
415 ; check if a switchback from CCR or pSCR bailout calculation is to be done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
416 btfsc FLAG_ccr_mode ; may a switchback from a CCR bailout calculation be needed?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
417 bra calc_deko_divemode2a ; in CCR mode, so may need to switch back from bailout calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
418 btfsc FLAG_pscr_mode ; may a switchback from a pSCR bailout calculation be needed?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
419 bra calc_deko_divemode2a ; in pSCR mode, so may need to switch back from bailout calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
420 bra calc_deko_divemode2e ; not in CCR nor pSCR, so no switchback needed, start normal plan now
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
421 ; (first cycle omits gas needs calculation in OC without delayed ascent)
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
422
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
423 ; switch back to loop calculation if last cycle was doing a bailout calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
424 calc_deko_divemode2a:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
425 movff opt_calc_asc_gasvolume,hi ; get the gas volume needs calculation setting
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
426 movf hi,W ; are gas volume calculations turned on?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
427 bz calc_deko_divemode2e ; NO - can't have done a bailout calculation then, start normal plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
428 btfsc is_bailout ; YES - check if a real bailout situation is present
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
429 bra calc_deko_divemode2e ; YES - OC gases have been set by bailout action then, start normal plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
430 movff active_gas,WREG ; NO - switch back to loop calculation: get current (diluent) gas, ...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
431 call deco_setup_cc_diluents ; ... set up deco calculations in CCR/pSCR mode with diluents,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
432 bra calc_deko_divemode2e ; ... and start in normal plan mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
433
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
434 ; The PLAN bit was cleared, i.e. a normal plan was computed in the last cycle. For the next
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
435 ; computation cycle the mode may be switched to alternative plan, or stay in normal mode...
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 473
diff changeset
436
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
437 calc_deko_divemode2b:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
438 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation (for safety only)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
439 btfsc is_bailout ; check if a real bailout situation is present
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
440 bra calc_deko_divemode2c ; YES - stay in normal plan mode and preclude delayed ascent calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
441 movff char_I_extra_time,hi ; NO - get the delayed ascent setting
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
442 tstfsz hi ; check if delayed ascent calculation is enabled
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
443 bsf lo,DECO_ASCENT_FLAG ; YES - set flag for delayed ascent calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
444 tstfsz hi ; check if delayed ascent calculation is enabled (again)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
445 bsf lo,DECO_PLAN_FLAG ; YES - set flag for alternative plan
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 473
diff changeset
446
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
447 ; check if a gas needs calculation shall be done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
448 calc_deko_divemode2c:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
449 bsf lo,DECO_VOLUME_FLAG ; set gas needs calculation flag (may be cleared again next)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
450 TSTOSS opt_calc_asc_gasvolume ; check if gas needs calculation is enabled
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
451 bcf lo,DECO_VOLUME_FLAG ; NO - reset flag again
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
452 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
453 TSTOSS opt_calc_asc_gasvolume ; check if gas volume calculation is enabled (again)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
454 bra calc_deko_divemode2e ; NO - no volume calculation, no simulated bailout plan in no case
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 473
diff changeset
455
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
456 ; check if conditions are met to calculate a bailout plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
457 btfsc is_bailout ; check if a real bailout situation is present
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
458 bra calc_deko_divemode2e ; YES - normal plan already does bailout (OC) calculation "for real"
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
459 btfss lo,DECO_MODE_LOOP_FLAG ; NO - have loop mode calculation been done during the normal plan?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
460 bra calc_deko_divemode2e ; NO - when not in loop mode, no simulated bailout to be done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
461 bsf lo,DECO_PLAN_FLAG ; YES - set flag for alternative plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
462 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
463 call get_first_gas_to_WREG ; get first OC gas, ...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
464 call deco_setup_oc_gases ; ... set up deco calculations in OC mode with OC gases,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
465 ;bra calc_deko_divemode2e ; ... and start in alternative plan mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
466
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
467
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
468 calc_deko_divemode2e:
0
heinrichsweikamp
parents:
diff changeset
469 clrf TMR5L
heinrichsweikamp
parents:
diff changeset
470 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
heinrichsweikamp
parents:
diff changeset
471 call deco_calc_hauptroutine ; calc_tissue
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
472 banksel common
0
heinrichsweikamp
parents:
diff changeset
473
heinrichsweikamp
parents:
diff changeset
474 ; Check if deco stops are necessary ?
heinrichsweikamp
parents:
diff changeset
475 movff char_O_first_deco_depth,wait_temp ; copy ceiling to temp register
heinrichsweikamp
parents:
diff changeset
476 tstfsz wait_temp ; Ceiling<0m?
heinrichsweikamp
parents:
diff changeset
477 bra calc_deko_divemode3 ; Yes!
heinrichsweikamp
parents:
diff changeset
478
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
479 btfsc decostop_active ; Already in nodeco mode ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
480 bsf FLAG_TFT_display_ndl_mask ; No, Clear deco data, display nostop time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
481 bcf decostop_active ; clear flag (again)
0
heinrichsweikamp
parents:
diff changeset
482
heinrichsweikamp
parents:
diff changeset
483 ; Copy for profile recording
heinrichsweikamp
parents:
diff changeset
484 clrf decodata+0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
485 movff char_O_nullzeit,decodata+1 ; NDL
0
heinrichsweikamp
parents:
diff changeset
486
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
487 bsf FLAG_TFT_display_ndl ; display no deco limit
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
488 return
0
heinrichsweikamp
parents:
diff changeset
489
heinrichsweikamp
parents:
diff changeset
490 calc_deko_divemode3:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
491 btfss decostop_active ; Already in deco mode ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
492 bsf FLAG_TFT_display_deko_mask ; No, clear nostop time, display decodata
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
493 bsf decostop_active ; Set flag (again)
0
heinrichsweikamp
parents:
diff changeset
494
heinrichsweikamp
parents:
diff changeset
495 ; Copy for profile recording
heinrichsweikamp
parents:
diff changeset
496 movff char_O_first_deco_depth,decodata+0 ; ceiling
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
497 movff char_O_first_deco_time,decodata+1 ; length of first stop in minutes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
498 bsf FLAG_TFT_display_deko ; display decodata
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
499 bsf FLAG_TFT_display_tts ; display TTS
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
500 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
501
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
502 ; --------------------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
503
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
504 global calc_deko_divemode_sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
505 calc_deko_divemode_sensor:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
506 ; sensor acquisition code
564
54346c651b6a bring digital S8 HUD back to life...
heinrichsweikamp
parents: 560
diff changeset
507 btfss s8_digital ; check if we have digital interface to the sensors
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
508 bra calc_deko_divemode_sensor_analog ; NO - use analog interface
564
54346c651b6a bring digital S8 HUD back to life...
heinrichsweikamp
parents: 560
diff changeset
509 btfss new_s8_data_available ; YES - check if a new data frame was received
54346c651b6a bring digital S8 HUD back to life...
heinrichsweikamp
parents: 560
diff changeset
510 bra calc_deko_divemode_sensor_common ; NO - use old values
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
511 call compute_mvolts_for_all_sensors ; YES - compute mV values from digital data
564
54346c651b6a bring digital S8 HUD back to life...
heinrichsweikamp
parents: 560
diff changeset
512 bra calc_deko_divemode_sensor_common
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
513
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
514 calc_deko_divemode_sensor_analog:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
515 call get_analog_inputs ; TODO: abort when OSTC model does not have analog inputs
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
516
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
517 calc_deko_divemode_sensor_common:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
518 ; Check for each sensor if it is calibrated and if its mv value is within min_mv and max_mv limits.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
519 ; If ok: compute o2_ppo2_sensorX := o2_mv_sensorX * opt_x_sX / 1000.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
520 ; If not ok: reset o2_ppo2_sensorX, reset use_O2_sensorX and show the customview 1 in case the sensor was ok before.
0
heinrichsweikamp
parents:
diff changeset
521
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
522 ; Check min_mv of sensor 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
523 btfss sensor1_calibrated_ok ; check if sensor is usable at all
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
524 bra check_sensor_1_fail ; NO - handle it as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
525 movff o2_mv_sensor1+0, sub_a+0 ; load sensor mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
526 movff o2_mv_sensor1+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
527 movlw LOW min_mv ; load minimum mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
528 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
529 movlw HIGH min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
530 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
531 call sub16 ; sub_c = sensor_mv - min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
532 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
533 bra check_sensor_1_fail ; YES - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
534 ; Check max_mv of sensor 1 NO - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
535 movff o2_mv_sensor1+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
536 movff o2_mv_sensor1+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
537 movlw LOW max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
538 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
539 movlw HIGH max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
540 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
541 call sub16 ; sub_c = sensor_mv - max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
542 btfss neg_flag ; check if result is negative, i.e. sensor_mv < max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
543 bra check_sensor_1_fail ; NO - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
544 ; Check HUD data, if available YES - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
545 btfss hud_connection_ok ; check if there is a HUD connected
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
546 bra check_sensor_1_ok ; NO - all checks done then and positive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
547 btfss sensor1_active ; YES - check HUD report on sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
548 bra check_sensor_1_fail ; HUD reports a fail
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
549
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
550 check_sensor_1_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
551 ; o2_ppo2_sensor1 := o2_mv_sensor1:2 * opt_x_s1:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
552 movff o2_mv_sensor1+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
553 movff o2_mv_sensor1+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
554 movff opt_x_s1+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
555 movff opt_x_s1+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
556 rcall compute_ppo2_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
557 movff xC+0,o2_ppo2_sensor1 ; result in 0.01bar
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
558 bra check_sensor_2 ; continue with next sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
559
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
560 check_sensor_1_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
561 clrf WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
562 movff WREG,o2_ppo2_sensor1 ; set ppO2 reading to zero
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
563 btfss use_O2_sensor1 ; check if sensor was in use before
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
564 bra check_sensor_1_fail_1 ; NO - no new news then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
565 call check_sensor_custview_helper ; YES - show customview 1 (sensor values) on further conditions met
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
566 check_sensor_1_fail_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
567 bcf use_O2_sensor1 ; revoke sensor from usage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
568 ;bra check_sensor_2 ; continue with next sensor
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
569
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
570 check_sensor_2: ; Check min_mv of sensor 2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
571 btfss sensor2_calibrated_ok ; check if sensor is usable at all
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
572 bra check_sensor_2_fail ; NO - handle it as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
573 movff o2_mv_sensor2+0, sub_a+0 ; load sensor mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
574 movff o2_mv_sensor2+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
575 movlw LOW min_mv ; load minimum mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
576 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
577 movlw HIGH min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
578 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
579 call sub16 ; sub_c = sensor_mv - min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
580 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
581 bra check_sensor_2_fail ; YES - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
582 ; Check max_mv of sensor 2 NO - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
583 movff o2_mv_sensor2+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
584 movff o2_mv_sensor2+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
585 movlw LOW max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
586 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
587 movlw HIGH max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
588 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
589 call sub16 ; sub_c = sensor_mv - max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
590 btfss neg_flag ; check if result is nagative, i.e. sensor_mv < max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
591 bra check_sensor_2_fail ; NO - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
592 ; Check HUD data, if available YES - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
593 btfss hud_connection_ok ; check if there is a HUD connected
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
594 bra check_sensor_2_ok ; NO - all checks done then and positive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
595 btfss sensor2_active ; YES - check HUD report on sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
596 bra check_sensor_2_fail ; HUD reports a fail
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
597
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
598 check_sensor_2_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
599 ; o2_ppo2_sensor2 := o2_mv_sensor2:2 * opt_x_s2:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
600 movff o2_mv_sensor2+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
601 movff o2_mv_sensor2+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
602 movff opt_x_s2+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
603 movff opt_x_s2+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
604 rcall compute_ppo2_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
605 movff xC+0,o2_ppo2_sensor2 ; result in 0.01bar
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
606 bra check_sensor_3 ; continue with next sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
607
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
608 check_sensor_2_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
609 clrf WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
610 movff WREG,o2_ppo2_sensor2 ; set ppO2 reading to zero
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
611 btfss use_O2_sensor2 ; check if sensor was in use before
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
612 bra check_sensor_2_fail_1 ; NO - no new news then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
613 call check_sensor_custview_helper ; YES - show customview 1 (sensor values) on further conditions met
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
614 check_sensor_2_fail_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
615 bcf use_O2_sensor2 ; revoke sensor from usage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
616 ;bra check_sensor_3 ; continue with next sensor
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
617
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
618 check_sensor_3: ; Check min_mv of sensor 2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
619 btfss sensor3_calibrated_ok ; check if sensor is usable at all
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
620 bra check_sensor_3_fail ; NO - handle it as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
621 movff o2_mv_sensor3+0, sub_a+0 ; load sensor mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
622 movff o2_mv_sensor3+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
623 movlw LOW min_mv ; load minimum mV value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
624 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
625 movlw HIGH min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
626 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
627 call sub16 ; sub_c = sensor_mv - min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
628 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
629 bra check_sensor_3_fail ; YES - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
630 ; Check max_mv of sensor 2 NO - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
631 movff o2_mv_sensor3+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
632 movff o2_mv_sensor3+1, sub_a+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
633 movlw LOW max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
634 movwf sub_b+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
635 movlw HIGH max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
636 movwf sub_b+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
637 call sub16 ; sub_c = sensor_mv - max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
638 btfss neg_flag ; check if result is nagative, i.e. sensor_mv < max_mv
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
639 bra check_sensor_3_fail ; NO - declare sensor as failed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
640 ; Check HUD data, if available YES - continue with next check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
641 btfss hud_connection_ok ; check if there is a HUD connected
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
642 bra check_sensor_3_ok ; NO - all checks done then and positive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
643 btfss sensor3_active ; YES - check HUD report on sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
644 bra check_sensor_3_fail ; HUD reports a fail
0
heinrichsweikamp
parents:
diff changeset
645
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
646 check_sensor_3_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
647 ; o2_ppo2_sensor3 := o2_mv_sensor3:2 * opt_x_s1:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
648 movff o2_mv_sensor3+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
649 movff o2_mv_sensor3+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
650 movff opt_x_s3+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
651 movff opt_x_s3+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
652 rcall compute_ppo2_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
653 movff xC+0,o2_ppo2_sensor3 ; result in 0.01bar
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
654 bra calc_deko_divemode_sensor1 ; continue with calculating sensor average
0
heinrichsweikamp
parents:
diff changeset
655
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
656 check_sensor_3_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
657 clrf WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
658 movff WREG,o2_ppo2_sensor3 ; set ppO2 reading to zero
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
659 btfss use_O2_sensor3 ; check if sensor was in use before
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
660 bra check_sensor_3_fail_1 ; NO - no new news then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
661 call check_sensor_custview_helper ; YES - show customview 1 (sensor values) on further conditions met
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
662 check_sensor_3_fail_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
663 bcf use_O2_sensor3 ; revoke sensor from usage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
664 ;bra calc_deko_divemode_sensor1 ; continue with calculating sensor average
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
665
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
666 calc_deko_divemode_sensor1: ; calculate sensor average
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
667 ; exit here if not in divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
668 btfss divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
669 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
670
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
671 ; compute sensor_setpoint := average of all o2_ppo2_sensorX of those sensors that have use_O2_sensorX == true
0
heinrichsweikamp
parents:
diff changeset
672 ; sum up sensor values (in xA:2) and active sensors in (xB:2)
heinrichsweikamp
parents:
diff changeset
673 clrf xB+0
heinrichsweikamp
parents:
diff changeset
674 clrf xB+1
heinrichsweikamp
parents:
diff changeset
675 clrf xA+0
heinrichsweikamp
parents:
diff changeset
676 clrf xA+1
192
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
677 btfss use_O2_sensor1 ; Sensor1 active?
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
678 bra divemode_setup_sensor_values2 ; No
0
heinrichsweikamp
parents:
diff changeset
679 movf o2_ppo2_sensor1,W
heinrichsweikamp
parents:
diff changeset
680 addwf xA+0
heinrichsweikamp
parents:
diff changeset
681 movlw .0
heinrichsweikamp
parents:
diff changeset
682 addwfc xA+1 ; Add into xA:2
heinrichsweikamp
parents:
diff changeset
683 incf xB+0,F ; Add a sensor
heinrichsweikamp
parents:
diff changeset
684 divemode_setup_sensor_values2:
192
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
685 btfss use_O2_sensor2 ; Sensor2 active?
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
686 bra divemode_setup_sensor_values3 ; No
0
heinrichsweikamp
parents:
diff changeset
687 movf o2_ppo2_sensor2,W
heinrichsweikamp
parents:
diff changeset
688 addwf xA+0
heinrichsweikamp
parents:
diff changeset
689 movlw .0
heinrichsweikamp
parents:
diff changeset
690 addwfc xA+1 ; Add into xA:2
heinrichsweikamp
parents:
diff changeset
691 incf xB+0,F ; Add a sensor
heinrichsweikamp
parents:
diff changeset
692 divemode_setup_sensor_values3:
192
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
693 btfss use_O2_sensor3 ; Sensor3 active?
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
694 bra divemode_setup_sensor_values4 ; No
0
heinrichsweikamp
parents:
diff changeset
695 movf o2_ppo2_sensor3,W
heinrichsweikamp
parents:
diff changeset
696 addwf xA+0
heinrichsweikamp
parents:
diff changeset
697 movlw .0
heinrichsweikamp
parents:
diff changeset
698 addwfc xA+1 ; Add into xA:2
heinrichsweikamp
parents:
diff changeset
699 incf xB+0,F ; Add a sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
700
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
701 ; Divide sum of sensor values by number of active sensors found.
0
heinrichsweikamp
parents:
diff changeset
702 divemode_setup_sensor_values4:
heinrichsweikamp
parents:
diff changeset
703 call div16x16 ; xA/xB=xC with xA+0 as remainder
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
704 movff xC+0,sensor_setpoint ; copy result
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
705
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
706 ; set default value for pSCR mode: 0 = let p2_deco.c compute the ppO2 based on current dil gas and depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
707 ; will be overwritten later in case we are in sensor mode and have at least one usable sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
708 clrf WREG ; preload a zero
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
709 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
710 movff WREG,char_I_const_ppO2 ; YES - write 0 to char_I_const_ppo2,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
711 ; it will be overwritten if we have a usable sensor reading
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
712
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
713 btfsc is_bailout ; check if we are in bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
714 bra calc_deko_divemode_sensor2 ; YES - no sensor data transfer to char_I_const_ppO2 in this case
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
715 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
716 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
717 bnz calc_deko_divemode_sensor2 ; not in sensor mode - no transfer of sensor data to char_I_const_ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
718 tstfsz xB+0 ; check if we have found at least one usable sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
719 bra calc_deko_divemode_sensor1a ; YES - we have at least one usable sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
720 bsf setpoint_fallback ; NO - we have NO usable sensors -> initiate fallback
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
721 btfss FLAG_ccr_mode ; check if we are in CCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
722 bra calc_deko_divemode_sensor2 ; NO - continue with voting logic flags
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
723 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; YES - select fixed setpoint no. 1 for fallback
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
724 bra calc_deko_divemode_sensor2 ; done - continue with voting logic flags
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
725 calc_deko_divemode_sensor1a: ; we have at least one usable sensor with a value > 0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
726 bcf setpoint_fallback ; clear fallback condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
727 movff sensor_setpoint,char_I_const_ppO2 ; transfer average sensor value to p2_deco.c code
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
728 ; bra calc_deko_divemode_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
729
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
730 calc_deko_divemode_sensor2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
731 bsf voting_logic_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
732 movff o2_ppo2_sensor1,temp1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
733 rcall check_sensor_voting_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
734 incfsz WREG ; Was Wreg=255?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
735 bcf voting_logic_sensor1 ; No, ignore this sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
736
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
737 bsf voting_logic_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
738 movff o2_ppo2_sensor2,temp1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
739 rcall check_sensor_voting_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
740 incfsz WREG ; Was Wreg=255?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
741 bcf voting_logic_sensor2 ; No, ignore this sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
742
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
743 bsf voting_logic_sensor3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
744 movff o2_ppo2_sensor3,temp1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
745 rcall check_sensor_voting_helper
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
746 incfsz WREG ; Was Wreg=255?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
747 bcf voting_logic_sensor3 ; No, ignore this sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
748
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
749 ; check if a warning shall be issued on sensor disagreement
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
750
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
751 btfsc FLAG_ccr_mode ; check if we are in CCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
752 bra check_warn_sensor_1 ; YES - continue with further checks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
753 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
754 bra check_warn_sensor_1 ; YES - continue with further checks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
755 bra check_warn_sensor_agree ; not in CCR and not in pSCR, so no warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
756 check_warn_sensor_1: ; we are in CCR or pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
757 btfsc is_bailout ; check if we are in bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
758 bra check_warn_sensor_agree ; YES - no warning in this case
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
759 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
760 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
761 bnz check_warn_sensor_agree ; not in sensor mode - no warning in this case
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
762 ; check sensor 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
763 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
764 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
765 btfss use_O2_sensor1 ; YES - check if sensor is in use
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
766 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
767 btfsc voting_logic_sensor1 ; YES - check if sensor value is within agreement range
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
768 bra check_warn_sensor_2 ; YES - continue with next sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
769 bcf sensors_agree ; NO - issue a warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
770 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
771
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
772 check_warn_sensor_2: ; check sensor 2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
773 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
774 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
775 btfss use_O2_sensor2 ; YES - check if sensor is in use
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
776 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
777 btfsc voting_logic_sensor2 ; YES - check if sensor value is within agreement range
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
778 bra check_warn_sensor_3 ; YES - continue with next sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
779 bcf sensors_agree ; NO - issue a warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
780 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
781
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
782 check_warn_sensor_3: ; check sensor 2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
783 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
784 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
785 btfss use_O2_sensor3 ; YES - check if sensor is in use
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
786 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
787 btfsc voting_logic_sensor3 ; YES - check if sensor value is within agreement range
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
788 bra check_warn_sensor_agree ; YES - continue with next sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
789 bcf sensors_agree ; NO - issue a warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
790 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
791
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
792 check_warn_sensor_agree:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
793 bsf sensors_agree
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
794 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
795
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
796 compute_ppo2_helper:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
797 call mult16x16 ;xA:2*xB:2=xC:4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
798 movlw LOW .1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
799 movwf xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
800 movlw HIGH .1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
801 movwf xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
802 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
803 movlw d'1'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
804 addwf xC+0,W ; we are just interessed in the carry flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
805 movlw d'0'
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
806 addwfc xC+1,W ; we are still just interessed in the carry flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
807 tstfsz WREG ; ppO2 is higher than 2.55bar?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
808 setf xC+0 ; Yes.
0
heinrichsweikamp
parents:
diff changeset
809 return
heinrichsweikamp
parents:
diff changeset
810
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
811 check_sensor_custview_helper:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
812 btfss divemode ; check if we are in divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
813 return ; NO - not in dive mode, return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
814 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
815 sublw .1 ; opt_ccr_mode = 1 (Sensors)?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
816 bnz check_sensor_helper_1 ; NO - not using the sensors in the moment
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
817 clrf menupos3 ; YES - arm customview 1 (sensor values)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
818 bsf toggle_customview ; and request a customview toggle
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
819 check_sensor_helper_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
820 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
821
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
822
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
823 check_sensor_voting_helper:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
824 movf temp1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
825 cpfsgt sensor_setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
826 bra check_sensor_voting_common2 ; temp1<sensor_setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
827 ; temp1>sensor_setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
828 movf temp1,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
829 subwf sensor_setpoint,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
830 movwf temp1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
831 check_sensor_voting_common1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
832 movlw sensor_voting_logic_threshold ; Threshold in 0.01 bar
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
833 cpfsgt temp1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
834 retlw .255 ; Within range
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
835 retlw .0 ; Out of range
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
836 check_sensor_voting_common2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
837 ; temp1<sensor_setpoint
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
838 movf sensor_setpoint,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
839 subwf temp1,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
840 bra check_sensor_voting_common1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
841
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
842 ;-----------------------------------------------------------------------------
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
843
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
844 divemodemode_togglegf: ; Toggle aGF/GF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
845 bcf toggle_gf ; clear flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
846 btg use_agf ; toggle GF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
847
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
848 movff opt_GF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
849 movff opt_GF_high,char_I_GF_High_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
850
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
851 ; Overwrite GF if aGF is wanted
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
852 btfsc use_agf ; =1: Use aGF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
853 movff opt_aGF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
854 btfsc use_agf ; =1: Use aGF
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
855 movff opt_aGF_high,char_I_GF_High_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
856
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
857 call TFT_gf_mask ; Setup Mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
858 goto restart_deco_engine ; ...and return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
859
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
860
0
heinrichsweikamp
parents:
diff changeset
861 calc_velocity: ; called every two seconds
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
862 btfsc display_velocity
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
863 bra calc_velocity1 ; Always update if already displayed
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
864 btfss divemode2
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
865 return ; display velocity only if deepter then 1m (Not at the surface after the dive)
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
866 calc_velocity1:
0
heinrichsweikamp
parents:
diff changeset
867 SAFE_2BYTE_COPY amb_pressure, sub_a
heinrichsweikamp
parents:
diff changeset
868 movff last_pressure_velocity+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
869 movff last_pressure_velocity+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
870 movff sub_a+0,last_pressure_velocity+0 ; store old value for velocity
heinrichsweikamp
parents:
diff changeset
871 movff sub_a+1,last_pressure_velocity+1
heinrichsweikamp
parents:
diff changeset
872
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
873 call subU16 ; sub_c = amb_pressure - last_pressure
0
heinrichsweikamp
parents:
diff changeset
874
318
6d8c82fe5a01 VSIbar #3d: more filter, neg_flag_velocity close to calculation, debug color for descend bar
janos_kovacs <kovjanos@gmail.com>
parents: 315
diff changeset
875 bcf neg_flag_velocity
6d8c82fe5a01 VSIbar #3d: more filter, neg_flag_velocity close to calculation, debug color for descend bar
janos_kovacs <kovjanos@gmail.com>
parents: 315
diff changeset
876 btfsc neg_flag
6d8c82fe5a01 VSIbar #3d: more filter, neg_flag_velocity close to calculation, debug color for descend bar
janos_kovacs <kovjanos@gmail.com>
parents: 315
diff changeset
877 bsf neg_flag_velocity
6d8c82fe5a01 VSIbar #3d: more filter, neg_flag_velocity close to calculation, debug color for descend bar
janos_kovacs <kovjanos@gmail.com>
parents: 315
diff changeset
878
0
heinrichsweikamp
parents:
diff changeset
879 movff sub_c+0,xA+0
heinrichsweikamp
parents:
diff changeset
880 movff sub_c+1,xA+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
881 movlw d'39' ; 77 when called every second....
0
heinrichsweikamp
parents:
diff changeset
882 movwf xB+0
heinrichsweikamp
parents:
diff changeset
883 clrf xB+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
884 call mult16x16 ; differential pressure in mbar*77...
0
heinrichsweikamp
parents:
diff changeset
885 movff xC+0,divA+0
heinrichsweikamp
parents:
diff changeset
886 movff xC+1,divA+1
heinrichsweikamp
parents:
diff changeset
887 movlw d'7'
heinrichsweikamp
parents:
diff changeset
888 movwf divB+0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
889 call div16 ; devided by 2^7 equals velocity in m/min
0
heinrichsweikamp
parents:
diff changeset
890
heinrichsweikamp
parents:
diff changeset
891 movlw d'99'
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
892 cpfsgt divA+0 ; limit to 99m/min
0
heinrichsweikamp
parents:
diff changeset
893 bra calc_velocity3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
894 movwf divA+0 ; divA=99
0
heinrichsweikamp
parents:
diff changeset
895
heinrichsweikamp
parents:
diff changeset
896 calc_velocity3:
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
897 ; Copy old speeds
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
898 movff old_velocity+2,old_velocity+3
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
899 movff old_velocity+1,old_velocity+2
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
900 movff old_velocity+0,old_velocity+1
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
901 movff divA+0,old_velocity+0
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
902
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
903 ; movff old_velocity+3,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
904 ; addwf divA+0,F ; add old speed
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
905 ; bcf STATUS,C
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
906 ; rrcf divA+0,F ; /2
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
907 ; movff old_velocity+2,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
908 ; addwf divA+0,F ; add old speed
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
909 ; bcf STATUS,C
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
910 ; rrcf divA+0,F ; /2
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
911 ; movff old_velocity+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
912 ; addwf divA+0,F ; add old speed
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
913 ; bcf STATUS,C
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
914 ; rrcf divA+0,F ; /2
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
915 ; movff old_velocity+0,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
916 ; addwf divA+0,F ; add old speed
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
917 ; bcf STATUS,C
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
918 ; rrcf divA+0,F ; /2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
919 goto TFT_display_velocity ; With divA+0 = m/min..., and return...
0
heinrichsweikamp
parents:
diff changeset
920
heinrichsweikamp
parents:
diff changeset
921
heinrichsweikamp
parents:
diff changeset
922 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
923
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
924 set_reset_safety_stop: ; Set flags for safety stop and/or reset safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
925 TSTOSS opt_enable_safetystop ; =1: A safety stop is shown
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
926 bra delete_safety_stop ; No, don't show safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
927
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
928 btfsc decostop_active ; Is a deco stop displayed?
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
929 bra delete_safety_stop ; Yes, don't show safety stop
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
930
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
931 ; Below "opt_safety_stop_reset"? Set flag and reset count-down timer
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
932 SAFE_2BYTE_COPY rel_pressure, lo
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
933 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
934 movff lo,sub_a+0
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
935 movff hi,sub_a+1
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
936 movff opt_safety_stop_reset,WREG ; [cbar]
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
937 mullw .10 ; mbar in PRODL:H
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
938 movff PRODL,sub_b+0
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
939 movff PRODH,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
940 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
941 btfss neg_flag
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
942 bra reset_safety_stop ; Below 10m, reset safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
943
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
944 ; Above "opt_safety_stop_end"? Clear flag.
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
945 SAFE_2BYTE_COPY rel_pressure, lo
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
946 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
947 movff lo,sub_a+0
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
948 movff hi,sub_a+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
949 movff opt_safety_stop_end,WREG ; [cbar]
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
950 mullw .10 ; mbar in PRODL:H
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
951 movff PRODL,sub_b+0
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
952 movff PRODH,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
953 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
954 btfsc neg_flag
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
955 bra delete_safety_stop ; Above 3m, remove safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
956
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
957 ; Above "opt_safety_stop_start"? Activate safety stop
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
958 SAFE_2BYTE_COPY rel_pressure, lo
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
959 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
960 movff lo,sub_a+0
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
961 movff hi,sub_a+1
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
962 movff opt_safety_stop_start,WREG ; [cbar]
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
963 mullw .10 ; mbar in PRODL:H
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
964 movff PRODL,sub_b+0
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
965 movff PRODH,sub_b+1
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
966 call subU16 ; sub_c = sub_a - sub_b
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
967 btfsc neg_flag
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
968 bra acivate_safety_stop ; Above 5m, activate safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
969 bra reset_safety_stop2 ; Pause safety stop
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
970
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
971 acivate_safety_stop:
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
972 tstfsz safety_stop_countdown ; Countdown at zero?
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
973 bsf show_safety_stop ; No, Set flag!
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
974 return
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
975
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
976 delete_safety_stop:
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
977 clrf safety_stop_countdown ; reset timer
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
978 bra reset_safety_stop2 ; Remove safety stop from display
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
979
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
980 reset_safety_stop:
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
981 movff opt_safety_stop_length,safety_stop_countdown ; reset timer
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
982 reset_safety_stop2:
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
983 bcf show_safety_stop ; Clear flag
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
984 btfss safety_stop_active ; Safety stop shown
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
985 return ; No, don't delete it
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
986 bcf safety_stop_active ; Clear flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
987 bsf FLAG_TFT_clear_safety_stop ; Clear safety stop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
988 return
428
eccae727702f some cleanup
heinrichsweikamp
parents: 403
diff changeset
989
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
990
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
991 ;=============================================================================
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
992
0
heinrichsweikamp
parents:
diff changeset
993 timeout_menuview:
heinrichsweikamp
parents:
diff changeset
994 decfsz timeout_counter3,F ; timeout for menuview
heinrichsweikamp
parents:
diff changeset
995 return ; No timeout, return
heinrichsweikamp
parents:
diff changeset
996 ; Timeout, clear e.g. "Menu?"
heinrichsweikamp
parents:
diff changeset
997 goto menuview_toggle_reset ; "returns"
heinrichsweikamp
parents:
diff changeset
998
heinrichsweikamp
parents:
diff changeset
999 timeout_divemode_menu:
heinrichsweikamp
parents:
diff changeset
1000 decfsz timeout_counter3,F ; timeout for divemode menu
heinrichsweikamp
parents:
diff changeset
1001 return
heinrichsweikamp
parents:
diff changeset
1002
heinrichsweikamp
parents:
diff changeset
1003 global timeout_divemode_menu2
heinrichsweikamp
parents:
diff changeset
1004 timeout_divemode_menu2: ; Called from divemenu_tree.asm
heinrichsweikamp
parents:
diff changeset
1005 bcf divemode_menu ; Timeout! Clear flag
heinrichsweikamp
parents:
diff changeset
1006 call TFT_clear_divemode_menu ; Clear menu
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1007 bsf FLAG_TFT_active_gas_divemode; Redraw gas/setpoint/diluent
0
heinrichsweikamp
parents:
diff changeset
1008 bcf blinking_better_gas ; Clear flag to have temperature updated once
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1009 bsf FLAG_TFT_temp_divemode ; Displays temperature
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1010 call TFT_draw_gassep_line ; Gas separator grid in spec mode only
0
heinrichsweikamp
parents:
diff changeset
1011
heinrichsweikamp
parents:
diff changeset
1012 btfss decostop_active ; In deco mode ?
heinrichsweikamp
parents:
diff changeset
1013 bra timeout_divemode_menu_ndl ; No, show NDL again
heinrichsweikamp
parents:
diff changeset
1014 ; Show deco
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1015 bsf FLAG_TFT_display_deko_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1016 bsf FLAG_TFT_display_deko
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1017 bsf FLAG_TFT_display_tts
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1018 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1019
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1020 timeout_divemode_menu_ndl:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1021 ; Show NDL
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1022 bsf FLAG_TFT_display_ndl_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1023 bsf FLAG_TFT_display_ndl
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1024 return
0
heinrichsweikamp
parents:
diff changeset
1025
heinrichsweikamp
parents:
diff changeset
1026 timeout_divemode:
heinrichsweikamp
parents:
diff changeset
1027 btfsc divemode_menu ; Divemode menu active?
heinrichsweikamp
parents:
diff changeset
1028 rcall timeout_divemode_menu ; Yes, check the timeout for it...
heinrichsweikamp
parents:
diff changeset
1029
heinrichsweikamp
parents:
diff changeset
1030 btfsc menuview ; is a menuview shown?
heinrichsweikamp
parents:
diff changeset
1031 rcall timeout_menuview ; Yes, check the timeout for it...
heinrichsweikamp
parents:
diff changeset
1032
heinrichsweikamp
parents:
diff changeset
1033 btfss realdive ; Dive longer then one minute
heinrichsweikamp
parents:
diff changeset
1034 return
heinrichsweikamp
parents:
diff changeset
1035
heinrichsweikamp
parents:
diff changeset
1036 btfsc FLAG_apnoe_mode ; In Apnoe mode?
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
1037 bra timeout_divemode2 ; Yes, use apnoe_timeout [min] for timeout
0
heinrichsweikamp
parents:
diff changeset
1038
heinrichsweikamp
parents:
diff changeset
1039 ifndef __DEBUG
heinrichsweikamp
parents:
diff changeset
1040 btfsc simulatormode_active ; In Simulator mode?
heinrichsweikamp
parents:
diff changeset
1041 bra timeout_divemode3 ; Yes, use simulator timeout
heinrichsweikamp
parents:
diff changeset
1042 endif
heinrichsweikamp
parents:
diff changeset
1043
heinrichsweikamp
parents:
diff changeset
1044 bcf divemode
148
022b886eddaf some cleanup
heinrichsweikamp
parents: 145
diff changeset
1045 infsnz timeout_counter,F
022b886eddaf some cleanup
heinrichsweikamp
parents: 145
diff changeset
1046 incf timeout_counter2,F ; timeout is 15bits
0
heinrichsweikamp
parents:
diff changeset
1047
444
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1048 movff opt_diveTimeout,WREG ; in [min]
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1049 mullw .60
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1050 movff PRODL,sub_a+0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1051 movff PRODH,sub_a+1 ; in [s]
0
heinrichsweikamp
parents:
diff changeset
1052
heinrichsweikamp
parents:
diff changeset
1053 movff timeout_counter, sub_b+0
heinrichsweikamp
parents:
diff changeset
1054 movff timeout_counter2, sub_b+1
heinrichsweikamp
parents:
diff changeset
1055 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
1056 btfss neg_flag ; Result negative?
heinrichsweikamp
parents:
diff changeset
1057 bsf divemode ; No, set flag
heinrichsweikamp
parents:
diff changeset
1058 return
heinrichsweikamp
parents:
diff changeset
1059
heinrichsweikamp
parents:
diff changeset
1060 timeout_divemode2:
heinrichsweikamp
parents:
diff changeset
1061 incf timeout_counter,F ; seconds...
heinrichsweikamp
parents:
diff changeset
1062 movlw d'60'
heinrichsweikamp
parents:
diff changeset
1063 cpfseq timeout_counter ; timeout_counter=60?
heinrichsweikamp
parents:
diff changeset
1064 return ; No.
heinrichsweikamp
parents:
diff changeset
1065 ; One minute timeout done.
heinrichsweikamp
parents:
diff changeset
1066 clrf timeout_counter
heinrichsweikamp
parents:
diff changeset
1067 bcf divemode
heinrichsweikamp
parents:
diff changeset
1068 incf apnoe_timeout_counter,F
heinrichsweikamp
parents:
diff changeset
1069 movlw apnoe_timeout ; apnoe timeout [min]
heinrichsweikamp
parents:
diff changeset
1070 cpfseq apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1071 bsf divemode
heinrichsweikamp
parents:
diff changeset
1072 return
heinrichsweikamp
parents:
diff changeset
1073
heinrichsweikamp
parents:
diff changeset
1074 timeout_divemode3:
heinrichsweikamp
parents:
diff changeset
1075 bcf divemode
heinrichsweikamp
parents:
diff changeset
1076 incf timeout_counter,F
heinrichsweikamp
parents:
diff changeset
1077 movlw simulator_timeout ; simulator timeout
heinrichsweikamp
parents:
diff changeset
1078 cpfsgt timeout_counter
heinrichsweikamp
parents:
diff changeset
1079 bsf divemode
heinrichsweikamp
parents:
diff changeset
1080 return
heinrichsweikamp
parents:
diff changeset
1081
heinrichsweikamp
parents:
diff changeset
1082 update_divemode60: ; update any minute
heinrichsweikamp
parents:
diff changeset
1083 call get_battery_voltage ; gets battery voltage
218
8fbd8c5ac51f 1.71beta start
heinrichsweikamp
parents: 216
diff changeset
1084 rcall set_powersafe ; Battery low?
0
heinrichsweikamp
parents:
diff changeset
1085 call customview_minute ; Do every-minute tasks for the custom view area
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
1086 bcf oneminupdate
0
heinrichsweikamp
parents:
diff changeset
1087
heinrichsweikamp
parents:
diff changeset
1088 btfss simulatormode_active ; in simulator mode?
heinrichsweikamp
parents:
diff changeset
1089 return ; No
heinrichsweikamp
parents:
diff changeset
1090 ; Yes, quite dive mode simulation after 21*256s=89min:36s
heinrichsweikamp
parents:
diff changeset
1091 movlw .20
heinrichsweikamp
parents:
diff changeset
1092 cpfsgt total_divetime_seconds+1 ; Timeout?
heinrichsweikamp
parents:
diff changeset
1093 return ; No
heinrichsweikamp
parents:
diff changeset
1094 ifdef __DEBUG
heinrichsweikamp
parents:
diff changeset
1095 return ; No simulator timeout in debug mode
heinrichsweikamp
parents:
diff changeset
1096 endif
heinrichsweikamp
parents:
diff changeset
1097 bra divemode_option1 ; Yes, set to 0m and "return"
heinrichsweikamp
parents:
diff changeset
1098
heinrichsweikamp
parents:
diff changeset
1099 set_max_depth:
heinrichsweikamp
parents:
diff changeset
1100 movff max_pressure+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1101 movff max_pressure+1,sub_a+1
heinrichsweikamp
parents:
diff changeset
1102 SAFE_2BYTE_COPY rel_pressure, sub_b
heinrichsweikamp
parents:
diff changeset
1103 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
1104 ; max_pressure<rel_pressure -> neg_flag=1
heinrichsweikamp
parents:
diff changeset
1105 ; rel_pressure<=max_pressure -> neg_flag=0
heinrichsweikamp
parents:
diff changeset
1106 btfss neg_flag
heinrichsweikamp
parents:
diff changeset
1107 return
heinrichsweikamp
parents:
diff changeset
1108 ; max_pressure<rel_pressure
heinrichsweikamp
parents:
diff changeset
1109 movff sub_b+0,max_pressure+0
heinrichsweikamp
parents:
diff changeset
1110 movff sub_b+1,max_pressure+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1111 bsf FLAG_TFT_max_depth ; Set flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1112 return
0
heinrichsweikamp
parents:
diff changeset
1113
heinrichsweikamp
parents:
diff changeset
1114 set_min_temp:
heinrichsweikamp
parents:
diff changeset
1115 movff minimum_temperature+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1116 movff minimum_temperature+1,sub_a+1
heinrichsweikamp
parents:
diff changeset
1117 SAFE_2BYTE_COPY temperature,sub_b
heinrichsweikamp
parents:
diff changeset
1118 call sub16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
1119 ; minimum_temperature<T -> neg_flag=1
heinrichsweikamp
parents:
diff changeset
1120 ; T<=minimum_temperature -> neg_flag=0
heinrichsweikamp
parents:
diff changeset
1121 btfsc neg_flag
heinrichsweikamp
parents:
diff changeset
1122 return
heinrichsweikamp
parents:
diff changeset
1123 ; minimum_temperature>=T
heinrichsweikamp
parents:
diff changeset
1124 movff sub_b+0,minimum_temperature+0
heinrichsweikamp
parents:
diff changeset
1125 movff sub_b+1,minimum_temperature+1
heinrichsweikamp
parents:
diff changeset
1126 return
heinrichsweikamp
parents:
diff changeset
1127
heinrichsweikamp
parents:
diff changeset
1128 global set_dive_modes
heinrichsweikamp
parents:
diff changeset
1129 set_dive_modes:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1130 btfsc high_altitude_mode ; In high altitude (Fly) mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1131 bra set_dive_modes3 ; Yes!
0
heinrichsweikamp
parents:
diff changeset
1132
heinrichsweikamp
parents:
diff changeset
1133 set_dive_modes0:
heinrichsweikamp
parents:
diff changeset
1134 movlw LOW start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1135 movwf sub_a+0 ; dive_treshold is in cm
0
heinrichsweikamp
parents:
diff changeset
1136 movlw HIGH start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1137 movwf sub_a+1 ; dive_treshold is in cm
0
heinrichsweikamp
parents:
diff changeset
1138
heinrichsweikamp
parents:
diff changeset
1139 set_dive_modes1:
heinrichsweikamp
parents:
diff changeset
1140 SAFE_2BYTE_COPY rel_pressure, sub_b
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1141 call subU16 ; sub_c = sub_a - sub_b
0
heinrichsweikamp
parents:
diff changeset
1142
heinrichsweikamp
parents:
diff changeset
1143 btfss neg_flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1144 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold)
0
heinrichsweikamp
parents:
diff changeset
1145
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1146 btfsc realdive ; Dive longer than one minute?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1147 clrf timeout_counter ; Yes, reset timout counter
0
heinrichsweikamp
parents:
diff changeset
1148
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1149 bsf divemode ; (Re-)Set divemode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1150 bsf divemode2 ; displayed divetime is running
0
heinrichsweikamp
parents:
diff changeset
1151 return
heinrichsweikamp
parents:
diff changeset
1152
heinrichsweikamp
parents:
diff changeset
1153 set_dive_modes2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1154 bcf divemode2 ; Stop time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1155 btfss realdive ; dive longer then one minute?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1156 bcf divemode ; no -> this was no real dive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1157 return ; No, return
0
heinrichsweikamp
parents:
diff changeset
1158
heinrichsweikamp
parents:
diff changeset
1159
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1160 set_dive_modes3: ; High-altitude mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1161 btfsc realdive ; dive longer then one minute?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1162 bra set_dive_modes0 ; Yes -> this is a real dive -> Use start_dive_threshold or ascend
0
heinrichsweikamp
parents:
diff changeset
1163
heinrichsweikamp
parents:
diff changeset
1164 movlw HIGH high_altitude_dive_threshold
heinrichsweikamp
parents:
diff changeset
1165 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
1166 movlw LOW high_altitude_dive_threshold
heinrichsweikamp
parents:
diff changeset
1167 movwf sub_a+0
heinrichsweikamp
parents:
diff changeset
1168 bra set_dive_modes1
heinrichsweikamp
parents:
diff changeset
1169
heinrichsweikamp
parents:
diff changeset
1170 set_powersafe:
heinrichsweikamp
parents:
diff changeset
1171 movlw color_code_battery_low+1; [%]
heinrichsweikamp
parents:
diff changeset
1172 cpfslt batt_percent
heinrichsweikamp
parents:
diff changeset
1173 return
heinrichsweikamp
parents:
diff changeset
1174
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1175 movlw d'7' ; Type of Alarm (Battery Low)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1176 movwf AlarmType ; Copy to Alarm Register
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1177 bsf event_occured ; Set Event Flag
0
heinrichsweikamp
parents:
diff changeset
1178 movlw .0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1179 movff WREG,opt_brightness ; Set Brightness to ECO
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1180 return ; return
0
heinrichsweikamp
parents:
diff changeset
1181
heinrichsweikamp
parents:
diff changeset
1182 calc_average_depth:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1183 btfsc reset_average_depth ; Reset the Average depth?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1184 rcall reset_average1 ; Reset the resettable average depth
0
heinrichsweikamp
parents:
diff changeset
1185
heinrichsweikamp
parents:
diff changeset
1186 ; 1. Add new 2xdepth to the Sum of depths registers
heinrichsweikamp
parents:
diff changeset
1187 SAFE_2BYTE_COPY rel_pressure, xB ; Buffer...
heinrichsweikamp
parents:
diff changeset
1188 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
1189 rlcf xB+0,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1190 rlcf xB+1,F ; x2
0
heinrichsweikamp
parents:
diff changeset
1191
heinrichsweikamp
parents:
diff changeset
1192 movf xB+0,w
heinrichsweikamp
parents:
diff changeset
1193 addwf average_depth_hold+0,F
heinrichsweikamp
parents:
diff changeset
1194 movf xB+1,w
heinrichsweikamp
parents:
diff changeset
1195 addwfc average_depth_hold+1,F
heinrichsweikamp
parents:
diff changeset
1196 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1197 addwfc average_depth_hold+2,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1198 addwfc average_depth_hold+3,F ; Will work up to 9999mbar*60*60*24=863913600mbar
0
heinrichsweikamp
parents:
diff changeset
1199
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1200 ; Do the same for the _total registers (Non-Resettable)
0
heinrichsweikamp
parents:
diff changeset
1201 movf xB+0,w
heinrichsweikamp
parents:
diff changeset
1202 addwf average_depth_hold_total+0,F
heinrichsweikamp
parents:
diff changeset
1203 movf xB+1,w
heinrichsweikamp
parents:
diff changeset
1204 addwfc average_depth_hold_total+1,F
heinrichsweikamp
parents:
diff changeset
1205 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1206 addwfc average_depth_hold_total+2,F
heinrichsweikamp
parents:
diff changeset
1207 addwfc average_depth_hold_total+3,F ; Will work up to 9999mbar*60*60*24=863913600mbar
heinrichsweikamp
parents:
diff changeset
1208
heinrichsweikamp
parents:
diff changeset
1209 ; 2. Compute Average Depth on base of average_divesecs:2
heinrichsweikamp
parents:
diff changeset
1210 movff average_divesecs+0,xB+0
heinrichsweikamp
parents:
diff changeset
1211 movff average_divesecs+1,xB+1 ; Copy
heinrichsweikamp
parents:
diff changeset
1212 movff average_depth_hold+0,xC+0
heinrichsweikamp
parents:
diff changeset
1213 movff average_depth_hold+1,xC+1
heinrichsweikamp
parents:
diff changeset
1214 movff average_depth_hold+2,xC+2
heinrichsweikamp
parents:
diff changeset
1215 movff average_depth_hold+3,xC+3
heinrichsweikamp
parents:
diff changeset
1216
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1217 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
437
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1218 movff xC+0,avg_rel_pressure+0
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1219 movff xC+1,avg_rel_pressure+1
0
heinrichsweikamp
parents:
diff changeset
1220
89
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 86
diff changeset
1221 btfss divemode2 ; displayed divetime is running?
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 86
diff changeset
1222 return ; No (e.g. too shallow)
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 86
diff changeset
1223
0
heinrichsweikamp
parents:
diff changeset
1224 ; 3. Compute Total Average Depth on base of total_divetime_seconds:2
heinrichsweikamp
parents:
diff changeset
1225 movff total_divetime_seconds+0,xB+0
heinrichsweikamp
parents:
diff changeset
1226 movff total_divetime_seconds+1,xB+1 ; Copy
heinrichsweikamp
parents:
diff changeset
1227 movff average_depth_hold_total+0,xC+0
heinrichsweikamp
parents:
diff changeset
1228 movff average_depth_hold_total+1,xC+1
heinrichsweikamp
parents:
diff changeset
1229 movff average_depth_hold_total+2,xC+2
heinrichsweikamp
parents:
diff changeset
1230 movff average_depth_hold_total+3,xC+3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1231 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
437
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1232 movff xC+0,avg_rel_pressure_total+0
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1233 movff xC+1,avg_rel_pressure_total+1
0
heinrichsweikamp
parents:
diff changeset
1234 return
heinrichsweikamp
parents:
diff changeset
1235
heinrichsweikamp
parents:
diff changeset
1236 reset_average1:
heinrichsweikamp
parents:
diff changeset
1237 clrf average_depth_hold+0
heinrichsweikamp
parents:
diff changeset
1238 clrf average_depth_hold+1
heinrichsweikamp
parents:
diff changeset
1239 clrf average_depth_hold+2
heinrichsweikamp
parents:
diff changeset
1240 clrf average_depth_hold+3 ; Clear average depth register
heinrichsweikamp
parents:
diff changeset
1241 movlw d'2'
heinrichsweikamp
parents:
diff changeset
1242 movwf average_divesecs+0
heinrichsweikamp
parents:
diff changeset
1243 clrf average_divesecs+1
heinrichsweikamp
parents:
diff changeset
1244 bcf reset_average_depth ; Clear flag
heinrichsweikamp
parents:
diff changeset
1245 return
heinrichsweikamp
parents:
diff changeset
1246
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1247 test_switches_divemode: ; checks switches in divemode
0
heinrichsweikamp
parents:
diff changeset
1248 btfsc divemode_menu ; Divemode menu shown?
heinrichsweikamp
parents:
diff changeset
1249 bra test_switches_divemode_menu ; Yes, use menu processor
heinrichsweikamp
parents:
diff changeset
1250 btfsc switch_left
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1251 ; bra test_switches_divemode2 ; Enter button pressed, check if we need to do something
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1252 goto menuview_toggle ; Menu or Simulator tasks; and return...
0
heinrichsweikamp
parents:
diff changeset
1253 btfss switch_right
heinrichsweikamp
parents:
diff changeset
1254 return ; No button press
heinrichsweikamp
parents:
diff changeset
1255 tstfsz menupos2 ; any option shown?
heinrichsweikamp
parents:
diff changeset
1256 bra test_switches_divemode1 ; Yes, do option tasks
heinrichsweikamp
parents:
diff changeset
1257 bsf toggle_customview ; No, toggle custom view
heinrichsweikamp
parents:
diff changeset
1258 return
heinrichsweikamp
parents:
diff changeset
1259
heinrichsweikamp
parents:
diff changeset
1260 test_switches_divemode_menu:
heinrichsweikamp
parents:
diff changeset
1261 btfsc switch_left
heinrichsweikamp
parents:
diff changeset
1262 bra test_switches_divemode_menu2 ; Move cursor
heinrichsweikamp
parents:
diff changeset
1263 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
1264 bra test_switches_divemode_menu3 ; Enter submenu or do something
heinrichsweikamp
parents:
diff changeset
1265 return ; No button press
heinrichsweikamp
parents:
diff changeset
1266
heinrichsweikamp
parents:
diff changeset
1267 test_switches_divemode_menu1:
heinrichsweikamp
parents:
diff changeset
1268 clrf menupos
heinrichsweikamp
parents:
diff changeset
1269 test_switches_divemode_menu2:
heinrichsweikamp
parents:
diff changeset
1270 incf menupos,F
heinrichsweikamp
parents:
diff changeset
1271 incf menupos4,W ; menupos4+1 -> WREG
heinrichsweikamp
parents:
diff changeset
1272 cpfslt menupos ; >menupos4 (Set in menu_processor.asm)?
heinrichsweikamp
parents:
diff changeset
1273 bra test_switches_divemode_menu1; > Yes, set to 1
heinrichsweikamp
parents:
diff changeset
1274 call TFT_divemode_menu_cursor ; Update the cursor
heinrichsweikamp
parents:
diff changeset
1275 bcf switch_left
heinrichsweikamp
parents:
diff changeset
1276 movlw divemode_menu_timeout ; Reload timeout
heinrichsweikamp
parents:
diff changeset
1277 movwf timeout_counter3 ; timeout for divemode menu
heinrichsweikamp
parents:
diff changeset
1278 return
heinrichsweikamp
parents:
diff changeset
1279
heinrichsweikamp
parents:
diff changeset
1280 test_switches_divemode_menu3: ; Enter submenu or do something
heinrichsweikamp
parents:
diff changeset
1281 bcf switch_right
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1282 ; decf menupos,F ; menu_processor needs 0-5...
0
heinrichsweikamp
parents:
diff changeset
1283 extern do_line_menu
heinrichsweikamp
parents:
diff changeset
1284 goto do_line_menu ; Warning! Trashes STKPTR and returns to diveloop_loop4:
heinrichsweikamp
parents:
diff changeset
1285
heinrichsweikamp
parents:
diff changeset
1286 test_switches_divemode1:
heinrichsweikamp
parents:
diff changeset
1287 bcf switch_right
heinrichsweikamp
parents:
diff changeset
1288 movlw divemode_menuview_timeout
heinrichsweikamp
parents:
diff changeset
1289 movwf timeout_counter3 ; Reload timeout
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1290 movff menupos2,WREG ; menupos2 holds number of customview/divemode menu function
0
heinrichsweikamp
parents:
diff changeset
1291 dcfsnz WREG,F
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1292 bra divemode_option_gaschange ; Switch to the indicated "better gas"
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1293 dcfsnz WREG,F
0
heinrichsweikamp
parents:
diff changeset
1294 bra divemode_option0 ; Start/Setup Divemode menu
heinrichsweikamp
parents:
diff changeset
1295 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1296 bra divemode_option1 ; Quit Simulation?
heinrichsweikamp
parents:
diff changeset
1297 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1298 bra divemode_option2 ; Descent 1m
heinrichsweikamp
parents:
diff changeset
1299 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1300 bra divemode_option3 ; Ascend 1m
heinrichsweikamp
parents:
diff changeset
1301 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1302 bra divemode_option4 ; Quit Apnoe mode
heinrichsweikamp
parents:
diff changeset
1303 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1304 bra divemode_option5 ; Reset Stopwatch (In Gauge mode)
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1305 dcfsnz WREG,F
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1306 bra divemode_option6 ; +5mins simulation
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1307 dcfsnz WREG,F
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1308 bra divemode_option7 ; Store heading
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1309 dcfsnz WREG,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1310 bra divemode_option8 ; Switch to alt. layout
0
heinrichsweikamp
parents:
diff changeset
1311 return
heinrichsweikamp
parents:
diff changeset
1312
heinrichsweikamp
parents:
diff changeset
1313 gas_switched_common:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1314 bcf divemode_gaschange ; Clear flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1315 tstfsz menupos ; menupos=0?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1316 bra gas_switched_common1 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1317 return ; Yes, do not switch gas (there is no Gas #0 !)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1318 gas_switched_common1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1319 movf menupos,W ; get selected gas into WREG (1-6)
274
9347893b74ce BUGFIX: Fast Gas change near the ppO2 limit could cause switching to a non-available Gas #0
heinrichsweikamp
parents: 256
diff changeset
1320
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1321 btfsc FLAG_ccr_mode ; in CCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1322 bra gas_switched_common2 ; YES - configure diluent or bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1323 btfsc FLAG_pscr_mode ; in pSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1324 bra gas_switched_common2 ; YES - configure diluent or bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1325
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1326 ; OC
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1327 rcall setup_gas_registers ; With WREG = Gas 1-6
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1328 rcall deco_setup_oc_gases ; With WREG = Gas 1-6
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1329 bra gas_switched_common3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1330
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1331 ; Loop or Bailout
506
b9f06f1a1f74 BUGFIX: PSCR mode "Better Gas" showed bailout gases instead of diluents
heinrichsweikamp
parents: 485
diff changeset
1332 gas_switched_common2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1333 rcall setup_dil_registers ; With WREG = diluent 1-6, in case of is_bailout reverts to OC gases
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1334 rcall deco_setup_cc_diluents ; With WREG = diluent 1-6, in case of is_bailout reverts to OC gases
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1335
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1336 gas_switched_common3:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1337 bsf FLAG_TFT_active_gas_divemode ; Redraw gas/setpoint/diluent
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1338 call restart_deco_engine_wo_ceiling ; abort any running deco calculations and restart the deco engine
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
1339
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
1340 ; Set flags for profile recording
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1341 bsf event_occured ; Set global event byte
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1342 btfsc is_bailout ; Choose OC Bailouts (OC Gases)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1343 bsf bailoutgas_event ; Bailout gas change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1344 btfss is_bailout ; Choose OC Bailouts (OC Gases)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1345 bsf stored_gas_changed ; OC gas change
0
heinrichsweikamp
parents:
diff changeset
1346 return
heinrichsweikamp
parents:
diff changeset
1347
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1348
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1349 ; Code to pass all parameters to the C code
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1350
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1351 global get_first_gas_to_WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1352 get_first_gas_to_WREG: ; Gets first gas (1-5) into WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1353 lfsr FSR1,opt_gas_type ; Point to gas types
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1354 clrf lo ; start with Gas0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1355 get_first_gas_to_WREG2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1356 movf lo,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1357 movf PLUSW1,W ; Get Type of Gas #lo
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1358 sublw .1 ; it is = 1 (First Gas)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1359 bz get_first_gas_to_WREG3 ; Found the first gas!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1360 incf lo,F ; ++
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1361 movlw NUM_GAS+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1362 cpfseq lo ; All done?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1363 bra get_first_gas_to_WREG2 ; Not yet
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1364 ; No first gas found, use #1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1365 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1366 movff WREG,opt_gas_type+0 ; Set Gas1 to First
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1367 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1368 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1369 get_first_gas_to_WREG3:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1370 movf lo,W ; Put into Wreg
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1371 incf WREG,W ; 0-4 -> 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1372 return ; Done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1373
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1374 global get_first_dil_to_WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1375 get_first_dil_to_WREG: ; Gets first dil (1-5) into WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1376 lfsr FSR1,opt_dil_type ; Point to dil types
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1377 clrf lo ; start with Gas0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1378 get_first_dil_to_WREG2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1379 movf lo,W
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1380 movf PLUSW1,W ; Get Type of Dil #lo
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1381 sublw .1 ; it is = 1 (First Dil)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1382 bz get_first_dil_to_WREG3 ; Found the first dil!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1383 incf lo,F ; ++
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1384 movlw NUM_GAS+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1385 cpfseq lo ; All done?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1386 bra get_first_dil_to_WREG2 ; Not yet
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1387 ; No first dil found, use #1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1388 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1389 movff WREG,opt_dil_type+0 ; Set Dil1 to First
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1390 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1391 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1392 get_first_dil_to_WREG3:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1393 movf lo,W ; Put into Wreg
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1394 incf WREG,W ; 0-4 -> 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1395 return ; Done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1396
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1397 global deco_setup_oc_gases
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1398 deco_setup_oc_gases: ; with currently breathed gas in WREG (1-5 or 6)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1399 movff WREG,char_I_current_gas ; gas to start with when doing the deco calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1400
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1401 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1402 movff opt_gas_O2_ratio+0,char_I_deco_O2_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1403 banksel opt_gas_type+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1404 movlw .3 ; 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1405 cpfseq opt_gas_type+0 ; Gas is deco type?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1406 clrf opt_OC_bail_gas_change+0 ; No, clear depth for 0=Disabled, 1=First and 2=Travel
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1407 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1408
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1409 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1410 movff opt_gas_O2_ratio+1,char_I_deco_O2_ratio+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1411 banksel opt_gas_type+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1412 movlw .3 ; 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1413 cpfseq opt_gas_type+1 ; Gas is deco type?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1414 clrf opt_OC_bail_gas_change+1 ; No, clear depth for 0=Disabled, 1=First and 2=Travel
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1415 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1416
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1417 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1418 movff opt_gas_O2_ratio+2,char_I_deco_O2_ratio+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1419 banksel opt_gas_type+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1420 movlw .3 ; 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1421 cpfseq opt_gas_type+2 ; Gas is deco type?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1422 clrf opt_OC_bail_gas_change+2 ; No, clear depth for 0=Disabled, 1=First and 2=Travel
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1423 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1424
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1425 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1426 movff opt_gas_O2_ratio+3,char_I_deco_O2_ratio+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1427 banksel opt_gas_type+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1428 movlw .3 ; 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1429 cpfseq opt_gas_type+3 ; Gas is deco type?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1430 clrf opt_OC_bail_gas_change+3 ; No, clear depth for 0=Disabled, 1=First and 2=Travel
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1431 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1432
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1433 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1434 movff opt_gas_O2_ratio+4,char_I_deco_O2_ratio+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1435 banksel opt_gas_type+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1436 movlw .3 ; 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1437 cpfseq opt_gas_type+4 ; Gas is deco type?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1438 clrf opt_OC_bail_gas_change+4 ; No, clear depth for 0=Disabled, 1=First and 2=Travel
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1439 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1440
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1441 ; Setup char_I_deco_gas_change array
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1442 movff opt_OC_bail_gas_change+0, char_I_deco_gas_change+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1443 movff opt_OC_bail_gas_change+1, char_I_deco_gas_change+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1444 movff opt_OC_bail_gas_change+2, char_I_deco_gas_change+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1445 movff opt_OC_bail_gas_change+3, char_I_deco_gas_change+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1446 movff opt_OC_bail_gas_change+4, char_I_deco_gas_change+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1447
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1448 ; switch to oc mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1449 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1450 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (may not be set, but never mind)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1451 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1452 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1453
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1454 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1455
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1456
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1457 global deco_setup_cc_diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1458 deco_setup_cc_diluents: ; with currently breathed gas in WREG (1-5 or 6)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1459 btfsc is_bailout ; check if in bailout condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1460 bra deco_setup_oc_gases ; revert to setting up OC gases in bailout condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1461
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1462 movff WREG,char_I_current_gas ; gas to start with when doing the deco calculations
0
heinrichsweikamp
parents:
diff changeset
1463
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1464 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1465 movff opt_dil_O2_ratio+0,char_I_deco_O2_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1466 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1467 tstfsz WREG ; Disabled?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1468 bra $+4 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1469 movff WREG,char_I_dil_change+0 ; Yes, clear char_I_deco_gas_change (Bank safe)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1470
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1471 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1472 movff opt_dil_O2_ratio+1,char_I_deco_O2_ratio+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1473 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1474 tstfsz WREG ; Disabled?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1475 bra $+4 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1476 movff WREG,char_I_dil_change+1 ; Yes, clear char_I_dil_change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1477
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1478 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1479 movff opt_dil_O2_ratio+2,char_I_deco_O2_ratio+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1480 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1481 tstfsz WREG ; Disabled?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1482 bra $+4 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1483 movff WREG,char_I_dil_change+2 ; Yes, clear char_I_dil_change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1484
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1485 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1486 movff opt_dil_O2_ratio+3,char_I_deco_O2_ratio+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1487 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1488 tstfsz WREG ; Disabled?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1489 bra $+4 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1490 movff WREG,char_I_dil_change+3 ; Yes, clear char_I_dil_change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1491
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1492 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1493 movff opt_dil_O2_ratio+4,char_I_deco_O2_ratio+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1494 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1495 tstfsz WREG ; Disabled?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1496 bra $+4 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1497 movff WREG,char_I_dil_change+4 ; Yes, clear char_I_dil_change
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1498
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1499 ; Setup char_I_deco_gas_change array
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1500 movff char_I_dil_change+0, char_I_deco_gas_change+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1501 movff char_I_dil_change+1, char_I_deco_gas_change+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1502 movff char_I_dil_change+2, char_I_deco_gas_change+2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1503 movff char_I_dil_change+3, char_I_deco_gas_change+3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1504 movff char_I_dil_change+4, char_I_deco_gas_change+4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1505
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1506 ; switch to CCR / pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1507 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1508 bsf lo,DECO_MODE_LOOP_FLAG ; loop flag is set in both, CCR and pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1509 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1510 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1511 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1512 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1513
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1514 return
0
heinrichsweikamp
parents:
diff changeset
1515
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1516 global setup_gas_registers
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1517 setup_gas_registers: ; with currently breathed gas in WREG (1-5 or 6)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1518 movwf active_gas ; set as current gas
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1519 movlw .6
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1520 cpfseq active_gas ; gas = gas6 ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1521 bra setup_gas_registers_15 ; NO - load gas 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1522 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1523 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1524 bra setup_gas_registers_com ; continue with common part
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1525 setup_gas_registers_15:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1526 decf active_gas,W ; 1-5 -> 0-4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1527 lfsr FSR1,opt_gas_O2_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1528 movff PLUSW1,char_I_O2_ratio ; copy gas 1-5 O2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1529 lfsr FSR1,opt_gas_He_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1530 movff PLUSW1,char_I_He_ratio ; copy gas 1-5 He ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1531 setup_gas_registers_com:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1532 ;lfsr FSR1,opt_gas_type ; commented out - currently not used anywhere
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1533 ;movff PLUSW1,active_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1534 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1535 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (may not be set, but never mind)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1536 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1537 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1538 movf active_gas,W ; reload WREG with diluent 1-5 or 6 (important!)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1539 return
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1540
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1541 global setup_dil_registers
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1542 setup_dil_registers: ; with currently breathed gas in WREG (1-5 or 6)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1543 btfsc is_bailout ; check if in bailout condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1544 bra setup_gas_registers ; revert to setting up OC gases in bailout condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1545 movwf active_gas ; set as current gas
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1546 movff WREG,active_diluent ; remember for when switching back from bailout to loop
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1547 movlw .6
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1548 cpfseq active_gas ; diluent = gas6 ?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1549 bra setup_dil_registers_15 ; NO - load diluent 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1550 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1551 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1552 bra setup_dil_registers_com ; continue with common part
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1553 setup_dil_registers_15:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1554 decf active_gas,W ; 1-5 -> 0-4
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1555 lfsr FSR1,opt_dil_O2_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1556 movff PLUSW1,char_I_O2_ratio ; copy diluent 1-5 O2 ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1557 lfsr FSR1,opt_dil_He_ratio+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1558 movff PLUSW1,char_I_He_ratio ; copy diluent 1-5 He ratio to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1559 setup_dil_registers_com:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1560 ;lfsr FSR1,opt_dil_type ; commented out - currently not used anywhere
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1561 ;movff PLUSW1,active_gas_type ; 0=Disabled, 1=First, 2=Normal (there is no type 3 for diluents)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1562 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1563 bsf lo,DECO_MODE_LOOP_FLAG ; loop flag is set in both, CCR and pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1564 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1565 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1566 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1567 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1568 movf active_gas,W ; reload WREG with diluent 1-5 or 6 (important!)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1569 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1570
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1571 divemode_option_gaschange: ; Switch to the better gas
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1572 movff better_gas_number,menupos ; 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1573 bsf divemode_gaschange ; Change the gas in the dive mode loop...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1574 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1575 bcf better_gas_available ; Clear flag immediately
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1576 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1577
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1578 divemode_option0: ; Start/Setup Divemode menu
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1579 call TFT_clear_divemode_menu ; Clear menu area
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1580 bcf menuview
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1581 extern do_main_divemenu
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1582 call do_main_divemenu
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1583
0
heinrichsweikamp
parents:
diff changeset
1584 global divemode_option0_return
heinrichsweikamp
parents:
diff changeset
1585 divemode_option0_return:
heinrichsweikamp
parents:
diff changeset
1586 ; movlw .1
heinrichsweikamp
parents:
diff changeset
1587 ; movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
1588 call TFT_divemode_menu_cursor; Show the cursor
heinrichsweikamp
parents:
diff changeset
1589 movlw divemode_menu_timeout
heinrichsweikamp
parents:
diff changeset
1590 movwf timeout_counter3 ; timeout for divemode menu
heinrichsweikamp
parents:
diff changeset
1591 bsf divemode_menu ; Set flag
heinrichsweikamp
parents:
diff changeset
1592 clrf menupos2 ; Clear option counter
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1593 goto diveloop_loop4 ; Goto back to diveloop (Menuprocessor trashes STKPTR!)
0
heinrichsweikamp
parents:
diff changeset
1594
heinrichsweikamp
parents:
diff changeset
1595 divemode_option4:
heinrichsweikamp
parents:
diff changeset
1596 movlw d'58' ; two seconds left
heinrichsweikamp
parents:
diff changeset
1597 movwf timeout_counter
heinrichsweikamp
parents:
diff changeset
1598 movlw apnoe_timeout-1 ; apnoe timeout [min]
heinrichsweikamp
parents:
diff changeset
1599 movwf apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1600 btfss simulatormode_active ; in simulator mode?
heinrichsweikamp
parents:
diff changeset
1601 return ; No
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1602 divemode_option1: ; Quit simulation mode
0
heinrichsweikamp
parents:
diff changeset
1603 banksel isr_backup
heinrichsweikamp
parents:
diff changeset
1604 movlw low .1000
heinrichsweikamp
parents:
diff changeset
1605 movwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1606 movlw high .1000
heinrichsweikamp
parents:
diff changeset
1607 movwf sim_pressure+1 ; Set to 0m -> End of Dive
heinrichsweikamp
parents:
diff changeset
1608 banksel common
heinrichsweikamp
parents:
diff changeset
1609 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
heinrichsweikamp
parents:
diff changeset
1610
heinrichsweikamp
parents:
diff changeset
1611 btfss FLAG_apnoe_mode ; In Apnoe mode?
heinrichsweikamp
parents:
diff changeset
1612 return ; No
heinrichsweikamp
parents:
diff changeset
1613 movlw d'58' ; two seconds left
heinrichsweikamp
parents:
diff changeset
1614 movwf timeout_counter
heinrichsweikamp
parents:
diff changeset
1615 movlw apnoe_timeout-1 ; apnoe timeout [min]
heinrichsweikamp
parents:
diff changeset
1616 movwf apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1617 return
heinrichsweikamp
parents:
diff changeset
1618
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1619 divemode_option3: ; minus 1m
0
heinrichsweikamp
parents:
diff changeset
1620 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1621 movlw d'100'
0
heinrichsweikamp
parents:
diff changeset
1622 subwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1623 movlw .0
heinrichsweikamp
parents:
diff changeset
1624 subwfb sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1625 rcall divemode_simulator_check_limits
heinrichsweikamp
parents:
diff changeset
1626 banksel common
heinrichsweikamp
parents:
diff changeset
1627 return
heinrichsweikamp
parents:
diff changeset
1628
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1629 divemode_option2: ; plus 1m
0
heinrichsweikamp
parents:
diff changeset
1630 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1631 movlw d'100'
0
heinrichsweikamp
parents:
diff changeset
1632 addwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1633 movlw .0
heinrichsweikamp
parents:
diff changeset
1634 addwfc sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1635 rcall divemode_simulator_check_limits
heinrichsweikamp
parents:
diff changeset
1636 banksel common
heinrichsweikamp
parents:
diff changeset
1637 return
heinrichsweikamp
parents:
diff changeset
1638
heinrichsweikamp
parents:
diff changeset
1639 divemode_option5:
heinrichsweikamp
parents:
diff changeset
1640 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
heinrichsweikamp
parents:
diff changeset
1641 bsf reset_average_depth ; Set Flag
heinrichsweikamp
parents:
diff changeset
1642 return
heinrichsweikamp
parents:
diff changeset
1643
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1644 divemode_option6:
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1645 bcf divemode2 ; Stop divetime
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1646 movlw .5
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1647 addwf divemins+0,F
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1648 movlw .0
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1649 addwfc divemins+1,F ; Add 5 mins
385
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1650 movlw LOW (.5*.60)
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1651 addwf average_divesecs+0,F
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1652 movlw HIGH (.5*.60)
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1653 addwfc average_divesecs+1,F ; Add 5*60 seconds
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1654 movlw LOW (.5*.60)
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1655 addwf total_divetime_seconds+0,F
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1656 movlw HIGH (.5*.60)
b075fa71b659 BUGFIX: +5min for stopwatch during simulation did not work
heinrichsweikamp
parents: 382
diff changeset
1657 addwfc total_divetime_seconds+1,F ; Add 5*60 seconds
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1658
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1659 ; 1. Add 300xdepth to the Sum of depths registers
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1660 SAFE_2BYTE_COPY rel_pressure, xB ; Buffer...
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1661 movlw LOW (.5*.60)
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1662 movwf xA+0
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1663 movlw HIGH (.5*.60)
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1664 movwf xA+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1665 call mult16x16 ; xA*xB=xC
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1666
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1667 movf xC+0,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1668 addwf average_depth_hold+0,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1669 movf xC+1,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1670 addwfc average_depth_hold+1,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1671 movf xC+2,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1672 addwfc average_depth_hold+2,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1673 movf xC+3,w
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1674 addwfc average_depth_hold+3,F ; Will work up to 9999mbar*60*60*24=863913600mbar
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1675
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1676 ; Do the same for the _total registers (Non-Resettable)
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1677 movf xC+0,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1678 addwf average_depth_hold_total+0,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1679 movf xC+1,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1680 addwfc average_depth_hold_total+1,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1681 movf xC+2,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1682 addwfc average_depth_hold_total+2,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1683 movf xC+3,w
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1684 addwfc average_depth_hold_total+3,F; Will work up to 9999mbar*60*60*24=863913600mbar
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1685
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1686 movlw .5 ; + 5 minutes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1687 movff WREG,char_I_sim_advance_time; copy to mailbox
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1688 bsf divemode2 ; continue divetime
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1689 call restart_deco_engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1690 goto menuview_toggle_reset ; and return...
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1691
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1692 divemode_option7:
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1693 ; Store heading for compass view
255
ad62dff7739a add bearing option to compass
heinrichsweikamp
parents: 254
diff changeset
1694 movff compass_heading_shown+0,compass_bearing+0
ad62dff7739a add bearing option to compass
heinrichsweikamp
parents: 254
diff changeset
1695 movff compass_heading_shown+1,compass_bearing+1
ad62dff7739a add bearing option to compass
heinrichsweikamp
parents: 254
diff changeset
1696 bsf compass_bearing_set ; set flag
428
eccae727702f some cleanup
heinrichsweikamp
parents: 403
diff changeset
1697 goto menuview_toggle_reset ; Done and return...
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1698
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1699 divemode_option8:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1700 bsf alternative_divelayout ; Set flag for mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1701 bsf FLAG_TFT_divemode_mask_alt ; Set flag for mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1702 movlw .1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1703 movwf menupos3 ; For the customviews...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1704 call TFT_ClearScreen ; Clear screen
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1705 goto menuview_toggle_reset ; Done and return...
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1706
0
heinrichsweikamp
parents:
diff changeset
1707 divemode_simulator_check_limits:
heinrichsweikamp
parents:
diff changeset
1708 ; Check limits (150m and 0m)
heinrichsweikamp
parents:
diff changeset
1709 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m).
heinrichsweikamp
parents:
diff changeset
1710 subwf sim_pressure+0,W
heinrichsweikamp
parents:
diff changeset
1711 movlw HIGH d'16000'
heinrichsweikamp
parents:
diff changeset
1712 subwfb sim_pressure+1,W
heinrichsweikamp
parents:
diff changeset
1713 bnc divemode_simulator_check_limits2 ; No-carry = borrow = not deeper
heinrichsweikamp
parents:
diff changeset
1714
heinrichsweikamp
parents:
diff changeset
1715 ; Too deep, limit to 150m
heinrichsweikamp
parents:
diff changeset
1716 movlw LOW d'16000'
heinrichsweikamp
parents:
diff changeset
1717 movwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1718 movlw HIGH d'16000'
heinrichsweikamp
parents:
diff changeset
1719 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1720 return
heinrichsweikamp
parents:
diff changeset
1721 divemode_simulator_check_limits2:
heinrichsweikamp
parents:
diff changeset
1722 movlw LOW d'1000' ; Compare to 1bar == 0m == 1000 mbar.
heinrichsweikamp
parents:
diff changeset
1723 subwf sim_pressure+0,W
heinrichsweikamp
parents:
diff changeset
1724 movlw HIGH d'1000'
heinrichsweikamp
parents:
diff changeset
1725 subwfb sim_pressure+1,W
heinrichsweikamp
parents:
diff changeset
1726 btfsc STATUS,C ; No-carry = borrow = not deeper.
heinrichsweikamp
parents:
diff changeset
1727 return ; Deeper than 0m == Ok.
heinrichsweikamp
parents:
diff changeset
1728 ; Too shallow, limit to 0m
heinrichsweikamp
parents:
diff changeset
1729 movlw LOW d'1000'
heinrichsweikamp
parents:
diff changeset
1730 movwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1731 movlw HIGH d'1000'
heinrichsweikamp
parents:
diff changeset
1732 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1733 return
heinrichsweikamp
parents:
diff changeset
1734
heinrichsweikamp
parents:
diff changeset
1735 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1736 ; Compare all enabled gas in list, to see if a better one is available.
heinrichsweikamp
parents:
diff changeset
1737 ;
heinrichsweikamp
parents:
diff changeset
1738 ; Output: better_gas_available, better_gas_number
heinrichsweikamp
parents:
diff changeset
1739 ;
heinrichsweikamp
parents:
diff changeset
1740 check_gas_change: ; Checks if a better gas should be selected (by user)
heinrichsweikamp
parents:
diff changeset
1741 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
heinrichsweikamp
parents:
diff changeset
1742 clrf better_gas_number ; Clear better gas register
heinrichsweikamp
parents:
diff changeset
1743
heinrichsweikamp
parents:
diff changeset
1744 SAFE_2BYTE_COPY rel_pressure,xA
heinrichsweikamp
parents:
diff changeset
1745 movlw d'100'
heinrichsweikamp
parents:
diff changeset
1746 movwf xB+0
heinrichsweikamp
parents:
diff changeset
1747 clrf xB+1
heinrichsweikamp
parents:
diff changeset
1748 call div16x16 ; compute depth in full m -> result in xC+0
heinrichsweikamp
parents:
diff changeset
1749
506
b9f06f1a1f74 BUGFIX: PSCR mode "Better Gas" showed bailout gases instead of diluents
heinrichsweikamp
parents: 485
diff changeset
1750 btfsc FLAG_pscr_mode ; In PSCR mode...
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
1751 bra check_gas_change2 ; Yes, check for diluents
0
heinrichsweikamp
parents:
diff changeset
1752 btfss FLAG_ccr_mode ; In CCR mode...
heinrichsweikamp
parents:
diff changeset
1753 bra check_gas_change_OC_bail; No, check for OC or bailout
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
1754 check_gas_change2:
0
heinrichsweikamp
parents:
diff changeset
1755 btfsc is_bailout ; Bailout?
heinrichsweikamp
parents:
diff changeset
1756 bra check_gas_change_OC_bail; Yes, check for OC or bailout
heinrichsweikamp
parents:
diff changeset
1757
heinrichsweikamp
parents:
diff changeset
1758 ; Check Diluents
heinrichsweikamp
parents:
diff changeset
1759 movlw .0
heinrichsweikamp
parents:
diff changeset
1760 rcall check_dil_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1761 movlw .1
heinrichsweikamp
parents:
diff changeset
1762 rcall check_dil_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1763 movlw .2
heinrichsweikamp
parents:
diff changeset
1764 rcall check_dil_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1765 movlw .3
heinrichsweikamp
parents:
diff changeset
1766 rcall check_dil_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1767 movlw .4
heinrichsweikamp
parents:
diff changeset
1768 rcall check_dil_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1769 bra check_gas_change_exit
heinrichsweikamp
parents:
diff changeset
1770
heinrichsweikamp
parents:
diff changeset
1771 check_gas_change_OC_bail:
heinrichsweikamp
parents:
diff changeset
1772 movlw .0
heinrichsweikamp
parents:
diff changeset
1773 rcall check_gas_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1774 movlw .1
heinrichsweikamp
parents:
diff changeset
1775 rcall check_gas_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1776 movlw .2
heinrichsweikamp
parents:
diff changeset
1777 rcall check_gas_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1778 movlw .3
heinrichsweikamp
parents:
diff changeset
1779 rcall check_gas_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1780 movlw .4
heinrichsweikamp
parents:
diff changeset
1781 rcall check_gas_common ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1782 ; bra check_gas_change_exit
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1783
0
heinrichsweikamp
parents:
diff changeset
1784 check_gas_change_exit:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1785 btfss better_gas_available ; Is a better gas available
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1786 bcf blinking_better_gas ; No, Clear blinking flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1787 btfss better_gas_available ; Is a better gas available
0
heinrichsweikamp
parents:
diff changeset
1788 clrf better_gas_number ; No, Clear better_gas_number (For gaslist display)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1789 bsf FLAG_TFT_active_gas_divemode; Redraw gas/setpoint/diluent
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1790 return
0
heinrichsweikamp
parents:
diff changeset
1791
heinrichsweikamp
parents:
diff changeset
1792 check_gas_common: ; With Gas 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1793 btfsc better_gas_available ; Better Gas already found?
heinrichsweikamp
parents:
diff changeset
1794 return ; Yes, return
heinrichsweikamp
parents:
diff changeset
1795 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
1796 btfss PLUSW1,0 ; Test for Bit0 and 1 -> type=3 -> Deco
heinrichsweikamp
parents:
diff changeset
1797 return ; No
heinrichsweikamp
parents:
diff changeset
1798 btfss PLUSW1,1 ; Test for Bit0 and 1 -> type=3 -> Deco
heinrichsweikamp
parents:
diff changeset
1799 return ; No
heinrichsweikamp
parents:
diff changeset
1800 incf WREG,W ; 1-5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1801 cpfseq active_gas ; is this gas current gas?
0
heinrichsweikamp
parents:
diff changeset
1802 bra check_gas_common2 ; No
heinrichsweikamp
parents:
diff changeset
1803 return ; Yes, skip test for active gas
heinrichsweikamp
parents:
diff changeset
1804 check_gas_common2:
heinrichsweikamp
parents:
diff changeset
1805 decf WREG,W ; 0-4
heinrichsweikamp
parents:
diff changeset
1806 movwf hi ; Save tested gas 0-4
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 89
diff changeset
1807 lfsr FSR1,opt_OC_bail_gas_change
0
heinrichsweikamp
parents:
diff changeset
1808 movff PLUSW1,lo ; Change depth into lo
heinrichsweikamp
parents:
diff changeset
1809 movlw minimum_change_depth
heinrichsweikamp
parents:
diff changeset
1810 cpfsgt lo ; Change depth>minimum_change_depth?
heinrichsweikamp
parents:
diff changeset
1811 return ; No, Change depth not deep enough, skip!
heinrichsweikamp
parents:
diff changeset
1812 movf xC+0,W ; load depth in m into WREG
heinrichsweikamp
parents:
diff changeset
1813 cpfsgt lo ; gas_change_depth < current depth?
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1814 bra check_gas_common3 ; No, check if we are within the better_gas_window_pos window
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1815 incf hi,W ; 1-5
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1816 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1817 movlw better_gas_window_neg
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1818 subwf lo,W ; Change depth-better_gas_window_neg
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1819 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1820 bra check_gas_common4 ; Ok, now check the better gas ppO2<char_I_ppO2_max
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1821 return
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1822
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1823 check_gas_common3:
0
heinrichsweikamp
parents:
diff changeset
1824 incf hi,W ; 1-5
heinrichsweikamp
parents:
diff changeset
1825 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1826 movlw better_gas_window_pos
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1827 addwf lo,W ; Change depth+better_gas_window_pos
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1828 cpfsgt xC+0 ; current depth>Change depth+better_gas_window_pos?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1829 bra check_gas_common4 ; Ok, now check the better gas ppO2<char_I_ppO2_max
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1830 return
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1831
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1832 check_gas_common4:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1833 movf hi,W ; gas 0-4 into WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1834 lfsr FSR1,char_I_deco_O2_ratio ; load base address char_I_deco_O2_ratio array
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1835 movff PLUSW1,lo ; read O2 ratio from array into lo
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1836
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1837 SAFE_2BYTE_COPY amb_pressure, xA
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1838 movlw d'10'
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1839 movwf xB+0
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1840 clrf xB+1
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1841 call div16x16 ; xC=p_amb/10
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1842 movff xC+0,xA+0
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1843 movff xC+1,xA+1
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1844 movff lo,xB+0 ; =O2 ratio
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1845 clrf xB+1
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1846 call mult16x16 ; lo * p_amb/10
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1847
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1848 ; Check very high ppO2 manually
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1849 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1850 return ; Done.
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1851 ; Check if ppO2>3,30bar
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1852 btfsc xC+1,7
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1853 return ; Done.
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1854
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1855 ; Check for low ppo2
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1856 movff xC+0,sub_b+0
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1857 movff xC+1,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1858 movff char_I_ppO2_min,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1859 mullw d'100' ; char_I_ppO2_min*100
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1860 movff PRODL,sub_a+0
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1861 movff PRODH,sub_a+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1862 call subU16 ; sub_c = sub_a - sub_b
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1863 btfss neg_flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1864 return ; Done (Too low).
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1865
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1866 ;check if we are within our warning thresholds!
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1867 movff xC+0,sub_a+0
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1868 movff xC+1,sub_a+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1869 movff char_I_ppO2_max_deco,WREG ; ppO2 max for MOD calculation and color coding in divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1870 addlw .1 ; e.g. >1.60
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1871 mullw d'100' ; char_I_ppO2_max*100
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1872 movff PRODL,sub_b+0
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1873 movff PRODH,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1874 call subU16 ; sub_c = sub_a - sub_b
526
0d1cda9f2d43 BUGFIX: Skip MOD Test for CCR in Sensor modes (OSTC cR and OSTC3 only)
heinrichsweikamp
parents: 521
diff changeset
1875 btfsc neg_flag
0
heinrichsweikamp
parents:
diff changeset
1876 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1877 return ; Done.
0
heinrichsweikamp
parents:
diff changeset
1878
heinrichsweikamp
parents:
diff changeset
1879 check_dil_common: ; With Dil 0-4 in WREG
heinrichsweikamp
parents:
diff changeset
1880 btfsc better_gas_available ; Better Diluent already found?
heinrichsweikamp
parents:
diff changeset
1881 return ; Yes, return
heinrichsweikamp
parents:
diff changeset
1882 lfsr FSR1,opt_dil_type ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
1883 tstfsz PLUSW1 ; =0?
heinrichsweikamp
parents:
diff changeset
1884 bra check_dil_common1 ; No
heinrichsweikamp
parents:
diff changeset
1885 return ; Yes, skip inactive diluents for test
heinrichsweikamp
parents:
diff changeset
1886 check_dil_common1:
heinrichsweikamp
parents:
diff changeset
1887 incf WREG,W ; 1-5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1888 cpfseq active_gas ; is this the current diluent?
0
heinrichsweikamp
parents:
diff changeset
1889 bra check_dil_common2 ; No
heinrichsweikamp
parents:
diff changeset
1890 return ; Yes, skip test for active diluent
heinrichsweikamp
parents:
diff changeset
1891 check_dil_common2:
heinrichsweikamp
parents:
diff changeset
1892 decf WREG,W ; 0-4
heinrichsweikamp
parents:
diff changeset
1893 movwf hi ; Save tested diluent 0-4
heinrichsweikamp
parents:
diff changeset
1894 lfsr FSR1,char_I_dil_change
heinrichsweikamp
parents:
diff changeset
1895 movff PLUSW1,lo ; Change depth into lo
heinrichsweikamp
parents:
diff changeset
1896 movlw minimum_change_depth
heinrichsweikamp
parents:
diff changeset
1897 cpfsgt lo ; Change depth>minimum_change_depth?
heinrichsweikamp
parents:
diff changeset
1898 return ; No, Change depth not deep enough, skip!
heinrichsweikamp
parents:
diff changeset
1899 movf xC+0,W ; load depth in m into WREG
heinrichsweikamp
parents:
diff changeset
1900 cpfsgt lo ; gas_change_depth < current depth?
heinrichsweikamp
parents:
diff changeset
1901 return ; No, check next gas
heinrichsweikamp
parents:
diff changeset
1902 incf hi,W ; 1-5
heinrichsweikamp
parents:
diff changeset
1903 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1904 movlw better_gas_window_neg
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1905 subwf lo,W ; Change depth-better_gas_window_neg
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1906 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg?
0
heinrichsweikamp
parents:
diff changeset
1907 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
heinrichsweikamp
parents:
diff changeset
1908 return
heinrichsweikamp
parents:
diff changeset
1909
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1910
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1911 ;=============================================================================
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1912 ; Check for Auto-SP
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1913 ;
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1914 check_dive_autosp: ; Check for Auto-SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1915 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1916 sublw .2 ; opt_ccr_mode = 2 (Auto SP)?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1917 bz check_dive_autosp2 ; Yes, check
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1918 return ; No, return for Sensor or Fixed mode
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1919 check_dive_autosp2:
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1920 SAFE_2BYTE_COPY rel_pressure,xA
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1921 movlw d'100'
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1922 movwf xB+0
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1923 clrf xB+1
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1924 call div16x16 ; compute depth in full m -> result in xC+0
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1925 ; Check SP2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1926 btfsc sp2_switched ; =1: This setpoint has been autoselected already
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1927 bra check_dive_autosp3 ; Skip check
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1928 movff char_I_setpoint_change+1,lo ; Get depth in m
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1929 tstfsz lo ; =0?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1930 bra check_dive_autosp2a ; No, continue
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1931 bra check_dive_autosp3 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1932 check_dive_autosp2a:
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1933 decf lo,W ; -1 -> WREG
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1934 cpfsgt xC+0 ; Compare with depth
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1935 bra check_dive_autosp3 ; lower depth, do not switch
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1936 ; auto switch to SP2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1937 movff char_I_setpoint_cbar+1,char_I_const_ppO2 ; Use SetPoint
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1938 rcall xmit_sp_set_flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1939 bsf sp2_switched ; Set flag
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1940 check_dive_autosp3:
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1941 ; Check SP3
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1942 btfsc sp3_switched ;=1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1943 bra check_dive_autosp4 ; Skip check
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1944 movff char_I_setpoint_change+2,lo ; Get depth in m
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1945 tstfsz lo ; =0?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1946 bra check_dive_autosp3a ; No, continue
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1947 bra check_dive_autosp4 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1948 check_dive_autosp3a:
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1949 decf lo,W ; -1 -> WREG
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1950 cpfsgt xC+0 ; Compare with depth
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1951 bra check_dive_autosp4 ; lower depth, do not switch
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1952 ; auto switch to SP3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1953 movff char_I_setpoint_cbar+2,char_I_const_ppO2 ; Use SetPoint
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1954 rcall xmit_sp_set_flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1955 bsf sp3_switched ; Set flag
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1956 check_dive_autosp4:
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1957 ; Check SP4
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1958 btfsc sp4_switched ;=1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1959 bra check_dive_autosp5 ; Skip check
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1960 movff char_I_setpoint_change+3,lo ; Get depth in m
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1961 tstfsz lo ; =0?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1962 bra check_dive_autosp4a ; No, continue
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1963 bra check_dive_autosp5 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1964 check_dive_autosp4a:
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1965 decf lo,W ; -1 -> WREG
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1966 cpfsgt xC+0 ; Compare with depth
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1967 bra check_dive_autosp5 ; lower depth, do not switch
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1968 ; auto switch to SP4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1969 movff char_I_setpoint_cbar+3,char_I_const_ppO2 ; Use SetPoint
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1970 rcall xmit_sp_set_flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1971 bsf sp4_switched ; Set flag
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1972 check_dive_autosp5:
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1973 ; Check SP5
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1974 btfsc sp5_switched ;=1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1975 bra check_dive_autosp6 ; Skip check
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1976 movff char_I_setpoint_change+4,lo ; Get depth in m
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1977 tstfsz lo ; =0?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1978 bra check_dive_autosp5a ; No, continue
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1979 bra check_dive_autosp6 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1980 check_dive_autosp5a:
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1981 decf lo,W ; -1 -> WREG
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1982 cpfsgt xC+0 ; Compare with depth
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1983 bra check_dive_autosp6 ; lower depth, do not switch
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1984 ; auto switch to SP5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1985 movff char_I_setpoint_cbar+4,char_I_const_ppO2 ; Use SetPoint
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1986 rcall xmit_sp_set_flag
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1987 bsf sp5_switched ; Set flag
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1988 check_dive_autosp6:
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1989 return
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1990
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1991 xmit_sp_set_flag:
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
1992 movff char_I_const_ppO2,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1993 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1994 bsf setpoint_changed ; Set flag (For profile)
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1995 bsf event_occured ; Set global event byte
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1996 return
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1997
0
heinrichsweikamp
parents:
diff changeset
1998 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1999 ; Setup everything to enter divemode.
heinrichsweikamp
parents:
diff changeset
2000 ;
heinrichsweikamp
parents:
diff changeset
2001 dive_boot_oc:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2002 rcall get_first_gas_to_WREG ; Gets first gas (1-5) into WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2003 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2004 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5)
0
heinrichsweikamp
parents:
diff changeset
2005 return
heinrichsweikamp
parents:
diff changeset
2006
heinrichsweikamp
parents:
diff changeset
2007 dive_boot_cc:
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
2008 bcf is_bailout ; =1: Bailout
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
2009 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2010 bcf blinking_setpoint ; Reset blinking SP flag
192
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
2011
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2012 ; revoke sensors from usage if they do not have a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2013 bsf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2014 bsf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2015 bsf use_O2_sensor3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2016 btfss sensor1_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2017 bcf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2018 btfss sensor2_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2019 bcf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2020 btfss sensor3_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2021 bcf use_O2_sensor3
549
7c408bfaf2e8 2.26 stable RC1
heinrichsweikamp
parents: 547
diff changeset
2022
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2023 ; In pSCR mode, only settings 0 (calculated ppO2) and 1 (ppO2 from sensors) are defined.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2024 ; In case we still have 3 (auto SP) selected out of previous ccr mode, we reset to 0.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2025 btfss FLAG_pscr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2026 bra dive_boot_cc_1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2027 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2028 sublw .2 ; opt_ccr_mode = 1 (Auto SP)?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2029 bnz dive_boot_cc_1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2030 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2031 movff WREG,opt_ccr_mode
549
7c408bfaf2e8 2.26 stable RC1
heinrichsweikamp
parents: 547
diff changeset
2032
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2033 dive_boot_cc_1:
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2034 bsf setpoint_changed ; Set flag (For profile)
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2035 bcf sp2_switched ; =1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2036 bcf sp3_switched ; =1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2037 bcf sp4_switched ; =1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2038 bcf sp5_switched ; =1: This setpoint has been autoselected already
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2039
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2040 rcall get_first_dil_to_WREG ; get first gas (1-5) into WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2041 rcall setup_dil_registers ; set-up of gas parameters for currently breathed gas (with WREG = current gas 1-5)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2042 rcall deco_setup_cc_diluents ; set-up of gas list for deco calculations (with WREG = current gas 1-5)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2043
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2044 ; Start with SP1 (CCR) or 0 (pSCR) as default.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2045 ; If in sensor mode, this value will be overwritten by calc_deko_divemode_sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2046 clrf WREG ; preload WREG with setpoint value 0 for pSCR calculated
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2047 btfss FLAG_ccr_mode ; are we in CCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2048 bra dive_boot_cc_2 ; NO - keep preloaded value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2049 movff char_I_setpoint_cbar+0,WREG ; YES - get value of setpoint 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2050 dive_boot_cc_2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2051 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2052 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2053 goto calc_deko_divemode_sensor ; read & process sensor data (and return)
0
heinrichsweikamp
parents:
diff changeset
2054
heinrichsweikamp
parents:
diff changeset
2055 diveloop_boot:
heinrichsweikamp
parents:
diff changeset
2056 call restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
2057
heinrichsweikamp
parents:
diff changeset
2058 call I2C_sleep_accelerometer ; Stop accelerometer
heinrichsweikamp
parents:
diff changeset
2059 call I2C_sleep_compass ; Stop compass
heinrichsweikamp
parents:
diff changeset
2060
heinrichsweikamp
parents:
diff changeset
2061 clrf WREG
heinrichsweikamp
parents:
diff changeset
2062 movff WREG,max_pressure+0 ; clear some variables
heinrichsweikamp
parents:
diff changeset
2063 movff WREG,max_pressure+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2064
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2065 ; init in invalid data state
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2066 clrf WREG ; set WREG to 0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2067 bsf WREG,int_invalid_flag ; set invalid flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2068 bsf WREG,int_is_zero ; set zero flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2069 movff WREG,int_O_tank_pres_need+1 ; Set flags for tank pressure needs = 0 before p2_deco.c
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2070 movff WREG,int_O_tank_pres_need+3 ; can do it. If this is not done here and the gas needs
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2071 movff WREG,int_O_tank_pres_need+5 ; custom view is shown before p2_deco.c completes the first
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2072 movff WREG,int_O_tank_pres_need+7 ; deco calculation, some rubbish numbers from last dive of
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2073 movff WREG,int_O_tank_pres_need+9 ; simulation may be shown
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2074
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2075 ; configure the deco engine:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2076 movff char_O_deco_status,WREG ; bank-safe copy
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2077 bsf WREG,DECO_STATUS_0_FLAG ; configure init ...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2078 bsf WREG,DECO_STATUS_1_FLAG ; ... state,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2079 bcf WREG,DECO_PLAN_FLAG ; normal plan mode,
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2080 bsf WREG,DECO_CNS_FLAG ; enable CNS calculation (CNS at end of dive),
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2081 bcf WREG,DECO_VOLUME_FLAG ; disable gas volume calculation, and
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2082 bcf WREG,DECO_ASCENT_FLAG ; disable delayed ascent calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2083 movff WREG,char_O_deco_status ; bank-safe copy back
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2084
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2085 clrf WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2086 movff WREG,char_O_main_status ; reset char_O_main_status
0
heinrichsweikamp
parents:
diff changeset
2087
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2088 movlw deco_distance
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2089 movff WREG,char_I_deco_distance
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2090 movff opt_last_stop,char_I_depth_last_deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2091 movff opt_GF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2092 movff opt_GF_high,char_I_GF_High_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2093
0
heinrichsweikamp
parents:
diff changeset
2094 bcf use_agf ; Start with normal GF set
heinrichsweikamp
parents:
diff changeset
2095 bcf divemode_menu ; clear divemode menu flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2096
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2097 bcf alternative_divelayout ; Start with default layout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2098
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2099 bcf blinking_depth_prev ; clear flag for blinking depth ## NEW BUGFIX
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2100 bcf blinking_depth_warning ; clear flag for blinking depth ## NEW BUGFIX
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2101 bcf blinking_depth_toggle ; clear flag for blinking depth ## NEW BUGFIX
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2102
0
heinrichsweikamp
parents:
diff changeset
2103 movlw d'1'
heinrichsweikamp
parents:
diff changeset
2104 movwf apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
2105 clrf apnoe_max_pressure+1
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2106 ; clrf apnoe_surface_mins
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2107 ; clrf apnoe_surface_secs
0
heinrichsweikamp
parents:
diff changeset
2108 clrf apnoe_mins
heinrichsweikamp
parents:
diff changeset
2109 clrf divemins+0
heinrichsweikamp
parents:
diff changeset
2110 clrf divemins+1
389
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2111
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2112 ; Copy date and time for logbook
389
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2113 movff year,start_year
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2114 movff month,start_month
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2115 movff day,start_day
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2116 movff hours,start_hours
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 386
diff changeset
2117 movff mins,start_mins
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2118
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2119 movff int_O_CNS_fraction+0,CNS_start+0 ; save CNS value at beginning of dive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2120 movff int_O_CNS_fraction+1,WREG ; get high byte to WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2121 bcf WREG,int_warning_flag ; clear warning flag bit
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2122 movff WREG,CNS_start+1 ; move high byte on
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2123 movff int_O_gradient_factor+0,GF_start ; save GF value at beginning of dive (only lower byte used for value)
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2124
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2125 bcf no_more_divesecs ; =1: do no longer show seconds in divemode
0
heinrichsweikamp
parents:
diff changeset
2126 bcf divemode_menu_active
heinrichsweikamp
parents:
diff changeset
2127 clrf menupos
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2128 clrf menupos2 ; Reset to zero (Zero=no premenu or simulator task)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2129 bsf sensors_agree ; init of sensors disagree warning system
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2130
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2131 btfsc FLAG_ccr_mode
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2132 bra diveloop_boot_cc
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2133 btfsc FLAG_pscr_mode
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2134 bra diveloop_boot_cc
0
heinrichsweikamp
parents:
diff changeset
2135 rcall dive_boot_oc
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2136 bra diveloop_boot_cont
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2137
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2138 diveloop_boot_cc:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2139 rcall dive_boot_cc
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2140
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2141 diveloop_boot_cont:
403
6e60012bb3fc NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents: 399
diff changeset
2142 ; Copy opt_dil_types into backup (For "lost gas" feature)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2143 movff opt_dil_type+0,opt_dil_type_backup+0 ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2144 movff opt_dil_type+1,opt_dil_type_backup+1 ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2145 movff opt_dil_type+2,opt_dil_type_backup+2 ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2146 movff opt_dil_type+3,opt_dil_type_backup+3 ; 0=Disabled, 1=First, 2=Normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2147 movff opt_dil_type+4,opt_dil_type_backup+4 ; 0=Disabled, 1=First, 2=Normal
403
6e60012bb3fc NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents: 399
diff changeset
2148 ; Copy opt_gas_types into backup (For "lost gas" feature)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2149 movff opt_gas_type+0,opt_gas_type_backup+0 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2150 movff opt_gas_type+1,opt_gas_type_backup+1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2151 movff opt_gas_type+2,opt_gas_type_backup+2 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2152 movff opt_gas_type+3,opt_gas_type_backup+3 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2153 movff opt_gas_type+4,opt_gas_type_backup+4 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
403
6e60012bb3fc NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents: 399
diff changeset
2154 ; Also copy change depths into backup (For "lost gas" feature)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2155 movff char_I_dil_change+0,opt_dil_change_backup+0 ; Gas change depths Diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2156 movff char_I_dil_change+1,opt_dil_change_backup+1 ; Gas change depths Diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2157 movff char_I_dil_change+2,opt_dil_change_backup+2 ; Gas change depths Diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2158 movff char_I_dil_change+3,opt_dil_change_backup+3 ; Gas change depths Diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2159 movff char_I_dil_change+4,opt_dil_change_backup+4 ; Gas change depths Diluents
516
2ef8cf6b320d NEW: ppO2 blinks in sensor mode when min/max boundaries are hit
heinrichsweikamp
parents: 513
diff changeset
2160 ; Also copy change depths into backup (For "lost gas" feature)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2161 movff opt_OC_bail_gas_change+0,opt_OC_bail_gas_change_backup+0; Gas change depths OC/Bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2162 movff opt_OC_bail_gas_change+1,opt_OC_bail_gas_change_backup+1; Gas change depths OC/Bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2163 movff opt_OC_bail_gas_change+2,opt_OC_bail_gas_change_backup+2; Gas change depths OC/Bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2164 movff opt_OC_bail_gas_change+3,opt_OC_bail_gas_change_backup+3; Gas change depths OC/Bailout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2165 movff opt_OC_bail_gas_change+4,opt_OC_bail_gas_change_backup+4; Gas change depths OC/Bailout
403
6e60012bb3fc NEW: "Lost Gas" feature allows disabling gases during the dive
heinrichsweikamp
parents: 399
diff changeset
2166
0
heinrichsweikamp
parents:
diff changeset
2167 clrf better_gas_number ; Clear better gas register
heinrichsweikamp
parents:
diff changeset
2168
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2169 bcf show_safety_stop ; =1: Show the safety stop
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
2170 clrf safety_stop_countdown ; Clear count-down
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
2171
0
heinrichsweikamp
parents:
diff changeset
2172 clrf samplesecs
heinrichsweikamp
parents:
diff changeset
2173 clrf apnoe_timeout_counter ; timeout in minutes
heinrichsweikamp
parents:
diff changeset
2174 clrf timeout_counter ; takes care of the timeout (Low byte)
heinrichsweikamp
parents:
diff changeset
2175 clrf timeout_counter2 ; takes care of the timeout (High byte)
heinrichsweikamp
parents:
diff changeset
2176 clrf AlarmType ; Clear all alarms
heinrichsweikamp
parents:
diff changeset
2177 bcf event_occured ; clear flag
heinrichsweikamp
parents:
diff changeset
2178 clrf average_depth_hold_total+0
heinrichsweikamp
parents:
diff changeset
2179 clrf average_depth_hold_total+1
heinrichsweikamp
parents:
diff changeset
2180 clrf average_depth_hold_total+2
heinrichsweikamp
parents:
diff changeset
2181 clrf average_depth_hold_total+3 ; Clear Non-Resettable Average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2182 rcall reset_average1 ; Reset the resettable average depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2183 bcf decostop_active
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2184 bcf better_gas_available ; =1: A better gas is available and a gas change is advised in divemode
204
heinrichsweikamp
parents: 197
diff changeset
2185 call ghostwriter_short_header ; Write short header with divenumber into profile memory
0
heinrichsweikamp
parents:
diff changeset
2186
heinrichsweikamp
parents:
diff changeset
2187 btfsc simulatormode_active
heinrichsweikamp
parents:
diff changeset
2188 bra diveloop_boot_1
heinrichsweikamp
parents:
diff changeset
2189 ; Normal mode = Surface pressure is the pressure 30mn before dive.
heinrichsweikamp
parents:
diff changeset
2190 SAFE_2BYTE_COPY last_surfpressure_30min, int_I_pres_surface ;copy surfacepressure to deco routine
heinrichsweikamp
parents:
diff changeset
2191 SAFE_2BYTE_COPY last_surfpressure_30min, last_surfpressure ;copy surfacepressure to last_surfpressure for correct depth
heinrichsweikamp
parents:
diff changeset
2192 bra diveloop_boot_2
heinrichsweikamp
parents:
diff changeset
2193
heinrichsweikamp
parents:
diff changeset
2194 diveloop_boot_1:
heinrichsweikamp
parents:
diff changeset
2195 ; Simulator mode: Surface pressure is 1bar.
heinrichsweikamp
parents:
diff changeset
2196 movlw LOW .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2197 movff WREG,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine
0
heinrichsweikamp
parents:
diff changeset
2198 movlw HIGH .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2199 movff WREG,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine
0
heinrichsweikamp
parents:
diff changeset
2200
heinrichsweikamp
parents:
diff changeset
2201 diveloop_boot_2:
heinrichsweikamp
parents:
diff changeset
2202 SAFE_2BYTE_COPY temperature,minimum_temperature ; Reset Min-Temp registers
heinrichsweikamp
parents:
diff changeset
2203
heinrichsweikamp
parents:
diff changeset
2204 ; Init profile recording parameters
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2205 movff samplingrate,samplesecs_value ; to avoid EEPROM access in the ISR
0
heinrichsweikamp
parents:
diff changeset
2206 movlw div_temperature
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2207 movwf divisor_temperature ; load divisors for profile storage
0
heinrichsweikamp
parents:
diff changeset
2208 movlw div_deco
heinrichsweikamp
parents:
diff changeset
2209 movwf divisor_deco
heinrichsweikamp
parents:
diff changeset
2210 movlw div_gf
heinrichsweikamp
parents:
diff changeset
2211 movwf divisor_gf
heinrichsweikamp
parents:
diff changeset
2212 movlw div_ppo2_sensors
heinrichsweikamp
parents:
diff changeset
2213 movwf divisor_ppo2_sensors
heinrichsweikamp
parents:
diff changeset
2214 movlw div_decoplan
heinrichsweikamp
parents:
diff changeset
2215 movwf divisor_decoplan
heinrichsweikamp
parents:
diff changeset
2216 movlw div_cns
heinrichsweikamp
parents:
diff changeset
2217 movwf divisor_cns
heinrichsweikamp
parents:
diff changeset
2218 movlw div_tank
heinrichsweikamp
parents:
diff changeset
2219 movwf divisor_tank
heinrichsweikamp
parents:
diff changeset
2220
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2221 btfss FLAG_apnoe_mode ; In Apnoe mode?
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2222 bra divemode_boot1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2223
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2224 ; Overwrite some parameters in Apnoe mode....
0
heinrichsweikamp
parents:
diff changeset
2225 movlw samplingrate_apnoe
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2226 movwf samplesecs_value ; to avoid EEPROM access in the ISR
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2227
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2228 divemode_boot1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2229 bsf ccr_diluent_setup ; For CCR mode (Required to have better gas working)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2230 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2231 bra divemode_boot2
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
2232 btfsc FLAG_pscr_mode
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
2233 bra divemode_boot2
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
2234
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2235 ; in OC Mode, disable ppO2 logging
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2236 movlw .0
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2237 movwf divisor_ppo2_sensors
543
a92cecf8cee4 BUGFIX: "lost gas" showed current set of gases (Diluents in CC, OC in Bailout) for both "lost gas" menus
heinrichsweikamp
parents: 541
diff changeset
2238
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2239 bcf ccr_diluent_setup ; For OC mode (Required to have better gas working)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2240
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2241 divemode_boot2:
0
heinrichsweikamp
parents:
diff changeset
2242 bcf LEDg
heinrichsweikamp
parents:
diff changeset
2243 bcf LEDr
heinrichsweikamp
parents:
diff changeset
2244 bcf realdive
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2245 btfss simulatormode_active ; do not disable in simulator mode!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2246 call disable_rs232 ; Disable RS232
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2247 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2248 call enable_rs232 ; Also sets to speed_normal ...
39
e4e91fe8b09d remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents: 38
diff changeset
2249 ; Reset divetime seconds
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2250 movlw .2 ; Start at 2seconds
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2251 movwf total_divetime_seconds+0
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2252 clrf total_divetime_seconds+1
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2253 movwf divesecs
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2254 movwf apnoe_secs
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2255 bsf divemode2 ; displayed divetime is running (Divetime starts HERE)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2256 return ; Done with divemode boot
0
heinrichsweikamp
parents:
diff changeset
2257
heinrichsweikamp
parents:
diff changeset
2258 divemode_check_for_warnings:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2259 movlw .1 ; One warning at a time in alt. layout mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2260 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2261 movlw .2 ; Two warnings at a time in default layout mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2262 cpfsgt warning_counter ; only one (or two) warnings active?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2263 bra divemode_check_for_warnings1 ; Yes, update every second
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2264
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2265 btfss secs,0 ; Every two seconds...
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2266 return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2267 btfss secs,1 ; Every four seconds...
0
heinrichsweikamp
parents:
diff changeset
2268 return
heinrichsweikamp
parents:
diff changeset
2269
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2270 divemode_check_for_warnings1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2271 bcf warning_active ; Clear flag
0
heinrichsweikamp
parents:
diff changeset
2272 clrf warning_counter ; Clear counter
heinrichsweikamp
parents:
diff changeset
2273
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2274 ; warnings sorted by severity, highest severity first
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2275
0
heinrichsweikamp
parents:
diff changeset
2276 ; Warnings for all modes
heinrichsweikamp
parents:
diff changeset
2277 call check_warn_battery ; Check if the battery level should be displayed/warned
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2278 call check_divetimeout ; Not actually a warning. Check and show the divemode timeout
0
heinrichsweikamp
parents:
diff changeset
2279
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2280 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
0
heinrichsweikamp
parents:
diff changeset
2281 bra divemode_check_for_warnings2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2282 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
0
heinrichsweikamp
parents:
diff changeset
2283 bra divemode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
2284
heinrichsweikamp
parents:
diff changeset
2285 ; Warnings only in deco modes
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2286 rcall check_ppO2 ; check ppO2 and displays warning, if required
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
2287
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2288 btfss sensors_agree ; are the sensor values within the threshold range?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2289 rcall check_warn_sensors_disagree ; NO - further evaluate
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2290 btfsc sensors_agree ; are the sensor values within the threshold range?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2291 bcf sensor_warning ; YES - revoke memorized sensor warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2292
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2293 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2294 btfsc WREG,outside_warning_lock ; are we outside of the ZH-L16 model?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2295 rcall warn_outside ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2296
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2297 rcall check_IBCD ; check for IBCD attention or warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2298
0
heinrichsweikamp
parents:
diff changeset
2299 btfsc decostop_active ; In deco mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2300 rcall check_and_store_gf_violation ; Yes, sets warnings, if required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2301
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2302 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2303 btfsc WREG,mbubble_warning_lock ; do we have a microbubbles warning?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2304 rcall warn_mbubbles ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2305
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2306 rcall check_cns_violation ; Check CNS value and display it, if required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2307
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2308 ;btfsc decostop_active ; In deco mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2309 rcall check_gas_needs ; show gas needs warning if any gas need is > threshold
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2310
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2311 rcall check_eod_cns_violation ; Check CNS values for end-of-dive and display warning, if required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2312
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2313 call TFT_display_ftts ; Show @+x time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2314
0
heinrichsweikamp
parents:
diff changeset
2315 btfsc use_agf ; In aGF mode?
heinrichsweikamp
parents:
diff changeset
2316 rcall warn_agf ; Yes, show a warning for it
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2317
145
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2318 btfsc setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2319 rcall warn_fallback ; Show the warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2320
0
heinrichsweikamp
parents:
diff changeset
2321 divemode_check_for_warnings2:
heinrichsweikamp
parents:
diff changeset
2322 ; Display the warning icon?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2323 btfsc warning_active ; Any warning active?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2324 bsf FLAG_TFT_divemode_warning ; Yes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2325 btfss warning_active ; Any warning active?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2326 bsf FLAG_TFT_divemode_warning_clear ; No, clear warning icon
0
heinrichsweikamp
parents:
diff changeset
2327
heinrichsweikamp
parents:
diff changeset
2328 ; Setup warning_page number
heinrichsweikamp
parents:
diff changeset
2329 incf warning_page,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2330 movf warning_page,W
0
heinrichsweikamp
parents:
diff changeset
2331 bcf STATUS,C
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2332 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2333 rlcf warning_page,W ; *2 (But only in standard layout mode)
0
heinrichsweikamp
parents:
diff changeset
2334 cpfsgt warning_counter ; > warning_counter
heinrichsweikamp
parents:
diff changeset
2335 clrf warning_page ; No, clear
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2336
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2337 ; Clear both rows of warnings if there is nothing to show at all
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2338 tstfsz warning_counter ; any warnings?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2339 bra divemode_check_for_warnings3 ; YES - look if second row needs to be cleared
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2340 bsf FLAG_TFT_dive_warning_text_clear ; Set flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2341 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2342 divemode_check_for_warnings3:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2343
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2344
0
heinrichsweikamp
parents:
diff changeset
2345 ; Clear 2nd row of warnings if there is nothing to show (on this page)
heinrichsweikamp
parents:
diff changeset
2346 btfss second_row_warning ; =1: The second row contains a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2347 bsf FLAG_TFT_dive_warning_text_clr2 ; Set flag for 2nd row
0
heinrichsweikamp
parents:
diff changeset
2348 return ; Done.
heinrichsweikamp
parents:
diff changeset
2349
heinrichsweikamp
parents:
diff changeset
2350 global check_warn_battery
heinrichsweikamp
parents:
diff changeset
2351 check_warn_battery:
heinrichsweikamp
parents:
diff changeset
2352 movff batt_percent,lo
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2353 movlw battery_show_level+1
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2354 cpfslt lo
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2355 return ; No Display, no warning
0
heinrichsweikamp
parents:
diff changeset
2356 ; Display Battery, but warn?
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2357 movff batt_percent,lo
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2358 movlw color_code_battery_low+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2359 cpfsgt lo ;
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2360 bsf warning_active ; Set Warning flag
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2361
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2362 movlw .4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2363 cpfseq menupos3 ; battery shown in Custom View 4?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2364 bra check_warn_battery2 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2365 return ; Yes, do not show twice (in custom view and in warning area)
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2366 check_warn_battery2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2367 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2368 goto TFT_update_batt_percent_divemode ; Show percent (And return)
513
heinrichsweikamp
parents: 507
diff changeset
2369
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2370 check_divetimeout:
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2371 btfsc divemode2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2372 return ; displayed divetime is not running
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2373 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2374 goto TFT_divetimeout ; Show timeout counter (and return)
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2375
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2376
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2377 check_ppO2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2378 btfsc FLAG_ccr_mode ; are we in CCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2379 bra check_ppO2_loop ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2380 btfsc FLAG_pscr_mode ; are we in pSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2381 bra check_ppO2_loop ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2382 bra check_ppO2_oc_1 ; NO - neither CCR nor pSCR
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2383 check_ppO2_loop:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2384 btfsc is_bailout ; in bailout?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2385 bra check_ppO2_oc_1 ; YES - continue with OC
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2386 movff int_O_pure_ppO2+1,hi ; NO - get upper part of int_O_pure_ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2387 btfsc hi,int_warning_flag ; ppO2 of the pure diluent to low or high?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2388 rcall check_ppO2_d ; YES - show warning and return on next line
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2389 bra check_ppO2_oc_2 ; skip pre-warning threshold test on breathed ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2390 check_ppO2_oc_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2391 movff int_O_breathed_ppO2+1,WREG ; get upper part of int_O_breathed_ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2392 btfsc WREG,int_prewarning_flag ; breathed ppO2 just above pre-warning threshold?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2393 bra check_ppo2_display ; YES - show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2394 check_ppO2_oc_2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2395 movff int_O_breathed_ppO2+1,WREG ; get upper part of int_O_breathed_ppO2 (perhaps again)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2396 btfsc WREG,int_low_flag ; breathed ppO2 to low?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2397 bra check_ppO2_low ; YES - record the warning and show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2398 btfsc WREG,int_high_flag ; breathed ppO2 to high?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2399 bra check_ppO2_high ; YES - record the warning and show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2400 TSTOSS opt_showppo2 ; show ppO2 anyhow? (0 = no, 1 = show always)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2401 return ; NO - no warnings, no show
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2402 bra check_ppo2_display ; YES - just show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2403 check_ppO2_low:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2404 movlw d'4' ; set type of alarm (ppO2 low)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2405 bra check_ppO2_common ; continue with common part
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2406 check_ppO2_high:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2407 movlw d'5' ; set type of alarm (ppO2 high)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2408 check_ppO2_common:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2409 movwf AlarmType ; copy alarm type to alarm register
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2410 bsf event_occured ; set event flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2411 bsf warning_active ; set warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2412 btfsc is_bailout ; are we in bailout?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2413 bra check_ppo2_display ; YES - skip CCR/pSCR checks
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2414 btfsc FLAG_ccr_mode ; are we in CCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2415 return ; YES - no extra warning required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2416 btfsc FLAG_pscr_mode ; are we in pSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2417 return ; YES - no extra warning required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2418 check_ppo2_display: ; display warning if ppO2 is not already shown in custom view
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2419 movlw .9
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2420 cpfseq menupos3 ; ppO2 shown in Custom View 9?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2421 bra check_ppO2_a ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2422 return ; Yes, do not show twice (in custom view and in warning area)
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2423 check_ppO2_a:
471
9edb1359ce43 NEW: New Customview 11 in dive mode shows ppO2, EAD/END and CNS
heinrichsweikamp
parents: 444
diff changeset
2424 movlw .11
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2425 cpfseq menupos3 ; ppO2 shown in Custom View 11?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2426 bra check_ppO2_b ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2427 return ; Yes, do not show twice (in custom view and in warning area)
471
9edb1359ce43 NEW: New Customview 11 in dive mode shows ppO2, EAD/END and CNS
heinrichsweikamp
parents: 444
diff changeset
2428 check_ppO2_b:
482
c0ee33f1f399 New customview #12 for PSCR mode shows ppO2, O2 drop and lung ratio
heinrichsweikamp
parents: 480
diff changeset
2429 movlw .12
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2430 cpfseq menupos3 ; ppO2 shown in Custom View 12?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2431 bra check_ppO2_c ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2432 return ; Yes, do not show twice (in custom view and in warning area)
482
c0ee33f1f399 New customview #12 for PSCR mode shows ppO2, O2 drop and lung ratio
heinrichsweikamp
parents: 480
diff changeset
2433 check_ppO2_c:
530
d36f9fca10ae 2.20beta release
heinrichsweikamp
parents: 527
diff changeset
2434 movlw .10
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2435 cpfseq menupos3 ; ppO2 shown in Custom View 10?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2436 bra check_ppO2_d ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2437 return ; Yes, do not show twice (in custom view and in warning area)
530
d36f9fca10ae 2.20beta release
heinrichsweikamp
parents: 527
diff changeset
2438 check_ppO2_d:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2439 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2440 goto TFT_display_ppo2 ; show breathed gas or diluent ppO2 warning (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2441
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2442
0
heinrichsweikamp
parents:
diff changeset
2443 global check_cns_violation
heinrichsweikamp
parents:
diff changeset
2444 check_cns_violation:
heinrichsweikamp
parents:
diff changeset
2445 ; Check if CNS should be displayed
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2446 movff int_O_CNS_fraction+1,WREG ; get high byte
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2447 btfsc WREG,int_warning_flag ; warning flag set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2448 bra check_cns_violation2 ; Yes - issue warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2449 btfsc WREG,int_prewarning_flag ; pre-warning flag set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2450 bra display_cns_violation ; YES - just display CNS
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2451 return ; No - no display, no warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2452 check_cns_violation2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2453 bsf warning_active ; Set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2454 display_cns_violation: ; Show CNS if not shown in the custom view
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2455 movlw .11
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2456 cpfseq menupos3 ; CNS shown in Custom View?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2457 bra display_cns_violation2 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2458 return ; Yes, do not show twice (in custom view and in warning area)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2459 display_cns_violation2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2460 movlw .8
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2461 cpfseq menupos3 ; CNS shown through Custom View 8 right now?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2462 bra display_cns_violation3 ; No
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2463 return ; Yes, do not show twice (in custom view and in warning area)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2464 display_cns_violation3:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2465 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2466 goto TFT_display_cns ; Show CNS (and return)
0
heinrichsweikamp
parents:
diff changeset
2467
471
9edb1359ce43 NEW: New Customview 11 in dive mode shows ppO2, EAD/END and CNS
heinrichsweikamp
parents: 444
diff changeset
2468
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2469 global check_eod_cns_violation ; check end-of-dive CNS values
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2470 check_eod_cns_violation:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2471 movff int_O_CNS_fraction+1,WREG ; get high-byte of current CNS value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2472 btfsc WREG,int_warning_flag ; current CNS value in warning state?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2473 return ; YES - inhibit eod warning if current CNS is already in warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2474 movff int_O_normal_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2475 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2476 bra check_eod_cns_violation1 ; YES - continue with checking the other CNS value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2477 btfsc WREG,int_warning_flag ; NO - flag for warning set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2478 bra check_eod_cns_violation2 ; YES - issue warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2479 check_eod_cns_violation1: ; NO - continue with checking the other CNS value
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2480 movff int_O_alternate_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2481 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2482 return ; YES - done with CNS checking
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2483 btfsc WREG,int_warning_flag ; NO - flag for warning set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2484 bra check_eod_cns_violation2 ; Yes - issue warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2485 return ; NO - done with CNS checking
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2486 check_eod_cns_violation2: ; YES - issue warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2487 bsf warning_active ; set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2488 movlw .8 ; issue textual warning if CNS values are not shown in the custom view right now
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2489 cpfseq menupos3 ; CNS values shown through Custom View 8 right now?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2490 bra display_eod_cns_violation ; NO - issue textual warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2491 return ; YES - do not show twice (in custom view and in warning area)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2492 display_eod_cns_violation:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2493 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2494 goto TFT_display_eod_cns ; issue CNS at end-of-dive warning (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2495
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2496
0
heinrichsweikamp
parents:
diff changeset
2497 global check_and_store_gf_violation
heinrichsweikamp
parents:
diff changeset
2498 check_and_store_gf_violation:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2499 movff int_O_gradient_factor+1,WREG ; get upper byte of gradient factor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2500 btfss WREG,int_warning_flag ; check if the warning flag is set
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2501 bra check_and_store_gf_violation2 ; NO - continue with checking for pre-warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2502 movlw d'2' ; YES - set type of alarm
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2503 movwf AlarmType ; copy to alarm register
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2504 bsf event_occured ; set event flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2505 bsf warning_active ; set warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2506 bra check_and_store_gf_violation3 ; show gf warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2507 check_and_store_gf_violation2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2508 btfsc WREG,int_prewarning_flag ; check if the pre-warning flag is set
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2509 bra check_and_store_gf_violation3 ; YES - show gf
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2510 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2511 bra check_and_store_gf_violation4 ; NO - continue checking of deco info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2512 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2513 btfss WREG,IBCD_warning ; is the IBCD warning flag set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2514 bra check_and_store_gf_violation4 ; NO - continue checking for deco info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2515 check_and_store_gf_violation3: ; YES - show gf
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2516 bsf warning_active ; set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2517 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2518 goto TFT_warning_gf ; show GF (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2519 check_and_store_gf_violation4: ; check for deco info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2520 btfss divemode ; in divemode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2521 return ; NO - done, return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2522 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2523 btfss WREG,deco_flag ; check if the deco flag is set
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2524 return ; NO - all done, return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2525 incf warning_counter,F ; YES - increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2526 goto TFT_info_deco ; show deco info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2527
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2528
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2529 warn_outside:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2530 incf warning_counter,F ; increase counter
0
heinrichsweikamp
parents:
diff changeset
2531 bsf warning_active ; Set Warning flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2532 goto TFT_warning_outside ; show microbubbles warning (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2533
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2534
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2535 global warn_mbubbles
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2536 warn_mbubbles:
0
heinrichsweikamp
parents:
diff changeset
2537 incf warning_counter,F ; increase counter
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2538 bsf warning_active ; Set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2539 goto TFT_warning_mbubbles ; show microbubbles warning (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2540
0
heinrichsweikamp
parents:
diff changeset
2541 warn_agf:
heinrichsweikamp
parents:
diff changeset
2542 incf warning_counter,F ; increase counter
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2543 goto TFT_warning_agf ; Show aGF warning (and return)
145
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2544
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2545 warn_fallback:
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2546 incf warning_counter,F ; increase counter
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2547 bsf warning_active ; Set Warning flag
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2548 goto TFT_warning_fallback ; Show fallback warning (and return)
0
heinrichsweikamp
parents:
diff changeset
2549
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2550
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2551 check_gas_needs:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2552 banksel int_O_tank_pres_need
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2553 movf int_O_tank_pres_need+1,w ; get HIGH(pres need of 1st tank)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2554 iorwf int_O_tank_pres_need+3,w ; inclusive or with HIGH(pres need of 2nd tank)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2555 iorwf int_O_tank_pres_need+5,w ; inclusive or with HIGH(pres need of 3rd tank)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2556 iorwf int_O_tank_pres_need+7,w ; inclusive or with HIGH(pres need of 4th tank)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2557 iorwf int_O_tank_pres_need+9,w ; inclusive or with HIGH(pres need of 5th tank)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2558 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2559 btfsc WREG,int_invalid_flag ; check if invalid flag is set
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2560 return ; YES - no further checking required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2561 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2562 bsf warning_active ; YES - set warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2563 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2564 goto TFT_warning_gas_needs_warn ; Yes - show a warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2565 btfsc WREG,int_prewarning_flag ; NO - check if any gas has a pres_need >= pres_fill * threshold
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2566 goto TFT_warning_gas_needs_att ; YES - show an attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2567 bcf gas_needs_attention ; NO - clear flag for a new attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2568 bcf gas_needs_warning ; clear flag for a new warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2569 return
0
heinrichsweikamp
parents:
diff changeset
2570
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2571
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2572 check_warn_sensors_disagree:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2573 incf warning_counter,F ; increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2574 bsf warning_active ; YES - set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2575 goto TFT_warning_sensor_disagree ; show sensor disagree warning (and return)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2576
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2577
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2578 check_IBCD:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2579 TSTOSS opt_enable_IBCD ; IBCD warning activated?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2580 return ; NO - done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2581 movff char_O_deco_warnings,WREG ; YES - get deco warnings vector
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2582 btfss WREG,IBCD_warning ; IBCD warning flag set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2583 return ; NO - return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2584 incf warning_counter,F ; YES - increase counter
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2585 goto TFT_warning_IBCD ; write warning to display
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2586
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2587
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2588
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2589 global restart_deco_engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2590 global restart_deco_engine_wo_ceiling
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2591 restart_deco_engine:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2592 ; make bank save copies and set flags for invalid data
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2593 movff int_O_ceiling+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2594 bsf WREG,char_invalid_flag ; int_O_ceiling has its invalid flag on a char's position!
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2595 movff WREG,int_O_ceiling+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2596
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2597 restart_deco_engine_wo_ceiling:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2598 ; make more bank save copies and set more flags for invalid data
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2599 movff char_O_deco_gas+0,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2600 bsf WREG,char_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2601 movff WREG,char_O_deco_gas+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2602
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2603 movff int_O_ascenttime+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2604 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2605 movff WREG,int_O_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2606
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2607 movff int_O_alternate_ascenttime+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2608 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2609 movff WREG,int_O_alternate_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2610
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2611 movff int_O_normal_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2612 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2613 movff WREG,int_O_normal_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2614
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2615 movff int_O_alternate_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2616 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2617 movff WREG,int_O_alternate_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2618
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2619 movff int_O_tank_pres_need+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2620 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2621 movff WREG,int_O_tank_pres_need+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2622
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2623 ; restart deco engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2624 movff char_O_deco_status,WREG ; get current deco engine configuration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2625 bcf WREG,DECO_STATUS_0_FLAG ; set status flags to...
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2626 bcf WREG,DECO_STATUS_1_FLAG ; ... DECO_STATUS_START
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2627 bsf WREG,DECO_PLAN_FLAG ; fake we came from alternative plan to force normal plan to be done next
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2628 movff WREG,char_O_deco_status ; write back new configuration to restart deco computations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2629
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2630 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2631
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2632
0
heinrichsweikamp
parents:
diff changeset
2633 END