annotate src/divemode.asm @ 582:b455b31ce022

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