annotate src/divemode.asm @ 586:06642f6ffe59

2.97 release
author heinrichsweikamp
date Thu, 01 Mar 2018 11:12:47 +0100
parents 6636cbe64c6d
children bf0c76e9b01b
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
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
528 calc_deko_divemode_sensor_opt:
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
529 btfss optical_input ; do we have an optical input?
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
530 return ; No, return (We have no sensors at all. Not analog, not S8 and not optical)
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
531 ;o2_ppo2_sensor1, o2_ppo2_sensor2 and o2_ppo2_sensor3 are already filled in ISR
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
532 ;clear use_O2_sensorX for timeout case
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
533 btfss sensor1_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
534 bcf use_O2_sensor1
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
535 btfss sensor2_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
536 bcf use_O2_sensor2
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
537 btfss sensor3_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
538 bcf use_O2_sensor3
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
539 bra calc_deko_divemode_sensor1
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
540
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
541 calc_deko_divemode_sensor_analog:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
542 btfss analog_o2_input ; do we have an analog input?
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
543 bra calc_deko_divemode_sensor_opt ; NO - check if we have an optical interface
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
544 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
545
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
546 calc_deko_divemode_sensor_common:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
547 ; 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
548 ; If ok: compute o2_ppo2_sensorX := o2_mv_sensorX * opt_x_sX / 1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
549 ; 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
550
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
551 ; Check min_mv of sensor 1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
552 btfss sensor1_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
553 bra check_sensor_1_fail ; NO - handle it as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
554 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
555 movff o2_mv_sensor1+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
556 movlw LOW min_mv ; load minimum mV value
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
557 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
558 movlw HIGH min_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
559 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
560 call sub16 ; sub_c = sensor_mv - min_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
561 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
562 bra check_sensor_1_fail ; YES - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
563 ; Check max_mv of sensor 1 ; NO - continue with next check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
564 movff o2_mv_sensor1+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
565 movff o2_mv_sensor1+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
566 movlw LOW max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
567 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
568 movlw HIGH max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
569 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
570 call sub16 ; sub_c = sensor_mv - max_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
571 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
572 bra check_sensor_1_fail ; NO - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
573 ; Check HUD data, if available ; YES - continue with next check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
574 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
575 bra check_sensor_1_ok ; NO - all checks done then and positive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
576 btfss sensor1_active ; YES - check HUD report on sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
577 bra check_sensor_1_fail ; HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
578
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
579 check_sensor_1_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
580 ; o2_ppo2_sensor1 := o2_mv_sensor1:2 * opt_x_s1:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
581 movff o2_mv_sensor1+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
582 movff o2_mv_sensor1+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
583 movff opt_x_s1+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
584 movff opt_x_s1+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
585 rcall compute_ppo2_helper
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
586 movff xC+0,o2_ppo2_sensor1 ; result in 0.01bar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
587 bra check_sensor_2 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
588
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
589 check_sensor_1_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
590 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
591 movff WREG,o2_ppo2_sensor1 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
592 btfss use_O2_sensor1 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
593 bra check_sensor_1_fail_1 ; NO - no new news then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
594 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
595 check_sensor_1_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
596 bcf use_O2_sensor1 ; revoke sensor from usage
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
597 ;bra check_sensor_2 ; continue with next sensor
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
598
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
599 check_sensor_2: ; Check min_mv of sensor 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
600 btfss sensor2_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
601 bra check_sensor_2_fail ; NO - handle it as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
602 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
603 movff o2_mv_sensor2+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
604 movlw LOW min_mv ; load minimum mV value
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
605 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
606 movlw HIGH min_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
607 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
608 call sub16 ; sub_c = sensor_mv - min_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
609 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
610 bra check_sensor_2_fail ; YES - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
611 ; Check max_mv of sensor 2 ; NO - continue with next check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
612 movff o2_mv_sensor2+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
613 movff o2_mv_sensor2+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
614 movlw LOW max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
615 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
616 movlw HIGH max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
617 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
618 call sub16 ; sub_c = sensor_mv - max_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
619 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
620 bra check_sensor_2_fail ; NO - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
621 ; Check HUD data, if available ; YES - continue with next check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
622 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
623 bra check_sensor_2_ok ; NO - all checks done then and positive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
624 btfss sensor2_active ; YES - check HUD report on sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
625 bra check_sensor_2_fail ; HUD reports a fail
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
626
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
627 check_sensor_2_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
628 ; o2_ppo2_sensor2 := o2_mv_sensor2:2 * opt_x_s2:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
629 movff o2_mv_sensor2+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
630 movff o2_mv_sensor2+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
631 movff opt_x_s2+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
632 movff opt_x_s2+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
633 rcall compute_ppo2_helper
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
634 movff xC+0,o2_ppo2_sensor2 ; result in 0.01bar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
635 bra check_sensor_3 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
636
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
637 check_sensor_2_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
638 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
639 movff WREG,o2_ppo2_sensor2 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
640 btfss use_O2_sensor2 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
641 bra check_sensor_2_fail_1 ; NO - no new news then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
642 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
643 check_sensor_2_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
644 bcf use_O2_sensor2 ; revoke sensor from usage
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
645 ;bra check_sensor_3 ; continue with next sensor
277
24daa6523218 1.79beta - update internal sensor registers during boot
heinrichsweikamp
parents: 275
diff changeset
646
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
647 check_sensor_3: ; Check min_mv of sensor 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
648 btfss sensor3_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
649 bra check_sensor_3_fail ; NO - handle it as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
650 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
651 movff o2_mv_sensor3+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
652 movlw LOW min_mv ; load minimum mV value
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
653 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
654 movlw HIGH min_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
655 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
656 call sub16 ; sub_c = sensor_mv - min_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
657 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
658 bra check_sensor_3_fail ; YES - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
659 ; Check max_mv of sensor 2 ; NO - continue with next check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
660 movff o2_mv_sensor3+0, sub_a+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
661 movff o2_mv_sensor3+1, sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
662 movlw LOW max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
663 movwf sub_b+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
664 movlw HIGH max_mv
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
665 movwf sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
666 call sub16 ; sub_c = sensor_mv - max_mv
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
667 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
668 bra check_sensor_3_fail ; NO - declare sensor as failed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
669 ; Check HUD data, if available ; YES - continue with next check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
670 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
671 bra check_sensor_3_ok ; NO - all checks done then and positive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
672 btfss sensor3_active ; YES - check HUD report on sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
673 bra check_sensor_3_fail ; HUD reports a fail
0
heinrichsweikamp
parents:
diff changeset
674
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
675 check_sensor_3_ok:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
676 ; o2_ppo2_sensor3 := o2_mv_sensor3:2 * opt_x_s1:2 / 1000
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
677 movff o2_mv_sensor3+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
678 movff o2_mv_sensor3+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
679 movff opt_x_s3+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
680 movff opt_x_s3+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
681 rcall compute_ppo2_helper
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
682 movff xC+0,o2_ppo2_sensor3 ; result in 0.01bar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
683 bra calc_deko_divemode_sensor1 ; continue with calculating sensor average
0
heinrichsweikamp
parents:
diff changeset
684
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
685 check_sensor_3_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
686 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
687 movff WREG,o2_ppo2_sensor3 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
688 btfss use_O2_sensor3 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
689 bra check_sensor_3_fail_1 ; NO - no new news then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
690 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
691 check_sensor_3_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
692 bcf use_O2_sensor3 ; revoke sensor from usage
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
693 ;bra calc_deko_divemode_sensor1 ; continue with calculating sensor average
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
694
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
695 calc_deko_divemode_sensor1: ; calculate sensor average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
696 ; exit here if not in divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
697 btfss divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
698 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
699
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
700 ; 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
701 ; sum up sensor values (in xA:2) and active sensors in (xB:2)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
702 clrf xB+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
703 clrf xB+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
704 clrf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
705 clrf xA+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
706 btfss use_O2_sensor1 ; Sensor1 active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
707 bra divemode_setup_sensor_values2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
708 movf o2_ppo2_sensor1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
709 addwf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
710 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
711 addwfc xA+1 ; Add into xA:2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
712 incf xB+0,F ; Add a sensor
0
heinrichsweikamp
parents:
diff changeset
713 divemode_setup_sensor_values2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
714 btfss use_O2_sensor2 ; Sensor2 active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
715 bra divemode_setup_sensor_values3 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
716 movf o2_ppo2_sensor2,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
717 addwf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
718 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
719 addwfc xA+1 ; Add into xA:2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
720 incf xB+0,F ; Add a sensor
0
heinrichsweikamp
parents:
diff changeset
721 divemode_setup_sensor_values3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
722 btfss use_O2_sensor3 ; Sensor3 active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
723 bra divemode_setup_sensor_values4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
724 movf o2_ppo2_sensor3,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
725 addwf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
726 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
727 addwfc xA+1 ; Add into xA:2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
728 incf xB+0,F ; Add a sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
729
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
730 ; Divide sum of sensor values by number of active sensors found.
0
heinrichsweikamp
parents:
diff changeset
731 divemode_setup_sensor_values4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
732 call div16x16 ; xA/xB=xC with xA+0 as remainder
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
733 movff xC+0,sensor_setpoint ; copy result
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
734
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
735 ; 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
736 ; 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
737 clrf WREG ; preload a zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
738 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
739 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
740 ; it will be overwritten if we have a usable sensor reading
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
741
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
742 btfsc is_bailout ; check if we are in bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
743 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
744 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
745 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
746 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
747 tstfsz xB+0 ; check if we have found at least one usable sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
748 bra calc_deko_divemode_sensor1a ; YES - we have at least one usable sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
749 bsf setpoint_fallback ; NO - we have NO usable sensors -> initiate fallback
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
750 btfss FLAG_ccr_mode ; check if we are in CCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
751 bra calc_deko_divemode_sensor2 ; NO - continue with voting logic flags
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
752 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
753 bra calc_deko_divemode_sensor2 ; done - continue with voting logic flags
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
754 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
755 bcf setpoint_fallback ; clear fallback condition
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
756 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
757 ;bra calc_deko_divemode_sensor2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
758
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
759 calc_deko_divemode_sensor2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
760 bsf voting_logic_sensor1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
761 movff o2_ppo2_sensor1,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
762 rcall check_sensor_voting_helper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
763 incfsz WREG ; Was WREG = 255?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
764 bcf voting_logic_sensor1 ; No, ignore this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
765
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
766 bsf voting_logic_sensor2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
767 movff o2_ppo2_sensor2,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
768 rcall check_sensor_voting_helper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
769 incfsz WREG ; Was WREG=255?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
770 bcf voting_logic_sensor2 ; No, ignore this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
771
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
772 bsf voting_logic_sensor3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
773 movff o2_ppo2_sensor3,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
774 rcall check_sensor_voting_helper
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
775 incfsz WREG ; Was WREG=255?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
776 bcf voting_logic_sensor3 ; No, ignore this sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
777
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
778 ; check if a warning shall be issued on sensor disagreement
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
779
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
780 btfsc FLAG_ccr_mode ; check if we are in CCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
781 bra check_warn_sensor_1 ; YES - continue with further checks
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
782 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
783 bra check_warn_sensor_1 ; YES - continue with further checks
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
784 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
785 check_warn_sensor_1: ; we are in CCR or pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
786 btfsc is_bailout ; check if we are in bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
787 bra check_warn_sensor_agree ; YES - no warning in this case
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
788 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
789 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
790 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
791 ; check sensor 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
792 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
793 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
794 btfss use_O2_sensor1 ; YES - check if sensor is in use
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
795 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
796 btfsc voting_logic_sensor1 ; YES - check if sensor value is within agreement range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
797 bra check_warn_sensor_2 ; YES - continue with next sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
798 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
799 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
800
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
801 check_warn_sensor_2: ; check sensor 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
802 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
803 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
804 btfss use_O2_sensor2 ; YES - check if sensor is in use
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
805 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
806 btfsc voting_logic_sensor2 ; YES - check if sensor value is within agreement range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
807 bra check_warn_sensor_3 ; YES - continue with next sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
808 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
809 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
810
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
811 check_warn_sensor_3: ; check sensor 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
812 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
813 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
814 btfss use_O2_sensor3 ; YES - check if sensor is in use
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
815 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
816 btfsc voting_logic_sensor3 ; YES - check if sensor value is within agreement range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
817 bra check_warn_sensor_agree ; YES - continue with next sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
818 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
819 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
820
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
821 check_warn_sensor_agree:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
822 bsf sensors_agree
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
823 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
824
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
825 compute_ppo2_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
826 call mult16x16 ; xA:2*xB:2=xC:4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
827 movlw LOW .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
828 movwf xB+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
829 movlw HIGH .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
830 movwf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
831 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
832 movlw d'1'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
833 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
834 movlw d'0'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
835 addwfc xC+1,W ; we are still just interested in the carry flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
836 tstfsz WREG ; ppO2 is higher than 2.55bar?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
837 setf xC+0 ; Yes.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
838 return
0
heinrichsweikamp
parents:
diff changeset
839
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
840 check_sensor_custview_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
841 btfss divemode ; check if we are in divemode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
842 return ; NO - not in dive mode, return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
843 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
844 sublw .1 ; opt_ccr_mode = 1 (Sensors)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
845 bnz check_sensor_helper_1 ; NO - not using the sensors in the moment
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
846 clrf menupos3 ; YES - arm customview 1 (sensor values)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
847 bsf toggle_customview ; and request a customview toggle
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
848 check_sensor_helper_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
849 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
850
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
851
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
852 check_sensor_voting_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
853 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
854 cpfsgt sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
855 bra check_sensor_voting_common2 ; lo < sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
856 ; lo > sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
857 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
858 subwf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
859 movwf lo
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
860 check_sensor_voting_common1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
861 movlw sensor_voting_logic_threshold ; Threshold in 0.01 bar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
862 cpfsgt lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
863 retlw .255 ; Within range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
864 retlw .0 ; Out of range
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
865 check_sensor_voting_common2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
866 ; lo<sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
867 movf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
868 subwf lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
869 bra check_sensor_voting_common1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
870
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
871 ;-----------------------------------------------------------------------------
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
872
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
873 divemodemode_togglegf: ; Toggle aGF/GF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
874 bcf toggle_gf ; clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
875 btg use_agf ; toggle GF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
876
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
877 btfsc use_agf ; switch to aGF?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
878 bra divemodemode_togglegf_1 ; YES - branch to using aGF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
879 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
880 movff opt_GF_high,char_I_GF_High_percentage ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
881 bra divemodemode_togglegf_2 ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
882
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
883 divemodemode_togglegf_1: ; use alternative GF factors
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
884 movff opt_aGF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
885 movff opt_aGF_high,char_I_GF_High_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
886
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
887 divemodemode_togglegf_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
888 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
889 ; the customview itself has been called from divemenu_tree before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
890 goto restart_deco_engine ; ...and return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
891
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
892
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
893 calc_velocity: ; called every two seconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
894 btfsc display_velocity
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
895 bra calc_velocity1 ; Always update if already displayed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
896 btfss divemode2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
897 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
898 calc_velocity1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
899 SAFE_2BYTE_COPY amb_pressure, sub_a
0
heinrichsweikamp
parents:
diff changeset
900 movff last_pressure_velocity+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
901 movff last_pressure_velocity+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
902 movff sub_a+0,last_pressure_velocity+0 ; store old value for velocity
heinrichsweikamp
parents:
diff changeset
903 movff sub_a+1,last_pressure_velocity+1
heinrichsweikamp
parents:
diff changeset
904
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
905 call subU16 ; sub_c = amb_pressure - last_pressure
0
heinrichsweikamp
parents:
diff changeset
906
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
907 bcf neg_flag_velocity
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
908 btfsc neg_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
909 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
910
0
heinrichsweikamp
parents:
diff changeset
911 movff sub_c+0,xA+0
heinrichsweikamp
parents:
diff changeset
912 movff sub_c+1,xA+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
913 movlw d'39' ; 77 when called every second....
0
heinrichsweikamp
parents:
diff changeset
914 movwf xB+0
heinrichsweikamp
parents:
diff changeset
915 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
916 call mult16x16 ; differential pressure in mbar*77...
0
heinrichsweikamp
parents:
diff changeset
917 movff xC+0,divA+0
heinrichsweikamp
parents:
diff changeset
918 movff xC+1,divA+1
heinrichsweikamp
parents:
diff changeset
919 movlw d'7'
heinrichsweikamp
parents:
diff changeset
920 movwf divB+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
921 call div16 ; divided by 2^7 equals velocity in m/min
0
heinrichsweikamp
parents:
diff changeset
922
heinrichsweikamp
parents:
diff changeset
923 movlw d'99'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
924 cpfsgt divA+0 ; limit to 99m/min
0
heinrichsweikamp
parents:
diff changeset
925 bra calc_velocity3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
926 movwf divA+0 ; divA=99
0
heinrichsweikamp
parents:
diff changeset
927
heinrichsweikamp
parents:
diff changeset
928 calc_velocity3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
929 ; Copy old speeds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
930 movff old_velocity+2,old_velocity+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
931 movff old_velocity+1,old_velocity+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
932 movff old_velocity+0,old_velocity+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
933 movff divA+0,old_velocity+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
934
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
935 ; movff old_velocity+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
936 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
937 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
938 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
939 ; movff old_velocity+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
940 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
941 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
942 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
943 ; movff old_velocity+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
944 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
945 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
946 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
947 ; movff old_velocity+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
948 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
949 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
950 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
951 goto TFT_display_velocity ; With divA+0 = m/min..., and return...
0
heinrichsweikamp
parents:
diff changeset
952
heinrichsweikamp
parents:
diff changeset
953
heinrichsweikamp
parents:
diff changeset
954 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
955
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
956 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
957 TSTOSS opt_enable_safetystop ; =1: A safety stop is shown
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
958 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
959
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
960 btfsc decostop_active ; Is a deco stop displayed?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
961 bra delete_safety_stop ; Yes, don't show safety stop
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
962
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
963 ; Below "opt_safety_stop_reset"? Set flag and reset count-down timer
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_reset,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 btfss neg_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
974 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
975
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
976 ; Above "opt_safety_stop_end"? Clear flag.
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_end,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 delete_safety_stop ; Above 3m, remove safety stop
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
988
399
db25f2028074 CHANGE: New segmented speed graph in divemode
heinrichsweikamp
parents: 398
diff changeset
989 ; Above "opt_safety_stop_start"? Activate safety stop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
990 SAFE_2BYTE_COPY rel_pressure, lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
991 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
992 movff lo,sub_a+0
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
993 movff hi,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
994 movff opt_safety_stop_start,WREG ; [cbar]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
995 mullw .10 ; mbar in PRODL:H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
996 movff PRODL,sub_b+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
997 movff PRODH,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
998 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
999 btfsc neg_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1000 bra acivate_safety_stop ; Above 5m, activate safety stop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1001 bra reset_safety_stop2 ; Pause safety stop
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1002
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1003 acivate_safety_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1004 tstfsz safety_stop_countdown ; Countdown at zero?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1005 bsf show_safety_stop ; No, Set flag!
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1006 return
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1007
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1008 delete_safety_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1009 clrf safety_stop_countdown ; reset timer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1010 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
1011
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1012 reset_safety_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1013 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
1014 reset_safety_stop2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1015 bcf show_safety_stop ; Clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1016 btfss safety_stop_active ; Safety stop shown
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1017 return ; No, don't delete it
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1018 bcf safety_stop_active ; Clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1019 bsf FLAG_TFT_clear_safety_stop ; Clear safety stop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1020 return
428
eccae727702f some cleanup
heinrichsweikamp
parents: 403
diff changeset
1021
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1022
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1023 ;=============================================================================
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1024
0
heinrichsweikamp
parents:
diff changeset
1025 timeout_menuview:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1026 decfsz timeout_counter2,F ; timeout for menuview
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1027 return ; No timeout, return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1028 ; Timeout, clear e.g. "Menu?"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1029 goto menuview_toggle_reset ; "returns"
0
heinrichsweikamp
parents:
diff changeset
1030
heinrichsweikamp
parents:
diff changeset
1031 timeout_divemode_menu:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1032 decfsz timeout_counter2,F ; timeout for divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1033 return
0
heinrichsweikamp
parents:
diff changeset
1034
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1035 global timeout_divemode_menu2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1036 timeout_divemode_menu2: ; Called from divemenu_tree.asm
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1037 bcf divemode_menu ; Timeout! Clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1038 call TFT_clear_divemode_menu ; Clear menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1039 bsf FLAG_TFT_active_gas_divemode; Redraw gas/setpoint/diluent
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1040 bcf blinking_better_gas ; Clear flag to have temperature updated once
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1041 bsf FLAG_TFT_temp_divemode ; Displays temperature
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1042 call TFT_draw_gassep_line ; Gas separator grid in spec mode only
0
heinrichsweikamp
parents:
diff changeset
1043
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1044 btfss decostop_active ; In deco mode ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1045 bra timeout_divemode_menu_ndl ; No, show NDL again
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1046 ; Show deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1047 bsf FLAG_TFT_display_deko_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1048 bsf FLAG_TFT_display_deko
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1049 bsf FLAG_TFT_display_tts
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1050 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1051
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1052 timeout_divemode_menu_ndl:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1053 ; Show NDL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1054 bsf FLAG_TFT_display_ndl_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1055 bsf FLAG_TFT_display_ndl
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1056 return
0
heinrichsweikamp
parents:
diff changeset
1057
heinrichsweikamp
parents:
diff changeset
1058 timeout_divemode:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1059 btfsc divemode_menu ; Divemode menu active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1060 rcall timeout_divemode_menu ; Yes, check the timeout for it...
0
heinrichsweikamp
parents:
diff changeset
1061
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1062 btfsc menuview ; is a menuview shown?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1063 rcall timeout_menuview ; Yes, check the timeout for it...
0
heinrichsweikamp
parents:
diff changeset
1064
heinrichsweikamp
parents:
diff changeset
1065 btfss realdive ; Dive longer then one minute
heinrichsweikamp
parents:
diff changeset
1066 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1067
0
heinrichsweikamp
parents:
diff changeset
1068 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
1069 bra timeout_divemode2 ; Yes, use apnoe_timeout [min] for timeout
0
heinrichsweikamp
parents:
diff changeset
1070
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1071 ifndef __DEBUG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1072 btfsc simulatormode_active ; In Simulator mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1073 bra timeout_divemode3 ; Yes, use simulator timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1074 endif
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1075
0
heinrichsweikamp
parents:
diff changeset
1076 bcf divemode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1077 infsnz timeout_counter1+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1078 incf timeout_counter1+1,F ; timeout is 16 bit counter
0
heinrichsweikamp
parents:
diff changeset
1079
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1080 movff opt_diveTimeout,WREG ; in [min]
444
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1081 mullw .60
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1082 movff PRODL,sub_a+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1083 movff PRODH,sub_a+1 ; in [s]
0
heinrichsweikamp
parents:
diff changeset
1084
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1085 movff timeout_counter1+0,sub_b+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1086 movff timeout_counter1+1,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1087 call subU16 ; sub_c = sub_a - sub_b
0
heinrichsweikamp
parents:
diff changeset
1088 btfss neg_flag ; Result negative?
heinrichsweikamp
parents:
diff changeset
1089 bsf divemode ; No, set flag
heinrichsweikamp
parents:
diff changeset
1090 return
heinrichsweikamp
parents:
diff changeset
1091
heinrichsweikamp
parents:
diff changeset
1092 timeout_divemode2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1093 incf timeout_counter1+0,F ; seconds...
0
heinrichsweikamp
parents:
diff changeset
1094 movlw d'60'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1095 cpfseq timeout_counter1+0 ; timeout_counter1+0 = 60 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1096 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1097 ; one minute timeout done
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1098 clrf timeout_counter1+0
0
heinrichsweikamp
parents:
diff changeset
1099 bcf divemode
heinrichsweikamp
parents:
diff changeset
1100 incf apnoe_timeout_counter,F
heinrichsweikamp
parents:
diff changeset
1101 movlw apnoe_timeout ; apnoe timeout [min]
heinrichsweikamp
parents:
diff changeset
1102 cpfseq apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1103 bsf divemode
heinrichsweikamp
parents:
diff changeset
1104 return
heinrichsweikamp
parents:
diff changeset
1105
heinrichsweikamp
parents:
diff changeset
1106 timeout_divemode3:
heinrichsweikamp
parents:
diff changeset
1107 bcf divemode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1108 incf timeout_counter1+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1109 movlw simulator_timeout ; simulator timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1110 cpfsgt timeout_counter1+0
0
heinrichsweikamp
parents:
diff changeset
1111 bsf divemode
heinrichsweikamp
parents:
diff changeset
1112 return
heinrichsweikamp
parents:
diff changeset
1113
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1114 update_divemode60: ; update any minute
0
heinrichsweikamp
parents:
diff changeset
1115 call get_battery_voltage ; gets battery voltage
218
8fbd8c5ac51f 1.71beta start
heinrichsweikamp
parents: 216
diff changeset
1116 rcall set_powersafe ; Battery low?
0
heinrichsweikamp
parents:
diff changeset
1117 call customview_minute ; Do every-minute tasks for the custom view area
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1118 bcf oneminupdate
0
heinrichsweikamp
parents:
diff changeset
1119
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1120 btfss simulatormode_active ; in simulator mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1121 return ; No
0
heinrichsweikamp
parents:
diff changeset
1122 ; Yes, quite dive mode simulation after 21*256s=89min:36s
heinrichsweikamp
parents:
diff changeset
1123 movlw .20
heinrichsweikamp
parents:
diff changeset
1124 cpfsgt total_divetime_seconds+1 ; Timeout?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1125 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1126
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1127 ifdef __DEBUG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1128 return ; No simulator timeout in debug mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1129 endif
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1131 bra divemode_option1 ; Yes, set to 0m and "return"
0
heinrichsweikamp
parents:
diff changeset
1132
heinrichsweikamp
parents:
diff changeset
1133 set_max_depth:
heinrichsweikamp
parents:
diff changeset
1134 movff max_pressure+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1135 movff max_pressure+1,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1136 SAFE_2BYTE_COPY rel_pressure, sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1137 call subU16 ; sub_c = sub_a - sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1138 ; max_pressure<rel_pressure -> neg_flag=1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1139 ; rel_pressure<=max_pressure -> neg_flag=0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1140 btfss neg_flag
0
heinrichsweikamp
parents:
diff changeset
1141 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1142 ; max_pressure<rel_pressure
0
heinrichsweikamp
parents:
diff changeset
1143 movff sub_b+0,max_pressure+0
heinrichsweikamp
parents:
diff changeset
1144 movff sub_b+1,max_pressure+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1145 bsf FLAG_TFT_max_depth ; Set flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1146 return
0
heinrichsweikamp
parents:
diff changeset
1147
heinrichsweikamp
parents:
diff changeset
1148 set_min_temp:
heinrichsweikamp
parents:
diff changeset
1149 movff minimum_temperature+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1150 movff minimum_temperature+1,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1151 SAFE_2BYTE_COPY temperature,sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1152 call sub16 ; sub_c = sub_a - sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1153 ; minimum_temperature<T -> neg_flag=1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1154 ; T<=minimum_temperature -> neg_flag=0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1155 btfsc neg_flag
0
heinrichsweikamp
parents:
diff changeset
1156 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1157 ; minimum_temperature >= T
0
heinrichsweikamp
parents:
diff changeset
1158 movff sub_b+0,minimum_temperature+0
heinrichsweikamp
parents:
diff changeset
1159 movff sub_b+1,minimum_temperature+1
heinrichsweikamp
parents:
diff changeset
1160 return
heinrichsweikamp
parents:
diff changeset
1161
heinrichsweikamp
parents:
diff changeset
1162 global set_dive_modes
heinrichsweikamp
parents:
diff changeset
1163 set_dive_modes:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1164 btfsc high_altitude_mode ; In high altitude (Fly) mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1165 bra set_dive_modes3 ; Yes!
0
heinrichsweikamp
parents:
diff changeset
1166
heinrichsweikamp
parents:
diff changeset
1167 set_dive_modes0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1168 movlw LOW start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1169 movwf sub_a+0 ; dive_treshold is in cm
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1170 movlw HIGH start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1171 movwf sub_a+1 ; dive_treshold is in cm
0
heinrichsweikamp
parents:
diff changeset
1172
heinrichsweikamp
parents:
diff changeset
1173 set_dive_modes1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1174 SAFE_2BYTE_COPY rel_pressure, sub_b
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1175 call subU16 ; sub_c = sub_a - sub_b
0
heinrichsweikamp
parents:
diff changeset
1176
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1177 btfss neg_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1178 bra set_dive_modes2 ; too shallow (rel_pressure < dive_threshold)
0
heinrichsweikamp
parents:
diff changeset
1179
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1180 btfsc realdive ; Dive longer than one minute?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1181 clrf timeout_counter1+0 ; Yes, reset timeout counter +++
0
heinrichsweikamp
parents:
diff changeset
1182
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1183 bsf divemode ; (Re-)Set divemode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1184 bsf divemode2 ; displayed divetime is running
0
heinrichsweikamp
parents:
diff changeset
1185 return
heinrichsweikamp
parents:
diff changeset
1186
heinrichsweikamp
parents:
diff changeset
1187 set_dive_modes2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1188 bcf divemode2 ; Stop time
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1189 btfss realdive ; dive longer then one minute?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1190 bcf divemode ; no -> this was no real dive
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1191 return ; No, return
0
heinrichsweikamp
parents:
diff changeset
1192
heinrichsweikamp
parents:
diff changeset
1193
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1194 set_dive_modes3: ; High-altitude mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1195 btfsc realdive ; dive longer then one minute?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1196 bra set_dive_modes0 ; Yes -> this is a real dive -> Use start_dive_threshold or ascend
0
heinrichsweikamp
parents:
diff changeset
1197
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1198 movlw LOW high_altitude_dive_threshold
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1199 movwf sub_a+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1200 movlw HIGH high_altitude_dive_threshold
0
heinrichsweikamp
parents:
diff changeset
1201 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
1202 bra set_dive_modes1
heinrichsweikamp
parents:
diff changeset
1203
heinrichsweikamp
parents:
diff changeset
1204 set_powersafe:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1205 movlw color_code_battery_low+1; [%]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1206 cpfslt batt_percent
0
heinrichsweikamp
parents:
diff changeset
1207 return
heinrichsweikamp
parents:
diff changeset
1208
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1209 movlw d'7' ; Type of Alarm (Battery Low)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1210 movwf AlarmType ; Copy to Alarm Register
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1211 bsf event_occured ; set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1212 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1213 movff WREG,opt_brightness ; Set Brightness to ECO
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1214 return ; return
0
heinrichsweikamp
parents:
diff changeset
1215
heinrichsweikamp
parents:
diff changeset
1216 calc_average_depth:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1217 btfsc reset_average_depth ; Reset the Average depth?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1218 rcall reset_average1 ; Reset the resettable average depth
0
heinrichsweikamp
parents:
diff changeset
1219
heinrichsweikamp
parents:
diff changeset
1220 ; 1. Add new 2xdepth to the Sum of depths registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1221 SAFE_2BYTE_COPY rel_pressure,xB ; Buffer...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1222 bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1223 rlcf xB+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1224 rlcf xB+1,F ; x2
0
heinrichsweikamp
parents:
diff changeset
1225
heinrichsweikamp
parents:
diff changeset
1226 movf xB+0,w
heinrichsweikamp
parents:
diff changeset
1227 addwf average_depth_hold+0,F
heinrichsweikamp
parents:
diff changeset
1228 movf xB+1,w
heinrichsweikamp
parents:
diff changeset
1229 addwfc average_depth_hold+1,F
heinrichsweikamp
parents:
diff changeset
1230 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1231 addwfc average_depth_hold+2,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1232 addwfc average_depth_hold+3,F ; Will work up to 9999mbar*60*60*24=863913600mbar
0
heinrichsweikamp
parents:
diff changeset
1233
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1234 ; Do the same for the _total registers (Non-Resettable)
0
heinrichsweikamp
parents:
diff changeset
1235 movf xB+0,w
heinrichsweikamp
parents:
diff changeset
1236 addwf average_depth_hold_total+0,F
heinrichsweikamp
parents:
diff changeset
1237 movf xB+1,w
heinrichsweikamp
parents:
diff changeset
1238 addwfc average_depth_hold_total+1,F
heinrichsweikamp
parents:
diff changeset
1239 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1240 addwfc average_depth_hold_total+2,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1241 addwfc average_depth_hold_total+3,F; Will work up to 9999mbar*60*60*24=863913600mbar
0
heinrichsweikamp
parents:
diff changeset
1242
heinrichsweikamp
parents:
diff changeset
1243 ; 2. Compute Average Depth on base of average_divesecs:2
heinrichsweikamp
parents:
diff changeset
1244 movff average_divesecs+0,xB+0
heinrichsweikamp
parents:
diff changeset
1245 movff average_divesecs+1,xB+1 ; Copy
heinrichsweikamp
parents:
diff changeset
1246 movff average_depth_hold+0,xC+0
heinrichsweikamp
parents:
diff changeset
1247 movff average_depth_hold+1,xC+1
heinrichsweikamp
parents:
diff changeset
1248 movff average_depth_hold+2,xC+2
heinrichsweikamp
parents:
diff changeset
1249 movff average_depth_hold+3,xC+3
heinrichsweikamp
parents:
diff changeset
1250
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1251 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
1252 movff xC+0,avg_rel_pressure+0
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1253 movff xC+1,avg_rel_pressure+1
0
heinrichsweikamp
parents:
diff changeset
1254
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1255 btfss divemode2 ; displayed divetime is running?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1256 return ; No (e.g. too shallow)
89
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 86
diff changeset
1257
0
heinrichsweikamp
parents:
diff changeset
1258 ; 3. Compute Total Average Depth on base of total_divetime_seconds:2
heinrichsweikamp
parents:
diff changeset
1259 movff total_divetime_seconds+0,xB+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1260 movff total_divetime_seconds+1,xB+1 ; Copy
0
heinrichsweikamp
parents:
diff changeset
1261 movff average_depth_hold_total+0,xC+0
heinrichsweikamp
parents:
diff changeset
1262 movff average_depth_hold_total+1,xC+1
heinrichsweikamp
parents:
diff changeset
1263 movff average_depth_hold_total+2,xC+2
heinrichsweikamp
parents:
diff changeset
1264 movff average_depth_hold_total+3,xC+3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1265 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
1266 movff xC+0,avg_rel_pressure_total+0
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 428
diff changeset
1267 movff xC+1,avg_rel_pressure_total+1
0
heinrichsweikamp
parents:
diff changeset
1268 return
heinrichsweikamp
parents:
diff changeset
1269
heinrichsweikamp
parents:
diff changeset
1270 reset_average1:
heinrichsweikamp
parents:
diff changeset
1271 clrf average_depth_hold+0
heinrichsweikamp
parents:
diff changeset
1272 clrf average_depth_hold+1
heinrichsweikamp
parents:
diff changeset
1273 clrf average_depth_hold+2
heinrichsweikamp
parents:
diff changeset
1274 clrf average_depth_hold+3 ; Clear average depth register
heinrichsweikamp
parents:
diff changeset
1275 movlw d'2'
heinrichsweikamp
parents:
diff changeset
1276 movwf average_divesecs+0
heinrichsweikamp
parents:
diff changeset
1277 clrf average_divesecs+1
heinrichsweikamp
parents:
diff changeset
1278 bcf reset_average_depth ; Clear flag
heinrichsweikamp
parents:
diff changeset
1279 return
heinrichsweikamp
parents:
diff changeset
1280
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1281 test_switches_divemode: ; checks switches in divemode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1282 btfsc divemode_menu ; Divemode menu shown?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1283 bra test_switches_divemode_menu ; Yes, use menu processor
0
heinrichsweikamp
parents:
diff changeset
1284 btfsc switch_left
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1285 ;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
1286 goto menuview_toggle ; Menu or Simulator tasks; and return...
0
heinrichsweikamp
parents:
diff changeset
1287 btfss switch_right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1288 return ; No button press
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1289 tstfsz menupos2 ; any option shown?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1290 bra test_switches_divemode1 ; Yes, do option tasks
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1291 bsf toggle_customview ; No, toggle custom view
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1292 return
0
heinrichsweikamp
parents:
diff changeset
1293
heinrichsweikamp
parents:
diff changeset
1294 test_switches_divemode_menu:
heinrichsweikamp
parents:
diff changeset
1295 btfsc switch_left
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1296 bra test_switches_divemode_menu2; Move cursor
0
heinrichsweikamp
parents:
diff changeset
1297 btfsc switch_right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1298 bra test_switches_divemode_menu3; Enter submenu or do something
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1299 return ; No button press
0
heinrichsweikamp
parents:
diff changeset
1300
heinrichsweikamp
parents:
diff changeset
1301 test_switches_divemode_menu1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1302 clrf menupos1
0
heinrichsweikamp
parents:
diff changeset
1303 test_switches_divemode_menu2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1304 incf menupos1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1305 incf menupos4,W ; menupos4+1 -> WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1306 cpfslt menupos1 ; > menupos4 (Set in menu_processor.asm)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1307 bra test_switches_divemode_menu1; > Yes, set to 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1308 call TFT_divemode_menu_cursor ; Update the cursor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1309 bcf switch_left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1310 movlw divemode_menu_timeout ; Reload timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1311 movwf timeout_counter2 ; timeout for divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1312 return
0
heinrichsweikamp
parents:
diff changeset
1313
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1314 test_switches_divemode_menu3: ; Enter submenu or do something
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1315 bcf switch_right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1316 ; decf menupos1,F ; menu_processor needs 0-5...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1317 goto do_line_menu ; Warning! Trashes STKPTR and returns to diveloop_loop4:
0
heinrichsweikamp
parents:
diff changeset
1318
heinrichsweikamp
parents:
diff changeset
1319 test_switches_divemode1:
heinrichsweikamp
parents:
diff changeset
1320 bcf switch_right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1321 movlw divemode_menuview_timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1322 movwf timeout_counter2 ; Reload timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1323 movff menupos2,WREG ; menupos2 holds number of customview/divemode menu function
0
heinrichsweikamp
parents:
diff changeset
1324 dcfsnz WREG,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1325 bra divemode_option_gaschange ; Switch to the indicated "better gas"
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1326 dcfsnz WREG,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1327 bra divemode_option0 ; Start/Setup Divemode menu
0
heinrichsweikamp
parents:
diff changeset
1328 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1329 bra divemode_option1 ; Quit Simulation?
heinrichsweikamp
parents:
diff changeset
1330 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1331 bra divemode_option2 ; Descent 1m
heinrichsweikamp
parents:
diff changeset
1332 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1333 bra divemode_option3 ; Ascend 1m
heinrichsweikamp
parents:
diff changeset
1334 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1335 bra divemode_option4 ; Quit Apnoe mode
heinrichsweikamp
parents:
diff changeset
1336 dcfsnz WREG,F
heinrichsweikamp
parents:
diff changeset
1337 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
1338 dcfsnz WREG,F
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1339 bra divemode_option6 ; +5mins simulation
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1340 dcfsnz WREG,F
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1341 bra divemode_option7 ; Store heading
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1342 dcfsnz WREG,F
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1343 bra divemode_option8 ; Switch to alt. layout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1344 return
0
heinrichsweikamp
parents:
diff changeset
1345
heinrichsweikamp
parents:
diff changeset
1346 gas_switched_common:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1347 bcf divemode_gaschange ; Clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1348 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
1349 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1350 bcf FLAG_back_to_loop ; YES - clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1351 movff active_diluent,menupos1 ; reload last diluent
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1352 bra gas_switched_common1 ; continue with common part
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1353 gas_switched_common0:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1354 tstfsz menupos1 ; menupos1=0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1355 bra gas_switched_common1 ; NO - valid gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1356 return ; YES - something went wrong, invalid gas, abort
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1357 gas_switched_common1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1358 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
1359
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1360 btfsc FLAG_ccr_mode ; in CCR mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1361 bra gas_switched_common2 ; YES - configure diluent or bailout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1362 btfsc FLAG_pscr_mode ; in pSCR mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1363 bra gas_switched_common2 ; YES - configure diluent or bailout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1364
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1365 ; OC
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1366 rcall setup_gas_registers ; With WREG = Gas 1-6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1367 rcall deco_setup_oc_gases ; With WREG = Gas 1-6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1368 bra gas_switched_common3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1369
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1370 ; loop or bailout
506
b9f06f1a1f74 BUGFIX: PSCR mode "Better Gas" showed bailout gases instead of diluents
heinrichsweikamp
parents: 485
diff changeset
1371 gas_switched_common2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1372 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
1373 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
1374
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1375 gas_switched_common3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1376 bsf FLAG_TFT_active_gas_divemode ; Redraw gas/setpoint/diluent
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1377 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
1378
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1379 ; Set flags for profile recording
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1380 bsf event_occured ; set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1381 btfsc is_bailout ; Choose OC Bailouts (OC Gases)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1382 bsf bailoutgas_event ; Bailout gas change
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1383 btfss is_bailout ; Choose OC Bailouts (OC Gases)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1384 bsf stored_gas_changed ; OC gas change
0
heinrichsweikamp
parents:
diff changeset
1385 return
heinrichsweikamp
parents:
diff changeset
1386
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1387
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1388 ; Code to pass all parameters to the C code
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1389
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1390 global get_first_gas_to_WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1391 get_first_gas_to_WREG: ; Gets first gas (1-5) into WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1392 lfsr FSR1,opt_gas_type ; Point to gas types
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1393 clrf lo ; start with Gas0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1394 get_first_gas_to_WREG2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1395 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1396 movf PLUSW1,W ; Get Type of Gas #lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1397 sublw .1 ; it is = 1 (First Gas)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1398 bz get_first_gas_to_WREG3 ; Found the first gas!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1399 incf lo,F ; ++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1400 movlw NUM_GAS+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1401 cpfseq lo ; All done?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1402 bra get_first_gas_to_WREG2 ; Not yet
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1403 ; No first gas found, use #1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1404 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1405 movff WREG,opt_gas_type+0 ; Set Gas1 to First
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1406 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1407 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1408 get_first_gas_to_WREG3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1409 movf lo,W ; Put into Wreg
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1410 incf WREG,W ; 0-4 -> 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1411 return ; Done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1412
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1413 global get_first_dil_to_WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1414 get_first_dil_to_WREG: ; Gets first dil (1-5) into WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1415 lfsr FSR1,opt_dil_type ; Point to dil types
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1416 clrf lo ; start with Gas0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1417 get_first_dil_to_WREG2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1418 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1419 movf PLUSW1,W ; Get Type of Dil #lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1420 sublw .1 ; it is = 1 (First Dil)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1421 bz get_first_dil_to_WREG3 ; Found the first dil!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1422 incf lo,F ; ++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1423 movlw NUM_GAS+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1424 cpfseq lo ; All done?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1425 bra get_first_dil_to_WREG2 ; Not yet
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1426 ; No first dil found, use #1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1427 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1428 movff WREG,opt_dil_type+0 ; Set Dil1 to First
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1429 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1430 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1431 get_first_dil_to_WREG3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1432 movf lo,W ; Put into Wreg
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1433 incf WREG,W ; 0-4 -> 1-5
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1434 return ; Done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1435
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1436 global deco_setup_oc_gases
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1437 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
1438 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
1439
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1440 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
1441
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1442 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1443 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
1444
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1445 movlw .3 ; 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1446 cpfseq opt_gas_type+0 ; Gas is deco type?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1447 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
1448
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1449 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1450 movff opt_gas_O2_ratio+1,char_I_deco_O2_ratio+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1451 movlw .3 ; 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1452 cpfseq opt_gas_type+1 ; Gas is deco type?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1453 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
1454
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1455 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1456 movff opt_gas_O2_ratio+2,char_I_deco_O2_ratio+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1457 movlw .3 ; 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1458 cpfseq opt_gas_type+2 ; Gas is deco type?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1459 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
1460
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1461 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1462 movff opt_gas_O2_ratio+3,char_I_deco_O2_ratio+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1463 movlw .3 ; 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1464 cpfseq opt_gas_type+3 ; Gas is deco type?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1465 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
1466
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1467 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1468 movff opt_gas_O2_ratio+4,char_I_deco_O2_ratio+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1469 movlw .3 ; 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1470 cpfseq opt_gas_type+4 ; Gas is deco type?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1471 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
1472
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1473 banksel common
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1474
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1475 ; Setup char_I_deco_gas_change array
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1476 movff opt_OC_bail_gas_change+0, char_I_deco_gas_change+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1477 movff opt_OC_bail_gas_change+1, char_I_deco_gas_change+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1478 movff opt_OC_bail_gas_change+2, char_I_deco_gas_change+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1479 movff opt_OC_bail_gas_change+3, char_I_deco_gas_change+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1480 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
1481
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1482 ; switch to oc mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1483 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
1484 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
1485 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1486 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
1487
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1488 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1489
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1490
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1491 global deco_setup_cc_diluents
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1492 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
1493 btfsc is_bailout ; check if in bailout condition
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1494 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
1495
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1496 movff WREG,char_I_current_gas ; gas to start with when doing the deco calculations
0
heinrichsweikamp
parents:
diff changeset
1497
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1498 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1499 movff opt_dil_O2_ratio+0,char_I_deco_O2_ratio+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1500 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1501 tstfsz WREG ; Disabled?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1502 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1503 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
1504
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1505 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1506 movff opt_dil_O2_ratio+1,char_I_deco_O2_ratio+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1507 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1508 tstfsz WREG ; Disabled?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1509 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1510 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
1511
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1512 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1513 movff opt_dil_O2_ratio+2,char_I_deco_O2_ratio+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1514 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1515 tstfsz WREG ; Disabled?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1516 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1517 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
1518
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1519 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1520 movff opt_dil_O2_ratio+3,char_I_deco_O2_ratio+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1521 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1522 tstfsz WREG ; Disabled?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1523 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1524 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
1525
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1526 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1527 movff opt_dil_O2_ratio+4,char_I_deco_O2_ratio+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1528 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1529 tstfsz WREG ; Disabled?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1530 bra $+4 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1531 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
1532
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1533 ; Setup char_I_deco_gas_change array
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1534 movff char_I_dil_change+0, char_I_deco_gas_change+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1535 movff char_I_dil_change+1, char_I_deco_gas_change+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1536 movff char_I_dil_change+2, char_I_deco_gas_change+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1537 movff char_I_dil_change+3, char_I_deco_gas_change+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1538 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
1539
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1540 ; switch to CCR / pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1541 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
1542 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
1543 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1544 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1545 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
1546 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
1547
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1548 return
0
heinrichsweikamp
parents:
diff changeset
1549
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1550 global setup_gas_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1551 setup_gas_registers: ; with currently breathed gas in WREG (1-5 or 6)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1552 movwf active_gas ; set as current gas
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1553 movlw .6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1554 cpfseq active_gas ; gas = gas6 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1555 bra setup_gas_registers_15 ; NO - load gas 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1556 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
1557 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
1558 bra setup_gas_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1559 setup_gas_registers_15:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1560 decf active_gas,W ; 1-5 -> 0-4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1561 lfsr FSR1,opt_gas_O2_ratio+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1562 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
1563 lfsr FSR1,opt_gas_He_ratio+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1564 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
1565 setup_gas_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1566 ;lfsr FSR1,opt_gas_type ; commented out - currently not used anywhere
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1567 ;movff PLUSW1,active_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1568 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
1569 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
1570 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1571 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
1572 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
1573 return
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1574
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1575 global setup_dil_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1576 setup_dil_registers: ; with currently breathed gas in WREG (1-5 or 6)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1577 btfsc is_bailout ; check if in bailout condition
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1578 bra setup_gas_registers ; revert to setting up OC gases in bailout condition
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1579 movwf active_gas ; set as current gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1580 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
1581 movlw .6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1582 cpfseq active_gas ; diluent = gas6 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1583 bra setup_dil_registers_15 ; NO - load diluent 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1584 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
1585 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
1586 bra setup_dil_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1587 setup_dil_registers_15:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1588 decf active_gas,W ; 1-5 -> 0-4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1589 lfsr FSR1,opt_dil_O2_ratio+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1590 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
1591 lfsr FSR1,opt_dil_He_ratio+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1592 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
1593 setup_dil_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1594 ;lfsr FSR1,opt_dil_type ; commented out - currently not used anywhere
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1595 ;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
1596 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
1597 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
1598 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1599 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1600 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1601 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
1602 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
1603 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1604
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1605 divemode_option_gaschange: ; Switch to the better gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1606 movff better_gas_number,menupos1 ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1607 bsf divemode_gaschange ; Change the gas in the dive mode loop...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1608 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1609 bcf better_gas_available ; Clear flag immediately
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1610 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1611
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1612 divemode_option0: ; Start/Setup Divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1613 call TFT_clear_divemode_menu ; Clear menu area
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1614 bcf menuview
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1615 call do_main_divemenu
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1616
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1617 global divemode_option0_return
0
heinrichsweikamp
parents:
diff changeset
1618 divemode_option0_return:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1619 ; movlw .1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1620 ; movwf menupos1 ; Set to first option in divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1621 call TFT_divemode_menu_cursor ; Show the cursor
0
heinrichsweikamp
parents:
diff changeset
1622 movlw divemode_menu_timeout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1623 movwf timeout_counter2 ; timeout for divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1624 bsf divemode_menu ; Set flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1625 clrf menupos2 ; Clear option counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1626 goto diveloop_loop4 ; Goto back to diveloop (menu processor trashes STKPTR!)
0
heinrichsweikamp
parents:
diff changeset
1627
heinrichsweikamp
parents:
diff changeset
1628 divemode_option4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1629 movlw d'58' ; two seconds left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1630 movwf timeout_counter1+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1631 movlw apnoe_timeout-1 ; apnoe timeout [min]
0
heinrichsweikamp
parents:
diff changeset
1632 movwf apnoe_timeout_counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1633 btfss simulatormode_active ; in simulator mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1634 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1635 divemode_option1: ; Quit simulation mode
0
heinrichsweikamp
parents:
diff changeset
1636 banksel isr_backup
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1637 movlw LOW .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1638 movwf sim_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1639 movlw HIGH .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1640 movwf sim_pressure+1 ; Set to 0m -> End of Dive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1641 banksel common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1642 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1643
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1644 btfss FLAG_apnoe_mode ; In Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1645 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1646 movlw d'58' ; two seconds left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1647 movwf timeout_counter1+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1648 movlw apnoe_timeout-1 ; apnoe timeout [min]
0
heinrichsweikamp
parents:
diff changeset
1649 movwf apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1650 return
heinrichsweikamp
parents:
diff changeset
1651
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1652 divemode_option3: ; minus 1m
0
heinrichsweikamp
parents:
diff changeset
1653 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1654 movlw d'100'
0
heinrichsweikamp
parents:
diff changeset
1655 subwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1656 movlw .0
heinrichsweikamp
parents:
diff changeset
1657 subwfb sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1658 rcall divemode_simulator_check_limits
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1659 banksel common
0
heinrichsweikamp
parents:
diff changeset
1660 return
heinrichsweikamp
parents:
diff changeset
1661
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1662 divemode_option2: ; plus 1m
0
heinrichsweikamp
parents:
diff changeset
1663 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1664 movlw d'100'
0
heinrichsweikamp
parents:
diff changeset
1665 addwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1666 movlw .0
heinrichsweikamp
parents:
diff changeset
1667 addwfc sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1668 rcall divemode_simulator_check_limits
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1669 banksel common
0
heinrichsweikamp
parents:
diff changeset
1670 return
heinrichsweikamp
parents:
diff changeset
1671
heinrichsweikamp
parents:
diff changeset
1672 divemode_option5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1673 call menuview_toggle_reset ; Reset to zero (Zero=no menuview)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1674 bsf reset_average_depth ; Set Flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1675 return
0
heinrichsweikamp
parents:
diff changeset
1676
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1677 divemode_option6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1678 bcf divemode2 ; Stop divetime
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1679 movlw .5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1680 addwf divemins+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1681 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1682 addwfc divemins+1,F ; Add 5 mins
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1683 movlw LOW (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1684 addwf average_divesecs+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1685 movlw HIGH (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1686 addwfc average_divesecs+1,F ; Add 5*60 seconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1687 movlw LOW (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1688 addwf total_divetime_seconds+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1689 movlw HIGH (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1690 addwfc total_divetime_seconds+1,F ; Add 5*60 seconds
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1691
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1692 ; 1. Add 300xdepth to the sum of depths registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1693 SAFE_2BYTE_COPY rel_pressure, xB ; Buffer...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1694 movlw LOW (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1695 movwf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1696 movlw HIGH (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1697 movwf xA+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1698 call mult16x16 ; xA*xB=xC
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1699
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1700 movf xC+0,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1701 addwf average_depth_hold+0,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1702 movf xC+1,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1703 addwfc average_depth_hold+1,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1704 movf xC+2,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1705 addwfc average_depth_hold+2,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1706 movf xC+3,w
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1707 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
1708
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1709 ; Do the same for the _total registers (Non-Resettable)
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1710 movf xC+0,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1711 addwf average_depth_hold_total+0,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1712 movf xC+1,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1713 addwfc average_depth_hold_total+1,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1714 movf xC+2,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1715 addwfc average_depth_hold_total+2,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1716 movf xC+3,w
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1717 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
1718
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1719 movlw .5 ; + 5 minutes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1720 movff WREG,char_I_sim_advance_time; copy to mailbox
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1721 bsf divemode2 ; continue divetime
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1722 call restart_deco_engine
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1723 goto menuview_toggle_reset ; and return...
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1724
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1725 divemode_option7:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1726 ; Store heading for compass view
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1727 movff compass_heading_shown+0,compass_bearing+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1728 movff compass_heading_shown+1,compass_bearing+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1729 bsf compass_bearing_set ; set flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1730 goto menuview_toggle_reset ; Done and return...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1731
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1732 divemode_option8:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1733 bsf alternative_divelayout ; Set flag for mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1734 bsf FLAG_TFT_divemode_mask_alt ; Set flag for mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1735 movlw .1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1736 movwf menupos3 ; For the customviews...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1737 call TFT_ClearScreen ; Clear screen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1738 goto menuview_toggle_reset ; Done and return...
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1739
0
heinrichsweikamp
parents:
diff changeset
1740 divemode_simulator_check_limits:
heinrichsweikamp
parents:
diff changeset
1741 ; Check limits (150m and 0m)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1742 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m).
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'16000'
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 bnc divemode_simulator_check_limits2 ; No-carry = borrow = not deeper
0
heinrichsweikamp
parents:
diff changeset
1747
heinrichsweikamp
parents:
diff changeset
1748 ; Too deep, limit to 150m
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1749 movlw LOW d'16000'
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'16000'
0
heinrichsweikamp
parents:
diff changeset
1752 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1753 return
heinrichsweikamp
parents:
diff changeset
1754 divemode_simulator_check_limits2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1755 movlw LOW d'1000' ; Compare to 1bar == 0m == 1000 mbar.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1756 subwf sim_pressure+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1757 movlw HIGH d'1000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1758 subwfb sim_pressure+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1759 btfsc STATUS,C ; No-carry = borrow = not deeper.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1760 return ; Deeper than 0m == Ok.
0
heinrichsweikamp
parents:
diff changeset
1761 ; Too shallow, limit to 0m
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1762 movlw LOW d'1000'
0
heinrichsweikamp
parents:
diff changeset
1763 movwf sim_pressure+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1764 movlw HIGH d'1000'
0
heinrichsweikamp
parents:
diff changeset
1765 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1766 return
heinrichsweikamp
parents:
diff changeset
1767
heinrichsweikamp
parents:
diff changeset
1768 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1769 ; Compare all enabled gas in list, to see if a better one is available.
heinrichsweikamp
parents:
diff changeset
1770 ;
heinrichsweikamp
parents:
diff changeset
1771 ; Output: better_gas_available, better_gas_number
heinrichsweikamp
parents:
diff changeset
1772 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1773 check_gas_change: ; Checks if a better gas should be selected (by user)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1774 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
1775 clrf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1776 movff WREG,better_gas_number ; clear better gas register
0
heinrichsweikamp
parents:
diff changeset
1777
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1778 SAFE_2BYTE_COPY rel_pressure,xA
0
heinrichsweikamp
parents:
diff changeset
1779 movlw d'100'
heinrichsweikamp
parents:
diff changeset
1780 movwf xB+0
heinrichsweikamp
parents:
diff changeset
1781 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1782 call div16x16 ; compute depth in full m -> result in xC+0
0
heinrichsweikamp
parents:
diff changeset
1783
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1784 btfsc FLAG_pscr_mode ; in PSCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1785 bra check_gas_change2 ; YES - check for diluents
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1786 btfss FLAG_ccr_mode ; in CCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1787 bra check_gas_change_OC_bail ; NO - check for OC
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 482
diff changeset
1788 check_gas_change2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1789 btfsc is_bailout ; in bailout?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1790 bra check_gas_change_OC_bail ; YES - check for OC
0
heinrichsweikamp
parents:
diff changeset
1791
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1792 ; Check Diluents
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_dil_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_dil_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_dil_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_dil_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_dil_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1803 bra check_gas_change_exit
0
heinrichsweikamp
parents:
diff changeset
1804
heinrichsweikamp
parents:
diff changeset
1805 check_gas_change_OC_bail:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1806 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1807 rcall check_gas_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1808 movlw .1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1809 rcall check_gas_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1810 movlw .2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1811 rcall check_gas_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1812 movlw .3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1813 rcall check_gas_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1814 movlw .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1815 rcall check_gas_common ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1816 ;bra check_gas_change_exit
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1817
0
heinrichsweikamp
parents:
diff changeset
1818 check_gas_change_exit:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1819 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1820 btfss better_gas_available ; is a better gas available?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1821 bcf blinking_better_gas ; NO - clear blinking flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1822 btfsc better_gas_available ; is a better gas available?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1823 return ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1824 clrf WREG ; NO - clear better_gas_number (for gaslist display)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1825 movff WREG,better_gas_number
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1826 return
0
heinrichsweikamp
parents:
diff changeset
1827
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1828 check_gas_common: ; With Gas 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1829 btfsc better_gas_available ; Better Gas already found?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1830 return ; Yes, return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1831 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1832 btfss PLUSW1,0 ; Test for Bit0 and 1 -> type=3 -> Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1833 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1834 btfss PLUSW1,1 ; Test for Bit0 and 1 -> type=3 -> Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1835 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1836 incf WREG,W ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1837 cpfseq active_gas ; is this gas current gas?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1838 bra check_gas_common2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1839 return ; Yes, skip test for active gas
0
heinrichsweikamp
parents:
diff changeset
1840 check_gas_common2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1841 decf WREG,W ; 0-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1842 movwf hi ; Save tested gas 0-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1843 lfsr FSR1,opt_OC_bail_gas_change
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1844 movff PLUSW1,lo ; Change depth into lo
0
heinrichsweikamp
parents:
diff changeset
1845 movlw minimum_change_depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1846 cpfsgt lo ; Change depth>minimum_change_depth?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1847 return ; No, Change depth not deep enough, skip!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1848 movf xC+0,W ; load depth in m into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1849 cpfsgt lo ; gas_change_depth < current depth?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1850 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
1851 incf hi,W ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1852 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
1853 movlw better_gas_window_neg
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1854 subwf lo,W ; Change depth-better_gas_window_neg
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1855 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1856 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
1857 return
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1858 check_gas_common3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1859 incf hi,W ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1860 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
1861 movlw better_gas_window_pos
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1862 addwf lo,W ; Change depth+better_gas_window_pos
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1863 cpfsgt xC+0 ; current depth>Change depth+better_gas_window_pos?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1864 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
1865 return
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1866 check_gas_common4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1867 movf hi,W ; gas 0-4 into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1868 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
1869 movff PLUSW1,lo ; read O2 ratio from array into lo
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1870
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1871 SAFE_2BYTE_COPY amb_pressure, xA
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1872 movlw d'10'
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1873 movwf xB+0
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1874 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1875 call div16x16 ; xC=p_amb/10
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1876 movff xC+0,xA+0
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1877 movff xC+1,xA+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1878 movff lo,xB+0 ; =O2 ratio
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1879 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1880 call mult16x16 ; lo * p_amb/10
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1881
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1882 ; Check very high ppO2 manually
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1883 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
1884 return ; Done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1885 ; Check if ppO2>3,30bar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1886 btfsc xC+1,7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1887 return ; Done.
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1888
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1889 ; 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
1890 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
1891 movff xC+1,sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1892 movff char_I_ppO2_min,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1893 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
1894 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
1895 movff PRODH,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1896 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
1897 btfss neg_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1898 return ; Done (Too low).
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
1899
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1900 ;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
1901 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
1902 movff xC+1,sub_a+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1903 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
1904 addlw .1 ; e.g. >1.60
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1905 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
1906 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
1907 movff PRODH,sub_b+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1908 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
1909 btfsc neg_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1910 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
1911 return ; Done.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1912
0
heinrichsweikamp
parents:
diff changeset
1913
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1914 check_dil_common: ; With Dil 0-4 in WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1915 btfsc better_gas_available ; Better Diluent already found?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1916 return ; Yes, return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1917 lfsr FSR1,opt_dil_type ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1918 tstfsz PLUSW1 ; =0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1919 bra check_dil_common1 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1920 return ; Yes, skip inactive diluents for test
0
heinrichsweikamp
parents:
diff changeset
1921 check_dil_common1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1922 incf WREG,W ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1923 cpfseq active_gas ; is this the current diluent?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1924 bra check_dil_common2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1925 return ; Yes, skip test for active diluent
0
heinrichsweikamp
parents:
diff changeset
1926 check_dil_common2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1927 decf WREG,W ; 0-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1928 movwf hi ; Save tested diluent 0-4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1929 lfsr FSR1,char_I_dil_change
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1930 movff PLUSW1,lo ; Change depth into lo
0
heinrichsweikamp
parents:
diff changeset
1931 movlw minimum_change_depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1932 cpfsgt lo ; Change depth>minimum_change_depth?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1933 return ; No, Change depth not deep enough, skip!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1934 movf xC+0,W ; load depth in m into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1935 cpfsgt lo ; gas_change_depth < current depth?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1936 return ; No, check next gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1937 incf hi,W ; 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1938 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
1939 movlw better_gas_window_neg
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1940 subwf lo,W ; Change depth-better_gas_window_neg
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1941 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1942 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
1943 return
0
heinrichsweikamp
parents:
diff changeset
1944
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1945
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1946 ;=============================================================================
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1947 ; Check for Auto-SP
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1948 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1949 check_dive_autosp: ; Check for Auto-SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1950 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1951 sublw .2 ; opt_ccr_mode = 2 (Auto SP)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1952 bz check_dive_autosp2 ; Yes, check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1953 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
1954 check_dive_autosp2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1955 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
1956 movlw d'100'
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1957 movwf xB+0
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1958 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1959 call div16x16 ; compute depth in full m -> result in xC+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1960 ; Check SP2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1961 btfsc sp2_switched ; =1: This setpoint has been autoselected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1962 bra check_dive_autosp3 ; Skip check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1963 movff char_I_setpoint_change+1,lo ; Get depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1964 tstfsz lo ; =0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1965 bra check_dive_autosp2a ; No, continue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1966 bra check_dive_autosp3 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1967 check_dive_autosp2a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1968 decf lo,W ; -1 -> WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1969 cpfsgt xC+0 ; Compare with depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1970 bra check_dive_autosp3 ; lower depth, do not switch
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1971 ; auto switch to SP2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1972 movff char_I_setpoint_cbar+1,char_I_const_ppO2 ; Use SetPoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1973 rcall xmit_sp_set_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1974 bsf sp2_switched ; Set flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1975 check_dive_autosp3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1976 ; Check SP3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1977 btfsc sp3_switched ;=1: This setpoint has been autoselected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1978 bra check_dive_autosp4 ; Skip check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1979 movff char_I_setpoint_change+2,lo ; Get depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1980 tstfsz lo ; =0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1981 bra check_dive_autosp3a ; No, continue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1982 bra check_dive_autosp4 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1983 check_dive_autosp3a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1984 decf lo,W ; -1 -> WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1985 cpfsgt xC+0 ; Compare with depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1986 bra check_dive_autosp4 ; lower depth, do not switch
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1987 ; auto switch to SP3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1988 movff char_I_setpoint_cbar+2,char_I_const_ppO2 ; Use SetPoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1989 rcall xmit_sp_set_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1990 bsf sp3_switched ; Set flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
1991 check_dive_autosp4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1992 ; Check SP4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1993 btfsc sp4_switched ;=1: This setpoint has been autoselected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1994 bra check_dive_autosp5 ; Skip check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1995 movff char_I_setpoint_change+3,lo ; Get depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1996 tstfsz lo ; =0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1997 bra check_dive_autosp4a ; No, continue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1998 bra check_dive_autosp5 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1999 check_dive_autosp4a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2000 decf lo,W ; -1 -> WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2001 cpfsgt xC+0 ; Compare with depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2002 bra check_dive_autosp5 ; lower depth, do not switch
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2003 ; auto switch to SP4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2004 movff char_I_setpoint_cbar+3,char_I_const_ppO2 ; Use SetPoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2005 rcall xmit_sp_set_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2006 bsf sp4_switched ; Set flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2007 check_dive_autosp5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2008 ; Check SP5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2009 btfsc sp5_switched ;=1: This setpoint has been autoselected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2010 bra check_dive_autosp6 ; Skip check
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2011 movff char_I_setpoint_change+4,lo ; Get depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2012 tstfsz lo ; =0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2013 bra check_dive_autosp5a ; No, continue
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2014 bra check_dive_autosp6 ; Skip check
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2015 check_dive_autosp5a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2016 decf lo,W ; -1 -> WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2017 cpfsgt xC+0 ; Compare with depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2018 bra check_dive_autosp6 ; lower depth, do not switch
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2019 ; auto switch to SP5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2020 movff char_I_setpoint_cbar+4,char_I_const_ppO2 ; Use SetPoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2021 rcall xmit_sp_set_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2022 bsf sp5_switched ; Set flag
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2023 check_dive_autosp6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2024 return
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2025
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2026 xmit_sp_set_flag:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2027 movff char_I_const_ppO2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2028 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2029 bsf setpoint_changed ; Set flag (for profile)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2030 bsf event_occured ; Set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2031 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2032
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2033 set_logbook_marker:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2034 bcf FLAG_set_marker ; clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2035 movlw d'6' ; set type of Alarm (manual marker)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2036 movwf AlarmType ; copy to Alarm Register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2037 bsf event_occured ; Set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2038 return
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2039
0
heinrichsweikamp
parents:
diff changeset
2040 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2041 ; Setup everything to enter divemode.
heinrichsweikamp
parents:
diff changeset
2042 ;
heinrichsweikamp
parents:
diff changeset
2043 dive_boot_oc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2044 rcall get_first_gas_to_WREG ; Gets first gas (1-5) into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2045 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
2046 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
2047 return
0
heinrichsweikamp
parents:
diff changeset
2048
heinrichsweikamp
parents:
diff changeset
2049 dive_boot_cc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2050 bcf is_bailout ; =1: Bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2051 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2052 bcf blinking_setpoint ; Reset blinking SP flag
192
efe70488a04b voting logic for external monitoring
heinrichsweikamp
parents: 178
diff changeset
2053
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2054 ; revoke sensors from usage if they do not have a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2055 bsf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2056 bsf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2057 bsf use_O2_sensor3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2058 btfss sensor1_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2059 bcf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2060 btfss sensor2_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2061 bcf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2062 btfss sensor3_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2063 bcf use_O2_sensor3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2064
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2065 btfss optical_input ; do we have an optical input?
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2066 bra dive_boot_cc_0 ; No
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2067 ; Copy (initial) valid flags from HUD/ppO2 Monitor
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2068 btfsc sensor1_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2069 bsf use_O2_sensor1
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2070 btfsc sensor2_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2071 bsf use_O2_sensor2
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2072 btfsc sensor3_active
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2073 bsf use_O2_sensor3
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2074
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2075 dive_boot_cc_0:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2076 ; 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
2077 ; 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
2078 btfss FLAG_pscr_mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2079 bra dive_boot_cc_1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2080 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
2081 sublw .2 ; opt_ccr_mode = 1 (Auto SP)?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2082 bnz dive_boot_cc_1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2083 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2084 movff WREG,opt_ccr_mode
549
7c408bfaf2e8 2.26 stable RC1
heinrichsweikamp
parents: 547
diff changeset
2085
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2086 dive_boot_cc_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2087 bsf setpoint_changed ; set flag (for profile)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2088 bcf sp2_switched ; =1: This setpoint has been auto-selected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2089 bcf sp3_switched ; =1: This setpoint has been auto-selected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2090 bcf sp4_switched ; =1: This setpoint has been auto-selected already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2091 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
2092
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2093 rcall get_first_dil_to_WREG ; get first gas (1-5) into WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2094 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
2095 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
2096
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2097 ; Start with SP1 (CCR) or 0 (pSCR) as default.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2098 ; 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
2099 clrf WREG ; preload WREG with setpoint value 0 for pSCR calculated
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2100 btfss FLAG_ccr_mode ; are we in CCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2101 bra dive_boot_cc_2 ; NO - keep preloaded value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2102 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
2103 dive_boot_cc_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2104 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2105 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2106 goto calc_deko_divemode_sensor ; read & process sensor data (and return)
0
heinrichsweikamp
parents:
diff changeset
2107
heinrichsweikamp
parents:
diff changeset
2108 diveloop_boot:
heinrichsweikamp
parents:
diff changeset
2109 call restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
2110
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2111 call I2C_sleep_accelerometer ; stop accelerometer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2112 call I2C_sleep_compass ; stop compass
0
heinrichsweikamp
parents:
diff changeset
2113
heinrichsweikamp
parents:
diff changeset
2114 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2115 movff WREG,max_pressure+0 ; clear some variables
0
heinrichsweikamp
parents:
diff changeset
2116 movff WREG,max_pressure+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2117
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2118 ; init in invalid data state
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2119 clrf WREG ; set WREG to 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2120 bsf WREG,int_invalid_flag ; set invalid flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2121 bsf WREG,int_is_zero ; set zero flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2122 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
2123 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
2124 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
2125 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
2126 movff WREG,int_O_tank_pres_need+9 ; simulation may be shown
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2127
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2128 ; configure the deco engine:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2129 movff char_O_deco_status,WREG ; bank-safe copy
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2130 bsf WREG,DECO_STATUS_0_FLAG ; configure init ...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2131 bsf WREG,DECO_STATUS_1_FLAG ; ... state,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2132 bcf WREG,DECO_PLAN_FLAG ; normal plan mode,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2133 bsf WREG,DECO_CNS_FLAG ; enable CNS calculation (CNS at end of dive),
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2134 bcf WREG,DECO_VOLUME_FLAG ; disable gas volume calculation, and
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2135 bcf WREG,DECO_ASCENT_FLAG ; disable delayed ascent calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2136 movff WREG,char_O_deco_status ; bank-safe copy back
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2137
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2138 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2139 movff WREG,char_O_main_status ; reset char_O_main_status
0
heinrichsweikamp
parents:
diff changeset
2140
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2141 movlw deco_distance
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2142 movff WREG,char_I_deco_distance
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2143 movff opt_last_stop,char_I_depth_last_deco
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2144 movff opt_GF_low,char_I_GF_Low_percentage
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2145 movff opt_GF_high,char_I_GF_High_percentage
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2146
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2147 bcf use_agf ; Start with normal GF set
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2148 bcf divemode_menu ; clear divemode menu flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2149
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2150 bcf alternative_divelayout ; Start with default layout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2151
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2152 bcf blinking_depth_prev ; clear flag for blinking depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2153 bcf blinking_depth_warning ; clear flag for blinking depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2154 bcf blinking_depth_toggle ; clear flag for blinking depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2155
0
heinrichsweikamp
parents:
diff changeset
2156 movlw d'1'
heinrichsweikamp
parents:
diff changeset
2157 movwf apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
2158 clrf apnoe_max_pressure+1
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2159 ; clrf apnoe_surface_mins
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2160 ; clrf apnoe_surface_secs
0
heinrichsweikamp
parents:
diff changeset
2161 clrf apnoe_mins
heinrichsweikamp
parents:
diff changeset
2162 clrf divemins+0
heinrichsweikamp
parents:
diff changeset
2163 clrf divemins+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2164
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2165 ; Copy date and time for logbook
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2166 movff year,start_year
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2167 movff month,start_month
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2168 movff day,start_day
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2169 movff hours,start_hours
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2170 movff mins,start_mins
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2171
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2172 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
2173 movff int_O_CNS_fraction+1,WREG ; get high byte to WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2174 bcf WREG,int_warning_flag ; clear warning flag bit
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2175 movff WREG,CNS_start+1 ; move high byte on
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2176 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
2177
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2178 bcf no_more_divesecs ; =1: do no longer show seconds in divemode
0
heinrichsweikamp
parents:
diff changeset
2179 bcf divemode_menu_active
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2180 clrf menupos1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2181 clrf menupos2 ; Reset to zero (Zero=no premenu or simulator task)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2182 bsf sensors_agree ; init of sensors disagree warning system
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2183
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2184 btfsc FLAG_ccr_mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2185 bra diveloop_boot_cc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2186 btfsc FLAG_pscr_mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2187 bra diveloop_boot_cc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2188 rcall dive_boot_oc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2189 bra diveloop_boot_cont
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2190
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2191 diveloop_boot_cc:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2192 rcall dive_boot_cc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2193
545
7e6df19264b6 BUGFIX: Simulator in CC mode
heinrichsweikamp
parents: 543
diff changeset
2194 diveloop_boot_cont:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2195 ; Copy opt_dil_types into backup (For "lost gas" feature)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2196 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
2197 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
2198 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
2199 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
2200 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
2201 ; Copy opt_gas_types into backup (For "lost gas" feature)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2202 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
2203 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
2204 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
2205 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
2206 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
2207 ; Also copy change depths into backup (For "lost gas" feature)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2208 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
2209 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
2210 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
2211 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
2212 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
2213 ; Also copy change depths into backup (For "lost gas" feature)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2214 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
2215 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
2216 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
2217 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
2218 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
2219
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2220 clrf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2221 movff WREG,better_gas_number ; clear better gas register
0
heinrichsweikamp
parents:
diff changeset
2222
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2223 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
2224 clrf safety_stop_countdown ; Clear count-down
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
2225
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2226 clrf samplesecs
0
heinrichsweikamp
parents:
diff changeset
2227 clrf apnoe_timeout_counter ; timeout in minutes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2228 clrf timeout_counter1+0 ; takes care of the timeout (low byte)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2229 clrf timeout_counter1+1 ; takes care of the timeout (high byte)
0
heinrichsweikamp
parents:
diff changeset
2230 clrf AlarmType ; Clear all alarms
heinrichsweikamp
parents:
diff changeset
2231 bcf event_occured ; clear flag
heinrichsweikamp
parents:
diff changeset
2232 clrf average_depth_hold_total+0
heinrichsweikamp
parents:
diff changeset
2233 clrf average_depth_hold_total+1
heinrichsweikamp
parents:
diff changeset
2234 clrf average_depth_hold_total+2
heinrichsweikamp
parents:
diff changeset
2235 clrf average_depth_hold_total+3 ; Clear Non-Resettable Average
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2236 rcall reset_average1 ; Reset the resettable average depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2237 bcf decostop_active
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2238 bcf better_gas_available ; =1: A better gas is available and a gas change is advised in divemode
204
heinrichsweikamp
parents: 197
diff changeset
2239 call ghostwriter_short_header ; Write short header with divenumber into profile memory
0
heinrichsweikamp
parents:
diff changeset
2240
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2241 btfsc simulatormode_active
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2242 bra diveloop_boot_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2243 ; Normal mode = Surface pressure is the pressure 30mn before dive.
0
heinrichsweikamp
parents:
diff changeset
2244 SAFE_2BYTE_COPY last_surfpressure_30min, int_I_pres_surface ;copy surfacepressure to deco routine
heinrichsweikamp
parents:
diff changeset
2245 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
2246 bra diveloop_boot_2
0
heinrichsweikamp
parents:
diff changeset
2247
heinrichsweikamp
parents:
diff changeset
2248 diveloop_boot_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2249 ; Simulator mode: Surface pressure is 1bar.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2250 movlw LOW .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2251 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
2252 movlw HIGH .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2253 movff WREG,int_I_pres_surface+1 ; HIGH copy surface pressure to deco routine
0
heinrichsweikamp
parents:
diff changeset
2254
heinrichsweikamp
parents:
diff changeset
2255 diveloop_boot_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2256 SAFE_2BYTE_COPY temperature,minimum_temperature ; Reset Min-Temp registers
0
heinrichsweikamp
parents:
diff changeset
2257
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2258 call init_recording_params ; set up all the divisors
0
heinrichsweikamp
parents:
diff changeset
2259
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2260 bsf ccr_diluent_setup ; For CCR mode (Required to have better gas working)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2261 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2262 bra divemode_boot2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2263 btfsc FLAG_pscr_mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2264 bra divemode_boot2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2265 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
2266
102
37275e0fa7f5 NEW: Show End-of-Dive time together with clock during deco
heinrichsweikamp
parents: 99
diff changeset
2267 divemode_boot2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2268 bcf LEDg ; switch off green LED / release reset to RX circuitry
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2269 bcf LEDr ; switch off red LED
0
heinrichsweikamp
parents:
diff changeset
2270 bcf realdive
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2271 btfss simulatormode_active ; do not disable in simulator mode!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2272 call disable_rs232 ; Disable RS232
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2273 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
2274 call enable_rs232 ; Also sets to speed_normal ...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2275 ; Reset divetime seconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2276 movlw .2 ; Start at 2seconds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2277 movwf total_divetime_seconds+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2278 clrf total_divetime_seconds+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2279 movwf divesecs
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2280 movwf apnoe_secs
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2281 bsf divemode2 ; displayed divetime is running (Divetime starts HERE)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2282 return ; Done with divemode boot
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2283
0
heinrichsweikamp
parents:
diff changeset
2284
heinrichsweikamp
parents:
diff changeset
2285 divemode_check_for_warnings:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2286 movlw .1 ; One warning at a time in alt. layout mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2287 btfss alternative_divelayout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2288 movlw .2 ; Two warnings at a time in default layout mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2289 cpfsgt warning_counter ; only one (or two) warnings active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2290 bra divemode_check_for_warnings1 ; Yes, update every second
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2291
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2292 btfss secs,0 ; Every two seconds...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2293 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2294 btfss secs,1 ; Every four seconds...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2295 return
0
heinrichsweikamp
parents:
diff changeset
2296
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2297 divemode_check_for_warnings1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2298 bcf warning_active ; Clear flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2299 clrf warning_counter ; Clear counter
0
heinrichsweikamp
parents:
diff changeset
2300
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2301 ; warnings sorted by severity, highest severity first
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2302
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2303 ; Warnings for all modes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2304 call check_warn_battery ; Check if the battery level should be displayed/warned
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2305 call check_divetimeout ; Not actually a warning. Check and show the divemode timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2306
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2307 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2308 bra divemode_check_for_warnings2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2309 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2310 bra divemode_check_for_warnings2
0
heinrichsweikamp
parents:
diff changeset
2311
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2312 ; Warnings only in deco modes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2313 rcall check_ppO2 ; check ppO2 and displays warning, if required
0
heinrichsweikamp
parents:
diff changeset
2314
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2315 btfss sensors_agree ; are the sensor values within the threshold range?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2316 rcall check_warn_sensors_disagree ; NO - further evaluate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2317 btfsc sensors_agree ; are the sensor values within the threshold range?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2318 bcf sensor_warning ; YES - revoke memorized sensor warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2319
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2320 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2321 btfsc WREG,outside_warning_lock ; are we outside of the ZH-L16 model?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2322 rcall warn_outside ; YES
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2323
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2324 rcall check_IBCD ; check for IBCD attention or warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2325
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2326 btfsc decostop_active ; In deco mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2327 rcall check_and_store_gf_violation; Yes, sets warnings, if required
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2328
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2329 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2330 btfsc WREG,mbubble_warning_lock ; do we have a microbubbles warning?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2331 rcall warn_mbubbles ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2332
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2333 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
2334
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2335 ;btfsc decostop_active ; In deco mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2336 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
2337
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2338 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
2339
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2340 call TFT_display_ftts ; Show @+x time
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2341
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2342 btfsc use_agf ; In aGF mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2343 rcall warn_agf ; Yes, show a warning for it
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2344
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2345 btfsc setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2346 rcall warn_fallback ; Show the warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2347
0
heinrichsweikamp
parents:
diff changeset
2348 divemode_check_for_warnings2:
heinrichsweikamp
parents:
diff changeset
2349 ; Display the warning icon?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2350 btfsc warning_active ; Any warning active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2351 bsf FLAG_TFT_divemode_warning ; Yes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2352 btfss warning_active ; Any warning active?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2353 bsf FLAG_TFT_divemode_warning_clear ; No, clear warning icon
0
heinrichsweikamp
parents:
diff changeset
2354
heinrichsweikamp
parents:
diff changeset
2355 ; Setup warning_page number
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2356 incf warning_page,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2357 movf warning_page,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2358 bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2359 btfss alternative_divelayout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2360 rlcf warning_page,W ; *2 (But only in standard layout mode)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2361 cpfsgt warning_counter ; > warning_counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2362 clrf warning_page ; No, clear
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2363
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2364 ; 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
2365 tstfsz warning_counter ; any warnings?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2366 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
2367 bsf FLAG_TFT_dive_warning_text_clear ; Set flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2368 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2369 divemode_check_for_warnings3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2370
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2371
0
heinrichsweikamp
parents:
diff changeset
2372 ; 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
2373 btfss second_row_warning ; =1: The second row contains a warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2374 bsf FLAG_TFT_dive_warning_text_clr2 ; Set flag for 2nd row
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2375 return ; Done.
0
heinrichsweikamp
parents:
diff changeset
2376
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2377 global check_warn_battery
0
heinrichsweikamp
parents:
diff changeset
2378 check_warn_battery:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2379 movff batt_percent,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2380 movlw battery_show_level+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2381 cpfslt lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2382 return ; No Display, no warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2383 ; Display Battery, but warn?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2384 movff batt_percent,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2385 movlw color_code_battery_low+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2386 cpfsgt lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2387 bsf warning_active ; Set Warning flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2388
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2389 movlw .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2390 cpfseq menupos3 ; battery shown in Custom View 4?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2391 bra check_warn_battery2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2392 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
2393 check_warn_battery2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2394 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2395 goto TFT_update_batt_percent_divemode ; Show percent (And return)
513
heinrichsweikamp
parents: 507
diff changeset
2396
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2397 check_divetimeout:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2398 btfsc divemode2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2399 return ; displayed divetime is not running
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2400 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2401 goto TFT_divetimeout ; Show timeout counter (and return)
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2402
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2403
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2404 check_ppO2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2405 btfsc FLAG_ccr_mode ; are we in CCR mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2406 bra check_ppO2_loop ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2407 btfsc FLAG_pscr_mode ; are we in pSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2408 bra check_ppO2_loop ; YES
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2409 bra check_ppO2_oc_1 ; NO - neither CCR nor pSCR
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2410 check_ppO2_loop:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2411 btfsc is_bailout ; in bailout?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2412 bra check_ppO2_oc_1 ; YES - continue with OC
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2413 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
2414 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
2415 rcall check_ppo2_display ; YES - show warning and return on next line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2416 btfsc hi,int_attention_flag ; ppO2 of the pure diluent close to setpoint?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2417 rcall check_ppo2_display ; YES - show warning and return on next line
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2418 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
2419 check_ppO2_oc_1:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2420 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
2421 btfsc WREG,int_attention_flag ; breathed ppO2 just above attention threshold?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2422 bra check_ppo2_display ; YES - show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2423 check_ppO2_oc_2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2424 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
2425 btfsc WREG,int_low_flag ; breathed ppO2 to low?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2426 bra check_ppO2_low ; YES - record the warning and show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2427 btfsc WREG,int_high_flag ; breathed ppO2 to high?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2428 bra check_ppO2_high ; YES - record the warning and show ppO2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2429 TSTOSS opt_showppo2 ; show ppO2 anyhow? (0 = no, 1 = show always)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2430 return ; NO - no warnings, no show
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2431 bra check_ppo2_display ; YES - just show ppO2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2432 check_ppO2_low:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2433 movlw d'4' ; set type of alarm (ppO2 low)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2434 bra check_ppO2_common ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2435 check_ppO2_high:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2436 movlw d'5' ; set type of alarm (ppO2 high)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2437 check_ppO2_common:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2438 movwf AlarmType ; copy alarm type to alarm register
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2439 bsf event_occured ; set event flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2440 bsf warning_active ; set warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2441 btfsc is_bailout ; are we in bailout?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2442 bra check_ppo2_display ; YES - skip CCR/pSCR checks
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2443 btfsc FLAG_ccr_mode ; are we in CCR mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2444 return ; YES - no extra warning required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2445 btfsc FLAG_pscr_mode ; are we in pSCR mode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2446 return ; YES - no extra warning required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2447 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
2448 movlw .9
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2449 cpfseq menupos3 ; ppO2 shown in Custom View 9?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2450 bra check_ppO2_a ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2451 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
2452 check_ppO2_a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2453 movlw .11
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2454 cpfseq menupos3 ; ppO2 shown in Custom View 11?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2455 bra check_ppO2_b ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2456 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
2457 check_ppO2_b:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2458 movlw .12
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2459 cpfseq menupos3 ; ppO2 shown in Custom View 12?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2460 bra check_ppO2_c ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2461 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
2462 check_ppO2_c:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2463 movlw .10
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2464 cpfseq menupos3 ; ppO2 shown in Custom View 10?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2465 bra check_ppO2_d ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2466 return ; Yes, do not show twice (in custom view and in warning area)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2467 check_ppO2_d:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2468 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2469 goto TFT_display_ppo2 ; show breathed gas or diluent ppO2 warning (and return)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2470
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2471
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2472 global check_cns_violation
0
heinrichsweikamp
parents:
diff changeset
2473 check_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2474 ; Check if CNS should be displayed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2475 movff int_O_CNS_fraction+1,WREG ; get high byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2476 btfsc WREG,int_warning_flag ; warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2477 bra check_cns_violation2 ; Yes - issue warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2478 btfsc WREG,int_attention_flag ; attention flag set?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2479 bra display_cns_violation ; YES - just display CNS
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2480 return ; No - no display, no warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2481 check_cns_violation2:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2482 bsf warning_active ; Set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2483 display_cns_violation: ; Show CNS if not shown in the custom view
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2484 movlw .11
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2485 cpfseq menupos3 ; CNS shown in Custom View?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2486 bra display_cns_violation2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2487 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
2488 display_cns_violation2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2489 movlw .8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2490 cpfseq menupos3 ; CNS shown through Custom View 8 right now?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2491 bra display_cns_violation3 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2492 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
2493 display_cns_violation3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2494 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2495 goto TFT_display_cns ; Show CNS (and return)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2496
0
heinrichsweikamp
parents:
diff changeset
2497
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2498 global check_eod_cns_violation ; check end-of-dive CNS values
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2499 check_eod_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2500 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
2501 btfsc WREG,int_warning_flag ; current CNS value in warning state?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2502 return ; YES - inhibit eod warning if current CNS is already in warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2503 movff int_O_normal_CNS_fraction+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2504 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2505 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
2506 btfsc WREG,int_warning_flag ; NO - flag for warning set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2507 bra check_eod_cns_violation2 ; YES - issue warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2508 check_eod_cns_violation1: ; NO - continue with checking the other CNS value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2509 movff int_O_alternate_CNS_fraction+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2510 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2511 return ; YES - done with CNS checking
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2512 btfsc WREG,int_warning_flag ; NO - flag for warning set?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2513 bra check_eod_cns_violation2 ; Yes - issue warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2514 return ; NO - done with CNS checking
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2515 check_eod_cns_violation2: ; YES - issue warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2516 bsf warning_active ; set Warning flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2517 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
2518 cpfseq menupos3 ; CNS values shown through Custom View 8 right now?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2519 bra display_eod_cns_violation ; NO - issue textual warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2520 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
2521 display_eod_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2522 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2523 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
2524
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2525
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2526 global check_and_store_gf_violation
0
heinrichsweikamp
parents:
diff changeset
2527 check_and_store_gf_violation:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2528 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
2529 btfss WREG,int_warning_flag ; check if the warning flag is set
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2530 bra check_and_store_gf_violation2 ; NO - continue with checking for attention flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2531 movlw d'2' ; YES - set type of alarm
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2532 movwf AlarmType ; copy to alarm register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2533 bsf event_occured ; set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2534 bsf warning_active ; set warning flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2535 bra check_and_store_gf_violation3 ; show gf warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2536 check_and_store_gf_violation2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2537 btfsc WREG,int_attention_flag ; check if the attention flag is set
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2538 bra check_and_store_gf_violation3 ; YES - show gf
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2539 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2540 bra check_and_store_gf_violation4 ; NO - continue checking of deco info
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2541 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2542 btfss WREG,IBCD_warning ; is the IBCD warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2543 bra check_and_store_gf_violation4 ; NO - continue checking for deco info
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2544 check_and_store_gf_violation3: ; YES - show gf
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2545 bsf warning_active ; set Warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2546 incf warning_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2547 goto TFT_warning_gf ; show GF (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2548 check_and_store_gf_violation4: ; check for deco info
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2549 btfss divemode ; in divemode?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2550 return ; NO - done, return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2551 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2552 btfss WREG,deco_flag ; check if the deco flag is set
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2553 return ; NO - all done, return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2554 incf warning_counter,F ; YES - increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2555 goto TFT_info_deco ; show deco info
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2556
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2557
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2558 warn_outside:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2559 incf warning_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2560 bsf warning_active ; Set Warning flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2561 goto TFT_warning_outside ; show outside warning (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2562
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2563
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2564 global warn_mbubbles
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2565 warn_mbubbles:
0
heinrichsweikamp
parents:
diff changeset
2566 incf warning_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2567 bsf warning_active ; Set Warning flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2568 goto TFT_warning_mbubbles ; show microbubbles warning (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2569
0
heinrichsweikamp
parents:
diff changeset
2570 warn_agf:
heinrichsweikamp
parents:
diff changeset
2571 incf warning_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2572 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
2573
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2574 warn_fallback:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2575 incf warning_counter,F ; increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2576 bsf warning_active ; Set Warning flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2577 goto TFT_warning_fallback ; Show fallback warning (and return)
0
heinrichsweikamp
parents:
diff changeset
2578
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2579
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2580 check_gas_needs:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2581 banksel int_O_tank_pres_need
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2582 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
2583 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
2584 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
2585 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
2586 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
2587 banksel common
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2588 btfsc WREG,int_invalid_flag ; check if invalid flag is set
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2589 return ; YES - no further checking required
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2590 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
2591 bsf warning_active ; YES - set warning flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2592 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
2593 goto TFT_warning_gas_needs_warn ; Yes - show a warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2594 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
2595 goto TFT_warning_gas_needs_att ; YES - show an attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2596 bcf gas_needs_attention ; NO - clear flag for a new attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2597 bcf gas_needs_warning ; clear flag for a new warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2598 return
0
heinrichsweikamp
parents:
diff changeset
2599
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2600
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2601 check_warn_sensors_disagree:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2602 incf warning_counter,F ; increase counter
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2603 bsf warning_active ; YES - set Warning flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2604 goto TFT_warning_sensor_disagree ; show sensor disagree warning (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2605
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 check_IBCD:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2608 TSTOSS opt_enable_IBCD ; IBCD warning activated?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2609 return ; NO - done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2610 movff char_O_deco_warnings,WREG ; YES - get deco warnings vector
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2611 btfss WREG,IBCD_warning ; IBCD warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2612 return ; NO - return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2613 incf warning_counter,F ; YES - increase counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2614 goto TFT_warning_IBCD ; write warning to display
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2615
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2616
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2617 global restart_deco_engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2618 global restart_deco_engine_wo_ceiling
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2619 restart_deco_engine:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2620 ; make bank save copies and set flags for invalid data
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2621 movff int_O_ceiling+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2622 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
2623 movff WREG,int_O_ceiling+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2624
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2625 restart_deco_engine_wo_ceiling:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2626 ; make more bank save copies and set more flags for invalid data
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2627 movff char_O_deco_gas+0,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2628 bsf WREG,char_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2629 movff WREG,char_O_deco_gas+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2630
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2631 movff int_O_ascenttime+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2632 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2633 movff WREG,int_O_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2634
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2635 movff int_O_alternate_ascenttime+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2636 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2637 movff WREG,int_O_alternate_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2638
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2639 movff int_O_normal_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2640 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2641 movff WREG,int_O_normal_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2642
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2643 movff int_O_alternate_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2644 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2645 movff WREG,int_O_alternate_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2646
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2647 movff int_O_tank_pres_need+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2648 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2649 movff WREG,int_O_tank_pres_need+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2650
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2651 ; restart deco engine
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2652 movff char_O_deco_status,WREG ; get current deco engine configuration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2653 bcf WREG,DECO_STATUS_0_FLAG ; set status flags to...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2654 bcf WREG,DECO_STATUS_1_FLAG ; ... DECO_STATUS_START
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2655 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
2656 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
2657
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2658 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2659
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2660 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2661 ; simulator mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2662 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2663
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2664 global do_demo_divemode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2665 do_demo_divemode:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2666 call option_save_all ; Save all settings into EEPROM before starting simulation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2667 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
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 ; +++ COMMENTED OUT FOR TESTING PURPOSE ONLY !!! +++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2671 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2672 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2673 bsf restore_deco_data ; Restore tissue and CNS after simulator use
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2674
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2675 bcf pressure_refresh
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2676 btfss pressure_refresh ; Wait for sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2677 bra $-2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2678
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2679 bsf simulatormode_active ; Set Flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2680 ; Compute dive ambient conditions
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2681 banksel char_I_bottom_depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2682 movf char_I_bottom_depth,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2683 mullw .100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2684 movff PRODL,rel_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2685 movff PRODH,rel_pressure+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2686 movlw LOW (.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2687 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2688 movff WREG,sim_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2689 movlw HIGH (.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2690 addwfc PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2691 movff WREG,sim_pressure+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2692 banksel common ; Bank1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2693
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2694 bsf divemode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2695 goto diveloop ; Switch into Divemode!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2696
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2697 END