annotate src/divemode.asm @ 605:5ce603c29750

gas color coding fixed
author heinrichsweikamp
date Sun, 25 Nov 2018 13:21:52 +0100
parents ca4556fb60b9
children 8b250afb8bdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3 ; File divemode.asm REFACTORED VERSION V2.99e
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
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
12 #include "hwos.inc" ; mandatory header
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
13 #include "shared_definitions.h" ; mailbox from/to p2_deco.c
582
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
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
29 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
30 #include "rx_ops.inc"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
31 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
32
0
heinrichsweikamp
parents:
diff changeset
33
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
34 extern TFT_dive_compass_heading
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
35 extern do_line_menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
36 extern do_main_divemenu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
37 extern option_save_all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
38 extern init_recording_params
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
39
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
40
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
41 ;---- Private local variables -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
42
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
43 CBLOCK local1 ; max size is 16 Byte !!!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
44 apnoe_timeout_counter ; timeout counter for apnoe mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
45 sensor_setpoint ; sensor ppo2 in 0.01bar for deco routine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
46 check_gas_num ; used in search for best gas/dil: current gas/dil number (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
47 check_gas_depth ; used in search for best gas/dil: current gas/dil change depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
48 check_gas_type ; used in search for best gas/dil: current gas/dil type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
49 check_gas_O2_ratio ; used in search for best gas/dil: current gas/dil O2 ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
50 best_gas_num ; used in search for best gas/dil: best gas/dil number (1-5) CAUTION: there is also a variable named best_gas_number !
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
51 best_gas_depth ; used in search for best gas/dil: best gas/dil change depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
52 ppO2_min ; used in search for best gas/dil: minimum ppO2 required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
53 ppO2_max ; used in search for best gas/dil: maximum ppO2 allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
54 ENDC ; used: 10 byte, remaining: 6 byte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
55
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
56 CBLOCK local2 ; max size is 16 Byte !!!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
57 average_depth_hold:4 ; used to calculate the resettable average depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
58 average_depth_hold_total:4 ; used to calculate the absolute average depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
59 ENDC ; used: 8 byte, remaining: 8 byte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
60
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
61 dmode CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
62
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
63 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
64
heinrichsweikamp
parents:
diff changeset
65 global diveloop
heinrichsweikamp
parents:
diff changeset
66 diveloop:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
67 banksel common
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
68 call speed_normal
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
69 call diveloop_boot ; boot tasks for all modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
70
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
71 ; startup tasks for all modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
72 call TFT_boot ; initialize TFT (includes clear screen)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
73 bsf FLAG_TFT_divemode_mask ; request display of dive mode mask
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
74
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
75 movff customview_divemode,menupos3; reload last custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
76 bsf redraw_custview_mask ; request redraw of last custom view
0
heinrichsweikamp
parents:
diff changeset
77
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
78 btfsc FLAG_apnoe_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
79 bsf realdive ; set realdive flag in apnoe mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
80
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
81 btfsc FLAG_apnoe_mode ; done for apnoe or gauge mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
82 bra diveloop_loop_start
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
83 btfsc FLAG_gauge_mode ; done for apnoe or gauge mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
84 bra diveloop_loop_start
0
heinrichsweikamp
parents:
diff changeset
85
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
86 ; Deco modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
87 bsf FLAG_TFT_active_gas_divemode; request display of gas and setpoint
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
88 bsf FLAG_TFT_display_ndl_mask ; request display of "NDL"
0
heinrichsweikamp
parents:
diff changeset
89
heinrichsweikamp
parents:
diff changeset
90 ; +@5 init
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
91 clrf WREG ; WAIT marker: display "---"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
92 movff WREG,char_I_sim_advance_time
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
93 movff WREG,int_O_alternate_ascenttime+0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
94 bsf WREG,int_not_yet_computed
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
95 bsf WREG,int_invalid_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
96 movff WREG,int_O_alternate_ascenttime+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
97
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
98 diveloop_loop_start:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
99 btfsc FLAG_TFT_divemode_mask
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
100 call TFT_divemode_mask
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
101 btfsc FLAG_TFT_display_ndl_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
102 call TFT_display_ndl_mask
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
103
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
104 diveloop_loop: ; the dive loop starts here
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
105 btfss quarter_second_update
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
106 bra diveloop_loop1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
107
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
108 ; tasks any 1/4 second, any mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
109 bcf quarter_second_update ; clear flag
0
heinrichsweikamp
parents:
diff changeset
110
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
111 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
112 bra diveloop_loop1 ; YES - no compass in alternative layout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
113 movlw index_compass_dm ; NO - index of compass view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
114 cpfseq menupos3 ; - in compass view?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
115 bra diveloop_loop1 ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
116 call TFT_dive_compass_heading ; YES - update compass heading value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
117 bsf FLAG_TFT_temp_divemode ; - redraw temperature (is slightly affected from compass heading arrow)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
118
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
119 diveloop_loop1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
120 btfss onesecupdate ; next second begun?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
121 bra diveloop_loop3 ; NO
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
122
0
heinrichsweikamp
parents:
diff changeset
123 ; tasks any new second...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
124 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
125
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
126 ; ###-- USE FOR DEBUG ONLY - RESETS RX CIRCUITRY --###
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
127 ; bsf LEDg
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
128 ; ###----------------------------------------------###
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
129
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
130 ; compute current depth in meters
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
131 SAFE_2BYTE_COPY rel_pressure,xA
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
132 movlw .100
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
133 movwf xB+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
134 clrf xB+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
135 call div16x16 ; xC = xA / xB, xC+0 now holds depth in full meters
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
136 movff xC+0,curr_depth ; store result in curr_depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
137
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
138 ; compute ambient pressure / 10, will be needed later
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
139 SAFE_2BYTE_COPY amb_pressure,xA
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
140 movlw .10
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
141 movwf xB+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
142 clrf xB+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
143 call div16x16 ; xC = xA / xB = p_amb / 10
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
144 movff xC+0,amb_press_10+0 ; store result for later use
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
145 movff xC+1,amb_press_10+1 ; ...
0
heinrichsweikamp
parents:
diff changeset
146
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
147 ; display depth based on full seconds interval (nicer blinking)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
148 btfss alternative_divelayout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
149 rcall TFT_output4_normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
150 btfsc alternative_divelayout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
151 rcall TFT_output4_alternative
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
152
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
153 btfsc FLAG_apnoe_mode ; in Apnoe mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
154 bra diveloop_loop1_nonedeco ; YES - do Apnoe mode every second tasks
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
155
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
156 ; tasks any new second - only for deco modes
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
157 diveloop_loop1_deco:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
158 bsf FLAG_TFT_divemins ; display (new) dive time!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
159 btfsc show_safety_stop ; show the safety stop?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
160 bsf FLAG_TFT_show_safety_stop ; YES - show/delete if done
0
heinrichsweikamp
parents:
diff changeset
161
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
162 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
163 rcall TFT_output1_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
164 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
165 rcall TFT_output1_alternative
0
heinrichsweikamp
parents:
diff changeset
166
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
167 call divemode_check_for_warnings ; check for warnings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
168
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
169 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
170 btfss FLAG_tr_enabled ; TR functions enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
171 bra diveloop_loop1_deco1 ; NO - skip pressure readings part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
172 call get_pressure_readings ; YES - get pressure readings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
173 call configure_sac_calculation ; - set up SAC calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
174 diveloop_loop1_deco1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
175 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
176
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
177 call calc_deco_divemode ; calculate decompression and set resulting display flags
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
178
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
179 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
180 rcall TFT_output2_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
181 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
182 rcall TFT_output2_alternative
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
183 bra diveloop_loop2 ; continue with common tasks
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
184
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
185 ; tasks any new second - only for apnoe mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
186 diveloop_loop1_nonedeco:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
187 rcall divemode_apnoe_tasks ; 1 sec. apnoe tasks
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
188 call customview_second ; do every-second tasks for the custom view area
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
189 ;bra diveloop_loop2 ; common tasks
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
190
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
191 ; continue tasks any new second, any mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
192 diveloop_loop2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
193 btfsc redraw_custview_mask ; shall we redraw the custom view mask?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
194 call customview_mask ; YES - redraw custom view mask
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
195
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
196 rcall timeout_divemode ; ** menu timeout? ** - this routine sets the required flags
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
197 rcall set_dive_modes ; tests if depth > threshold
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
198 rcall set_min_temp ; store min. temp if required (future hardware will need this to be checked 1/second...)
0
heinrichsweikamp
parents:
diff changeset
199
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
200 btfsc oneminupdate ; one minute tasks
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
201 rcall update_divemode60 ; update clock, etc.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
202
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
203 btfss FLAG_oc_mode ; are we in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
204 bsf FLAG_TFT_active_gas_divemode; NO - have the gas and setpoint redrawn on every second to update setpoint display, animate the blinking, etc.
0
heinrichsweikamp
parents:
diff changeset
205
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
206 btfss alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
207 rcall TFT_output3_normal
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
208 btfsc alternative_divelayout
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
209 rcall TFT_output3_alternative
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
210
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
211 ; ###-- USE FOR DEBUG ONLY - RESETS RX CIRCUITRY --###
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
212 ; bcf LEDg
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
213 ; ###----------------------------------------------###
0
heinrichsweikamp
parents:
diff changeset
214
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
215 ; tasks any round, any mode
0
heinrichsweikamp
parents:
diff changeset
216 diveloop_loop3:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
217 call test_switches_divemode ; check switches in dive mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
218
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
219 global diveloop_loop4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
220 diveloop_loop4: ; menu-exit returns here...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
221 btfsc toggle_customview ; next view?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
222 call customview_toggle ; YES - show next custom view (and delete this flag)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
223
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
224 btfsc divemode_gaschange ; gas switch flag set?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
225 call gas_switched_common ; YES
0
heinrichsweikamp
parents:
diff changeset
226
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
227 btfsc toggle_gf ; toggle GF/aGF?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
228 rcall divemodemode_togglegf ; YES
0
heinrichsweikamp
parents:
diff changeset
229
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
230 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
231 btfsc toggle_turn_dive ; toggle dive turned?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
232 rcall divemodemode_toggleturn ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
233 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
234
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
235 btfsc FLAG_set_marker ; shall set a marker?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
236 call set_logbook_marker ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
237
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
238 btfsc store_sample ; shall store new sample?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
239 call store_dive_data ; YES - store profile data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
240
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
241 btfss divemode ; dive finished?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
242 goto ghostwriter_end_dive ; YES - dive finished!
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 69
diff changeset
243
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
244 btfsc pressure_refresh ; new pressure available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
245 rcall set_max_depth ; YES - update max. depth if required
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
246 btfsc pressure_refresh ; new pressure available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
247 bsf FLAG_TFT_depth ; YES - update depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
248 bcf pressure_refresh ; clear flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
249
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
250 btfsc temp_changed ; temperature changed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
251 bsf FLAG_TFT_temp_divemode ; YES - display temperature
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
252
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
253 IFDEF _screendump
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
254 btfsc enable_screen_dumps ; screen dump function enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
255 call TFT_dump_screen_check ; YES - check if requested and do it
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
256 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
257
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
258 bra diveloop_loop ; loop the dive mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
259
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
260 ;--------------------------------------------------------------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
261
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
262 TFT_output1_normal: ; beginning of any new second - only for deco modes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
263 btfsc FLAG_TFT_divemode_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
264 call TFT_divemode_mask
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
265 btfsc FLAG_TFT_divemins
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
266 call TFT_divemins ; display (new) dive time!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
267 call customview_second ; do every-second tasks for the custom view area (in sync with the dive time) mH
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
268 btfsc FLAG_TFT_show_safety_stop
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
269 call TFT_show_safety_stop ; show safety stop
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
270 btfsc FLAG_TFT_clear_safety_stop
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
271 call TFT_clear_safety_stop ; clear safety stop
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
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
274 TFT_output1_alternative: ; beginning of any new second - only for deco modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
275 btfsc FLAG_TFT_divemode_mask_alt
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
276 call TFT_divemode_mask_alternative ; alternative mask
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
277 btfsc FLAG_TFT_divemins
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
278 call TFT_divemins_alternative ; display (new) divetime!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
279 call customview_alternative_second ; do every-second tasks for the custom view area (in sync with the dive time) mH
588
bf0c76e9b01b Sync safety stop countdown output
heinrichsweikamp
parents: 583
diff changeset
280 btfsc FLAG_TFT_big_deco_alt
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
281 call TFT_big_deco_alt ; big deco, also manages alternative safety stop thus moved to first wave of outputs [rl]
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
282 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
283
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
284 TFT_output2_normal: ; any new second - only for deco modes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
285 btfsc FLAG_TFT_display_ndl_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
286 call TFT_display_ndl_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
287 btfsc FLAG_TFT_display_ndl
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
288 call TFT_display_ndl
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
289 btfsc FLAG_TFT_display_deko_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
290 call TFT_display_deko_mask
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
291 btfsc FLAG_TFT_display_deko
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
292 call TFT_display_deko
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
293 btfsc FLAG_TFT_display_tts
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
294 call TFT_display_tts
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
295 return
0
heinrichsweikamp
parents:
diff changeset
296
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
297 TFT_output2_alternative: ; any new second - only for deco modes
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
298 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
299
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
300 TFT_output3_normal: ; tasks any new second, any mode, after deco calculations
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
301 btfsc FLAG_TFT_max_depth
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
302 call TFT_max_depth ; use normal max. depth
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
303 btfsc FLAG_TFT_divemode_warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
304 call TFT_divemode_warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
305 btfsc FLAG_TFT_divemode_warning_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
306 call TFT_divemode_warning_clear
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
307 btfsc FLAG_TFT_dive_warning_text_clear
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
308 call TFT_clear_warning_text ; clear complete warnings area
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
309 btfsc FLAG_TFT_dive_warning_text_clr2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
310 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
311 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
312
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
313 TFT_output3_alternative: ; tasks any new second
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
314 btfsc FLAG_TFT_max_depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
315 call TFT_max_depth_alternative ; big max. depth
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
316 btfsc FLAG_TFT_dive_warning_text_clear
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
317 call TFT_clear_warning_text ; clear complete warnings area (in alt mode only 2nd row...)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
318 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
319
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
320 TFT_output4_normal: ; tasks any round, any mode, before deco calculations (stable timebase)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
321 btfsc FLAG_TFT_depth
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
322 call TFT_depth ; display depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
323 btfsc FLAG_TFT_active_gas_divemode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
324 call TFT_active_gas_divemode ; display gas/setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
325 btfsc FLAG_TFT_temp_divemode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
326 call TFT_temp_divemode ; update temperature
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
327 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
328
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
329 TFT_output4_alternative: ; tasks any round, any mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
330 btfsc FLAG_TFT_depth
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
331 call TFT_depth ; display new depth
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
332 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
333
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
334
0
heinrichsweikamp
parents:
diff changeset
335 ;--------------------------------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
336
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
337 divemode_apnoe_tasks: ; 1 sec. apnoe tasks
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
338 call TFT_display_apnoe_descent ; show descent timer
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
339 call TFT_max_depth ; use normal max. depth
0
heinrichsweikamp
parents:
diff changeset
340
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
341 btfsc divemode2 ; time running?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
342 bra divemode_apnoe_tasks2 ; YES - new descent, reset data if flag is set
0
heinrichsweikamp
parents:
diff changeset
343
heinrichsweikamp
parents:
diff changeset
344 rcall apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
345 call TFT_display_apnoe_surface
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
346 call TFT_display_apnoe_last_max ; show last max. depth
0
heinrichsweikamp
parents:
diff changeset
347 incf apnoe_surface_secs,F
heinrichsweikamp
parents:
diff changeset
348 movlw d'60'
heinrichsweikamp
parents:
diff changeset
349 cpfseq apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
350 bra divemode_apnoe_tasks1
heinrichsweikamp
parents:
diff changeset
351 clrf apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
352 incf apnoe_surface_mins,F
heinrichsweikamp
parents:
diff changeset
353
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
354 divemode_apnoe_tasks1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
355 bcf FLAG_active_descent ; clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
356 btfsc divemode2 ; time running?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
357 return ; YES - return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
358 bsf FLAG_active_descent ; set flag
0
heinrichsweikamp
parents:
diff changeset
359 return
heinrichsweikamp
parents:
diff changeset
360
heinrichsweikamp
parents:
diff changeset
361 divemode_apnoe_tasks2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
362 btfss FLAG_active_descent ; are we descending?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
363 return ; NO - we are at the surface
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
364 rcall apnoe_calc_maxdepth ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
365 call TFT_apnoe_clear_surface ; clear surface timer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
366 clrf apnoe_timeout_counter ; delete timeout
0
heinrichsweikamp
parents:
diff changeset
367 clrf apnoe_surface_secs
heinrichsweikamp
parents:
diff changeset
368 clrf apnoe_surface_mins
heinrichsweikamp
parents:
diff changeset
369 clrf apnoe_secs
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
370 clrf apnoe_mins ; reset descent time
0
heinrichsweikamp
parents:
diff changeset
371 movlw .0
heinrichsweikamp
parents:
diff changeset
372 movff WREG,max_pressure+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
373 movff WREG,max_pressure+1 ; reset max. depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
374 bcf FLAG_active_descent ; clear flag
0
heinrichsweikamp
parents:
diff changeset
375 return
heinrichsweikamp
parents:
diff changeset
376
heinrichsweikamp
parents:
diff changeset
377 global apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
378 apnoe_calc_maxdepth:
heinrichsweikamp
parents:
diff changeset
379 movff apnoe_max_pressure+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
380 movff apnoe_max_pressure+1,sub_a+1
heinrichsweikamp
parents:
diff changeset
381 movff max_pressure+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
382 movff max_pressure+1,sub_b+1
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
383 call subU16 ; sub_c = sub_a - sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
384 ; apnoe_max_pressure < max_pressure -> neg_flag=1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
385 ; max_pressure <= apnoe_max_pressure -> neg_flag=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
386 btfss neg_flag
0
heinrichsweikamp
parents:
diff changeset
387 return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
388 ;apnoe_max_pressure<max_pressure
0
heinrichsweikamp
parents:
diff changeset
389 movff max_pressure+0,apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
390 movff max_pressure+1,apnoe_max_pressure+1
heinrichsweikamp
parents:
diff changeset
391 return
heinrichsweikamp
parents:
diff changeset
392
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
393 ; --------------------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
394
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
395 calc_deco_divemode:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
396 btfss FLAG_gauge_mode ; in gauge mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
397 rcall calc_deko_engine ; NO - do deco calculations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
398
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
399 ; Increment the time accumulators used for calculating the average depths.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
400 ; This done here and not in the ISR to guarantee synchronism between time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
401 ; and depth accumulator incrementing.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
402 infsnz average_divesecs+0,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
403 incf average_divesecs+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
404 infsnz average_divesecs_total+0,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
405 incf average_divesecs_total+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
406
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
407 btg onesectoggle ; toggle the one-second toggle bit
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
408 btfss onesectoggle ; toggle bit set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
409 bra calc_deko_divemode2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
410 ;bra calc_deko_divemode1 ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
411
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
412 calc_deko_divemode1: ; every-2-seconds tasks, 1st phase
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
413 ; call TFT_debug_output ; optional debug output
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
414 btfsc FLAG_gauge_mode ; in gauge mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
415 return ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
416 goto check_gas_best ; NO - checks if a better gas should be selected (by user) and return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
417
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
418 calc_deko_divemode2: ; every-2-seconds tasks, 2nd phase
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
419 call calc_average_depth ; calculate average depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
420 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
421 goto set_reset_safety_stop ; set/reset flags for safety stop and return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
422
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
423
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
424 calc_deko_engine:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
425 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
426 call check_dive_autosp ; YES - check for Auto-SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
427
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
428 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
429 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable by OSTC model
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
430
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
431 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
432 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable by OSTC model
0
heinrichsweikamp
parents:
diff changeset
433
195
bca0f054f023 allow auto-return from setpoint fallback
heinrichsweikamp
parents: 193
diff changeset
434
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
435 ; check deco engine state and switch between normal and alternative plan calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
436 ;
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
437 ; Remark: Any reconfigurations done here do only affect the ascent & deco calculation settings,
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
438 ; not the settings for the calculations done on the real tissues. The later ones are only
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
439 ; altered in case of a gas change, or in case of a real bailout or switchback to setpoint
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
440 ; or sensor, respectively.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
441 ; In case of a gas change or real bailout/switchback, the settings for the deco calculations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
442 ; are also changed to match the settings for the real tissues. This is done on signal through
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
443 ; 'divemode_gaschange' and will also leave the deco engine status in state as if having done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
444 ; the alternative plan last.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
445
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
446 ; get working copies of char_O_main_status and char_O_deco_status
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
447 movff char_O_main_status,hi ; get char_O_main_status into hi
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
448 movff char_O_deco_status,lo ; get char_O_deco_status into lo
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
449
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
450 ; check state of deco calculations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
451 btfsc hi,DECO_COMPLETED_NORM ; finished calculations for normal plan?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
452 bra calc_deko_engine_alt ; YES - do an alternative plan next (or a normal one with more features enabled)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
453 btfsc hi,DECO_COMPLETED_ALT ; finished calculations for alternative plan?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
454 bra calc_deko_engine_norm ; YES - do a normal plan next
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
455 bra calc_deko_engine_cont ; NO to both - continue calculations / do first invocation in INIT mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
456
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
457 calc_deko_engine_norm:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
458 ; Last cycle did an alternative plan, or the deco engine has been restarted because of a gas change etc.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
459 ; --> Reconfigure to normal plan for next computation cycle.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
460 bcf lo,DECO_PLAN_FLAG ; clear flag for alternative plan to do a normal plan next
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
461 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
462 bcf lo,DECO_VOLUME_FLAG ; clear flag for gas needs calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
463 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
464 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
465 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
466 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
467
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
468 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
469 bra calc_deko_engine_norm_loop ; YES - reload diluents and reconfigure CCR mode if not in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
470 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
471 bra calc_deko_engine_norm_loop ; YES - reload diluents and reconfigure pSCR mode if not in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
472 ;bra calc_deko_engine_norm_OC ; neither in CCR nor pSCR mode, so reload OC gases and reconfigure OC mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
473 ; (first cycle omits gas needs calculation for faster first deco results)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
474 calc_deko_engine_norm_OC:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
475 movff active_gas,WREG ; get current OC gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
476 call deco_setup_oc_gases_pre ; set up deco calculations in OC mode with OC gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
477 bra calc_deko_engine_start ; start deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
478
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
479 calc_deko_engine_norm_loop: ; switch to loop calculation if not in a real bailout situation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
480 btfsc FLAG_bailout_mode ; check if a real bailout situation is present
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
481 bra calc_deko_engine_norm_OC ; YES - revert to OC mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
482 ; NO - switch to loop calculation:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
483 movff active_dil,WREG ; - get current diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
484 call deco_setup_cc_diluents_pre ; - set up deco calculations in CCR/pSCR mode with diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
485 bra calc_deko_engine_start ; - start deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
486
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
487 calc_deko_engine_alt:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
488 ; A normal plan was computed in the last cycle. For the next calculation cycle the mode may be switched
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
489 ; to alternative plan, or stay in normal plan but with certain features enabled...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
490 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
491 bcf lo,DECO_VOLUME_FLAG ; clear flag for gas needs calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
492 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
493 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
494 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
495 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
496
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
497 btfsc FLAG_bailout_mode ; check if a real bailout situation is present
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
498 bra calc_deko_engine_alt_1 ; YES - stay in normal plan mode and preclude delayed ascent calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
499 TSTOSS char_I_extra_time ; NO - check if a delayed ascent is enabled
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
500 bra calc_deko_engine_alt_1 ; NO - stay in normal plan mode and preclude delayed ascent calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
501 bsf lo,DECO_PLAN_FLAG ; YES - set flag for alternative plan
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
502 bsf lo,DECO_ASCENT_FLAG ; - set flag for delayed ascent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
503
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
504 calc_deko_engine_alt_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
505 TSTOSS opt_calc_asc_gasvolume ; check if gas volume calculation is enabled
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
506 bra calc_deko_engine_start ; NO - no volume calculation, no simulated bailout plan in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
507 bsf lo,DECO_VOLUME_FLAG ; YES - set gas needs calculation flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
508
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
509 btfsc FLAG_bailout_mode ; check if a real bailout situation is present
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
510 bra calc_deko_engine_start ; YES - normal plan already does bailout (OC) calculation "for real"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
511
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
512 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
513 bsf hi,DECO_CAVE_MODE ; activate cave mode by default
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
514 btfss FLAG_cave_mode ; cave mode switched on?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
515 bcf hi,DECO_CAVE_MODE ; NO - deactivate p2deco cave mode again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
516 btfsc FLAG_dive_turned ; dive turned?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
517 bcf hi,DECO_CAVE_MODE ; YES - deactivate p2deco cave mode again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
518 btfsc FLAG_cave_mode_shutdown ; cave mode function shut down?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
519 bcf hi,DECO_CAVE_MODE ; YES - deactivate p2deco cave mode again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
520 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
521
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
522 btfss lo,DECO_MODE_LOOP_FLAG ; NO - has a loop mode calculation been done during the normal plan?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
523 bra calc_deko_engine_start ; NO - when not in loop mode, no simulated bailout to be done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
524 decf best_gas_number,W ; YES - get best gas number -1 into WREG. If not available, WREG will be 255 now. If not computed yet, WREG will be 254 now.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
525 btfsc WREG,7 ; - WREG < 128 (a bailout gas is available)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
526 bra calc_deko_engine_alt_2 ; NO - no simulated bailout possible because no bailout gas available to switch to
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
527 bsf lo,DECO_PLAN_FLAG ; YES - set flag for alternative plan
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
528 bsf lo,DECO_BAILOUT_FLAG ; - set bailout mode flag (enables gas changes before 1st stop)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
529 movf best_gas_number,W ; - put number of best gas into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
530 call deco_setup_oc_gases_pre ; - set up deco calculations in OC mode with OC gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
531 bra calc_deko_engine_start ; - start in alternative plan mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
532
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
533 calc_deko_engine_alt_2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
534 bcf lo,DECO_PLAN_FLAG ; clear flag for alternative plan
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
535 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
536 bcf lo,DECO_VOLUME_FLAG ; clear flag for gas needs calculation
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
537 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
538 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
539 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
540 call inval_alternative_plan_data ; invalidate all alternative (bailout) plan data because they are not applicable any more
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
541
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
542 calc_deko_engine_start:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
543 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
544 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
545 ENDIF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
546 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface
0
heinrichsweikamp
parents:
diff changeset
547
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
548 calc_deko_engine_cont:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
549 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; transfer ambient pressure to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
550 clrf TMR5L ; restart timer used to preempt stops calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
551 clrf TMR5H ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
552 call deco_calc_hauptroutine ; invoke the deco engine (p2_deco.c)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
553 banksel common
0
heinrichsweikamp
parents:
diff changeset
554
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
555 ; the displayed gas may need a different color-coding
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
556 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
557
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
558 ; check if display shall be updated due to deco engine restart
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
559 btfsc FLAG_TFT_display_ndl_or_deko; shall update immediately?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
560 bra calc_deko_engine_update ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
561
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
562 ; check if new calculation results for normal plan mode are available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
563 movff char_O_main_status,WREG ; get deco status of deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
564 btfss WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
565 return ; NO - done
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
566
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
567 calc_deko_engine_update:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
568 bcf FLAG_TFT_display_ndl_or_deko; YES - reset flag for immediate update
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
569 movff char_O_deco_info,WREG ; - get deco info vector
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
570 btfsc WREG,deco_ceiling ; - ceiling depth > 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
571 bra calc_deko_engine_update_deco; YES - in deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
572 ;bra calc_deko_engine_update_NDL ; NO - within NDL
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
573
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
574 calc_deko_engine_update_NDL: ; within NDL
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
575 btfsc decostop_active ; been in deco mode before?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
576 bsf FLAG_TFT_display_ndl_mask ; YES - clear deco data, display NDL time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
577 bsf FLAG_TFT_display_ndl ; display NDL time
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
578 bcf decostop_active ; clear flag for been in deco mode before
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
579 return
0
heinrichsweikamp
parents:
diff changeset
580
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
581 calc_deko_engine_update_deco: ; in deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
582 btfss decostop_active ; already been in deco mode before?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
583 bsf FLAG_TFT_display_deko_mask ; NO - clear NDL time, display deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
584 bsf FLAG_TFT_display_deko ; display deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
585 bsf FLAG_TFT_display_tts ; display TTS
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
586 bsf decostop_active ; set flag for being in deco mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
587 return
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 ; --------------------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
590
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
591 global calc_deko_divemode_sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
592 calc_deko_divemode_sensor:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
593 ; sensor acquisition code
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
594 btfss s8_digital ; check if we have a digital interface to the sensors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
595 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
596 btfss new_s8_data_available ; YES - check if a new data frame was received
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
597 bra calc_deko_divemode_sensor_common ; NO - use old values
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
598 call compute_mvolts_for_all_sensors ; YES - compute mV values from digital data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
599 bra calc_deko_divemode_sensor_common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
600 calc_deko_divemode_sensor_analog:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
601 btfss analog_o2_input ; do we have an analog input?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
602 bra calc_deko_divemode_sensor_opt ; NO - check if we have an optical interface
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
603 call get_analog_inputs ; YES - get the analog voltages and continue with the common part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
604 bra calc_deko_divemode_sensor_common
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
605 calc_deko_divemode_sensor_opt:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
606 btfss optical_input ; do we have an optical input?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
607 return ; NO - return (we have no sensors at all: not analog, not S8 and not optical)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
608 btfss sensor1_active ; YES - o2_ppo2_sensor1, o2_ppo2_sensor2 and o2_ppo2_sensor3 are already filled in ISR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
609 bcf use_O2_sensor1 ; check HUD status data and eventually clear use_O2_sensorX
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
610 btfss sensor2_active
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
611 bcf use_O2_sensor2
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
612 btfss sensor3_active
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
613 bcf use_O2_sensor3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
614 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
615
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
616 calc_deko_divemode_sensor_common:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
617 ; Check each sensor if it is calibrated and if its mV value is within min_mv and max_mv limits.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
618 ; If ok: compute o2_ppo2_sensorX = o2_mv_sensorX * opt_x_sX / 1000
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
619 ; 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
620
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
621 ; check sensor 1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
622 btfss sensor1_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
623 bra check_sensor_1_fail ; NO - handle it as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
624 ; check min threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
625 movff o2_mv_sensor1+0,sub_a+0 ; load sensor mV value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
626 movff o2_mv_sensor1+1,sub_a+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
627 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
628 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
629 bra check_sensor_1_fail ; YES - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
630 ; check max_threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
631 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
632 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
633 bra check_sensor_1_fail ; NO - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
634 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
635 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
636 bra check_sensor_1_ok ; NO - all checks done then and positive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
637 btfss sensor1_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
638 bra check_sensor_1_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
639 check_sensor_1_ok:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
640 ; o2_ppo2_sensor1 = o2_mv_sensor1:2 * opt_x_s1:2 / 1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
641 movff o2_mv_sensor1+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
642 movff o2_mv_sensor1+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
643 movff opt_x_s1+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
644 movff opt_x_s1+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
645 rcall compute_ppo2_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
646 movff xC+0,o2_ppo2_sensor1 ; result in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
647 bra check_sensor_2 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
648 check_sensor_1_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
649 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
650 movff WREG,o2_ppo2_sensor1 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
651 btfss use_O2_sensor1 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
652 bra check_sensor_1_fail_1 ; NO - no new news then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
653 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
654 check_sensor_1_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
655 bcf use_O2_sensor1 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
656
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
657 check_sensor_2: ; check min_mv of sensor 2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
658 btfss sensor2_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
659 bra check_sensor_2_fail ; NO - handle it as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
660 ; check min threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
661 movff o2_mv_sensor2+0,sub_a+0 ; load sensor mV value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
662 movff o2_mv_sensor2+1,sub_a+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
663 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
664 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
665 bra check_sensor_2_fail ; YES - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
666 ; check max_threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
667 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
668 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
669 bra check_sensor_2_fail ; NO - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
670 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
671 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
672 bra check_sensor_2_ok ; NO - all checks done then and positive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
673 btfss sensor2_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
674 bra check_sensor_2_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
675 check_sensor_2_ok:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
676 ; o2_ppo2_sensor2 = o2_mv_sensor2:2 * opt_x_s2:2 / 1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
677 movff o2_mv_sensor2+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
678 movff o2_mv_sensor2+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
679 movff opt_x_s2+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
680 movff opt_x_s2+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
681 rcall compute_ppo2_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
682 movff xC+0,o2_ppo2_sensor2 ; result in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
683 bra check_sensor_3 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
684 check_sensor_2_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
685 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
686 movff WREG,o2_ppo2_sensor2 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
687 btfss use_O2_sensor2 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
688 bra check_sensor_2_fail_1 ; NO - no new news then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
689 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
690 check_sensor_2_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
691 bcf use_O2_sensor2 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
692
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
693 check_sensor_3: ; check min_mv of sensor 2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
694 btfss sensor3_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
695 bra check_sensor_3_fail ; NO - handle it as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
696 ; check min threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
697 movff o2_mv_sensor3+0,sub_a+0 ; load sensor mV value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
698 movff o2_mv_sensor3+1,sub_a+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
699 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
700 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
701 bra check_sensor_3_fail ; YES - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
702 ; check max threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
703 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
704 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
705 bra check_sensor_3_fail ; NO - declare sensor as failed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
706 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
707 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
708 bra check_sensor_3_ok ; NO - all checks done then and positive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
709 btfss sensor3_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
710 bra check_sensor_3_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
711 check_sensor_3_ok:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
712 ; o2_ppo2_sensor3 = o2_mv_sensor3:2 * opt_x_s1:2 / 1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
713 movff o2_mv_sensor3+0,xA+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
714 movff o2_mv_sensor3+1,xA+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
715 movff opt_x_s3+0,xB+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
716 movff opt_x_s3+1,xB+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
717 rcall compute_ppo2_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
718 movff xC+0,o2_ppo2_sensor3 ; result in 0.01 bar
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
719 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
720 check_sensor_3_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
721 clrf WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
722 movff WREG,o2_ppo2_sensor3 ; set ppO2 reading to zero
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
723 btfss use_O2_sensor3 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
724 bra check_sensor_3_fail_1 ; NO - no new news then
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
725 call check_sensor_custview_helper; YES - show custom view 1 (sensor values) on further conditions met
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
726 check_sensor_3_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
727 bcf use_O2_sensor3 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
728
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
729 calc_deko_divemode_sensor_A: ; calculate sensor average
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
730 ; exit here if not in dive mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
731 btfss divemode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
732 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
733
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
734 ; 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
735 ; sum up sensor values (in xA:2) and active sensors in (xB:2)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
736 clrf xB+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
737 clrf xB+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
738 clrf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
739 clrf xA+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
740 divemode_setup_sensor_1_value:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
741 btfss use_O2_sensor1 ; sensor1 active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
742 bra divemode_setup_sensor_2_value ; NO
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
743 movf o2_ppo2_sensor1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
744 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
745 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
746 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
747 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
748 divemode_setup_sensor_2_value:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
749 btfss use_O2_sensor2 ; sensor2 active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
750 bra divemode_setup_sensor_3_value ; NO
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
751 movf o2_ppo2_sensor2,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
752 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
753 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
754 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
755 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
756 divemode_setup_sensor_3_value:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
757 btfss use_O2_sensor3 ; sensor3 active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
758 bra divemode_setup_sensor_mean ; NO
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
759 movf o2_ppo2_sensor3,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
760 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
761 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
762 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
763 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
764
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
765 ; divide sum of sensor values by number of active sensors found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
766 divemode_setup_sensor_mean:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
767 clrf xC+0 ; set zero as default result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
768 tstfsz xB+0 ; pending div/0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
769 call div16x16 ; NO - execute xC = xA / xB = summed ppO2 / number of sensors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
770 movff xC+0,sensor_setpoint ; copy result (or its default)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
771
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
772 ; set default value for pSCR mode: 0 => let p2_deco.c compute the ppO2 based on current dil gas and depth
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
773 ; will be overwritten later in case we are in sensor mode and have at least one usable sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
774 clrf WREG ; preload a zero
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
775 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
776 movff WREG,char_I_const_ppO2 ; YES - write 0 to char_I_const_ppo2,
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
777 ; it will be overwritten if we have a usable sensor reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
778 btfsc FLAG_bailout_mode ; check if we are in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
779 bra calc_deko_divemode_sensor_V ; YES - no sensor data transfer to char_I_const_ppO2 in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
780 movff opt_ccr_mode,WREG ; NO - get mode (0: Fixed SP, 1: Sensor, 2: Auto SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
781 sublw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
782 bnz calc_deko_divemode_sensor_V ; NO - not in sensor mode - no transfer of sensor data to char_I_const_ppO2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
783 tstfsz xB+0 ; YES - check if we have found at least one usable sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
784 bra divemode_setup_sensor_mean1 ; YES - we have at least one usable sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
785 bsf setpoint_fallback ; NO - we have NO usable sensors -> initiate fallback
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
786 btfss FLAG_ccr_mode ; - check if we are in CCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
787 bra calc_deko_divemode_sensor_V ; NO - continue with voting logic flags
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
788 movff char_I_setpoint_cbar+0,char_I_const_ppO2; YES - select fixed setpoint no. 1 for fallback
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
789 bra calc_deko_divemode_sensor_V ; - continue with voting logic flags
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
790 ; we have at least one usable sensor with a ppO2 value > 0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
791 divemode_setup_sensor_mean1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
792 bcf setpoint_fallback ; clear fallback condition
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
793 movff sensor_setpoint,char_I_const_ppO2 ; transfer average sensor value to p2_deco.c code
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
794 ; vote sensors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
795 calc_deko_divemode_sensor_V:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
796 bsf voting_logic_sensor1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
797 movff o2_ppo2_sensor1,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
798 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
799 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
800 bcf voting_logic_sensor1 ; NO - vote out this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
801
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
802 bsf voting_logic_sensor2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
803 movff o2_ppo2_sensor2,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
804 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
805 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
806 bcf voting_logic_sensor2 ; NO - vote out this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
807
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
808 bsf voting_logic_sensor3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
809 movff o2_ppo2_sensor3,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
810 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
811 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
812 bcf voting_logic_sensor3 ; NO - vote out this sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
813
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
814 ; check if a warning shall be issued on sensor disagreement
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
815 btfsc FLAG_ccr_mode ; check if we are in CCR mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
816 bra check_warn_sensor_0 ; YES - continue with further checks
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
817 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
818 bra check_warn_sensor_0 ; YES - continue with further checks
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
819 bra check_warn_sensor_done ; not in CCR and not in pSCR, so no warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
820 check_warn_sensor_0: ; we are in CCR or pSCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
821 btfsc FLAG_bailout_mode ; check if we are in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
822 bra check_warn_sensor_done ; YES - no warning in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
823 movff opt_ccr_mode,WREG ; get mode (0: Fixed SP, 1: Sensor, 2: Auto SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
824 sublw .1 ; in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
825 bnz check_warn_sensor_done ; NO - not in sensor mode - no warning in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
826 ; check sensor 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
827 check_warn_sensor_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
828 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
829 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
830 btfss use_O2_sensor1 ; YES - check if sensor is in use
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
831 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
832 btfsc voting_logic_sensor1 ; YES - check if sensor value is within agreement range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
833 bra check_warn_sensor_2 ; YES - continue with next sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
834 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
835 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
836 ; check sensor 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
837 check_warn_sensor_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
838 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
839 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
840 btfss use_O2_sensor2 ; YES - check if sensor is in use
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
841 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
842 btfsc voting_logic_sensor2 ; YES - check if sensor value is within agreement range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
843 bra check_warn_sensor_3 ; YES - continue with next sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
844 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
845 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
846 ; check sensor 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
847 check_warn_sensor_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
848 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
849 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
850 btfss use_O2_sensor3 ; YES - check if sensor is in use
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
851 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
852 btfsc voting_logic_sensor3 ; YES - check if sensor value is within agreement range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
853 bra check_warn_sensor_agree ; YES - continue with next sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
854 bcf sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
855 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
856 ; no need for a warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
857 check_warn_sensor_done:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
858 check_warn_sensor_agree:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
859 bsf sensors_agree
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
860 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
861
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
862
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
863 check_min_threshold:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
864 movlw LOW min_mv ; load minimum mV value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
865 movwf sub_b+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
866 movlw HIGH min_mv
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
867 movwf sub_b+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
868 goto sub16 ; sub_c = sensor_mv - min_mv (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
869
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
870 check_max_threshold:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
871 movlw LOW max_mv
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
872 movwf sub_b+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
873 movlw HIGH max_mv
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
874 movwf sub_b+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
875 goto sub16 ; sub_c = sensor_mv - max_mv (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
876
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
877 compute_ppo2_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
878 call mult16x16 ; xA:2*xB:2=xC:4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
879 movlw LOW .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
880 movwf xB+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
881 movlw HIGH .1000
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
882 movwf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
883 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
884 movlw d'1'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
885 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
886 movlw d'0'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
887 addwfc xC+1,W ; we are still just interested in the carry flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
888 tstfsz WREG ; ppO2 is higher than 2.55bar?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
889 setf xC+0 ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
890 return
0
heinrichsweikamp
parents:
diff changeset
891
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
892 check_sensor_custview_helper:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
893 btfss divemode ; check if we are in dive mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
894 return ; NO - not in dive mode, return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
895 movff opt_ccr_mode,WREG ; YES - =0: Fixed SP, =1: Sensor, =2: Auto SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
896 decfsz WREG,W ; - opt_ccr_mode = 1 (sensors)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
897 return ; NO - not using the sensors in the moment
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
898 btfsc alternative_divelayout ; YES - in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
899 call switch_layout_to_normal ; YES - switch to normal layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
900 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
901 movwf menupos3 ; set custom view number
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
902 bsf toggle_customview ; initiate toggle to desired custom view -> ppO2 sensors
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
903 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
904
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
905 check_sensor_voting_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
906 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
907 cpfsgt sensor_setpoint
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
908 bra check_sensor_voting_helper2 ; lo < sensor_setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
909 ; lo > sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
910 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
911 subwf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
912 movwf lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
913 check_sensor_voting_helper1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
914 movlw sensor_voting_logic_threshold ; threshold in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
915 cpfsgt lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
916 retlw .0 ; within range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
917 retlw .1 ; out of range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
918 check_sensor_voting_helper2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
919 ; lo < sensor_setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
920 movf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
921 subwf lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
922 bra check_sensor_voting_helper1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
923
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
924 ;-----------------------------------------------------------------------------
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
925
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
926 divemodemode_togglegf: ; toggle aGF/GF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
927 bcf toggle_gf ; clear command flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
928 btg use_agf ; toggle status flag for GF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
929
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
930 btfsc use_agf ; aGF activated?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
931 bra divemodemode_togglegf_1 ; YES - branch to using aGF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
932 movff opt_GF_low,char_I_GF_Low_percentage ; NO - use normal GF factors
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
933 movff opt_GF_high,char_I_GF_High_percentage ; -
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
934 bra divemodemode_togglegf_2 ; - continue with common part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
935 divemodemode_togglegf_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
936 movff opt_aGF_low,char_I_GF_Low_percentage ; YES - use alternative GF factors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
937 movff opt_aGF_high,char_I_GF_High_percentage ; -
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
938 divemodemode_togglegf_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
939 call TFT_gf_factors_mask ; update custom view mask to show which one is in use
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
940 ; the custom view itself has been called from divemenu_tree before
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
941 goto restart_deco_engine ; ...and return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
942
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
943
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
944 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
945 divemodemode_toggleturn:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
946 bcf toggle_turn_dive ; clear command flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
947 btg FLAG_dive_turned ; toggle dive turned state
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
948 btfsc FLAG_cave_mode_shutdown ; cave mode function shut down?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
949 bsf FLAG_dive_turned ; YES - allow only activating turned state
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
950 goto set_logbook_marker ; set a logbook marker (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
951 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
952
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
953 calc_velocity: ; called every two seconds
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
954 btfsc display_velocity
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
955 bra calc_velocity1 ; always update if already displayed
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
956 btfss divemode2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
957 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
958 calc_velocity1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
959 SAFE_2BYTE_COPY amb_pressure, sub_a
0
heinrichsweikamp
parents:
diff changeset
960 movff last_pressure_velocity+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
961 movff last_pressure_velocity+1,sub_b+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
962 movff sub_a+0,last_pressure_velocity+0 ; store old value for velocity
0
heinrichsweikamp
parents:
diff changeset
963 movff sub_a+1,last_pressure_velocity+1
heinrichsweikamp
parents:
diff changeset
964
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
965 call subU16 ; sub_c = amb_pressure - last_pressure
0
heinrichsweikamp
parents:
diff changeset
966
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
967 bcf neg_flag_velocity
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
968 btfsc neg_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
969 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
970
0
heinrichsweikamp
parents:
diff changeset
971 movff sub_c+0,xA+0
heinrichsweikamp
parents:
diff changeset
972 movff sub_c+1,xA+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
973 movlw d'39' ; 77 when called every second....
0
heinrichsweikamp
parents:
diff changeset
974 movwf xB+0
heinrichsweikamp
parents:
diff changeset
975 clrf xB+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
976 call mult16x16 ; differential pressure in mbar*77...
0
heinrichsweikamp
parents:
diff changeset
977 movff xC+0,divA+0
heinrichsweikamp
parents:
diff changeset
978 movff xC+1,divA+1
heinrichsweikamp
parents:
diff changeset
979 movlw d'7'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
980 call div16 ; divA = divA / 2^WREG, divide by 2^7 equals velocity in m/min
0
heinrichsweikamp
parents:
diff changeset
981
heinrichsweikamp
parents:
diff changeset
982 movlw d'99'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
983 cpfsgt divA+0 ; velocity > 99 m/min ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
984 bra calc_velocity3 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
985 movwf divA+0 ; YES - set divA = 99
0
heinrichsweikamp
parents:
diff changeset
986
heinrichsweikamp
parents:
diff changeset
987 calc_velocity3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
988 ; Copy old speeds
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
989 movff old_velocity+2,old_velocity+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
990 movff old_velocity+1,old_velocity+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
991 movff old_velocity+0,old_velocity+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
992 movff divA+0,old_velocity+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
993
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
994 ; movff old_velocity+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
995 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
996 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
997 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
998 ; movff old_velocity+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
999 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1000 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1001 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1002 ; movff old_velocity+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1003 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1004 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1005 ; rrcf divA+0,F ; /2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1006 ; movff old_velocity+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1007 ; addwf divA+0,F ; add old speed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1008 ; bcf STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1009 ; rrcf divA+0,F ; /2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1010 goto TFT_display_velocity ; with divA+0 = m/min..., and return...
0
heinrichsweikamp
parents:
diff changeset
1011
heinrichsweikamp
parents:
diff changeset
1012
heinrichsweikamp
parents:
diff changeset
1013 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1014
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1015 set_reset_safety_stop: ; set flags for safety stop and/or reset safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1016 TSTOSS opt_enable_safetystop ; safety stop enabled? (=1: show safety stop)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1017 bra delete_safety_stop ; NO - don't show safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1018
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1019 btfsc decostop_active ; is a deco stop displayed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1020 bra delete_safety_stop ; YES - don't show safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1021
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1022 ; Below "opt_safety_stop_reset"? if yes, set flag and reset count-down timer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1023 SAFE_2BYTE_COPY rel_pressure, lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1024 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
1025 movff lo,sub_a+0
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1026 movff hi,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1027 movff opt_safety_stop_reset,WREG ; [cbar]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1028 mullw .10 ; mbar in PRODL:H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1029 movff PRODL,sub_b+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1030 movff PRODH,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1031 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1032 btfss neg_flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1033 bra reset_safety_stop ; below 10m, reset safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1034
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1035 ; Above "opt_safety_stop_end"? if yes ,clear flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1036 movff opt_safety_stop_end,WREG ; [cbar]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1037 mullw .10 ; mbar in PRODL:H
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1038 movff PRODL,sub_b+0 ; sub_a is still loaded with adjusted rel_pressure
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1039 movff PRODH,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1040 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1041 btfsc neg_flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1042 bra delete_safety_stop ; above 3m, remove safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1043
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1044 ; Above "opt_safety_stop_start"? if yes, activate safety stop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1045 movff opt_safety_stop_start,WREG ; [cbar]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1046 mullw .10 ; mbar in PRODL:H
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1047 movff PRODL,sub_b+0 ; sub_a is still loaded with adjusted rel_pressure
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1048 movff PRODH,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1049 call subU16 ; sub_c = sub_a - sub_b
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1050 btfsc neg_flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1051 bra acivate_safety_stop ; above 5m, activate safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1052 bra reset_safety_stop2 ; pause safety stop
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1053
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1054 acivate_safety_stop:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1055 tstfsz safety_stop_countdown ; countdown at zero?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1056 bsf show_safety_stop ; NO - set flag
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1057 return
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1058
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1059 delete_safety_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1060 clrf safety_stop_countdown ; reset timer
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1061 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
1062
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1063 reset_safety_stop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1064 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
1065 reset_safety_stop2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1066 bcf show_safety_stop ; clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1067 btfss safety_stop_active ; safety stop shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1068 return ; NO - don't delete it
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1069 bcf safety_stop_active ; clear flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1070 bsf FLAG_TFT_clear_safety_stop ; Clear safety stop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1071 return
428
eccae727702f some cleanup
heinrichsweikamp
parents: 403
diff changeset
1072
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1073
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1074 ;=============================================================================
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1075
0
heinrichsweikamp
parents:
diff changeset
1076 timeout_menuview:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1077 decfsz timeout_counter2,F ; timeout for menu view?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1078 return ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1079 ; Timeout, clear e.g. "Menu?"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1080 goto menuview_toggle_reset ; ...and return
0
heinrichsweikamp
parents:
diff changeset
1081
heinrichsweikamp
parents:
diff changeset
1082 timeout_divemode_menu:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1083 decfsz timeout_counter2,F ; timeout for divemode menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1084 return
0
heinrichsweikamp
parents:
diff changeset
1085
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1086 global timeout_divemode_menu2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1087 timeout_divemode_menu2: ; called from divemenu_tree.asm
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1088 bcf divemode_menu ; timeout, clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1089 call TFT_clear_divemode_menu ; clear menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1090 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1091 bcf blinking_better_gas ; clear flag to have temperature updated once
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1092 bcf blinking_better_dil ; clear flag to have temperature updated once
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1093 bsf FLAG_TFT_temp_divemode ; display temperature
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1094 call TFT_draw_gassep_line ; gas separator grid in spec mode only
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1095
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1096 btfss decostop_active ; in deco mode ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1097 bra timeout_divemode_menu_ndl ; NO - show NDL again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1098 ; Show deco data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1099 bsf FLAG_TFT_display_deko_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1100 bsf FLAG_TFT_display_deko
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1101 bsf FLAG_TFT_display_tts
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1102 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1103
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1104 timeout_divemode_menu_ndl:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1105 ; Show NDL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1106 bsf FLAG_TFT_display_ndl_mask
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1107 bsf FLAG_TFT_display_ndl
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1108 return
0
heinrichsweikamp
parents:
diff changeset
1109
heinrichsweikamp
parents:
diff changeset
1110 timeout_divemode:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1111 btfsc divemode_menu ; divemode menu active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1112 rcall timeout_divemode_menu ; YES - check the timeout for it...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1113
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1114 btfsc menuview ; is a menu view shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1115 rcall timeout_menuview ; YES - check the timeout for it...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1116
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1117 btfss realdive ; dive longer than one minute?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1118 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1119
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1120 btfsc FLAG_apnoe_mode ; in apnoe mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1121 bra timeout_divemode2 ; YES - use apnoe_timeout [min] for timeout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1122
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1123 IFNDEF __DEBUG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1124 btfsc simulatormode_active ; in simulator mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1125 bra timeout_divemode3 ; YES - use simulator timeout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1126 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1127
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1128 bcf divemode ; terminate divemode my default
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1129 infsnz timeout_counter1+0,F ; increment timeout counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1130 incf timeout_counter1+1,F ; timeout is 16 bit counter
0
heinrichsweikamp
parents:
diff changeset
1131
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1132 movff opt_diveTimeout,WREG ; get timeout in minutes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1133 mullw .60 ; convert into seconds
444
d93d75ae01bf Adjustable timeout for Divemode (Config 0x48)
heinrichsweikamp
parents: 437
diff changeset
1134 movff PRODL,sub_a+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1135 movff PRODH,sub_a+1
0
heinrichsweikamp
parents:
diff changeset
1136
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1137 movff timeout_counter1+0,sub_b+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1138 movff timeout_counter1+1,sub_b+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1139 call subU16 ; sub_c = sub_a - sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1140 btfss neg_flag ; result negative, i.e. timeout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1141 bsf divemode ; NO - set divemode flag again
0
heinrichsweikamp
parents:
diff changeset
1142 return
heinrichsweikamp
parents:
diff changeset
1143
heinrichsweikamp
parents:
diff changeset
1144 timeout_divemode2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1145 incf timeout_counter1+0,F ; seconds...
0
heinrichsweikamp
parents:
diff changeset
1146 movlw d'60'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1147 cpfseq timeout_counter1+0 ; timeout_counter1+0 = 60 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1148 return ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1149 ; one minute timeout done
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1150 clrf timeout_counter1+0
0
heinrichsweikamp
parents:
diff changeset
1151 bcf divemode
heinrichsweikamp
parents:
diff changeset
1152 incf apnoe_timeout_counter,F
heinrichsweikamp
parents:
diff changeset
1153 movlw apnoe_timeout ; apnoe timeout [min]
heinrichsweikamp
parents:
diff changeset
1154 cpfseq apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1155 bsf divemode
heinrichsweikamp
parents:
diff changeset
1156 return
heinrichsweikamp
parents:
diff changeset
1157
heinrichsweikamp
parents:
diff changeset
1158 timeout_divemode3:
heinrichsweikamp
parents:
diff changeset
1159 bcf divemode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1160 incf timeout_counter1+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1161 movlw simulator_timeout ; simulator timeout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1162 cpfsgt timeout_counter1+0
0
heinrichsweikamp
parents:
diff changeset
1163 bsf divemode
heinrichsweikamp
parents:
diff changeset
1164 return
heinrichsweikamp
parents:
diff changeset
1165
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1166 update_divemode60: ; update any minute
0
heinrichsweikamp
parents:
diff changeset
1167 call get_battery_voltage ; gets battery voltage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1168 rcall set_powersafe ; check if battery low
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1169 ;call customview_minute ; do every-minute tasks for the custom view area
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1170 bcf oneminupdate
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1171 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1172 movlw .1 ; prepare to add backtrack data for 1 minute
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1173 btfsc FLAG_cave_mode ; cave mode enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1174 rcall update_backtrack ; YES - make it so
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1175 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1176 btfss simulatormode_active ; in simulator mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1177 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1178 movlw .20 ; YES - quite dive mode simulation after 21 * 256 sec = 89 min : 36 sec
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1179 cpfsgt total_divetime_seconds+1 ; timeout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1180 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1181 IFDEF __DEBUG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1182 return ; YES - but no timeout in debug mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1183 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1184 bra divemode_option1 ; YES - set depth to 0 m and "return"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1185
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1186 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1187 update_backtrack:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1188 btfsc FLAG_dive_turned ; dive turned?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1189 return ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1190 movwf lo ; store minutes to add in lo
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1191 lfsr FSR1,char_I_backtrack_depth ; load FSR1 with base address of backtrack storage
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1192 movff char_I_backtrack_time,FSR1L ; adjust FSR1 to last index
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1193 update_backtrack_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1194 btfsc FLAG_cave_mode_shutdown ; backtrack storage full?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1195 return ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1196 movff curr_depth,PREINC1 ; NO - increment index and write current depth to backtrack storage
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1197 incfsz FSR1L,W ; - did a wrap-around of the index occur (backtrack storage full)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1198 bra update_backtrack_loop_1 ; NO - continue loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1199 bsf FLAG_cave_mode_shutdown ; YES - flag backtrack storage as being full
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1200 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1201 update_backtrack_loop_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1202 decfsz lo,F ; decrement loop counter, did it became zero?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1203 bra update_backtrack_loop ; NO - loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1204 movff FSR1L,char_I_backtrack_time ; YES - read-back index
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1205 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1206 ENDIF
0
heinrichsweikamp
parents:
diff changeset
1207
heinrichsweikamp
parents:
diff changeset
1208 set_max_depth:
heinrichsweikamp
parents:
diff changeset
1209 movff max_pressure+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1210 movff max_pressure+1,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1211 SAFE_2BYTE_COPY rel_pressure, sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1212 call subU16 ; sub_c = sub_a - sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1213 ; max_pressure < rel_pressure -> neg_flag=1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1214 ; rel_pressure <= max_pressure -> neg_flag=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1215 btfss neg_flag
0
heinrichsweikamp
parents:
diff changeset
1216 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1217 ; max_pressure < rel_pressure
0
heinrichsweikamp
parents:
diff changeset
1218 movff sub_b+0,max_pressure+0
heinrichsweikamp
parents:
diff changeset
1219 movff sub_b+1,max_pressure+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1220 bsf FLAG_TFT_max_depth ; set flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1221 return
0
heinrichsweikamp
parents:
diff changeset
1222
heinrichsweikamp
parents:
diff changeset
1223 set_min_temp:
heinrichsweikamp
parents:
diff changeset
1224 movff minimum_temperature+0,sub_a+0
heinrichsweikamp
parents:
diff changeset
1225 movff minimum_temperature+1,sub_a+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1226 SAFE_2BYTE_COPY temperature,sub_b
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1227 call sub16 ; sub_c = sub_a - sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1228 ; minimum_temperature < T -> neg_flag=1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1229 ; T <= minimum_temperature -> neg_flag=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1230 btfsc neg_flag
0
heinrichsweikamp
parents:
diff changeset
1231 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1232 ; minimum_temperature >= T
0
heinrichsweikamp
parents:
diff changeset
1233 movff sub_b+0,minimum_temperature+0
heinrichsweikamp
parents:
diff changeset
1234 movff sub_b+1,minimum_temperature+1
heinrichsweikamp
parents:
diff changeset
1235 return
heinrichsweikamp
parents:
diff changeset
1236
heinrichsweikamp
parents:
diff changeset
1237 global set_dive_modes
heinrichsweikamp
parents:
diff changeset
1238 set_dive_modes:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1239 btfsc high_altitude_mode ; in high altitude (fly) mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1240 bra set_dive_modes3 ; YES
0
heinrichsweikamp
parents:
diff changeset
1241
heinrichsweikamp
parents:
diff changeset
1242 set_dive_modes0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1243 movlw LOW start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1244 movwf sub_a+0 ; dive_treshold is in cm
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1245 movlw HIGH start_dive_threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1246 movwf sub_a+1 ; dive_treshold is in cm
0
heinrichsweikamp
parents:
diff changeset
1247
heinrichsweikamp
parents:
diff changeset
1248 set_dive_modes1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1249 SAFE_2BYTE_COPY rel_pressure, sub_b
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1250 call subU16 ; sub_c = sub_a - sub_b
0
heinrichsweikamp
parents:
diff changeset
1251
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1252 btfss neg_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1253 bra set_dive_modes2 ; too shallow (rel_pressure < dive_threshold)
0
heinrichsweikamp
parents:
diff changeset
1254
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1255 btfsc realdive ; dive longer than one minute?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1256 clrf timeout_counter1+0 ; YES - reset timeout counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1257
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1258 bsf divemode ; (re-)set divemode flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1259 bsf divemode2 ; displayed divetime is running
0
heinrichsweikamp
parents:
diff changeset
1260 return
heinrichsweikamp
parents:
diff changeset
1261
heinrichsweikamp
parents:
diff changeset
1262 set_dive_modes2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1263 bcf divemode2 ; stop time
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1264 btfss realdive ; dive longer then one minute?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1265 bcf divemode ; NO - this was no real dive
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1266 return ; YES - return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1267
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1268 set_dive_modes3: ; high-altitude mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1269 btfsc realdive ; dive longer then one minute?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1270 bra set_dive_modes0 ; YES - this is a real dive -> Use start_dive_threshold or ascend
0
heinrichsweikamp
parents:
diff changeset
1271
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1272 movlw LOW high_altitude_dive_threshold
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1273 movwf sub_a+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1274 movlw HIGH high_altitude_dive_threshold
0
heinrichsweikamp
parents:
diff changeset
1275 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
1276 bra set_dive_modes1
heinrichsweikamp
parents:
diff changeset
1277
heinrichsweikamp
parents:
diff changeset
1278 set_powersafe:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1279 movlw color_code_battery_low+1; [%]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1280 cpfslt batt_percent
0
heinrichsweikamp
parents:
diff changeset
1281 return
heinrichsweikamp
parents:
diff changeset
1282
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1283 movlw d'7' ; type of alarm (battery Low)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1284 movwf AlarmType ; copy to alarm register
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1285 bsf event_occured ; set event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1286 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1287 movff WREG,opt_brightness ; set brightness to ECO
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1288 return ; return
0
heinrichsweikamp
parents:
diff changeset
1289
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1290
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1291 reset_average:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1292 bcf reset_average_depth ; clear reset-average flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1293 clrf average_depth_hold+0 ; clear the depth accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1294 clrf average_depth_hold+1 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1295 clrf average_depth_hold+2 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1296 clrf average_depth_hold+3 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1297 clrf average_divesecs+0 ; clear the time accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1298 clrf average_divesecs+1 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1299 SAFE_2BYTE_COPY rel_pressure,avg_rel_pressure ; prime result with current rel.pressure/depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1300 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1301
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1302
0
heinrichsweikamp
parents:
diff changeset
1303 calc_average_depth:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1304 ; 1. compute rel_pressure x 2, because this routine is called every 2nd second only
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1305 SAFE_2BYTE_COPY rel_pressure,xB ; copy current rel pressure to xB
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1306 bcf STATUS,C
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1307 rlcf xB+0,F ; multiply rel pressure x 2 (via shift left)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1308 rlcf xB+1,F ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1309
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1310 ; 2a add (rel_pressure x 2) to the resettable depth accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1311 movf xB+0,W
0
heinrichsweikamp
parents:
diff changeset
1312 addwf average_depth_hold+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1313 movf xB+1,W
0
heinrichsweikamp
parents:
diff changeset
1314 addwfc average_depth_hold+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1315 movlw .0
0
heinrichsweikamp
parents:
diff changeset
1316 addwfc average_depth_hold+2,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1317 addwfc average_depth_hold+3,F ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1318
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1319 ; 2b add (rel_pressure x 2) to the total depth accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1320 movf xB+0,W
0
heinrichsweikamp
parents:
diff changeset
1321 addwf average_depth_hold_total+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1322 movf xB+1,W
0
heinrichsweikamp
parents:
diff changeset
1323 addwfc average_depth_hold_total+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1324 movlw .0
0
heinrichsweikamp
parents:
diff changeset
1325 addwfc average_depth_hold_total+2,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1326 addwfc average_depth_hold_total+3,F ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1327
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1328 ; 3a compute avg_rel_pressure on base of average_divesecs:2
0
heinrichsweikamp
parents:
diff changeset
1329 movff average_depth_hold+0,xC+0
heinrichsweikamp
parents:
diff changeset
1330 movff average_depth_hold+1,xC+1
heinrichsweikamp
parents:
diff changeset
1331 movff average_depth_hold+2,xC+2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1332 movff average_depth_hold+3,xC+3 ; copy accumulated depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1333 movff average_divesecs+0,xB+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1334 movff average_divesecs+1,xB+1 ; copy accumulated time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1335 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
1336 movff xC+0,avg_rel_pressure+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1337 movff xC+1,avg_rel_pressure+1 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1338
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1339 btfss divemode2 ; displayed divetime is running?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1340 return ; NO (e.g. too shallow)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1341
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1342 ; 3b compute avg_rel_pressure_total on base of average_divesecs_total:2
0
heinrichsweikamp
parents:
diff changeset
1343 movff average_depth_hold_total+0,xC+0
heinrichsweikamp
parents:
diff changeset
1344 movff average_depth_hold_total+1,xC+1
heinrichsweikamp
parents:
diff changeset
1345 movff average_depth_hold_total+2,xC+2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1346 movff average_depth_hold_total+3,xC+3 ; copy accumulated depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1347 movff average_divesecs_total+0,xB+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1348 movff average_divesecs_total+1,xB+1 ; copy accumulated time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1349 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
1350 movff xC+0,avg_rel_pressure_total+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1351 movff xC+1,avg_rel_pressure_total+1 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1352
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1353 btfsc reset_average_depth ; reset the resettable average depth?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1354 rcall reset_average ; YES - reset the resettable average depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1355
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1356 TSTOSS opt_2ndDepthDisp ; drawing avg depth instead of max depth?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1357 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1358 bsf FLAG_TFT_max_depth ; YES - flag to update display
0
heinrichsweikamp
parents:
diff changeset
1359 return
heinrichsweikamp
parents:
diff changeset
1360
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1361
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1362 test_switches_divemode: ; checks switches in divemode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1363 btfsc divemode_menu ; divemode menu shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1364 bra test_switches_divemode_menu ; YES - use menu processor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1365 btfsc switch_left ; NO - left button pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1366 goto menuview_toggle ; YES - menu or simulator tasks; and return...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1367 btfss switch_right ; NO - right button pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1368 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1369 tstfsz menupos2 ; YES - any option shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1370 bra test_switches_divemode1 ; YES - do option tasks
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1371 bsf toggle_customview ; NO - toggle custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1372 return ; - done
0
heinrichsweikamp
parents:
diff changeset
1373
heinrichsweikamp
parents:
diff changeset
1374 test_switches_divemode_menu:
heinrichsweikamp
parents:
diff changeset
1375 btfsc switch_left
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1376 bra test_switches_divemode_menu2 ; move cursor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1377 btfsc switch_right ; left button pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1378 bra test_switches_divemode_menu3 ; YES - enter submenu or do something
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1379 return ; NO - done
0
heinrichsweikamp
parents:
diff changeset
1380
heinrichsweikamp
parents:
diff changeset
1381 test_switches_divemode_menu1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1382 clrf menupos1
0
heinrichsweikamp
parents:
diff changeset
1383 test_switches_divemode_menu2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1384 incf menupos1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1385 incf menupos4,W ; menupos4 + 1 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1386 cpfslt menupos1 ; > menupos4 (set in menu_processor.asm)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1387 bra test_switches_divemode_menu1 ; YES - set to 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1388 call TFT_divemode_menu_cursor ; update the cursor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1389 bcf switch_left
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1390 movlw divemode_menu_timeout ; reload timeout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1391 movwf timeout_counter2 ; timeout for divemode menu
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1392 return
0
heinrichsweikamp
parents:
diff changeset
1393
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1394 test_switches_divemode_menu3: ; enter submenu or do something
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1395 bcf switch_right
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1396 ; decf menupos1,F ; menu_processor needs 0-5...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1397 goto do_line_menu ; Warning! trashes STKPTR and returns to diveloop_loop4:
0
heinrichsweikamp
parents:
diff changeset
1398
heinrichsweikamp
parents:
diff changeset
1399 test_switches_divemode1:
heinrichsweikamp
parents:
diff changeset
1400 bcf switch_right
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1401 movlw divemode_menuview_timeout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1402 movwf timeout_counter2 ; reload timeout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1403 movff menupos2,WREG ; menupos2 holds number of customview/divemode menu function
0
heinrichsweikamp
parents:
diff changeset
1404 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1405 bra divemode_option_gaschange ; switch to the the "better gas" / "better diluent"
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1406 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1407 bra divemode_option0 ; start/setup Divemode menu
0
heinrichsweikamp
parents:
diff changeset
1408 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1409 bra divemode_option1 ; quit simulation?
0
heinrichsweikamp
parents:
diff changeset
1410 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1411 bra divemode_option2 ; descent 1m
0
heinrichsweikamp
parents:
diff changeset
1412 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1413 bra divemode_option3 ; ascend 1m
0
heinrichsweikamp
parents:
diff changeset
1414 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1415 bra divemode_option4 ; quit Apnoe mode
0
heinrichsweikamp
parents:
diff changeset
1416 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1417 bra divemode_option5 ; reset stopwatch (gauge mode only)
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1418 dcfsnz WREG,F
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1419 bra divemode_option6 ; +5mins simulation
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1420 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1421 bra divemode_option7 ; store heading
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1422 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1423 bra divemode_option8 ; switch to alternative layout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1424 return
0
heinrichsweikamp
parents:
diff changeset
1425
heinrichsweikamp
parents:
diff changeset
1426 gas_switched_common:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1427 bcf divemode_gaschange ; clear flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1428 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
1429 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1430 bcf FLAG_back_to_loop ; YES - clear flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1431 movff active_dil,menupos1 ; reload last diluent
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1432 bra gas_switched_common1 ; continue with common part
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1433 gas_switched_common0:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1434 tstfsz menupos1 ; menupos1 = 0 ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1435 bra gas_switched_common1 ; NO - valid gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1436 return ; YES - something went wrong, invalid gas, abort
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1437 gas_switched_common1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1438 movf menupos1,W ; get selected gas into WREG (1-6)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1439 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1440 bra gas_switched_common_OC ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1441 btfsc FLAG_bailout_mode ; in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1442 bra gas_switched_common_OC ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1443 gas_switched_common_loop: ; NO to both - must be loop mode then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1444 rcall setup_dil_registers ; with WREG = diluent 1-6
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1445 rcall deco_setup_cc_diluents ; with WREG = diluent 1-6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1446 bra gas_switched_common3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1447 gas_switched_common_OC:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1448 rcall setup_gas_registers ; with WREG = Gas 1-6
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1449 rcall deco_setup_oc_gases ; with WREG = Gas 1-6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1450 gas_switched_common3:
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1451 banksel int_O_breathed_ppO2
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1452 bcf int_O_breathed_ppO2+1,int_low_flag ; | clear all flags that control color-coding
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1453 bcf int_O_breathed_ppO2+1,int_high_flag ; | to have the new gas initially displayed in
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1454 bcf int_O_breathed_ppO2+1,int_attention_flag ; | memo color instead of a warning or attention
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1455 bcf int_O_breathed_ppO2+1,int_warning_flag ; | color that belonged to the previous gas
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1456 banksel common
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1457 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1458 call restart_deco_engine_wo_ceiling ; abort any running deco calculations and restart the deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1459 ; set flags for profile recording
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1460 bsf event_occured ; set event flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1461 btfsc FLAG_bailout_mode ; choose OC Bailouts (OC Gases)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1462 bsf bailoutgas_event ; bailout gas change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1463 btfss FLAG_bailout_mode ; choose OC Bailouts (OC Gases)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1464 bsf stored_gas_changed ; OC gas change
0
heinrichsweikamp
parents:
diff changeset
1465 return
heinrichsweikamp
parents:
diff changeset
1466
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1467
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1468 ; Code to pass all parameters to the C code
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1469
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1470 global get_first_gas_to_WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1471 get_first_gas_to_WREG: ; gets first gas (1-5) into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1472 lfsr FSR1,opt_gas_type ; point to gas types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1473 clrf lo ; start with gas 0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1474 get_first_gas_to_WREG2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1475 movf lo,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1476 movf PLUSW1,W ; get type of gas #lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1477 sublw .1 ; it is = 1 (First Gas)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1478 bz get_first_gas_to_WREG3 ; found the first gas!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1479 incf lo,F ; ++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1480 movlw NUM_GAS+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1481 cpfseq lo ; all done?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1482 bra get_first_gas_to_WREG2 ; NO - not yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1483 ; no first gas found, use #1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1484 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1485 movff WREG,opt_gas_type+0 ; set gas 1 to First
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1486 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1487 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1488 get_first_gas_to_WREG3:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1489 movf lo,W ; put into WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1490 incf WREG,W ; 0-4 -> 1-5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1491 return ; done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1492
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1493 global get_first_dil_to_WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1494 get_first_dil_to_WREG: ; gets first dil (1-5) into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1495 lfsr FSR1,opt_dil_type ; point to dil types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1496 clrf lo ; start with dil 0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1497 get_first_dil_to_WREG2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1498 movf lo,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1499 movf PLUSW1,W ; get type of Dil #lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1500 sublw .1 ; it is = 1 (First Dil)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1501 bz get_first_dil_to_WREG3 ; found the first dil!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1502 incf lo,F ; ++
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1503 movlw NUM_GAS+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1504 cpfseq lo ; all done?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1505 bra get_first_dil_to_WREG2 ; NO - not yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1506 ; no first dil found, use #1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1507 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1508 movff WREG,opt_dil_type+0 ; set dil 1 to First
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1509 incf WREG,W ; 0 -> 1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1510 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1511 get_first_dil_to_WREG3:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1512 movf lo,W ; Put into WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1513 incf WREG,W ; 0-4 -> 1-5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1514 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1515
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1516
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1517 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
1518 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1519 deco_setup_oc_gases_pre: ; entry point with lo preloaded
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1520 movff WREG,char_I_current_gas ; set gas to start with when doing the deco calculations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1521 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1522 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1523 ; ---------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1524 ; opt_gas_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1525 ; opt_dil_O2_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1526 ; opt_gas_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1527 ; opt_dil_He_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1528 ; opt_gas_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1529 ; opt_dil_type res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1530 ; opt_gas_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1531 ; opt_dil_change res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1532 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1533 lfsr FSR2,char_I_deco_O2_ratio ; Load FSR2 with base address of char_I_deco_O2_ratio.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1534 ; FSR2 will step through all char_I_deco_... vars.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1535 lfsr FSR1,opt_gas_O2_ratio ; load FSR1 with base address of opt_gas_O2_ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1536 rcall deco_setup_copy ; copy all OC O2 ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1537 lfsr FSR1,opt_gas_He_ratio ; load FSR1 with base address of opt_gas_He_ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1538 rcall deco_setup_copy ; copy all OC He ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1539 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1540 rcall deco_setup_copy ; copy all gas types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1541 lfsr FSR1,opt_gas_change ; load FSR1 with base address of opt_gas_change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1542 rcall deco_setup_copy ; copy all gas change depths
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1543 ; switch to oc mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1544 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
1545 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
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
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1547 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1548
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1549
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1550 deco_setup_cc_diluents: ; with currently breathed diluent in WREG (1-5 or 6)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1551 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1552 deco_setup_cc_diluents_pre: ; entry point with lo preloaded
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1553 btfsc FLAG_bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY --------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1554 bra deco_setup_oc_gases_pre ; YES - revert to setting up OC gases | This branch should never happen to be taken...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1555 movff WREG,char_I_current_gas ; NO - set diluent to start with when doing the deco calculations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1556 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1557 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1558 ; ---------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1559 ; opt_gas_O2_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1560 ; opt_dil_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1561 ; opt_gas_He_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1562 ; opt_dil_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1563 ; opt_gas_type res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1564 ; opt_dil_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1565 ; opt_gas_change res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1566 ; opt_dil_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1567 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1568 lfsr FSR2,char_I_deco_O2_ratio ; Load FSR2 with base address of char_I_deco_O2_ratio.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1569 ; FSR2 will step through all char_I_deco_... vars.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1570 lfsr FSR1,opt_dil_O2_ratio ; load FSR1 with base address of opt_dil_O2_ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1571 rcall deco_setup_copy ; copy all dil O2 ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1572 lfsr FSR1,opt_dil_He_ratio ; load FSR1 with base address of opt_dil_He_ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1573 rcall deco_setup_copy ; copy all dil He ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1574 lfsr FSR1,opt_dil_type ; load FSR1 with base address of opt_dil_type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1575 rcall deco_setup_copy ; copy all dil types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1576 lfsr FSR1,opt_dil_change ; load FSR1 with base address of opt_dil_change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1577 rcall deco_setup_copy ; copy all dil change depths
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1578 ; switch to CCR / pSCR mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1579 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
1580 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1581 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1582 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1583 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1584 return
0
heinrichsweikamp
parents:
diff changeset
1585
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1586 deco_setup_copy:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1587 movlw NUM_GAS ; load loop counter with number of gases (5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1588 deco_setup_copy_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1589 movff POSTINC1,POSTINC2 ; copy from (FSR1) to (FSR2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1590 decfsz WREG ; decrement loop counter and check if it became 0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1591 bra deco_setup_copy_loop ; NO - not yet, loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1592 return ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1593
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1594
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1595 global setup_gas_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1596 setup_gas_registers: ; with currently breathed gas in WREG (1-5 or 6)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1597 movwf active_gas ; set as current gas
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1598 movlw .6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1599 cpfseq active_gas ; gas = gas6 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1600 bra setup_gas_registers_15 ; NO - load gas 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1601 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1602 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1603 movlw .3 ; declare gas6 as a deco gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1604 movff WREG,char_I_current_gas_type; copy gas type to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1605 movff curr_depth,char_I_gas6_depth; set current depth as change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1606 bra setup_gas_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1607 setup_gas_registers_15:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1608 decf active_gas,W ; 1-5 -> 0-4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1609 lfsr FSR1,opt_gas_O2_ratio
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1610 movff PLUSW1,char_I_O2_ratio ; copy gas 1-5 O2 ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1611 lfsr FSR1,opt_gas_He_ratio
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1612 movff PLUSW1,char_I_He_ratio ; copy gas 1-5 He ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1613 lfsr FSR1,opt_gas_type ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1614 movff PLUSW1,char_I_current_gas_type ; copy gas 1-5 type (0=Disabled, 1=First, 2=Travel, 3=Deco)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1615 setup_gas_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1616 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
1617 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
1618 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1619 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1620 movf active_gas,W ; reload WREG with gas 1-5 or 6 (important!)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1621 return
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1622
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1623 global setup_dil_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1624 setup_dil_registers: ; with currently breathed gas in WREG (1-5 or 6)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1625 btfsc FLAG_bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY --------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1626 bra setup_gas_registers ; revert to setting up OC gases in bailout condition | This branch should never happen to be taken...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1627 movwf active_dil ; set as current diluent
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1628 movlw .6
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1629 cpfseq active_dil ; diluent = gas6 ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1630 bra setup_dil_registers_15 ; NO - load diluent 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1631 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
1632 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1633 movlw .2 ; declare gas6 as a normal diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1634 movff WREG,char_I_current_gas_type; copy gas type to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1635 movff curr_depth,char_I_gas6_depth; set current depth as change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1636 bra setup_dil_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1637 setup_dil_registers_15:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1638 decf active_dil,W ; 1-5 -> 0-4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1639 lfsr FSR1,opt_dil_O2_ratio
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1640 movff PLUSW1,char_I_O2_ratio ; copy diluent 1-5 O2 ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1641 lfsr FSR1,opt_dil_He_ratio
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1642 movff PLUSW1,char_I_He_ratio ; copy diluent 1-5 He ratio to deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1643 lfsr FSR1,opt_dil_type ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1644 movff PLUSW1,char_I_current_gas_type ; copy dil type (0=Disabled, 1=First, 2=Normal)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1645 setup_dil_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1646 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
1647 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
1648 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1649 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1650 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1651 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1652 movf active_dil,W ; reload WREG with diluent 1-5 or 6 (important!)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1653 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1654
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1655
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1656 divemode_option_gaschange: ; switch to the "better gas" / "better diluent"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1657 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1658 bra divemode_option_gaschange_oc; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1659 btfsc FLAG_bailout_mode ; in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1660 bra divemode_option_gaschange_oc; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1661 divemode_option_gaschange_loop: ; in CCR/pSCR mode and not in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1662 movff best_dil_number,menupos1 ; NO - select best diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1663 bcf better_dil_available ; - clear flag immediately
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1664 bra divemode_option_gaschange3 ; - continue with common part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1665 divemode_option_gaschange_oc: ; in OC or bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1666 movff best_gas_number,menupos1 ; select best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1667 bcf better_gas_available ; clear flag immediately
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1668 divemode_option_gaschange3 ; common part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1669 bsf divemode_gaschange ; command a gas/diluent change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1670 call menuview_toggle_reset ; terminate the options menu
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1671 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1672
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1673 divemode_option0: ; start/setup dive mode menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1674 call TFT_clear_divemode_menu ; clear menu area
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1675 bcf menuview
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1676 call do_main_divemenu
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1677
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1678 global divemode_option0_return
0
heinrichsweikamp
parents:
diff changeset
1679 divemode_option0_return:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1680 ; movlw .1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1681 ; movwf menupos1 ; set to first option in dive mode menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1682 call TFT_divemode_menu_cursor ; show the cursor
0
heinrichsweikamp
parents:
diff changeset
1683 movlw divemode_menu_timeout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1684 movwf timeout_counter2 ; timeout for dive mode menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1685 bsf divemode_menu ; set flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1686 clrf menupos2 ; clear option counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1687 goto diveloop_loop4 ; go back to dive loop (menu processor trashes STKPTR!)
0
heinrichsweikamp
parents:
diff changeset
1688
heinrichsweikamp
parents:
diff changeset
1689 divemode_option4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1690 movlw d'58' ; two seconds left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1691 movwf timeout_counter1+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1692 movlw apnoe_timeout-1 ; apnoe timeout [min]
0
heinrichsweikamp
parents:
diff changeset
1693 movwf apnoe_timeout_counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1694 btfss simulatormode_active ; in simulator mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1695 return ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1696 ;bra divemode_option1 ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1697
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1698 divemode_option1: ; quit simulation mode
0
heinrichsweikamp
parents:
diff changeset
1699 banksel isr_backup
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1700 movlw LOW .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1701 movwf sim_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1702 movlw HIGH .1000
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1703 movwf sim_pressure+1 ; set to 0m -> end of dive
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1704 banksel common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1705 call menuview_toggle_reset ; reset to zero (zero = no menu view)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1706
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1707 btfss FLAG_apnoe_mode ; in apnoe mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1708 return ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1709 movlw d'58' ; two seconds left
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1710 movwf timeout_counter1+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1711 movlw apnoe_timeout-1 ; apnoe timeout [min]
0
heinrichsweikamp
parents:
diff changeset
1712 movwf apnoe_timeout_counter
heinrichsweikamp
parents:
diff changeset
1713 return
heinrichsweikamp
parents:
diff changeset
1714
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1715 divemode_option3: ; minus 1m
0
heinrichsweikamp
parents:
diff changeset
1716 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1717 movlw d'100'
0
heinrichsweikamp
parents:
diff changeset
1718 subwf sim_pressure+0
heinrichsweikamp
parents:
diff changeset
1719 movlw .0
heinrichsweikamp
parents:
diff changeset
1720 subwfb sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1721 rcall divemode_simulator_check_limits
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1722 banksel common
0
heinrichsweikamp
parents:
diff changeset
1723 return
heinrichsweikamp
parents:
diff changeset
1724
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1725 divemode_option2: ; plus 1m
0
heinrichsweikamp
parents:
diff changeset
1726 banksel isr_backup
315
4f83470dcece VSIbar #3: remaining changes for the split style bar
Janos Kovacs <kovjanos@gmail.com>
parents: 310
diff changeset
1727 movlw d'100'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1728 addwf sim_pressure+0,F
0
heinrichsweikamp
parents:
diff changeset
1729 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1730 addwfc sim_pressure+1,F
0
heinrichsweikamp
parents:
diff changeset
1731 rcall divemode_simulator_check_limits
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1732 banksel common
0
heinrichsweikamp
parents:
diff changeset
1733 return
heinrichsweikamp
parents:
diff changeset
1734
heinrichsweikamp
parents:
diff changeset
1735 divemode_option5:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1736 call menuview_toggle_reset ; reset to zero (zero = no menu view)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1737 bsf reset_average_depth ; set flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1738 return
0
heinrichsweikamp
parents:
diff changeset
1739
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1740 divemode_option6:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1741 ; advance tissues and deco by 5 minutes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1742 movlw .5 ; + 5 minutes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1743 movff WREG,char_I_sim_advance_time; copy to mailbox
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1744 call restart_deco_engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1745
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1746 ; stop divetime incrementing in ISR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1747 bcf divemode2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1748
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1749 ; add 5 minutes to divemins
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1750 movlw .5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1751 addwf divemins+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1752 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1753 addwfc divemins+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1754
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1755 ; add 5 minutes (5 * 60 seconds) to total_divetime_seconds
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1756 movlw LOW (.5*.60)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1757 addwf total_divetime_seconds+0,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1758 movlw HIGH (.5*.60)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1759 addwfc total_divetime_seconds+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1760
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1761 ; continue dive time incrementing in ISR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1762 bsf divemode2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1763
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1764 ; add 5 minutes (5 * 60 seconds) to resettable time accumulator
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1765 movlw LOW (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1766 addwf average_divesecs+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1767 movlw HIGH (.5*.60)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1768 addwfc average_divesecs+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1769
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1770 ; add 5 minutes (5 * 60 seconds) to total time accumulator
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1771 movlw LOW (.5*.60)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1772 addwf average_divesecs_total+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1773 movlw HIGH (.5*.60)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1774 addwfc average_divesecs_total+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1775
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1776
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1777 ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1778 SAFE_2BYTE_COPY rel_pressure, xB
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1779 movlw LOW (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1780 movwf xA+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1781 movlw HIGH (.5*.60)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1782 movwf xA+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1783 call mult16x16 ; xA*xB=xC
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1784
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1785 ; add to the resettable depth accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1786 movf xC+0,W
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1787 addwf average_depth_hold+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1788 movf xC+1,W
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1789 addwfc average_depth_hold+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1790 movf xC+2,W
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1791 addwfc average_depth_hold+2,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1792 movf xC+3,W
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1793 addwfc average_depth_hold+3,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1794
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1795 ; add to the total depth accumulator
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1796 movf xC+0,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1797 addwf average_depth_hold_total+0,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1798 movf xC+1,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1799 addwfc average_depth_hold_total+1,F
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1800 movf xC+2,w
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1801 addwfc average_depth_hold_total+2,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1802 movf xC+3,w
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1803 addwfc average_depth_hold_total+3,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1804
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1805 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1806 ; update backtracking data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1807 movlw .5 ; add backtrack data for 5 minutes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1808 call update_backtrack ; make it so
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1809 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1810
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1811 goto menuview_toggle_reset ; and return...
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1812
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1813 divemode_option7:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1814 ; Store heading for compass view
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1815 movff compass_heading_shown+0,compass_bearing+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1816 movff compass_heading_shown+1,compass_bearing+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1817 bsf compass_bearing_set ; set flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1818 goto menuview_toggle_reset ; and return...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1819
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1820 divemode_option8:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1821 bsf alternative_divelayout ; set flag for alternative layout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1822 call menuview_toggle_reset ; terminate the pre-menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1823 call TFT_ClearScreen ; clear the whole screen
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1824 bsf FLAG_TFT_divemode_mask_alt ; set flag to draw the alternative mask
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1825 movff menupos3,customview_divemode; back-up the custom view shown in normal layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1826 clrf menupos3 ; select the default alternative layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1827 call customview_mask_alternative ; draw the default alternative layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1828 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1829
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1830
0
heinrichsweikamp
parents:
diff changeset
1831 divemode_simulator_check_limits:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1832 ; check limits (150m and 0m)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1833 movlw LOW d'16000' ; compare to 16 bar = 16000 mbar (150m)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1834 subwf sim_pressure+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1835 movlw HIGH d'16000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1836 subwfb sim_pressure+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1837 bnc divemode_simulator_check_limits2 ; no carry = borrow = not deeper
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1838
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1839 ; too deep, limit to 150m
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1840 movlw LOW d'16000'
0
heinrichsweikamp
parents:
diff changeset
1841 movwf sim_pressure+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1842 movlw HIGH d'16000'
0
heinrichsweikamp
parents:
diff changeset
1843 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1844 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1845
0
heinrichsweikamp
parents:
diff changeset
1846 divemode_simulator_check_limits2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1847 movlw LOW d'1000' ; compare to 1 bar == 0m == 1000 mbar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1848 subwf sim_pressure+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1849 movlw HIGH d'1000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1850 subwfb sim_pressure+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1851 btfsc STATUS,C ; no carry = borrow = not deeper
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1852 return ; deeper than 0 m == ok
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1853 ; too shallow, limit to 0m
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1854 movlw LOW d'1000'
0
heinrichsweikamp
parents:
diff changeset
1855 movwf sim_pressure+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1856 movlw HIGH d'1000'
0
heinrichsweikamp
parents:
diff changeset
1857 movwf sim_pressure+1
heinrichsweikamp
parents:
diff changeset
1858 return
heinrichsweikamp
parents:
diff changeset
1859
heinrichsweikamp
parents:
diff changeset
1860 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1861 ; Find the best gas and diluent for the current depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1862 ; and check if a gas/diluent change is to be advised.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1863 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1864 ; Output: best_gas_number : number of best gas, 0= none avail, 255= not computed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1865 ; best_dil_number : number of best dil, 0= none avail, 255= not computed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1866 ; better_gas_available : flag indicating if a change is advised
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1867 ; better_dil_available : flag indicating if a change is advised
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1868 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1869 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1870 ; in CCR and pSCR mode: - checks both, gases and diluents for respective best gas / best diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1871 ; - if not in bailout, sets better_dil_available on diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1872 ; - if in bailout, sets better_gas_available on OC gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1873 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1874 ; in OC mode : - checks only gases for best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1875 ; - sets better_gas_available on OC gases
0
heinrichsweikamp
parents:
diff changeset
1876 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1877 check_gas_best:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1878 movff amb_press_10+0,xA+0 ; copy ambient pressure / 10 into xA:2, will be used by ppO2 min/max checks later
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1879 movff amb_press_10+1,xA+1 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1880 ; set maximum ppO2 allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1881 movff char_I_ppO2_max,ppO2_max ; max ppO2 for working phase (default)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1882 movff char_O_deco_info,lo ; bank-safe copy of deco info vector
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1883 btfsc lo,deco_flag ; is the ppo2 deco limit enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1884 movff char_I_ppO2_max_deco,ppO2_max ; YES - replace by max ppO2 for deco phase
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1885 ; check dive mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1886 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1887 bra check_gas_best_gas ; YES - skip diluents, check for best gas only
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1888
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1889 check_gas_best_dil:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1890 ; set minimum ppO2 required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1891 movff char_I_ppO2_min,WREG ; min ppO2 for pure diluent in CCR mode (default)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1892 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1893 movff char_I_ppO2_min_loop,ppO2_min ; YES - replace by min ppO2 for pure diluent in pSCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1894 ; preset results to nothing found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1895 clrf best_gas_num ; initialize best diluent as 0 = nothing found yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1896 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in divemode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1897 ; ; current diluent = 'gas6' ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1898 ; movlw .6 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1899 ; cpfseq active_dil ; using 'gas6' as current diluent?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1900 ; bra check_gas_best_dil0 ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1901 ; bra check_gas_best_dil3 ; YES - suppress better diluent search in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1902 ;check_gas_best_dil0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1903 ; check all diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1904 lfsr FSR1,opt_dil_O2_ratio ; set base address for diluent arrays
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1905 movff active_dil,lo ; number of currently used diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1906 setf best_gas_depth ; initialize change depth of best dil found so far to 255 meter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1907 ; original code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1908 clrf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1909 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1910 rcall check_gas_best_common ; check diluent 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1911 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1912 rcall check_gas_best_common ; check diluent 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1913 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1914 rcall check_gas_best_common ; check diluent 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1915 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1916 rcall check_gas_best_common ; check diluent 4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1917 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1918 rcall check_gas_best_common ; check diluent 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1919 ; alternative code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1920 ; movlw .5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1921 ; movwf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1922 ;check_gas_best_dil_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1923 ; rcall check_gas_best_common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1924 ; decfsz check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1925 ; bra check_gas_best_dil_loop
0
heinrichsweikamp
parents:
diff changeset
1926 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1927 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1928 movff best_gas_num,best_dil_number ; store new best diluent found (1-5 or 0 of no usable diluent available)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1929 ; check if change advices shall be given in general
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1930 btfsc FLAG_bailout_mode ; in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1931 bra check_gas_best_gas ; YES - no better diluent advice when in bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1932 check_gas_best_dil1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1933 ; check if a change advice shall be given right now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1934 movf best_dil_number,W ; load number of best diluent into WREG (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1935 bz check_gas_best_dil3 ; has a best diluent been found at all? NO - nothing to signal for
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1936 cpfseq active_dil ; is this the currently used diluent?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1937 bra check_gas_best_dil2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1938 bra check_gas_best_dil3 ; YES - no need to signal a better diluent if this diluent is already in use
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1939 check_gas_best_dil2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1940 btfsc setpoint_fallback ; is a fallback warning active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1941 bra check_gas_best_dil3 ; YES - suppress better diluent prompt in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1942 ; not using the best gas - show better diluent hint whenever a better diluent is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1943 bsf better_dil_available ; signal that a better diluent is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1944 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1945 check_gas_best_dil3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1946 btfss better_dil_available ; shall a better diluent be signaled for?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1947 bcf blinking_better_dil ; NO - clear blinking flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1948 ; continue with checking for best bailout gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1949
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1950 check_gas_best_gas:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1951 ; set minimum ppO2 required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1952 movff char_I_ppO2_min,ppO2_min ; min ppO2 for OC/Bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1953 ; preset results to nothing found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1954 clrf best_gas_num ; initialize best gas as 0 = nothing found yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1955 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in divemode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1956 ; ; current gas = 'gas6' ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1957 ; movlw .6 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1958 ; cpfseq active_gas ; using 'gas6' as current gas?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1959 ; bra check_gas_best_gas0 ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1960 ; bra check_gas_best_gas3 ; YES - suppress better gas search in this case
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1961 ;check_gas_best_gas0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1962 ; check all gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1963 lfsr FSR1,opt_gas_O2_ratio ; set base address for gas arrays
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1964 movff active_gas,lo ; number of currently used gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1965 setf best_gas_depth ; initialize change depth of best gas found so far to 255 meter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1966 ; original code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1967 clrf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1968 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1969 rcall check_gas_best_common ; check gas 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1970 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1971 rcall check_gas_best_common ; check gas 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1972 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1973 rcall check_gas_best_common ; check gas 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1974 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1975 rcall check_gas_best_common ; check gas 4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1976 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1977 rcall check_gas_best_common ; check gas 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1978 ; alternative code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1979 ; movlw .5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1980 ; movwf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1981 ;check_gas_best_gas_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1982 ; rcall check_gas_best_common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1983 ; decfsz check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1984 ; bra check_gas_best_gas_loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1985 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1986 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1987 movff best_gas_num,best_gas_number ; store new best gas found (1-5 or 0 of no usable gas available)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1988 ; check if change advices shall be given in general
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1989 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1990 bra check_gas_best_gas1 ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1991 btfsc FLAG_bailout_mode ; in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1992 bra check_gas_best_gas1 ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1993 return ; NO - no better (OC) gas advice when not in OC or bailout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1994 check_gas_best_gas1: ; check if we are already on the best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1995 ; check if a change advice shall be given right now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1996 movf best_gas_number,W ; load number of best gas into WREG (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1997 bz check_gas_best_gas3 ; has a best gas been found at all? NO - nothing to signal for
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1998 cpfseq active_gas ; is this the currently used gas?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1999 bra check_gas_best_gas2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2000 bra check_gas_best_gas3 ; YES - no need to signal a better gas if this gas is already in use
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2001 check_gas_best_gas2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2002 ; not using the best gas - show better gas hint whenever a better gas is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2003 bsf better_gas_available ; YES - signal that a better gas is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2004 bsf FLAG_TFT_active_gas_divemode ; YES - redraw gas/setpoint/diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2005 check_gas_best_gas3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2006 btfss better_gas_available ; shall a better gas be signaled for?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2007 bcf blinking_better_gas ; NO - clear blinking flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2008 return
0
heinrichsweikamp
parents:
diff changeset
2009
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2010 check_gas_best_common: ; with gas to be checked in check_gas_num (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2011 ; ; and current gas in lo (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2012 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2013 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2014 ; ---------------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2015 ; opt_gas_O2_ratio res 5 ; base address for gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2016 ; opt_dil_O2_ratio res 5 ; base address for diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2017 ; opt_gas_He_ratio res 5 ; (not needed here)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2018 ; opt_dil_He_ratio res 5 ; (not needed here)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2019 ; opt_gas_type res 5 ; has offset of 20 bytes from base address for gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2020 ; opt_dil_type res 5 ; has offset of 20 bytes from base address for diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2021 ; opt_gas_change res 5 ; has offset of 10 bytes from opt_gas_type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2022 ; opt_dil_change res 5 ; has offset of 10 bytes from opt_dil_type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2023
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2024 ; get gas data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2025 decf check_gas_num,W ; (1-5) -> (0-4) into WREG to be used as index
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2026 movff PLUSW1,check_gas_O2_ratio ; load O2 ratio (%) of current gas/dil into check_gas_O2_ratio
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2027 addlw .20 ; add offset of 20 bytes to index type in opt_gas_type/opt_dil_type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2028 movff PLUSW1,check_gas_type ; load type of current gas/dil into check_gas_type (0=disabled, 1=first, 2=travel/normal, 3=deco/-)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2029 addlw .10 ; add offset of 10 bytes to index change depth in opt_gas_change/opt_dil_change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2030 movff PLUSW1,check_gas_depth ; load change depth of current gas/dil into check_gas_depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2031 ; check if gas is usable (i.e. not disabled)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2032 tstfsz check_gas_type ; type = disabled (0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2033 bra check_gas_best_common0 ; NO - continue checks
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2034 movf check_gas_num,W ; YES - get the number of the gas to be checked (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2035 cpfseq lo ; - is this the currently used gas?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2036 return ; NO - skip disabled gases which are not the current gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2037 bra check_gas_best_common1 ; YES - a gas in use overrides it's disabled status, therefore treat it as available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2038 check_gas_best_common0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2039 ; skip deco gases (type=3) if not in deco mode, but search among all enabled gases when in loop or bailout mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2040 movlw .3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2041 cpfseq check_gas_type ; type = deco (3)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2042 bra check_gas_best_common1 ; NO - proceed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2043 btfsc FLAG_bailout_mode ; YES - in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2044 bra check_gas_best_common1 ; YES - proceed, include deco gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2045 movff char_O_main_status,WREG ; NO - get main deco mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2046 btfsc WREG,DECO_MODE_LOOP_FLAG ; - in loop mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2047 bra check_gas_best_common1 ; YES - proceed, include deco gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2048 movff char_O_deco_info,WREG ; NO - get deco info vector
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2049 btfss WREG,deco_flag ; - in deco mode (deco_flag set), i.e. use of deco gases allowed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2050 return ; NO - skip deco gas while not in deco mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2051 check_gas_best_common1: ; YES - proceed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2052 ; ; check if gas change depth is below minimum change depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2053 ; movlw minimum_change_depth ; for value see definition in hwos.inc
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2054 ; cpfsgt check_gas_depth ; change depth of checked gas > minimum_change_depth?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2055 ; return ; NO - change depth not deep enough, skip and check next gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2056 ; check if gas is usable, i.e. its change depth is below or equal to the current depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2057 movf curr_depth,W ; load current depth (in m) into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2058 cpfslt check_gas_depth ; change depth of checked gas < (shallower than) current depth?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2059 bra check_gas_best_common2 ; NO - gas is usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2060 return ; YES - gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2061 check_gas_best_common2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2062 ; check if this gas is the first best gas candidate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2063 movf best_gas_num,W ; get best gas found so far (1-5) or 0 if none found yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2064 tstfsz WREG ; has a best gas candidate been found yet?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2065 bra check_gas_best_common3 ; YES - check if the new one is better than the one we have so far
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2066 bra check_gas_best_common4 ; NO - no need to do the above mentioned check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2067 check_gas_best_common3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2068 ; check if the change depth of the checked gas is < (shallower) than the change depth of the best gas found so far
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2069 movf best_gas_depth,W ; load change depth of best gas so far into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2070 cpfslt check_gas_depth ; change depth of checked gas < (shallower than) change depth of best gas so far?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2071 return ; NO - this gas is not better than the best already found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2072 check_gas_best_common4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2073 ; check if the gas fits into the ppO2 limits
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2074 movff check_gas_O2_ratio,xB+0 ; xB = O2 ratio, xA is still loaded with (p_amb / 10)
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
2075 clrf xB+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2076 call mult16x16 ; xC = O2 ratio * (p_amb / 10)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2077 ; check for very high ppO2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2078 tstfsz xC+2 ; O2_ratio * p_amb / 10 > 65536, i.e. ppO2 > 6.55 bar ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2079 return ; YES - gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2080 btfsc xC+1,7 ; check if ppO2 > 3.30 bar
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2081 return ; YES - gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2082 ; 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
2083 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
2084 movff xC+1,sub_a+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2085 movf ppO2_min,W
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2086 mullw .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
2087 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
2088 movff PRODH,sub_b+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2089 call subU16 ; sub_c = sub_a - sub_b
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2090 btfsc neg_flag ; within limit?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2091 return ; NO - too low, gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2092 ; check for high ppO2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2093 movf ppO2_max,W
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2094 mullw .100 ; ppO2_max * 100
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2095 movff PRODL,sub_b+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2096 movff PRODH,sub_b+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2097 infsnz sub_b+0,F ; add 1 mbar to allowance to avoid exclusion on equal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2098 incf sub_b+1,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2099 call subU16 ; sub_c = sub_a - sub_b
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2100 btfss neg_flag ; within limit?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2101 return ; NO - too high, gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2102 ; we have a (new) best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2103 movff check_gas_num, best_gas_num ; set checked gas (1-5) as best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2104 movff check_gas_depth,best_gas_depth ; memorize its change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2105 return
0
heinrichsweikamp
parents:
diff changeset
2106
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2107
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2108 ;=============================================================================
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2109 ; Check for Auto-SP
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2110 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2111 check_dive_autosp: ; check for Auto-SP
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2112 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2113 sublw .2 ; opt_ccr_mode = 2 (Auto SP)?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2114 bz check_dive_autosp2 ; YES - check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2115 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
2116 check_dive_autosp2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2117 ; Check SP2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2118 btfsc sp2_switched ; SP 2 used so far?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2119 bra check_dive_autosp3 ; YES - continue with SP 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2120 movff char_I_setpoint_change+1,lo ; NO - get depth in m
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2121 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2122 bra check_dive_autosp2a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2123 bra check_dive_autosp3 ; YES - continue with SP 3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2124 check_dive_autosp2a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2125 decf lo,W ; SP change depth -1 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2126 cpfsgt curr_depth ; current depth > change depth - 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2127 bra check_dive_autosp3 ; NO - continue with SP 3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2128 ; auto switch to SP2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2129 movff char_I_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2130 rcall xmit_sp_set_flag ; - send SP to external devices
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2131 bsf sp2_switched ; - set SP 2 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2132 check_dive_autosp3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2133 ; Check SP3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2134 btfsc sp3_switched ; SP 3 used so far?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2135 bra check_dive_autosp4 ; YES - continue with SP 4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2136 movff char_I_setpoint_change+2,lo ; NO - get depth in m
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2137 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2138 bra check_dive_autosp3a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2139 bra check_dive_autosp4 ; YES - continue with SP 4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2140 check_dive_autosp3a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2141 decf lo,W ; SP change depth -1 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2142 cpfsgt curr_depth ; current depth > change depth - 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2143 bra check_dive_autosp4 ; NO - continue with SP 4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2144 ; auto switch to SP3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2145 movff char_I_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2146 rcall xmit_sp_set_flag ; - send SP to external devices
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2147 bsf sp3_switched ; - set SP 3 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2148 check_dive_autosp4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2149 ; Check SP4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2150 btfsc sp4_switched ; SP 4 used so far?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2151 bra check_dive_autosp5 ; YES - continue with SP 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2152 movff char_I_setpoint_change+3,lo ; NO - get depth in m
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2153 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2154 bra check_dive_autosp4a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2155 bra check_dive_autosp5 ; YES - continue with SP 5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2156 check_dive_autosp4a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2157 decf lo,W ; SP change depth -1 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2158 cpfsgt curr_depth ; current depth > change depth - 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2159 bra check_dive_autosp5 ; NO - continue with SP 5
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2160 ; auto switch to SP4
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2161 movff char_I_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2162 rcall xmit_sp_set_flag ; - send SP to external devices
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2163 bsf sp4_switched ; - set SP 4 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2164 check_dive_autosp5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2165 ; Check SP5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2166 btfsc sp5_switched ; SP 5 used so far?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2167 bra check_dive_autosp6 ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2168 movff char_I_setpoint_change+4,lo ; NO - get depth in m
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2169 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2170 bra check_dive_autosp5a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2171 bra check_dive_autosp6 ; YES - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2172 check_dive_autosp5a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2173 decf lo,W ; SP change depth -1 -> WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2174 cpfsgt curr_depth ; current depth > change depth - 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2175 bra check_dive_autosp6 ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2176 ; auto switch to SP5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2177 movff char_I_setpoint_cbar+4,char_I_const_ppO2 ; YES - use SP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2178 rcall xmit_sp_set_flag ; - send SP to external devices
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2179 bsf sp5_switched ; - set SP 5 used flag
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2180 check_dive_autosp6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2181 return
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2182
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2183 xmit_sp_set_flag:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2184 movff char_I_const_ppO2,WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2185 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2186 bsf setpoint_changed ; set flag (for profile)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2187 bsf event_occured ; set event flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2188 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2189
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2190 set_logbook_marker:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2191 bcf FLAG_set_marker ; clear flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2192 movlw d'6' ; set type of alarm (manual marker)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2193 movwf AlarmType ; copy to alarm register
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2194 bsf event_occured ; set event flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2195 return
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2196
0
heinrichsweikamp
parents:
diff changeset
2197 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2198 ; Setup everything to enter dive mode
0
heinrichsweikamp
parents:
diff changeset
2199 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2200 global dive_boot_oc_bail
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2201 dive_boot_oc_bail:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2202 ; copy opt_gas_types into backup (for "lost gas" feature)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2203 movff opt_gas_type+0,opt_gas_type_backup+0 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2204 movff opt_gas_type+1,opt_gas_type_backup+1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2205 movff opt_gas_type+2,opt_gas_type_backup+2 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2206 movff opt_gas_type+3,opt_gas_type_backup+3 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2207 movff opt_gas_type+4,opt_gas_type_backup+4 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2208 ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2209 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2210
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2211 global dive_boot_oc
0
heinrichsweikamp
parents:
diff changeset
2212 dive_boot_oc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2213 ; set-up registers
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2214 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2215 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
2216 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
2217 return
0
heinrichsweikamp
parents:
diff changeset
2218
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2219 global dive_boot_cc
0
heinrichsweikamp
parents:
diff changeset
2220 dive_boot_cc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2221 ; copy opt_dil_types into backup (for "lost diluent" feature)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2222 movff opt_dil_type+0,opt_dil_type_backup+0 ; 0=Disabled, 1=First, 2=Normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2223 movff opt_dil_type+1,opt_dil_type_backup+1 ; 0=Disabled, 1=First, 2=Normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2224 movff opt_dil_type+2,opt_dil_type_backup+2 ; 0=Disabled, 1=First, 2=Normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2225 movff opt_dil_type+3,opt_dil_type_backup+3 ; 0=Disabled, 1=First, 2=Normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2226 movff opt_dil_type+4,opt_dil_type_backup+4 ; 0=Disabled, 1=First, 2=Normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2227 ; clear flags
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2228 bcf FLAG_bailout_mode ; =1: bailout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2229 bcf setpoint_fallback ; =1: fallback to SP1 due to external O2 sensor failure
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2230 ; set-up registers
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2231 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2232 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (with WREG = current diluent 1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2233 rcall deco_setup_cc_diluents ; set-up of diluent list for deco calculations (with WREG = current diluent 1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2234 ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2235 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2236
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2237 dive_boot_cc_part2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2238 ; revoke sensors from usage if they do not have a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2239 bsf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2240 bsf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2241 bsf use_O2_sensor3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2242 btfss sensor1_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2243 bcf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2244 btfss sensor2_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2245 bcf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2246 btfss sensor3_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2247 bcf use_O2_sensor3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2248 ; check for external HUD/ppO2 Monitor
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2249 btfss optical_input ; do we have an optical input?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2250 bra dive_boot_cc_part2_1 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2251 ; copy (initial) valid flags from HUD/ppO2 Monitor
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2252 btfsc sensor1_active
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2253 bsf use_O2_sensor1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2254 btfsc sensor2_active
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2255 bsf use_O2_sensor2
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2256 btfsc sensor3_active
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2257 bsf use_O2_sensor3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2258 dive_boot_cc_part2_1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2259 ; In pSCR mode, only settings 0 (calculated ppO2) and 1 (ppO2 from sensors) are defined.
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2260 ; In case we still have 3 (auto SP) selected out of previous CCR mode, we reset to 0.
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2261 btfss FLAG_pscr_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2262 bra dive_boot_cc_part2_2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2263 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
2264 sublw .2 ; opt_ccr_mode = 1 (Auto SP)?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2265 bnz dive_boot_cc_part2_2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2266 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2267 movff WREG,opt_ccr_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2268 dive_boot_cc_part2_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2269 bsf setpoint_changed ; set flag (for profile)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2270 bcf sp2_switched ; =1: this setpoint has been auto-selected already
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2271 bcf sp3_switched ; =1: this setpoint has been auto-selected already
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2272 bcf sp4_switched ; =1: this setpoint has been auto-selected already
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2273 bcf sp5_switched ; =1: this setpoint has been auto-selected already
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2274 ; Start with SP1 (CCR) or 0 (pSCR) as default.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2275 ; 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
2276 clrf WREG ; preload WREG with setpoint value 0 for pSCR calculated
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2277 btfsc FLAG_ccr_mode ; are we in CCR mode?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2278 movff char_I_setpoint_cbar+0,WREG ; YES - get value of setpoint 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2279 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2280 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2281 goto calc_deko_divemode_sensor ; read & process sensor data (and return)
0
heinrichsweikamp
parents:
diff changeset
2282
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2283
0
heinrichsweikamp
parents:
diff changeset
2284 diveloop_boot:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2285
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2286 ; do the basic initialization
0
heinrichsweikamp
parents:
diff changeset
2287 call restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
2288
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2289 ; stop accelerometer and compass
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2290 call I2C_sleep_accelerometer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2291 call I2C_sleep_compass
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2292
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2293 ; reset max pressure aka max depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2294 clrf WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2295 movff WREG,max_pressure+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2296 movff WREG,max_pressure+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2297
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2298 ; initialize press needs to zero and invalid (not yet computed) state
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2299 clrf WREG ; set WREG to 0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2300 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2301 movff WREG,char_I_backtrack_time ; clear backtracking time (index to char_I_backtrack_depth)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2302 movff WREG,char_I_backtrack_depth ; prime first entry with depth 0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2303 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2304 bsf WREG,int_is_zero ; set zero flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2305 bsf WREG,int_invalid_flag ; set invalid flag (additionally)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2306 banksel int_O_ascent_pres_need ; select bank with shared output vars
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2307 movwf int_O_ascent_pres_need+1 ; Set flags for tank pressure needs = 0 before p2_deco.c
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2308 movwf int_O_ascent_pres_need+3 ; can do it. If this is not done here and the gas needs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2309 movwf int_O_ascent_pres_need+5 ; custom view is shown before p2_deco.c completes the first
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2310 movwf int_O_ascent_pres_need+7 ; deco calculation, some rubbish numbers from last dive or
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2311 movwf int_O_ascent_pres_need+9 ; simulation may be shown
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2312 banksel common ; back to bank common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2313
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2314 ; configure the deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2315 clrf hi
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2316 bsf hi,DECO_Z_FACTOR_FLAG ; enable Z factor mode by default
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2317 TSTOSS opt_ZfactorUse ; shall use Z factor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2318 bcf hi,DECO_Z_FACTOR_FLAG ; NO - disable again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2319 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2320 bsf hi,DECO_TR_FUNCTIONS ; enable TR mode by default
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2321 btfss FLAG_tr_enabled ; shall use TR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2322 bcf hi,DECO_TR_FUNCTIONS ; NO - disable again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2323 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2324 movff hi,char_O_main_status ; bank-safe copy to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2325
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2326 movff char_O_deco_status,lo ; bank-safe read
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2327 bsf lo,DECO_STATUS_0_FLAG ; set init- | ATTENTION: The deco engine must be started in init state! If omitted, it may
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2328 bsf lo,DECO_STATUS_1_FLAG ; state, | enter an infinite loop at some point in time and brick the OSTC!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2329 bcf lo,DECO_PLAN_FLAG ; normal plan mode,
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2330 bcf lo,DECO_VOLUME_FLAG ; disable gas volume calculation, and
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2331 bcf lo,DECO_ASCENT_FLAG ; disable delayed ascent calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2332 movff lo,char_O_deco_status ; bank-safe copy back to deco engine
0
heinrichsweikamp
parents:
diff changeset
2333
heinrichsweikamp
parents:
diff changeset
2334 clrf WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2335 movff WREG,char_O_deco_warnings ; clear any deco warnings remaining from last dive
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2336 movff WREG,char_O_deco_info ; clear any deco infos remaining from last dive
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2337
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2338 movlw deco_distance ; load distance between actual depth and depth used for deco calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2339 movff WREG,char_I_deco_distance ; write distance to the deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2340
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2341 movff opt_last_stop,char_I_depth_last_deco ; write last stop depth to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2342 movff opt_GF_low,char_I_GF_Low_percentage ; write GF low to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2343 movff opt_GF_high,char_I_GF_High_percentage ; write GF high to deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2344
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2345 bcf onesectoggle ; clear toggle bit for calculation phasing
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2346 bcf use_agf ; start with normal GF set
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2347 bcf divemode_menu ; clear dive mode menu flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2348 bcf alternative_divelayout ; start with default layout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2349 bcf blinking_depth_prev ; clear flag for blinking depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2350 bcf blinking_depth_toggle ; clear flag for blinking depth
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2351 bcf blinking_depth_warning ; clear flag for blinking depth as warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2352 bcf blinking_depth_attention ; clear flag for blinking depth as attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2353 bcf max_depth_greater_100m ; clear flag for last max/avg depth was > 100 m
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2354
0
heinrichsweikamp
parents:
diff changeset
2355 movlw d'1'
heinrichsweikamp
parents:
diff changeset
2356 movwf apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
2357 clrf apnoe_max_pressure+1
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
2358 ; clrf apnoe_surface_mins
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2359 ; clrf apnoe_surface_secs
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2360
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2361 ; copy date and time for logbook
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2362 movff year,start_year
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2363 movff month,start_month
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2364 movff day,start_day
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2365 movff hours,start_hours
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2366 movff mins,start_mins
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2367
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2368 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
2369 movff int_O_CNS_fraction+1,WREG ; get high byte to WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2370 bcf WREG,int_warning_flag ; clear warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2371 bcf WREG,int_attention_flag ; clear attention flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2372 movff WREG,CNS_start+1 ; move high byte on
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2373 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
2374
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2375 bcf no_more_divesecs ; =1: do no longer show seconds in dive mode
0
heinrichsweikamp
parents:
diff changeset
2376 bcf divemode_menu_active
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2377 clrf menupos1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2378 clrf menupos2 ; reset to zero (Zero=no pre-menu or simulator task)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2379 bsf sensors_agree ; init of sensors disagree warning system
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2380
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2381 bcf show_safety_stop ; =1: show the safety stop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2382 clrf safety_stop_countdown ; clear count-down
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2383
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2384 clrf samplesecs ; timer for data logging
0
heinrichsweikamp
parents:
diff changeset
2385 clrf apnoe_timeout_counter ; timeout in minutes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2386 clrf timeout_counter1+0 ; takes care of the timeout (low byte)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2387 clrf timeout_counter1+1 ; takes care of the timeout (high byte)
0
heinrichsweikamp
parents:
diff changeset
2388 clrf AlarmType ; Clear all alarms
heinrichsweikamp
parents:
diff changeset
2389 bcf event_occured ; clear flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2390 clrf average_divesecs_total+0 ; clear non-resettable time accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2391 clrf average_divesecs_total+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2392 clrf average_depth_hold_total+0 ; clear non-resettable average depth
0
heinrichsweikamp
parents:
diff changeset
2393 clrf average_depth_hold_total+1
heinrichsweikamp
parents:
diff changeset
2394 clrf average_depth_hold_total+2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2395 clrf average_depth_hold_total+3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2396 call reset_average ; reset the resettable average depth
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2397
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2398 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2399 btfss FLAG_tr_enabled ; TR functions enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2400 bra diveloop_boot_0 ; NO - skip TR function initialization
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2401 ; YES - initialize TR function variables
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2402 banksel int_O_sac_rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2403 clrf int_O_sac_rate+0 ; clear low byte of SAC rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2404 clrf int_O_pressure_need+0 ; clear low byte of 1st pressure need value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2405 clrf int_O_pressure_need+2 ; clear low byte of 2nd pressure need value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2406 banksel int_IO_pressure_value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2407 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2408 clrf int_IO_pressure_value+2 ; clear low byte of 2nd pressure reading value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2409 clrf int_I_pressure_drop+0 ; clear low byte of 1st pressure drop value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2410 clrf int_I_pressure_drop+2 ; clear low byte of 2nd pressure drop value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2411 clrf char_I_pressure_gas+0 ; clear gas selection of 1st pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2412 clrf char_I_pressure_gas+1 ; clear gas selection of 2nd pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2413 clrf char_I_pressure_age+0 ; clear age of 1st pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2414 clrf char_I_pressure_age+1 ; clear age of 2nd pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2415 clrf char_I_pressure_stat+0 ; clear status of 1st pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2416 clrf char_I_pressure_stat+1 ; clear status of 2nd pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2417 clrf WREG ; clear WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2418 bsf WREG,int_not_avail_flag ; set WREG to coding for integer numbers -> data not available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2419 banksel int_O_sac_rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2420 movwf int_O_sac_rate+1 ; copy to high byte of SAC rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2421 movwf int_O_pressure_need+1 ; copy to high byte of 1st pressure need value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2422 movwf int_O_pressure_need+3 ; copy to high byte of 1st pressure need value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2423 banksel int_IO_pressure_value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2424 movwf int_IO_pressure_value+1 ; copy to high byte of 1st pressure reading value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2425 movwf int_IO_pressure_value+3 ; copy to high byte of 2nd pressure reading value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2426 movwf int_I_pressure_drop+1 ; copy to high byte of 1st pressure drop value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2427 movwf int_I_pressure_drop+3 ; copy to high byte of 1st pressure drop value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2428 banksel gas__last_1st ; select bank with vars for pressure drop calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2429 setf gas__last_1st ; invalidate last gas of 1st reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2430 setf gas__last_2nd ; invalidate last gas of 2nd reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2431 banksel common ; back to bank common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2432 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2433
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2434 diveloop_boot_0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2435 bcf decostop_active ; clear flag for being in deco
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2436 setf best_gas_number ; initialize best gas as not computed yet (255)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2437 setf best_dil_number ; initialize best diluent as not computed yet (255)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2438 bcf better_gas_available ; =1: a better gas is available and a gas change is advised
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2439 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2440
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2441 rcall dive_boot_oc_bail ; basic settings required for all modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2442
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2443 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2444 rcall dive_boot_oc ; YES - add OC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2445
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2446 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2447 rcall dive_boot_cc ; YES - add CC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2448 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2449 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2450
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2451 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2452 rcall dive_boot_cc ; YES - add CC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2453 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2454 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2455
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2456 call ghostwriter_short_header ; write short header with dive number into profile memory
0
heinrichsweikamp
parents:
diff changeset
2457
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2458 btfsc simulatormode_active
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2459 bra diveloop_boot_1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2460
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2461 ; normal mode = surface pressure is the pressure 30 minutes before dive
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2462 SAFE_2BYTE_COPY last_surfpressure_30min, int_I_pres_surface ;copy surface pressure to deco routine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2463 SAFE_2BYTE_COPY last_surfpressure_30min, last_surfpressure ;copy surface pressure to last_surfpressure for correct depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2464 bra diveloop_boot_2
0
heinrichsweikamp
parents:
diff changeset
2465
heinrichsweikamp
parents:
diff changeset
2466 diveloop_boot_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2467 ; simulator mode: set surface pressure to 1 bar because simulated depths are also based on 1 bar surface pressure
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2468 movlw LOW .1000
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2469 movff WREG,int_I_pres_surface+0 ; LOW copy surface pressure to deco routine
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2470 movlw HIGH .1000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2471 movff WREG,int_I_pres_surface+1 ; HIGH copy surface pressure to deco routine
0
heinrichsweikamp
parents:
diff changeset
2472
heinrichsweikamp
parents:
diff changeset
2473 diveloop_boot_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2474 SAFE_2BYTE_COPY temperature,minimum_temperature ; reset minimum temperature registers
0
heinrichsweikamp
parents:
diff changeset
2475
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2476 call init_recording_params ; set up all the divisors
0
heinrichsweikamp
parents:
diff changeset
2477
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2478 bsf FLAG_diluent_setup ; for CCR mode (required to have better gas working)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2479 btfsc FLAG_ccr_mode ; =1: CCR mode (fixed ppO2 or Sensor) active
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2480 bra diveloop_boot_3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2481 btfsc FLAG_pscr_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2482 bra diveloop_boot_3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2483 bcf FLAG_diluent_setup ; for OC mode (required to have better gas working)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2484
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2485 diveloop_boot_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2486 bcf LEDg ; switch off green LED / release reset to RX circuitry
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2487 bcf LEDr ; switch off red LED
0
heinrichsweikamp
parents:
diff changeset
2488 bcf realdive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2489 btfss simulatormode_active ; in simulator mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2490 call disable_rs232 ; NO - disable RS232
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2491
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2492 IFDEF _screendump
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2493 btfsc enable_screen_dumps ; =1: ignore vin_usb, wait for "l" command (screen dump)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2494 call enable_rs232 ; also sets to speed_normal
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2495 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2496
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2497 ; reset dive time seconds
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2498 ; movlw .2 ; start at 2 seconds
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2499 ; movwf total_divetime_seconds+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2500 ; clrf total_divetime_seconds+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2501 ; movwf divesecs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2502 ; movwf apnoe_secs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2503 ; bsf divemode2 ; displayed dive time is running (dive time starts HERE)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2504
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2505 ; clear the timers (start dive times at zero)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2506 clrf total_divetime_seconds+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2507 clrf total_divetime_seconds+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2508 clrf divesecs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2509 clrf divemins+0
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2510 clrf divemins+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2511 clrf apnoe_secs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2512 clrf apnoe_mins
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2513
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2514 ; divemode2 flag will be set by pressure & timeout evaluation in function set_dive_modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2515
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2516 return ; done with dive mode boot
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2517
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2518
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2519 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
2520
heinrichsweikamp
parents:
diff changeset
2521 divemode_check_for_warnings:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2522 movlw .1 ; one message at a time in alternative layout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2523 btfss alternative_divelayout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2524 movlw .2 ; two messages at a time in default layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2525 cpfsgt message_counter ; only one (or two) messages active?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2526 bra divemode_check_for_warnings1; YES - update every second
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2527
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2528 btfss secs,0 ; every two seconds...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2529 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2530 btfss secs,1 ; every four seconds...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2531 return
0
heinrichsweikamp
parents:
diff changeset
2532
131
35b9da423de6 NEW: Update warnings every second
heinrichsweikamp
parents: 113
diff changeset
2533 divemode_check_for_warnings1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2534 bcf message_advice ; clear flag for messages of level advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2535 bcf message_attention ; clear flag for messages of level attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2536 bcf message_warning ; clear flag for messages of level warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2537 clrf message_counter ; clear message counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2538
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2539 ; messages sorted by severity: highest severity warnings first, then attentions, advices and last info
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2540
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2541 ; warnings for all modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2542 call check_warn_battery ; check if the battery level should be displayed/warned
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2543 call check_divetimeout ; check and show the dive mode timeout (not actually a warning)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2544
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2545 btfsc FLAG_apnoe_mode ; in Apnoe mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2546 bra divemode_check_for_warnings2; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2547 btfsc FLAG_gauge_mode ; in gauge mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2548 bra divemode_check_for_warnings2; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2549
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2550 ; warnings applicable only in deco modes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2551 rcall check_ppO2 ; check ppO2 and displays warning, if required
0
heinrichsweikamp
parents:
diff changeset
2552
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2553 btfss sensors_agree ; are the sensor values within the threshold range?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2554 rcall check_warn_sensors_disagree ; NO - further evaluate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2555 btfsc sensors_agree ; are the sensor values within the threshold range?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2556 bcf sensor_warning ; YES - revoke memorized sensor warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2557
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2558 rcall check_outside ; check of ZHL16 model violation
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2559
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2560 rcall check_IBCD ; check for IBCD attention or warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2561
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2562 rcall check_OC_gas_avail ; check if a breathable OC gas is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2563
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2564 btfsc decostop_active ; in deco mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2565 rcall check_and_store_gf_violation; YES - sets warnings, if required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2566
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2567 rcall check_mbubbles ; check for micro bubbles
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2568
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2569 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
2570
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2571 rcall check_gas_needs_ascent ; show gas needs warning if any gas need for ascent is > threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2572
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2573 rcall check_eod_cns_violation ; check CNS values for end-of-dive and display warning, if required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2574
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2575 rcall check_display_ftts ; show @+x time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2576
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2577 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2578 btfsc FLAG_cave_mode ; cave mode enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2579 rcall check_cavemode ; YES - check cave mode status
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2580 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2581
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2582 btfsc use_agf ; in aGF mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2583 rcall warn_agf ; YES - show memo
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2584
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2585 btfsc setpoint_fallback ; fallback to SP1 due to external O2 sensor failure?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2586 rcall warn_fallback ; YES - show a warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2587
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2588 btfsc better_dil_available ; is a better diluent available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2589 rcall advice_gas_change ; YES - display an advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2590 btfsc better_gas_available ; is a better gas available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2591 rcall advice_gas_change ; YES - display an advice
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2592
0
heinrichsweikamp
parents:
diff changeset
2593 divemode_check_for_warnings2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2594 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2595 btfss FLAG_tr_enabled ; TR functions enabled?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2596 bra divemode_check_for_warnings3 ; NO - skip
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2597 call check_tr_functions ; YES - check transmitter functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2598 call check_tr_messages ; - check SAC attention and switch advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2599 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2600
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2601 divemode_check_for_warnings3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2602 ; Display the attention or warning icon?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2603 btfsc message_advice ; any message of level advice?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2604 bsf FLAG_TFT_divemode_warning ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2605 btfsc message_attention ; any message of level attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2606 bsf FLAG_TFT_divemode_warning ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2607 btfsc message_warning ; any message of level warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2608 bsf FLAG_TFT_divemode_warning ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2609 btfss FLAG_TFT_divemode_warning ; any message of above levels?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2610 bsf FLAG_TFT_divemode_warning_clear ; NO - clear warning icon
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2611
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2612 ; Setup message page number
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2613 incf message_page,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2614 movf message_page,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2615 bcf STATUS,C
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2616 btfss alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2617 rlcf message_page,W ; NO - *2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2618 cpfsgt message_counter ; > message_counter?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2619 clrf message_page ; NO - clear
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2620
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2621 ; Clear both rows of messages if there is nothing to show at all
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2622 tstfsz message_counter ; any messages?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2623 bra divemode_check_for_warnings4 ; YES - look if second row needs to be cleared
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2624 bsf FLAG_TFT_dive_warning_text_clear; set flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2625 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2626
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2627 divemode_check_for_warnings4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2628 ; Clear 2nd row of messages if there is nothing to show (on this page)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2629 btfss second_row_warning ; =1: the second row contains a warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2630 bsf FLAG_TFT_dive_warning_text_clr2 ; set flag for 2nd row
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2631 return ; done
0
heinrichsweikamp
parents:
diff changeset
2632
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2633 global check_warn_battery
0
heinrichsweikamp
parents:
diff changeset
2634 check_warn_battery:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2635 movff batt_percent,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2636 movlw battery_show_level+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2637 cpfslt lo ; battery percentage ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2638 return ; YES - no display, no warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2639 ; Display Battery, but warn?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2640 movff batt_percent,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2641 movlw color_code_battery_low+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2642 cpfsgt lo ; battery percent below warning threshold?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2643 bsf message_warning ; YES - set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2644 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2645 bra check_warn_battery2 ; YES - show warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2646 movlw index_clock_batt_surfpress ; NO - index of custom view clock, battery and surface pressure
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2647 cpfseq menupos3 ; - battery shown in custom view?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2648 bra check_warn_battery2 ; NO - show warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2649 return ; YES - do not show twice (in custom view and in message area)
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 471
diff changeset
2650 check_warn_battery2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2651 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2652 goto TFT_update_batt_percent_divemode ; show percent (and return)
513
heinrichsweikamp
parents: 507
diff changeset
2653
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2654 check_divetimeout:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2655 btfsc divemode2 ; dive time running?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2656 return ; YES - do nothing
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2657 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2658 goto TFT_divetimeout ; show timeout counter (and return)
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2659
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2660 check_ppO2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2661 btfsc FLAG_oc_mode ; are we in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2662 bra check_ppO2_1 ; YES - continue with breathed gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2663 btfsc FLAG_bailout_mode ; NO - in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2664 bra check_ppO2_1 ; YES - continue with breathed gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2665 ; CCR / pSCR mode - checks on pure diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2666 movff int_O_pure_ppO2+0,lo ; get value and attention/warning flags for the pure diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2667 movff int_O_pure_ppO2+1,hi ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2668 btfsc hi,int_warning_flag ; ppO2 of the pure diluent to low or high?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2669 rcall check_ppO2_dw ; YES - show warning and return on next line
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2670 btfsc hi,int_attention_flag ; ppO2 of the pure diluent in attention state?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2671 rcall check_ppO2_da ; YES - show attention and return on next line
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2672 ; all modes - checks on breathed gas (OC or from loop)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2673 check_ppO2_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2674 movff int_O_breathed_ppO2+0,lo ; get value and attention/warning flags for the breathed gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2675 movff int_O_breathed_ppO2+1,hi ; get warnings for breathed gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2676 btfsc hi,int_attention_flag ; breathed ppO2 in attention state (when in loop mode, no attention will be generated)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2677 bra check_ppo2_display_a ; YES - set attention flag and show ppO2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2678 btfsc hi,int_low_flag ; breathed ppO2 to low?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2679 bra check_ppO2_low ; YES - record the warning and show ppO2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2680 btfsc hi,int_high_flag ; breathed ppO2 to high?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2681 bra check_ppO2_high ; YES - record the warning and show ppO2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2682 TSTOSS opt_showppo2 ; show ppO2 anyhow? (0 = no, 1 = show always)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2683 return ; NO - no warnings, no show - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2684 bra check_ppO2_common_2 ; YES - but only when in OC or bailout...
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2685 check_ppO2_low:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2686 movlw d'4' ; set type of alarm (ppO2 low)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2687 bra check_ppO2_common ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2688 check_ppO2_high:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2689 movlw d'5' ; set type of alarm (ppO2 high)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2690 check_ppO2_common:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2691 movwf AlarmType ; copy alarm type to alarm register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2692 bsf event_occured ; set event flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2693 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2694 check_ppO2_common_2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2695 btfsc FLAG_oc_mode ; are we in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2696 bra check_ppo2_display ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2697 btfsc FLAG_bailout_mode ; are we in bailout mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2698 bra check_ppo2_display ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2699 return ; NO - in loop mode, ppO2 is already shown via setpoint display
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2700 check_ppo2_display_a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2701 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2702 check_ppo2_display:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2703 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2704 bra check_ppO2_d ; YES - show warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2705 movlw index_ppo2_ead_end_cns ; NO - index of custom view ppO2, EAD/END and CNS)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2706 cpfseq menupos3 ; ppO2 shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2707 bra check_ppO2_b ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2708 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
2709 check_ppO2_b:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2710 movlw index_pscr_info ; index of custom view with pSCR data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2711 cpfseq menupos3 ; ppO2 shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2712 bra check_ppO2_d ; NO - show warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2713 return ; YES - do not show twice (in custom view and in warning area)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2714 check_ppO2_dw:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2715 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2716 check_ppO2_da:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2717 bsf message_attention ; show attention sign (no problem if a warning sign is set as well, as it will take priority)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2718 check_ppO2_d:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2719 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2720 goto TFT_display_ppo2_warning ; show breathed gas or diluent ppO2 warning (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2721
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2722
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2723 check_display_ftts:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2724 movff char_I_extra_time,lo ; get extra time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2725 tstfsz lo ; extra time > 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2726 bra check_display_ftts_1 ; YES - continue checking bailout condition
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2727 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2728 check_display_ftts_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2729 btfsc FLAG_bailout_mode ; in bailout mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2730 return ; YES - in bailout no fTTS will be computed, so nothing to display
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2731 incf message_counter,F ; NO - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2732 goto TFT_display_ftts ; - show @+x time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2733
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2734
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2735 global check_cns_violation
0
heinrichsweikamp
parents:
diff changeset
2736 check_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2737 ; Check if CNS should be displayed
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2738 movff int_O_CNS_fraction+1,WREG ; get high byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2739 btfsc WREG,int_warning_flag ; warning flag set?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2740 bra check_cns_violation_1 ; YES - issue warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2741 btfsc WREG,int_attention_flag ; NO - attention flag set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2742 bra check_cns_violation_2 ; YES - issue attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2743 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2744 check_cns_violation_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2745 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2746 check_cns_violation_2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2747 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2748 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2749 bra check_cns_violation_4 ; YES - show attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2750 movlw index_ppo2_ead_end_cns ; NO - index of custom view ppO2, EAD/END and CNS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2751 cpfseq menupos3 ; - CNS shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2752 bra check_cns_violation_3 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2753 return ; YES - do not show twice (in custom view and in warning area)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2754 check_cns_violation_3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2755 movlw index_CNS ; index of custom view with CNS values
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2756 cpfseq menupos3 ; CNS shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2757 bra check_cns_violation_4 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2758 return ; YES - do not show twice (in custom view and in warning area)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2759 check_cns_violation_4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2760 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2761 goto TFT_display_cns ; show CNS (and return)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2762
0
heinrichsweikamp
parents:
diff changeset
2763
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2764 global check_eod_cns_violation ; check end-of-dive CNS values
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2765 check_eod_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2766 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
2767 btfsc WREG,int_warning_flag ; current CNS value in warning state?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2768 return ; YES - inhibit end-of-dive warning if current CNS is already in warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2769 movff int_O_normal_CNS_fraction+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2770 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2771 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
2772 btfsc WREG,int_warning_flag ; NO - flag for warning set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2773 bra check_eod_cns_violation2 ; YES - issue warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2774 check_eod_cns_violation1: ; NO - continue with checking the other CNS value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2775 movff int_O_alternate_CNS_fraction+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2776 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2777 return ; YES - done with CNS checking
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2778 btfsc WREG,int_warning_flag ; NO - flag for warning set?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2779 bra check_eod_cns_violation2 ; YES - issue warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2780 return ; NO - done with CNS checking
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2781 check_eod_cns_violation2: ; issue warning (actually only on attention level)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2782 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2783 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2784 bra display_eod_cns_violation ; YES - show warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2785 movlw index_CNS ; NO - index of custom view with CNS values
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2786 cpfseq menupos3 ; - CNS values shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2787 bra display_eod_cns_violation ; NO - issue textual warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2788 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
2789 display_eod_cns_violation:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2790 incf message_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2791 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
2792
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2793
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2794 global check_and_store_gf_violation
0
heinrichsweikamp
parents:
diff changeset
2795 check_and_store_gf_violation:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2796 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
2797 btfss WREG,int_warning_flag ; check if the warning flag is set
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2798 bra check_and_store_gf_violation2 ; NO - continue with checking for attention flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2799 movlw d'2' ; YES - set type of alarm
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2800 movwf AlarmType ; copy to alarm register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2801 bsf event_occured ; set event flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2802 bsf message_warning ; set warning flag
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2803 bra check_and_store_gf_violation3 ; show gf warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2804 check_and_store_gf_violation2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2805 btfsc WREG,int_attention_flag ; check if the attention flag is set
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2806 bra check_and_store_gf_violation3 ; YES - show gf
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2807 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2808 bra check_and_store_gf_violation4 ; NO - continue checking of deco info
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2809 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2810 btfss WREG,IBCD_warning ; is the IBCD warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2811 bra check_and_store_gf_violation4 ; NO - continue checking for deco info
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2812 check_and_store_gf_violation3: ; YES - show gf
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2813 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2814 incf message_counter,F ; increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2815 goto TFT_warning_gf ; show GF (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2816 check_and_store_gf_violation4: ; check for deco info
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2817 btfss divemode ; in dive mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2818 return ; NO - done, return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2819 btfsc FLAG_bailout_mode ; YES - in bailout mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2820 return ; YES - done, return (deco_decreasing flag is not updated when in bailout mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2821 movff char_O_deco_info,WREG ; NO - get the deco info vector
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2822 btfss WREG,deco_decreasing ; check if the deco_decreasing flag is set
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2823 return ; NO - done, return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2824 incf message_counter,F ; YES - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2825 goto TFT_info_deco ; - show deco info
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2826
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2827
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2828 check_outside:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2829 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2830 btfss WREG,outside_warning_lock ; are we outside of the ZH-L16 model?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2831 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2832 incf message_counter,F ; YES - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2833 bsf message_attention ; - show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2834 btfsc WREG,outside_warning ; - are we outside the ZH-L16 model right now (-> warning)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2835 bsf message_warning ; - set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2836 goto TFT_warning_outside ; - show outside-ZHL-model warning/attention (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2837
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2838
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2839 global check_mbubbles
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2840 check_mbubbles:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2841 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2842 btfsc WREG,mbubble_warning ; are we in micro bubbling zone right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2843 bra check_mbubbles_warn ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2844 btfss WREG,mbubble_warning_lock ; were we in micro bubbling zone?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2845 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2846 check_mbubble_att ; YES - attention level
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2847 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2848 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2849 goto TFT_warning_mbubbles ; show micro bubble attention (and return) - TFT_warning_mbubbles switches by itself between attention and warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2850 check_mbubbles_warn: ; locked micro bubbles - warning level if at issue, attention level if locked
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2851 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2852 bsf message_warning ; set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2853 goto TFT_warning_mbubbles ; show micro bubbles warning (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2854
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2855 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2856 check_cavemode:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2857 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2858 btfsc FLAG_dive_turned ; dive turned?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2859 goto TFT_info_dive_turned ; YES - show info that dive is turned
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2860 btfsc FLAG_cave_mode_shutdown ; NO - has cave mode shut down?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2861 goto TFT_warn_cave_shutdown ; YES - show that cave mode has shut down
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2862 goto TFT_info_cave_mode ; NO - show that cave mode is active
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2863 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2864
0
heinrichsweikamp
parents:
diff changeset
2865 warn_agf:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2866 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2867 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
2868
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
2869 warn_fallback:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2870 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2871 bsf message_warning ; set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2872 goto TFT_warning_fallback ; show fallback warning (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2873
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2874
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2875 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2876
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2877 check_tr_messages:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2878 movff int_O_sac_rate+1,WREG ; bank-safe copy of current SAC rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2879 btfss WREG,int_attention_flag ; attention flag set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2880 bra check_tr_messages2 ; NO - skip
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2881 btfsc WREG,int_not_avail_flag ; SAC rate available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2882 bra check_tr_messages2 ; NO - continue with swap advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2883 bsf message_attention ; YES - show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2884 btfsc alternative_divelayout ; - in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2885 bra check_tr_messages1 ; YES - show attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2886 movlw index_pressures_SAC ; NO - index of custom view with SAC rate
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2887 cpfseq menupos3 ; - SAC rate shown right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2888 bra check_tr_messages1 ; NO - show attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2889 bra check_tr_messages2 ; YES - do not show twice, continue with swap advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2890 check_tr_messages1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2891 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2892 call TFT_attention_sac ; show SAC attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2893 check_tr_messages2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2894 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2895 btfss WREG,ind_double_switch ; swap tank flag set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2896 return ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2897 incf message_counter,F ; YES - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2898 bsf message_advice ; - show advice sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2899 goto TFT_advice_switch ; - show swap advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2900
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2901
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2902 #DEFINE show_custview ul,0 ; show pressure readings custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2903 #DEFINE show_transmitter ul,1 ; show transmitter attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2904 #DEFINE show_pres_warning ul,2 ; show transmitter pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2905 #DEFINE show_pres_attention ul,3 ; show transmitter pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2906
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2907 check_tr_functions:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2908 clrf ul ; set all messages as not shown yet
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2909 btfsc alternative_divelayout ; in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2910 bra check_tr_functions_tr1 ; YES - continue with checking transmitter 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2911 movlw index_pressures_SAC ; NO - index of custom view pressure readings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2912 cpfseq menupos3 ; - pressure readings shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2913 bra check_tr_functions_tr1 ; NO - continue with checking transmitter 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2914 bsf show_custview ; YES - suppress redraw by faking it has already been redrawn
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2915 check_tr_functions_tr1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2916 movff char_I_pressure_stat+0,WREG ; get status of 1st pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2917 rcall check_tr_functions_helper1 ; check for transmitter 1 lost
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2918 rcall check_tr_functions_helper2 ; check for transmitter 1 low battery
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2919 movff int_IO_pressure_value+1,WREG ; get high byte of 1st pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2920 rcall check_tr_functions_helper3 ; check for transmitter 1 pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2921 rcall check_tr_functions_helper4 ; check for transmitter 1 pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2922 check_tr_functions_tr2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2923 movff char_I_pressure_stat+1,WREG ; get status of 2nd pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2924 rcall check_tr_functions_helper5 ; check for transmitter 2 lost
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2925 rcall check_tr_functions_helper6 ; check for transmitter 2 low battery
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2926 movff int_IO_pressure_value+3,WREG ; get high byte of 2nd pressure reading
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2927 rcall check_tr_functions_helper7 ; check for transmitter 2 pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2928 rcall check_tr_functions_helper8 ; check for transmitter 2 pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2929 check_tr_functions_show_xmtr:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2930 btfss show_transmitter ; shall show transmitter message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2931 bra check_tr_functions_show_warn ; NO - continue with pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2932 bsf message_attention ; YES - set flag for attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2933 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2934 call TFT_attention_transmitter ; - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2935 check_tr_functions_show_warn:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2936 btfss show_pres_warning ; shall show pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2937 bra check_tr_functions_show_att ; NO - continue with pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2938 bsf message_warning ; YES - set flag for warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2939 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2940 goto TFT_warning_pres_reading ; - pressure reading warning message and done then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2941 check_tr_functions_show_att:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2942 btfss show_pres_attention ; shall show pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2943 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2944 bsf message_attention ; YES - set flag for attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2945 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2946 goto TFT_attention_pres_reading ; - pressure reading warning message and done then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2947
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2948 check_tr_functions_helper1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2949 btfsc WREG,char_transmitter_lost ; transmitter 1 lost?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2950 bra check_tr_functions_helper1a ; YES - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2951 bcf transmitter1_lost ; NO - clear flag for old lost attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2952 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2953 check_tr_functions_helper1a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2954 bsf show_transmitter ; show transmitter attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2955 btfsc transmitter1_lost ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2956 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2957 bsf transmitter1_lost ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2958 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2959
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2960 check_tr_functions_helper2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2961 btfsc WREG,char_transmitter_low_bat ; transmitter 1 low battery?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2962 bra check_tr_functions_helper2a ; YES - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2963 bcf transmitter1_battery ; NO - clear flag for old battery attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2964 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2965 check_tr_functions_helper2a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2966 bsf show_transmitter ; show transmitter attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2967 btfsc transmitter1_battery ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2968 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2969 bsf transmitter1_battery ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2970 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2971
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2972 check_tr_functions_helper3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2973 btfsc WREG,int_warning_flag ; transmitter 1 pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2974 bra check_tr_functions_helper3a ; YES - show pressure reading message as warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2975 bcf transmitter1_pres_warn ; NO - clear flag for old warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2976 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2977 check_tr_functions_helper3a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2978 bsf show_pres_warning ; show pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2979 btfsc transmitter1_pres_warn ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2980 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2981 bsf transmitter1_pres_warn ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2982 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2983
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2984 check_tr_functions_helper4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2985 btfsc WREG,int_attention_flag ; transmitter 1 pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2986 bra check_tr_functions_helper4a ; YES - show pressure reading message as attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2987 bcf transmitter1_pres_att ; NO - clear flag for old attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2988 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2989 check_tr_functions_helper4a
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2990 bsf show_pres_attention ; show pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2991 btfsc transmitter1_pres_att ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2992 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2993 bsf transmitter1_pres_att ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2994 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2995
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2996 check_tr_functions_helper5:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2997 btfsc WREG,char_transmitter_lost ; transmitter 2 lost?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2998 bra check_tr_functions_helper5a ; YES - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2999 bcf transmitter2_lost ; NO - clear flag for old lost attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3000 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3001 check_tr_functions_helper5a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3002 bsf show_transmitter ; show transmitter attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3003 btfsc transmitter2_lost ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3004 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3005 bsf transmitter2_lost ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3006 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3007
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3008 check_tr_functions_helper6:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3009 btfsc WREG,char_transmitter_low_bat ; transmitter 2 low battery?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3010 bra check_tr_functions_helper6a ; YES - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3011 bcf transmitter2_battery ; NO - clear flag for old battery attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3012 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3013 check_tr_functions_helper6a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3014 bsf show_transmitter ; show transmitter attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3015 btfsc transmitter2_battery ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3016 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3017 bsf transmitter2_battery ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3018 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3019
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3020 check_tr_functions_helper7:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3021 btfsc WREG,int_warning_flag ; transmitter 2 pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3022 bra check_tr_functions_helper7a ; YES - show pressure reading message as warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3023 bcf transmitter2_pres_warn ; NO - clear flag for old warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3024 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3025 check_tr_functions_helper7a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3026 bsf show_pres_warning ; show pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3027 btfsc transmitter2_pres_warn ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3028 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3029 bsf transmitter2_pres_warn ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3030 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3031
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3032 check_tr_functions_helper8:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3033 btfsc WREG,int_attention_flag ; transmitter 2 pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3034 bra check_tr_functions_helper8a ; YES - show pressure reading message as attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3035 bcf transmitter2_pres_att ; NO - clear flag for old attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3036 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3037 check_tr_functions_helper8a
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3038 bsf show_pres_attention ; show pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3039 btfsc transmitter2_pres_att ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3040 return ; NO - do not show the pressure readings custom view again
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3041 bsf transmitter2_pres_att ; YES - memorize it's an old message now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3042 ;bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3043
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3044 check_tr_functions_show_cv:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3045 btfsc show_custview ; is the pressure readings custom view not shown yet shown?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3046 return ; NO - already shown, done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3047 bsf show_custview ; YES - mark as shown
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3048 btfsc alternative_divelayout ; - in alternative layout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3049 call switch_layout_to_normal ; YES - switch to normal layout
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3050 movlw index_pressures_SAC-1 ; custom view number one below pressure readings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3051 movwf menupos3 ; set custom view number
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3052 bsf toggle_customview ; initiate toggle to desired custom view -> pressure readings view will be shown
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3053 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3054
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3055 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3056
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3057
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3058 check_gas_needs_ascent:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3059 banksel int_O_ascent_pres_need
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3060 movf int_O_ascent_pres_need+1,w ; get high byte from pres need of 1st tank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3061 iorwf int_O_ascent_pres_need+3,w ; inclusive or with high byte from pres need of 2nd tank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3062 iorwf int_O_ascent_pres_need+5,w ; inclusive or with high byte from pres need of 3rd tank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3063 iorwf int_O_ascent_pres_need+7,w ; inclusive or with high byte from pres need of 4th tank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3064 iorwf int_O_ascent_pres_need+9,w ; inclusive or with high byte from pres need of 5th tank
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3065 banksel common
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3066 btfsc WREG,int_invalid_flag ; check if invalid flag is set
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3067 return ; YES - no further checking required
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3068 btfsc WREG,int_warning_flag ; check if any gas has a pres_need >= pres_fill
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3069 bsf message_warning ; YES - set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3070 btfsc WREG,int_warning_flag ; check if any gas has a pres_need >= pres_fill
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3071 goto TFT_warning_gas_needs_warn ; Yes - show a warning
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3072 btfsc WREG,int_attention_flag ; check if any gas has a pres_need >= pres_fill * threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3073 bsf message_attention ; YES - set attention flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3074 btfsc WREG,int_attention_flag ; check if any gas has a pres_need >= pres_fill * threshold
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3075 goto TFT_warning_gas_needs_att ; YES - show an attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3076 bcf gas_needs_attention ; NO - clear flag for a new attention
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3077 bcf gas_needs_warning ; clear flag for a new warning
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3078 return
0
heinrichsweikamp
parents:
diff changeset
3079
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3080
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3081 check_warn_sensors_disagree:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3082 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3083 bsf message_warning ; YES - set warning flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3084 goto TFT_warning_sensor_disagree ; show sensor disagree warning (and return)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3085
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3086
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3087 check_IBCD:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3088 TSTOSS opt_enable_IBCD ; IBCD warning activated?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3089 return ; NO - done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3090 movff char_O_deco_warnings,WREG ; YES - get deco warnings vector
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3091 btfss WREG,IBCD_warning ; IBCD warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3092 return ; NO - return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3093 incf message_counter,F ; YES - increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3094 goto TFT_warning_IBCD ; write warning to display
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3095
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3096
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3097 check_OC_gas_avail:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3098 tstfsz best_gas_number ; is a breathable gas available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3099 return ; > 0 : a breathable gas is available
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3100 btfsc FLAG_ccr_mode ; = 0 : problem - in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3101 bra check_OC_gas_avail_1 ; YES - real problem
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3102 btfsc FLAG_pscr_mode ; NO - in PSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3103 bra check_OC_gas_avail_1 ; YES - real problem
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3104 return ; NO - neither CCR nor pSCR mode, suppress warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3105 check_OC_gas_avail_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3106 btfsc FLAG_bailout_mode ; in bailout?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3107 return ; YES - suppress warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3108 incf message_counter,F ; NO - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3109 bsf message_attention ; set attention flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3110 goto TFT_warning_no_BO_gas ; show message (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3111
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3112
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3113 advice_gas_change:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3114 bsf message_advice ; show advice sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3115 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3116 goto TFT_advice_gas_change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3117
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3118
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3119 global restart_deco_engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3120 global restart_deco_engine_wo_ceiling
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3121 restart_deco_engine:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3122 ; invalidate ceiling
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3123 movff int_O_ceiling+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3124 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
3125 movff WREG,int_O_ceiling+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3126
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3127 restart_deco_engine_wo_ceiling:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3128 ; invalidate deco data (stop table data)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3129 movff char_O_deco_gas+0,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3130 bsf WREG,char_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3131 movff WREG,char_O_deco_gas+0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3132
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3133 ; invalidate ascent time (normal plan)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3134 movff int_O_ascenttime+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3135 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3136 movff WREG,int_O_ascenttime+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3137
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3138 ; invalidate CNS at end of dive in normal plan
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3139 movff int_O_normal_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3140 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3141 movff WREG,int_O_normal_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3142
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3143 ; restart deco engine
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3144 movff char_O_main_status,WREG ; get current main engine configuration
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3145 bcf WREG,DECO_COMPLETED_NORM ; eventually clear flag stating completion of normal plan
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3146 bsf WREG,DECO_COMPLETED_ALT ; fake we came from alternative plan to force normal plan to be done next
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3147 movff WREG,char_O_main_status ; write back new configuration
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3148 movff char_O_deco_status,WREG ; get current deco engine status
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3149 bcf WREG,DECO_STATUS_0_FLAG ; set status flags to...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3150 bcf WREG,DECO_STATUS_1_FLAG ; ... DECO_STATUS_START
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3151 movff WREG,char_O_deco_status ; write back new configuration to restart deco computations
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3152
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3153 inval_alternative_plan_data:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3154 ; invalidate ascent time (alternative plan)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3155 movff int_O_alternate_ascenttime+1,WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3156 bsf WREG,int_invalid_flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3157 movff WREG,int_O_alternate_ascenttime+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3158
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3159 ; invalidate CNS at end of dive in alternative plan
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3160 movff int_O_alternate_CNS_fraction+1,WREG
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3161 bsf WREG,int_invalid_flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3162 movff WREG,int_O_alternate_CNS_fraction+1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3163
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3164 ; invalidate ascent gas needs
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3165 movff int_O_ascent_pres_need+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3166 bsf WREG,int_invalid_flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3167 movff WREG,int_O_ascent_pres_need+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3168
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3169 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3170 ; invalidate pressure needs (TR functions)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3171 movff int_O_pressure_need+1,WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3172 bsf WREG,int_not_avail_flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3173 movff WREG,int_O_pressure_need+1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3174 movff int_O_pressure_need+3,WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3175 bsf WREG,int_not_avail_flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3176 movff WREG,int_O_pressure_need+3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3177 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3178
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3179 ; update display depended on NDL or deco mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3180 bsf FLAG_TFT_display_ndl_or_deko
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3181
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3182 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3183
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3184 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3185 ; Simulator Mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3186 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3187
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3188 global do_demo_divemode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3189 do_demo_divemode:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3190 call TFT_ClearScreen ; blank screen
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3191 call option_save_all ; save all settings into EEPROM before starting simulation
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3192 call deco_push_tissues_to_vault ; C-code: back-up status of the real tissues
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3193 banksel common ; bank 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3194
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3195 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3196 bsf restore_deco_data ; restore tissue and CNS after simulator use
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3197 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3198
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3199 bcf pressure_refresh
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3200 btfss pressure_refresh ; wait for sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3201 bra $-2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3202
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3203 bsf simulatormode_active ; set flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3204
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3205 banksel char_I_bottom_depth ; compute dive ambient conditions
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3206 movf char_I_bottom_depth,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3207 mullw .100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3208 movff PRODL,rel_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3209 movff PRODH,rel_pressure+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3210 movlw LOW (.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3211 addwf PRODL,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3212 movff WREG,sim_pressure+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3213 movlw HIGH (.1000)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3214 addwfc PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3215 movff WREG,sim_pressure+1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3216 banksel common ; bank 1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3217
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3218 bsf divemode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3219 goto diveloop ; switch into dive mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3220
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3221 END