annotate src/divemode.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents c40025d8e750
children 185ba2f91f59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3 ; File divemode.asm combined next generation V3.04.3
0
heinrichsweikamp
parents:
diff changeset
4 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
5 ; Dive Mode
0
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 "math.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
19 #include "wait.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
20 #include "customview.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
21 #include "start.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
22 #include "adc_lightsensor.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
23 #include "ghostwriter.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
24 #include "i2c.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
25 #include "calibrate.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
26 #include "convert.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
27 #include "surfmode.inc"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
28 #include "rx_ops.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
29
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
30
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
31 extern do_line_menu
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
32 extern do_main_divemenu
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
33 extern menu_draw_lines_divemode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
34 extern option_save_all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
35 extern init_recording_params
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
36
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
37 IFDEF _compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
38 extern TFT_dive_compass_heading
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
39 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
40
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
41
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
42 ;---- Private local Variables -------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
43
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
44 CBLOCK local1 ; max size is 16 Byte !!!
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
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
52 last_pressure_velocity:2 ; cached last absolute pressure for velocity calculation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
53 TFT_output_flags_1 ; TFT update flags for output phase 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
54 TFT_output_flags_2 ; TFT update flags for output phase 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
55 TFT_output_flags_3 ; TFT update flags for output phase 3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
56 TFT_output_flags_4 ; TFT update flags for output phase 4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
57 DM_flags_local ; various dive mode flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
58 ENDC ; used: 14 byte, remaining: 2 byte
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
59
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
60 CBLOCK local2 ; max size is 16 Byte !!!
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
61 pressure_rel_accu_trip:4 ; pressure accumulator for calculating the resettable average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
62 pressure_rel_accu_total:4 ; pressure accumulator for calculating the total dive average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
63 xmitter_flags_stat ; pressure transmitter flags for status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
64 xmitter_flags_mesg ; pressure transmitter flags for messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
65 ppO2_min:2 ; used in search for best gas/dil: minimum ppO2 required
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
66 ppO2_max_default:2 ; used in search for best gas/dil: default maximum ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
67 ppO2_max_deco:2 ; used in search for best gas/dil: deco maximum ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
68 ENDC ; used: 16 byte, remaining: 0 byte ==> FULL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
69
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
70
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
71 ;---- Private local Flags ----------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
72
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
73 ; TFT_output_flags_1 - phase 1: every second - before deco calculations, all modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
74 #DEFINE FLAG_TFT_depth_current TFT_output_flags_1,0 ; =1: show current depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
75 #DEFINE FLAG_TFT_depth_maximum TFT_output_flags_1,1 ; =1: show maximum depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
76 #DEFINE FLAG_TFT_active_gas_divemode TFT_output_flags_1,2 ; =1: show active gas and dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
77 #DEFINE FLAG_TFT_apnoe_surface_time TFT_output_flags_1,3 ; =1: show apnoe mode surface time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
78 #DEFINE FLAG_TFT_depth_maximum_apnoe TFT_output_flags_1,4 ; =1: show maximum depth of last apnoe dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
79 #DEFINE FLAG_TFT_clear_apnoe_surface TFT_output_flags_1,5 ; =1: clear apnoe mode surface data from screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
80 #DEFINE FLAG_TFT_apnoe_divetime TFT_output_flags_1,6 ; =1: show apnoe mode dive times
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
81 ; TFT_output_flags_1,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
82
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
83 ; TFT_output_flags_2 - phase 2: every second - before deco calculations, deco modes only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
84 #DEFINE FLAG_TFT_divemode_mask TFT_output_flags_2,0 ; =1: show dive mode mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
85 #DEFINE FLAG_TFT_divetime TFT_output_flags_2,1 ; =1: show dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
86 #DEFINE FLAG_TFT_safety_stop_show TFT_output_flags_2,2 ; =1: show safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
87 #DEFINE FLAG_TFT_safety_stop_clear TFT_output_flags_2,3 ; =1: clear safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
88 #DEFINE FLAG_TFT_temperature TFT_output_flags_2,4 ; =1: show temperature (or resettable dive time when in compass view)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
89 ; TFT_output_flags_2,5 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
90 ; TFT_output_flags_2,6 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
91 ; TFT_output_flags_2,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
92
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
93 ; TFT_output_flags_3 - phase 3: every second - after deco calculations, deco modes only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
94 #DEFINE FLAG_TFT_clear_deco_data TFT_output_flags_3,0 ; =1: clear deco data (NDL or stop & TTS)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
95 #DEFINE FLAG_TFT_display_ndl_mask TFT_output_flags_3,1 ; =1: show NDL mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
96 #DEFINE FLAG_TFT_display_deco_mask TFT_output_flags_3,2 ; =1: show deco mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
97 #DEFINE FLAG_TFT_display_ndl TFT_output_flags_3,3 ; =1: show NDL data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
98 #DEFINE FLAG_TFT_display_deco TFT_output_flags_3,4 ; =1: show deco stop data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
99 #DEFINE FLAG_TFT_display_tts TFT_output_flags_3,5 ; =1: show deco TTS data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
100 ; TFT_output_flags_3,6 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
101 ; TFT_output_flags_3,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
102
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
103 ; TFT_output_flags_4 - phase 4: every second - after deco calculations, all modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
104 #DEFINE FLAG_TFT_customview_mask TFT_output_flags_4,0 ; =1: show the custom view mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
105 #DEFINE FLAG_TFT_sign_show TFT_output_flags_4,1 ; =1: show the advice / attention / warning sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
106 #DEFINE FLAG_TFT_sign_clear TFT_output_flags_4,2 ; =1: clear the advice / attention / warning sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
107 #DEFINE FLAG_TFT_message_clear_both TFT_output_flags_4,3 ; =1: clear messages, both rows
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
108 #DEFINE FLAG_TFT_message_clear_2nd TFT_output_flags_4,4 ; =1: clear messages, 2nd row only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
109 #DEFINE FLAG_TFT_velocity_show TFT_output_flags_4,5 ; =1: show vertical velocity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
110 #DEFINE FLAG_TFT_velocity_clear TFT_output_flags_4,6 ; =1: clear vertical velocity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
111 ; TFT_output_flags_4,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
112
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
113
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
114 ; Pressure Transmitter Status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
115 #DEFINE transmitter1_lost xmitter_flags_stat,0 ; =1: transmitter 1 lost is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
116 #DEFINE transmitter1_battery xmitter_flags_stat,1 ; =1: transmitter 1 battery low is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
117 #DEFINE transmitter1_pres_warn xmitter_flags_stat,2 ; =1: transmitter 1 pressure warning is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
118 #DEFINE transmitter1_pres_att xmitter_flags_stat,3 ; =1: transmitter 1 pressure attention is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
119 #DEFINE transmitter2_lost xmitter_flags_stat,4 ; =1: transmitter 2 lost is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
120 #DEFINE transmitter2_battery xmitter_flags_stat,5 ; =1: transmitter 2 battery low is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
121 #DEFINE transmitter2_pres_warn xmitter_flags_stat,6 ; =1: transmitter 2 pressure warning is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
122 #DEFINE transmitter2_pres_att xmitter_flags_stat,7 ; =1: transmitter 2 pressure attention is an old message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
123
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
124 ; Pressure Transmitter Messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
125 #DEFINE pres_customview_shown xmitter_flags_mesg,0 ; =1: pressure readings custom view has been shown before
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
126 #DEFINE show_transmitter_attention xmitter_flags_mesg,1 ; =1: show transmitter attention
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
127 #DEFINE show_pres_warning xmitter_flags_mesg,2 ; =1: show transmitter pressure warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
128 #DEFINE show_pres_attention xmitter_flags_mesg,3 ; =1: show transmitter pressure attention
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
129 ; xmitter_flags_mesg,4 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
130 ; xmitter_flags_mesg,5 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
131 ; xmitter_flags_mesg,6 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
132 ; xmitter_flags_mesg,7 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
133
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
134 ; various Flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
135 #DEFINE FLAG_backtrack_full DM_flags_local,0 ; =1: the backtracking storage is full
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
136 #DEFINE new_deco_data_avail DM_flags_local,1 ; =1: new NDL or deco data available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
137 #DEFINE o2_sensors_agree DM_flags_local,2 ; =1: the ppO2 of all sensors are within the threshold range
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
138 #DEFINE update_menu DM_flags_local,3 ; =1: redraw the dive menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
139 #DEFINE FLAG_SP2_used DM_flags_local,4 ; =1: setpoint 2 has been auto-selected already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
140 #DEFINE FLAG_SP3_used DM_flags_local,5 ; =1: setpoint 3 has been auto-selected already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
141 #DEFINE FLAG_SP4_used DM_flags_local,6 ; =1: setpoint 4 has been auto-selected already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
142 #DEFINE FLAG_SP5_used DM_flags_local,7 ; =1: setpoint 5 has been auto-selected already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
143
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
144
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
145 dmode CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
146
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
147 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
148
heinrichsweikamp
parents:
diff changeset
149 global diveloop
heinrichsweikamp
parents:
diff changeset
150 diveloop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
151 clrf STKPTR ; clear return addresses stack
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
152
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
153 ; start with a clean time base
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
154 bsf reset_timebase ; request ISR to reset the main timebase,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
155 ; as we are in dive mode the dive timers will be reset as well
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
156
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
157 ; reset global flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
158 clrf DM_flags_state ; clear all flags for dive mode status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
159 clrf DM_flags_request ; clear all flags for user requests
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
160 clrf DM_flags_event ; clear all flags for data recording events
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
161 clrf DM_flags_layout1 ; clear all flags for display control / layout (1)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
162 clrf DM_flags_layout2 ; clear all flags for display control / layout (2)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
163 clrf DM_flags_message ; clear all flags for display control / messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
164 clrf DM_flags_gas_dil ; clear all flags for display control / gases and diluents
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
165
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
166 bcf dive_main_menu ; clear dive main menu flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
167 bcf dive_options_menu ; clear dive options menu flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
168
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
169 ; reset local flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
170 clrf TFT_output_flags_1 ; clear all flags for TFT output phase 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
171 clrf TFT_output_flags_2 ; clear all flags for TFT output phase 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
172 clrf TFT_output_flags_3 ; clear all flags for TFT output phase 3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
173 clrf TFT_output_flags_4 ; clear all flags for TFT output phase 4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
174 clrf xmitter_flags_stat ; clear all pressure transmitter status flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
175 clrf xmitter_flags_mesg ; clear all pressure transmitter message flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
176 clrf DM_flags_local ; clear all the various other flags, too
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
177
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
178 ; set initial screen layout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
179 bcf alt_layout_active ; default to normal layout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
180 TSTOSC opt_layout ; alternative layout enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
181 bsf alt_layout_active ; YES - start with alternative layout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
182
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
183 IFDEF _gas_contingency
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
184 ; disable gas contingency mode (may be left over activated by deco calculator)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
185 clrf WREG
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
186 movff WREG,char_I_gas_contingency
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
187 ENDIF
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
188
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
189 ; boot tasks for all modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
190 call diveloop_boot
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
191
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
192 ; startup tasks for all modes
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
193 ; clrf CCP1CON ; stop PWM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
194 ; bcf PORTC,2 ; pull PWM output to GND
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
195 ; clrf CCPR1L ; backlight off
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
196 call TFT_boot ; initialize TFT (includes clear screen)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
197 call TFT_show_divemode_mask ; display static dive mode mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
198 call TFT_Display_FadeIn ; dim up the display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
199
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
200 ; reload and redraw last custom view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
201 movff customview_divemode,active_customview
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
202 bsf FLAG_TFT_customview_mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
203
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
204 bcf divetime_longer_1min ; the dive has just begun
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
205 btfsc FLAG_apnoe_mode ; in apnea mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
206 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
207 btfsc sensor_override_active ; in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
208 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
209
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
210 bsf trigger_pres_cur_changed ; flag that the pressures have changed to have all data...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
211 bsf trigger_pres_max_changed ; ... written to the display on the first output round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
212
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
213 bsf trigger_temp_changed ; flag that the temperature has changed to have the temperature ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
214 ; ... written to the display on the first output round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
215
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
216 bsf new_deco_data_avail ; flag that new deco engine results are available to have the initial data ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
217 ; ... written to the display on the first output round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
218
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
219 ; clear the resettable average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
220 call clear_resettable_average_depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
221
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
222 ; ; initial caching of new absolute and relative pressure, ISR-safe 2 byte copies
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
223 ; SMOVII pressure_abs, pressure_abs_cached
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
224 ; SMOVII pressure_rel_cur,pressure_rel_cur_cached
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
225
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
226 ; ; initial transfer of absolute pressure to deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
227 ; MOVII pressure_abs_cached,int_I_pres_respiration
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
228
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
229 btfsc FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
230 bra diveloop_1 ; YES - done with initialization
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
231 btfsc FLAG_gauge_mode ; NO - in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
232 bra diveloop_1 ; YES - done with initialization
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
233 bsf FLAG_TFT_display_ndl_mask ; NO - in deco mode then, display NDL mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
234 bsf FLAG_TFT_active_gas_divemode; - request initial display of gas and setpoint
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
235
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
236 diveloop_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
237 btfsc reset_timebase ; has the ISR confirmed reset of the timebase meanwhile?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
238 bra $-2 ; NO - not yet, loop waiting for confirmation before entering the dive loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
239
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
240 diveloop_loop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
241 ; ### the dive loop starts here ###
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
242 btfsc trigger_full_second ; new 1/1 second?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
243 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
244 btfsc trigger_half_second ; NO - new 1/2 second?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
245 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
246
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
247 ; tasks every round except every 1/1 or 1/2 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
248 IFDEF _compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
249 movlw index_compass_dm ; index of compass view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
250 cpfseq active_customview ; in compass view?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
251 bra diveloop_loop_11 ; NO - continue with tasks every round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
252 call TFT_dive_compass_heading ; YES - update compass heading value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
253 bsf FLAG_TFT_temperature ; - redraw temperature (will show resettable dive time now)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
254 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
255 bra diveloop_loop_11 ; - continue tasks every round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
256
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
257 diveloop_loop_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
258 ; tasks every 1/2 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
259 bcf trigger_half_second ; clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
260 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
261 bra diveloop_loop_11 ; YES - done with 1/2 second tasks
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
262 btfsc FLAG_apnoe_mode ; NO - in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
263 bra diveloop_loop_11 ; YES - done with 1/2 second tasks
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
264
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
265 ; tasks every 1/2 second in deco modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
266 call calc_deco_engine ; ##### calculate decompression #####
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
267 bra diveloop_loop_11 ; done with 1/2 second tasks
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
268
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
269 diveloop_loop_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
270 ; tasks every 1/1 second (code includes tasks every 1/2 second that fall onto the full second)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
271 bcf trigger_full_second ; clear flag for new 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
272 bcf trigger_half_second ; clear flag for new 1/2 second as well
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
273
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
274 btfss trigger_temp_changed ; has the temperature changed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
275 bra diveloop_loop_3 ; NO - continue with tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
276
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
277 bsf FLAG_TFT_temperature ; YES - display temperature
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
278 bcf trigger_temp_changed ; - clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
279
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
280 ; "future hardware will need min temperature checked every second..." (?)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
281
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
282 MOVII temperature_min,sub_a ; - copy last temperature_min to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
283 SMOVII temperature_cur,sub_b ; - ISR-safe 2 byte copy of current temperature to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
284 call sub16 ; - sub_c = sub_a - sub_b = temperature_min - temperature
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
285 btfsc neg_flag ; - temperature > temperature_min ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
286 bra diveloop_loop_3 ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
287 MOVII sub_b,temperature_min ; NO - store new minimum temperature
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
288
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
289 diveloop_loop_3:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
290 ; tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
291 btfss trigger_pres_cur_changed ; has the pressure changed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
292 bra diveloop_loop_4 ; NO - continue with tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
293
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
294 ; set flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
295 bcf trigger_pres_cur_changed ; clear flag for pressure change
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
296 bsf FLAG_TFT_depth_current ; set flag to display updated depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
297
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
298 ; cache new absolute and relative pressure, ISR-safe 2 byte copies
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
299 SMOVII pressure_abs, pressure_abs_cached
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
300 SMOVII pressure_rel_cur,pressure_rel_cur_cached
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
301
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
302 ; transfer absolute pressure to deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
303 MOVII pressure_abs_cached,int_I_pres_respiration
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
304
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
305 ; compute absolute pressure / 10, will be used later on a couple of times
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
306 MOVII pressure_abs_cached,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
307 MOVLI .10,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
308 call div16x16 ; xC = xA / xB = absolute pressure / 10
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
309 MOVII xC,pressure_abs_10 ; store result for later use
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
310
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
311 ; compute current depth in meters
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
312 MOVII pressure_rel_cur_cached,xA ; copy current relative pressure to xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
313 ADDLI .50, xA ; add 0.5 meter = 50 mbar for rounding up/down at 0.5 meters
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
314 MOVLI .100,xB ; divide by 100 to turn mbar into meters
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
315 call div16x16 ; xC = xA / xB = depth in full meters
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
316 movff xC+0,depth_meter ; store result in depth_meter, only LSB of result needed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
317
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
318 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
319 ; adjust auto-setpoint
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
320 btfsc FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
321 call check_dive_autosp ; YES - check for Auto-SP
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
322 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
323
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
324 ; check for new max pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
325 btfss trigger_pres_max_changed ; has the max pressure changed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
326 bra diveloop_loop_4 ; NO - continue with tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
327 bcf trigger_pres_max_changed ; YES - clear flag for new max pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
328 bsf FLAG_TFT_depth_maximum ; - set flag for displaying new max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
329 SMOVII pressure_rel_max,pressure_rel_max_cached ; - cache new max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
330
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
331 diveloop_loop_4:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
332 ; continue tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
333
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
334 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
335 btfsc FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
336 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
337 btfsc FLAG_pscr_mode ; in pSCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
338 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
339 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
340
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
341 btfsc FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
342 rcall divemode_apnoe_tasks ; YES - do 1 sec. apnoe tasks
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
343
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
344 ; display all animated (blinking) values at the beginning of each full second to have a stable timebase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
345 rcall TFT_output_1 ; do display updates
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
346
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
347 btfss FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
348 bra diveloop_loop_5 ; NO - continue with deco mode tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
349
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
350 ; apnoe mode tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
351 call dive_customview_second ; do every second tasks for the custom view area
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
352 bra diveloop_loop_10 ; continue with common tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
353
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
354 diveloop_loop_5:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
355 ; deco mode tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
356 bsf FLAG_TFT_divetime ; display (new) dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
357
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
358 rcall safety_stop_show ; serve safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
359
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
360 rcall TFT_output_2 ; do display updates
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
361
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
362 call divemode_check_warnings ; check for warnings
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
363
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
364 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
365 btfss tr_functions_activated ; TR functions activated?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
366 bra diveloop_loop_6 ; NO - continue with deco mode tasks every 1/2 second
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
367 call get_pressure_readings ; YES - get pressure readings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
368 call configure_sac_calculation ; - set up SAC calculation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
369 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
370
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
371 diveloop_loop_6:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
372 ; deco mode tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
373 INCI divesecs_avg_trip ; increment the resettable dive time
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
374 INCI divesecs_avg_total ; increment the total dive time
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
375
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
376 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
377 bra diveloop_loop_7 ; YES - skip deco calculations
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
378
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
379 call calc_deco_engine ; ##### calculate decompression #####
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
380
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
381 btfsc new_deco_data_avail ; new NDL or deco data available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
382 call show_new_deco_data ; YES - update the display and update the decostop_active flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
383
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
384 btfsc decostop_active ; in deco mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
385 bsf FLAG_TFT_display_deco ; YES - update deco stop depth & time every second because of depth-dependent color-coding
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
386
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
387 bsf FLAG_TFT_depth_current ; set flag to display depth (in next round, needed in deco modes irrespectively of a pressure change for color-coding and blinking effects)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
388
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
389 diveloop_loop_7:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
390 ; deco mode tasks alternating every 2 seconds on timebase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
391 btfss timebase_1sec ; on even second of timebase?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
392 rcall calc_velocity ; YES - calculate velocity and display if > threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
393 btfsc timebase_1sec ; on odd second of timebase?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
394 call check_gas_best ; YES - check if a better gas cue can be given
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
395
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
396 diveloop_loop_8:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
397 ; deco mode tasks alternating every 2 seconds on resettable dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
398 btfss divesecs_avg_trip+0,0 ; on even second of resettable dive time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
399 rcall calc_average_depth ; YES - calculate average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
400 btfsc divesecs_avg_trip+0,0 ; on odd second of resettable dive time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
401 rcall safety_stop_control ; YES - exercise safety stop control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
402
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
403 diveloop_loop_9:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
404 ; deco mode tasks every 1/1 second
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
405 rcall check_deco_states ; check and lock if in deco and in the deco stops region
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
406 rcall TFT_output_3 ; do display updates
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
407
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
408 diveloop_loop_10:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
409 ; common tasks every 1/1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
410 rcall timeout_divemode ; check for timeout condition
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
411 rcall check_dive_modes ; test if depth still deeper than threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
412
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
413 btfsc trigger_full_minute ; has next minute begun?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
414 rcall update_divemode60 ; YES - update clock, etc.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
415
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
416 btfss FLAG_oc_mode ; are we in OC mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
417 bsf FLAG_TFT_active_gas_divemode; NO - have the gas and setpoint redrawn on every second to update setpoint display, animate the blinking, etc.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
418
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
419 btfsc dive_main_menu ; dive mode menu shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
420 bsf update_menu ; YES - request update
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
421
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
422 rcall TFT_output_4 ; do display updates
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
423
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
424 ; tasks every round, every mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
425 diveloop_loop_11:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
426 call test_switches_divemode ; check switches in dive mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
427 bra diveloop_loop_12
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
428
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
429 global diveloop_menu_exit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
430 diveloop_menu_exit: ; jump-in from menu exit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
431 bsf FLAG_TFT_temperature ; restore temperature display or resettable dive time (was overwritten by menu)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
432
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
433 diveloop_loop_12:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
434 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
435
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
436 btfsc request_next_custview ; shall show next custom view?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
437 call dive_customview_toggle ; YES - show next custom view (and delete this flag)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
438
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
439 btfsc request_gaschange ; shall change gas?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
440 call gas_switched_common ; YES
0
heinrichsweikamp
parents:
diff changeset
441
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
442 btfsc request_toggle_GF ; shall toggle GF/aGF?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
443 rcall divemodemode_togglegf ; YES
0
heinrichsweikamp
parents:
diff changeset
444
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
445 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
446 btfsc request_turn_dive ; shall turn dive?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
447 rcall divemodemode_toggleturn ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
448 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
449
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
450 btfsc request_set_marker ; shall set a marker?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
451 call set_logbook_marker ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
452
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
453 btfsc trigger_sample_divedata ; shall store new sample of dive data?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
454 call store_dive_data ; YES - store profile data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
455
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
456 btfss divemode ; dive finished?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
457 goto ghostwriter_end_dive ; YES - dive finished
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
458
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
459 IFDEF _screendump
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
460 btfsc screen_dump_avail ; screen dump function enabled?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
461 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
462 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
463
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
464 bra diveloop_loop ; loop in dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
465
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
466 ;--------------------------------------------------------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
467
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
468 TFT_output_1: ; every second - before deco calculations, all mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
469 btfsc FLAG_TFT_clear_apnoe_surface ; shall clear apnoe mode surface data from screen?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
470 call TFT_clear_apnoe_surface ; YES - clear apnoe mode surface data from screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
471
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
472 btfsc FLAG_TFT_depth_current ; shall show depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
473 call TFT_show_depth ; YES - display depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
474 btfsc FLAG_TFT_depth_maximum ; shall show max depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
475 call TFT_show_max_depth ; YES - display max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
476 btfsc FLAG_TFT_active_gas_divemode ; shall show active gas and dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
477 call TFT_show_active_gas_divemode ; YES - display gas, setpoint and mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
478
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
479 btfsc FLAG_TFT_apnoe_surface_time ; shall show apnoe mode surface time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
480 call TFT_show_apnoe_surface ; YES - show apnoe mode surface time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
481 btfsc FLAG_TFT_depth_maximum_apnoe ; shall show max. depth of last dive?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
482 call TFT_show_apnoe_max_depth ; YES - show max. depth of last dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
483 btfsc FLAG_TFT_apnoe_divetime ; shall show apnoe dive time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
484 call TFT_show_apnoe_times ; YES - show apnoe dive time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
485
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
486 clrf TFT_output_flags_1 ; mark all TFT updates done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
487 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
488
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
489 TFT_output_2: ; every second - before deco calculations, deco modes only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
490 btfsc FLAG_TFT_divemode_mask ; shall re-draw mask?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
491 call TFT_show_divemode_mask ; YES - re-draw mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
492 btfsc FLAG_TFT_divetime ; shall show dive time?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
493 call TFT_show_divetime ; YES - show dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
494 btfsc FLAG_TFT_safety_stop_show ; shall show safety stop?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
495 call TFT_safety_stop_show ; YES - show safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
496 btfsc FLAG_TFT_safety_stop_clear ; shall clear safety stop?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
497 call TFT_safety_stop_clear ; YES - clear safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
498 btfsc FLAG_TFT_temperature ; shall show temperature?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
499 call TFT_show_temp_divemode ; YES - display temperature (or resettable dive time)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
500 clrf TFT_output_flags_2 ; mark all TFT updates done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
501 goto dive_customview_second ; do every-second tasks for the custom view area (in sync with the dive time) and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
502
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
503 TFT_output_3: ; every second - after deco calculations, deco modes only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
504 btfsc FLAG_TFT_clear_deco_data ; shall clear deco data (NDL or stop & TTS)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
505 call TFT_clear_deco_data ; YES - clear deco data (NDL or stop & TTS)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
506 btfsc FLAG_TFT_display_ndl_mask ; shall show NDL mask?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
507 call TFT_show_ndl_mask ; YES - show NDL mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
508 btfsc FLAG_TFT_display_ndl ; shall show NDL data?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
509 call TFT_show_ndl ; YES - show NDL data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
510 btfsc FLAG_TFT_display_deco_mask ; shall show deco mask?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
511 call TFT_show_deco_mask ; YES - show deco mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
512 btfsc FLAG_TFT_display_deco ; shall show deco stop?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
513 call TFT_show_deco ; YES - show deco stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
514 btfsc FLAG_TFT_display_tts ; shall show deco TTS?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
515 call TFT_show_tts ; YES - show deco TTS
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
516 clrf TFT_output_flags_3 ; mark all TFT updates done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
517 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
518
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
519 TFT_output_4: ; every second - after deco calculations, all modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
520 btfsc FLAG_TFT_customview_mask ; shall redraw the custom view mask?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
521 call dive_customview_mask ; YES - redraw custom view mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
522 btfsc FLAG_TFT_velocity_show ; shall show vertical velocity?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
523 call TFT_velocity_show ; YES - show vertical velocity?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
524 btfsc FLAG_TFT_velocity_clear ; shall clear vertical velocity?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
525 call TFT_velocity_clear ; YES - clear vertical velocity?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
526 btfsc FLAG_TFT_sign_show ; shall show the advice / attention / warning sign?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
527 call TFT_divemode_sign_show ; YES - show sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
528 btfsc FLAG_TFT_sign_clear ; shall clear the advice / attention / warning sign?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
529 call TFT_divemode_sign_clear ; YES - clear sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
530 btfsc FLAG_TFT_message_clear_both ; shall clear all messages?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
531 call TFT_clear_message_window ; YES - clear complete message area
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
532 btfsc FLAG_TFT_message_clear_2nd ; shall clear 2nd row of message area?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
533 call TFT_clear_message_window_row2 ; YES - clear 2nd row of message area
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
534 clrf TFT_output_flags_4 ; mark all TFT updates done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
535 return ; done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
536
0
heinrichsweikamp
parents:
diff changeset
537 ;--------------------------------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
538
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
539 divemode_apnoe_tasks: ; 1 sec. apnoe tasks
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
540 bsf FLAG_TFT_apnoe_divetime ; show apnoe dive times (current/last dive and total)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
541 btfsc apnoe_at_surface ; at the surface?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
542 bra divemode_apnoe_tasks_surf ; YES - at the surface
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
543 ;bra divemode_apnoe_tasks_dive ; NO - in dive phase
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
544
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
545 divemode_apnoe_tasks_dive: ; apnoe mode, submerged
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
546 btfss apnoe_new_dive ; new dive begun?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
547 return ; NO - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
548 bcf apnoe_new_dive ; YES - clear flag
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
549 bsf FLAG_TFT_clear_apnoe_surface ; - clear apnoe mode surface data from screen
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
550 return ; - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
551
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
552 divemode_apnoe_tasks_surf: ; apnoe mode, at the surface
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
553 bsf FLAG_TFT_apnoe_surface_time ; show apnoe mode surface time
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
554 ; TODO: these outputs would need to be done only once after surfacing...
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
555 bsf FLAG_TFT_depth_maximum_apnoe ; show max. depth of last dive
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
556 bsf FLAG_TFT_depth_maximum ; show max. depth of all dives
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
557 ;bra apnoe_calc_maxdepth ; calculate overall max. depth and return
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
558
0
heinrichsweikamp
parents:
diff changeset
559
heinrichsweikamp
parents:
diff changeset
560 global apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
561 apnoe_calc_maxdepth:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
562 MOVII apnoe_max_pressure, sub_a ; get max depth from all dives to far
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
563 MOVII pressure_rel_max_cached,sub_b ; get max depth of last dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
564 call cmpU16 ; sub_a - sub_b = apnoe_max_pressure - pressure_rel_max_cached
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
565 btfss neg_flag ; last dive deeper than all the others before?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
566 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
567 MOVII pressure_rel_max_cached,apnoe_max_pressure ; YES - store new overall max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
568 return ; - done
0
heinrichsweikamp
parents:
diff changeset
569
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
570 ; --------------------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
571
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
572 calc_deco_engine:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
573 ; check deco engine state and switch between normal and alternative plan calculations
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
574 ;
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
575 ; 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
576 ; 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
577 ; 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
578 ; or sensor, respectively.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
579 ; 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
580 ; are also changed to match the settings for the real tissues. This is done on signal through
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
581 ; 'request_gaschange' and will also leave the deco engine status in state as if having done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
582 ; the alternative plan last.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
583
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
584 ; 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
585 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
586 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
587
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
588 ; check state of deco calculations
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
589 btfsc lo,DECO_COMPLETED_NORM ; finished calculations for normal plan?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
590 bra calc_deco_engine_alt ; YES - do an alternative plan next (or a normal one with more features enabled)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
591 btfsc lo,DECO_COMPLETED_ALT ; finished calculations for alternative plan?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
592 bra calc_deco_engine_norm ; YES - do a normal plan next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
593 bra calc_deco_engine_cont ; NO to both - continue calculations / do first invocation in INIT mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
594
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
595 calc_deco_engine_norm:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
596 ; 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
597 ; --> Reconfigure to normal plan for next computation cycle.
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
598 bcf lo,DECO_COMPLETED_ALT ; clear flag indicating last plan was an alternative one
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
599 bsf lo,DECO_START_NORM ; set flag to calculate a normal deco plan next
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
600 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
601 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
602 bcf hi,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
603 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
604 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
605 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
606
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
607 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
608 btfsc FLAG_ccr_mode ; in CCR mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
609 bra calc_deco_engine_norm_loop ; YES - reload diluents and reconfigure CCR mode if not in bailout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
610 btfsc FLAG_pscr_mode ; in pSCR mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
611 bra calc_deco_engine_norm_loop ; YES - reload diluents and reconfigure pSCR mode if not in bailout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
612 ;bra calc_deco_engine_norm_OC ; neither in CCR nor pSCR mode, so reload OC gases and reconfigure OC mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
613 ; (first cycle omits gas needs calculation for faster first deco results)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
614 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
615
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
616 calc_deco_engine_norm_OC:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
617 movff active_gas,WREG ; get current OC gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
618 call deco_setup_oc_gases_pre ; set up deco calculations in OC mode with OC gases
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
619 bra calc_deco_engine_start ; start deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
620
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
621 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
622 calc_deco_engine_norm_loop: ; switch to loop calculation if not in a real bailout situation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
623 btfsc bailout_mode ; check if a real bailout situation is present
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
624 bra calc_deco_engine_norm_OC ; YES - revert to OC mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
625 ; NO - switch to loop calculation:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
626 movff active_dil,WREG ; - get current diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
627 call deco_setup_cc_diluents_pre ; - set up deco calculations in CCR/pSCR mode with diluents
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
628 bra calc_deco_engine_start ; - start deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
629 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
630
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
631 calc_deco_engine_alt:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
632 ; 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
633 ; 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
634 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
635 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
636 bcf hi,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
637 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
638 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
639 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
640
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
641 btfsc bailout_mode ; check if a real bailout situation is present
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
642 bra calc_deco_engine_alt_1 ; YES - stay in normal plan mode and preclude delayed ascent calculation
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
643 TSTOSS char_I_extra_time ; NO - check if a delayed ascent is enabled
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
644 bra calc_deco_engine_alt_1 ; NO - stay in normal plan mode and preclude delayed ascent calculation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
645 bcf lo,DECO_COMPLETED_NORM ; YES - clear flag indicating last plan was a normal one
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
646 bsf lo,DECO_START_ALT ; - set flag to calculate an alternative deco plan next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
647 bsf lo,DECO_ASCENT_FLAG ; - set flag for delayed ascent
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
648
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
649 calc_deco_engine_alt_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
650 TSTOSS opt_calc_asc_gasvolume ; check if gas volume calculation is enabled
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
651 bra calc_deco_engine_start ; NO - no volume calculation, no simulated bailout plan in this case
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
652 bsf hi,DECO_VOLUME_FLAG ; YES - set gas needs calculation flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
653
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
654 btfsc bailout_mode ; check if a real bailout situation is present
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
655 bra calc_deco_engine_start ; YES - normal plan already does bailout (OC) calculation "for real"
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 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
658 bsf hi,DECO_CAVE_MODE ; activate cave mode by default
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
659 btfss cave_mode ; cave mode switched on?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
660 bcf hi,DECO_CAVE_MODE ; NO - deactivate p2deco cave mode again
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
661 btfsc dive_turned ; dive turned?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
662 bcf hi,DECO_CAVE_MODE ; YES - deactivate p2deco cave mode again
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
663 btfsc FLAG_backtrack_full ; backtracking storage full?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
664 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
665 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
666
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
667 btfss lo,DECO_MODE_LOOP_FLAG ; NO - has a loop mode calculation been done during the normal plan?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
668 bra calc_deco_engine_start ; NO - when not in loop mode, no simulated bailout to be done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
669 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
670 btfsc WREG,7 ; - WREG < 128 (a bailout gas is available)?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
671 bra calc_deco_engine_alt_2 ; NO - no simulated bailout possible because no bailout gas available to switch to
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
672 bcf lo,DECO_COMPLETED_NORM ; YES - clear flag indicating last plan was a normal one
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
673 bsf lo,DECO_START_ALT ; - set flag to calculate an alternative deco plan next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
674 bsf lo,DECO_BAILOUT_FLAG ; - set flag for bailout mode (enables gas switches before 1st stop)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
675 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
676 call deco_setup_oc_gases_pre ; - set up deco calculations in OC mode with OC gases
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
677 bra calc_deco_engine_start ; - start in alternative plan mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
678
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
679 calc_deco_engine_alt_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
680 bcf lo,DECO_START_ALT ; clear flag to calculate an alternative deco plan next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
681 bsf lo,DECO_START_NORM ; set flag to calculate a normal deco plan next
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
682 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
683 bcf hi,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
684 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
685 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
686 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
687 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
688
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
689 calc_deco_engine_start:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
690 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
691 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface
0
heinrichsweikamp
parents:
diff changeset
692
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
693 calc_deco_engine_cont:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
694 ; +++++++++++++++++++++++++++++++++++++
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
695 call deco_calc_hauptroutine ; invoke the deco engine (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
696 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
697 ; +++++++++++++++++++++++++++++++++++++
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
698
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
699 call TFT_debug_output ; debug output of scheduling performance data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
700
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
701 ; check if new calculation results for normal plan mode are available
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
702 movff char_O_deco_status,WREG ; get deco status of deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
703 btfsc WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
704 bsf new_deco_data_avail ; YES - set flag for new NDL or deco data available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
705 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
706
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
707
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
708 show_new_deco_data:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
709 bcf new_deco_data_avail ; reset flag for new NDL or deco data available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
710 movff char_O_deco_info,WREG ; get the deco info vector
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
711 btfsc WREG,deco_stops ; deco stops found?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
712 bra show_new_deco_data_deco ; YES - in deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
713 ;bra show_new_deco_data_ndl ; NO - within NDL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
714
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
715 show_new_deco_data_ndl: ; within NDL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
716 btfsc decostop_active ; been in deco mode before?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
717 bsf FLAG_TFT_clear_deco_data ; YES - clear old deco data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
718 btfsc decostop_active ; been in deco mode before?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
719 bsf FLAG_TFT_display_ndl_mask ; YES - display NDL data mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
720 bcf decostop_active ; clear flag for been in deco mode before
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
721 bsf FLAG_TFT_display_ndl ; display NDL time
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
722 return
0
heinrichsweikamp
parents:
diff changeset
723
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
724 show_new_deco_data_deco: ; in deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
725 btfss decostop_active ; been in deco mode before?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
726 bsf FLAG_TFT_clear_deco_data ; NO - clear old deco data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
727 btfss decostop_active ; been in deco mode before?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
728 bsf FLAG_TFT_display_deco_mask ; NO - display deco data mask
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
729 bsf decostop_active ; set flag for being in deco mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
730 bsf FLAG_TFT_display_tts ; display TTS time (display or stop data is managed somewhere else)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
731 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
732
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
733 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
734
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
735 IFDEF _external_sensor
0
heinrichsweikamp
parents:
diff changeset
736
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
737 global calc_deko_divemode_sensor
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
738 calc_deko_divemode_sensor:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
739 ; sensor acquisition code
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
740 btfss s8_digital_avail ; do we have a digital S8 interface?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
741 bra calc_deko_divemode_sensor_analog ; NO - check if we have an analog interface
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
742 btfss trigger_S8_data_update ; YES - check if a new data frame was received
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
743 bra calc_deko_divemode_sensor_common ; NO - use old values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
744 bcf trigger_S8_data_update ; YES - clear update flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
745 call compute_mvolts_for_all_sensors ; - compute mV values from digital data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
746 bra calc_deko_divemode_sensor_common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
747 calc_deko_divemode_sensor_analog:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
748 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
749 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
750 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
751 bra calc_deko_divemode_sensor_common
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
752 calc_deko_divemode_sensor_opt:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
753 btfss optical_input ; do we have an optical input?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
754 return ; NO - return (we have no sensors at all: not analog, not S8 and not optical)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
755 btfss sensor1_active ; YES - sensor1_ppO2, sensor2_ppO2 and sensor3_ppO2 are already filled in ISR
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
756 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
757 btfss sensor2_active
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
758 bcf use_O2_sensor2
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
759 btfss sensor3_active
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
760 bcf use_O2_sensor3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
761 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
762
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
763 calc_deko_divemode_sensor_common:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
764 ; 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
765 ; 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
766 ; 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
767
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
768 ; check sensor 1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
769 btfss sensor1_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
770 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
771 ; check min threshold
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
772 SMOVII sensor1_mv,sub_a ; load sensor mV value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
773 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
774 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
775 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
776 ; check max_threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
777 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
778 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
779 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
780 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
781 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
782 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
783 btfss sensor1_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
784 bra check_sensor_1_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
785 check_sensor_1_ok:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
786 ; sensor1_ppO2 = sensor1_mv:2 * opt_x_s1:2 / 1000
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
787 SMOVII sensor1_mv,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
788 MOVII opt_x_s1, xB
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
789 rcall compute_ppo2_helper
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
790 movff xC+0,sensor1_ppO2 ; result in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
791 bra check_sensor_2 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
792 check_sensor_1_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
793 clrf WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
794 movff WREG,sensor1_ppO2 ; set ppO2 reading to zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
795 btfss use_O2_sensor1 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
796 bra check_sensor_1_fail_1 ; NO - no new news then
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
797 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
798 check_sensor_1_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
799 bcf use_O2_sensor1 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
800
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
801 check_sensor_2: ; check min_mv of sensor 2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
802 btfss sensor2_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
803 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
804 ; check min threshold
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
805 SMOVII sensor2_mv,sub_a ; load sensor mV value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
806 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
807 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
808 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
809 ; check max_threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
810 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
811 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
812 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
813 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
814 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
815 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
816 btfss sensor2_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
817 bra check_sensor_2_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
818 check_sensor_2_ok:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
819 ; sensor2_ppO2 = sensor2_mv:2 * opt_x_s2:2 / 1000
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
820 SMOVII sensor2_mv,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
821 MOVII opt_x_s2, xB
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
822 rcall compute_ppo2_helper
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
823 movff xC+0,sensor2_ppO2 ; result in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
824 bra check_sensor_3 ; continue with next sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
825 check_sensor_2_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
826 clrf WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
827 movff WREG,sensor2_ppO2 ; set ppO2 reading to zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
828 btfss use_O2_sensor2 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
829 bra check_sensor_2_fail_1 ; NO - no new news then
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
830 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
831 check_sensor_2_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
832 bcf use_O2_sensor2 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
833
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
834 check_sensor_3: ; check min_mv of sensor 2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
835 btfss sensor3_calibrated_ok ; check if sensor is usable at all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
836 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
837 ; check min threshold
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
838 SMOVII sensor3_mv,sub_a ; load sensor mV value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
839 rcall check_min_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
840 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
841 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
842 ; check max threshold
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
843 rcall check_max_threshold
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
844 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
845 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
846 ; check HUD data, if available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
847 btfss hud_connection_ok ; check if there is a HUD connected
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
848 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
849 btfss sensor3_active ; YES - HUD status ok?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
850 bra check_sensor_3_fail ; NO - HUD reports a fail
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
851 check_sensor_3_ok:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
852 ; sensor3_ppO2 = sensor3_mv:2 * opt_x_s1:2 / 1000
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
853 SMOVII sensor3_mv,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
854 MOVII opt_x_s3, xB
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
855 rcall compute_ppo2_helper
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
856 movff xC+0,sensor3_ppO2 ; result in 0.01 bar
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
857 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
858 check_sensor_3_fail:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
859 clrf WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
860 movff WREG,sensor3_ppO2 ; set ppO2 reading to zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
861 btfss use_O2_sensor3 ; check if sensor was in use before
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
862 bra check_sensor_3_fail_1 ; NO - no new news then
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
863 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
864 check_sensor_3_fail_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
865 bcf use_O2_sensor3 ; revoke sensor from usage
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
866
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
867 calc_deko_divemode_sensor_A: ; calculate sensor average
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
868 btfss divemode ; in dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
869 return ; NO - done here if not in dive mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
870
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
871 ; 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
872 ; sum up sensor values (in xA:2) and active sensors in (xB:2)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
873 CLRI xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
874 CLRI xB
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
875 divemode_setup_sensor_1_value:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
876 btfss use_O2_sensor1 ; sensor 1 active?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
877 bra divemode_setup_sensor_2_value ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
878 movff sensor1_ppO2,WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
879 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
880 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
881 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
882 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
883 divemode_setup_sensor_2_value:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
884 btfss use_O2_sensor2 ; sensor 2 active?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
885 bra divemode_setup_sensor_3_value ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
886 movff sensor2_ppO2,WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
887 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
888 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
889 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
890 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
891 divemode_setup_sensor_3_value:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
892 btfss use_O2_sensor3 ; sensor 3 active?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
893 bra divemode_setup_sensor_mean ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
894 movff sensor3_ppO2,WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
895 addwf xA+0,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
896 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
897 addwfc xA+1,F ; add into xA:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
898 incf xB+0,F ; add a sensor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
899
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
900 ; 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
901 divemode_setup_sensor_mean:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
902 clrf xC+0 ; set zero as default result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
903 tstfsz xB+0 ; pending div/0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
904 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
905 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
906
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
907 ; 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
908 ; will be overwritten later in case we are in sensor mode and have at least one usable sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
909 clrf WREG ; pre-load a zero
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
910 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
911 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
912 ; it will be overwritten if we have a usable sensor reading
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
913 btfsc bailout_mode ; check if we are in bailout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
914 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
915 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
916 sublw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
917 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
918 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
919 bra divemode_setup_sensor_mean1 ; YES - we have at least one usable sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
920 bsf sp_fallback ; NO - we have NO usable sensors -> initiate fallback
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
921 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
922 bra calc_deko_divemode_sensor_V ; NO - continue with voting logic flags
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
923 movff opt_setpoint_cbar+0,char_I_const_ppO2 ; YES - select fixed setpoint no. 1 for fallback
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
924 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
925 ; 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
926 divemode_setup_sensor_mean1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
927 bcf sp_fallback ; clear fallback condition
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
928 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
929 ; vote sensors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
930 calc_deko_divemode_sensor_V:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
931 bsf voting_logic_sensor1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
932 movff sensor1_ppO2,lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
933 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
934 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
935 bcf voting_logic_sensor1 ; NO - vote out this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
936
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
937 bsf voting_logic_sensor2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
938 movff sensor2_ppO2,lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
939 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
940 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
941 bcf voting_logic_sensor2 ; NO - vote out this sensor
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
942
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
943 bsf voting_logic_sensor3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
944 movff sensor3_ppO2,lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
945 rcall check_sensor_voting_helper
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
946 tstfsz WREG ; sensor within range (WREG = 0)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
947 bcf voting_logic_sensor3 ; NO - vote out this sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
948
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
949 ; check if a warning shall be issued on sensor disagreement
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
950 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
951 bra check_warn_sensor_0 ; YES - continue with further checks
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
952 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
953 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
954 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
955 check_warn_sensor_0: ; we are in CCR or pSCR mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
956 btfsc bailout_mode ; check if we are in bailout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
957 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
958 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
959 sublw .1 ; in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
960 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
961 ; check sensor 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
962 check_warn_sensor_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
963 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
964 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
965 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
966 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
967 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
968 bra check_warn_sensor_2 ; YES - continue with next sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
969 bcf o2_sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
970 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
971 ; check sensor 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
972 check_warn_sensor_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
973 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
974 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
975 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
976 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
977 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
978 bra check_warn_sensor_3 ; YES - continue with next sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
979 bcf o2_sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
980 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
981 ; check sensor 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
982 check_warn_sensor_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
983 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
984 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
985 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
986 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
987 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
988 bra check_warn_sensor_agree ; YES - continue with next sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
989 bcf o2_sensors_agree ; NO - issue a warning
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
990 return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
991 ; no need for a warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
992 check_warn_sensor_done:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
993 check_warn_sensor_agree:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
994 bsf o2_sensors_agree
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
995 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
996
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
997 check_min_threshold:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
998 MOVLI min_mv,sub_b ; load minimum mV value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
999 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
1000
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1001 check_max_threshold:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1002 MOVLI max_mv,sub_b ; load maximum mV value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1003 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
1004
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1005 compute_ppo2_helper:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1006 call mult16x16 ; xC:4 = xA:2 * xB:2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1007 MOVLI .1000,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1008 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1009 tstfsz xC+1 ; is the ppO2 higher than 2.55 bar?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1010 setf xC+0 ; YES - set result to 255 aka 2.55 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1011 return
0
heinrichsweikamp
parents:
diff changeset
1012
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1013 check_sensor_custview_helper:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1014 btfss divemode ; check if we are in dive mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1015 return ; NO - not in dive mode, return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1016 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
1017 decfsz WREG,W ; - opt_ccr_mode = 1 (sensors)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1018 return ; NO - not using the sensors in the moment
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1019 show_sensors_custview:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1020 movlw index_ppo2_sensors-1 ; YES - custom view number one below ppO2 sensors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1021 movwf active_customview ; - set custom view number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1022 bsf request_next_custview ; - initiate toggle to desired custom view -> ppO2 sensors
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1023 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1024
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1025 check_sensor_voting_helper:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1026 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1027 cpfsgt sensor_setpoint
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1028 bra check_sensor_voting_helper2 ; lo < sensor_setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1029 ; lo > sensor_setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1030 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1031 subwf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1032 movwf lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1033 check_sensor_voting_helper1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1034 movlw sensor_voting_logic_threshold ; threshold in 0.01 bar
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1035 cpfsgt lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1036 retlw .0 ; within range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1037 retlw .1 ; out of range
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1038 check_sensor_voting_helper2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1039 ; lo < sensor_setpoint
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1040 movf sensor_setpoint,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1041 subwf lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1042 bra check_sensor_voting_helper1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1043
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1044 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1045
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1046 ;=============================================================================
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1047
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1048 divemodemode_togglegf: ; toggle aGF/GF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1049 bcf request_toggle_GF ; clear request flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1050 btg use_aGF ; toggle normal / alternative GF factor selection
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1051 btfsc use_aGF ; alternative GF factors activated?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1052 bra divemodemode_togglegf_1 ; YES - branch to using aGF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1053 movff opt_GF_low, char_I_GF_Low_percentage ; NO - use normal GF factor low
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1054 movff opt_GF_high,char_I_GF_High_percentage ; - use normal GF factor high
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1055 bra divemodemode_togglegf_2 ; - continue with common part
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1056 divemodemode_togglegf_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1057 movff opt_aGF_low, char_I_GF_Low_percentage ; YES - use alternative GF factor low
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1058 movff opt_aGF_high,char_I_GF_High_percentage ; - use alternative GF factor high
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1059 divemodemode_togglegf_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1060 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
1061 ; the custom view itself has been called from divemenu_tree before
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1062 goto restart_deco_engine ; ...and return
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1063
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1064 ;=============================================================================
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1065
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1066 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1067
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1068 divemodemode_toggleturn:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1069 bcf request_turn_dive ; clear request flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1070 btg dive_turned ; toggle dive turned state
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1071 btfsc FLAG_backtrack_full ; backtracking storage full?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1072 bsf dive_turned ; YES - allow only activating turned state
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1073 goto set_logbook_marker ; set a logbook marker (and return)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1074
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1075 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1076
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1077 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1078
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1079 calc_velocity: ; called every two seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1080 btfsc velocity_active_num ; was velocity shown in last cycle?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1081 bra calc_velocity_1 ; YES - always update if shown before
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1082 btfss count_divetime ; NO - is the dive time counted, i.e. deeper than dive threshold?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1083 return ; NO - display velocity only if deeper than 1m,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1084 ; i.e. not at the surface after the dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1085 calc_velocity_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1086 ; calculate pressure difference
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1087 MOVII pressure_abs_cached, sub_a; current pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1088 MOVII last_pressure_velocity,sub_b; last pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1089 call subU16 ; do an unsigned subtraction
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1090
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1091 ; decide if ascending or descending
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1092 bcf neg_flag_velocity ; set to ascending by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1093 btfsc neg_flag ; pressure differential negative?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1094 bsf neg_flag_velocity ; YES - descending
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1095
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1096 ; store current pressure as last pressure for next round
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1097 MOVII pressure_abs_cached,last_pressure_velocity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1098
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1099 ; calculate velocity in m/min
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1100 MOVII sub_c,xA ; copy pressure differential to xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1101 MOVLI .39,xB ; put scale coefficient into xB (use 77 when called every second)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1102 call mult16x16 ; compute differential pressure in mbar * scale coefficient
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1103 MOVII xC,divA ; copy result to divA
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1104 ADDLI .64,divA ; add some round-up TODO: too sensitive with this?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1105 movlw .7 ; divide by 2^7
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1106 call div16 ; divA = divA / 2^WREG, yields velocity in m/min
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1107
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1108 movlw .99 ; load a 99
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1109 cpfslt divA+0 ; velocity < 99 m/min ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1110 movwf divA+0 ; NO - limit to 99 m/min
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1111
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1112 bcf STATUS,C ; clear carry flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1113 movlw velocity_display_threshold ; get threshold for displaying vertical velocity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1114 subwf divA+0,W ; subtract threshold from velocity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1115 btfss STATUS,C ; above threshold?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1116 bsf FLAG_TFT_velocity_clear ; NO - don't show / request to clear
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1117 btfsc STATUS,C ; above threshold?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1118 bsf FLAG_TFT_velocity_show ; YES - request to show
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1119 return ; done
0
heinrichsweikamp
parents:
diff changeset
1120
heinrichsweikamp
parents:
diff changeset
1121
heinrichsweikamp
parents:
diff changeset
1122 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1123
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1124 check_deco_states:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1125 btfsc deco_region ; been within the deco stops region before?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1126 return ; YES - been in deco then before too, done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1127 movff char_O_deco_info,WREG ; NO - get deco info vector
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1128 btfss WREG,deco_stops ; do we have a deco obligation right now?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1129 return ; NO - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1130 bsf deco_locked ; YES - memorize dive was in deco
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1131 movff char_O_deco_depth+0,WREG ; - get depth of first stop in meters into WREG
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1132 addlw deco_region_distance+.1 ; - add deco region start distance + 1 meter for the negative test to work
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1133 subwf depth_meter,W ; - compute current depth - (first stop depth + deco distance)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1134 btfss STATUS,C ; - result negative?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1135 bsf deco_region ; YES - memorize to have entered the deco stops region
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1136 return ; - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1137
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1138 ;=============================================================================
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1139
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1140 safety_stop_control:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1141 TSTOSS opt_enable_safetystop ; safety stop enabled? (=1: show safety stop)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1142 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1143
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1144 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1145 return ; YES - omit (well, else fix collision of safety stop output with avg depth label)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1146
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1147 ; setup
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1148 bcf safety_stop_enabled ; disable safety stop by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1149
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1150 ; check for deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1151 btfsc decostop_active ; in deco mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1152 bra safety_stop_finish ; YES - shut down safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1153
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1154 ; below "opt_safety_stop_reset"?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1155 MOVII pressure_rel_cur_cached,mpr ; get current depth into hi:lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1156 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1157 MOVII mpr,sub_a ; move adjusted depth to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1158 movff opt_safety_stop_reset,WREG ; load safety stop reset threshold [cbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1159 mullw .10 ; convert threshold from [cbar] to [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1160 MOVII PROD,sub_b ; move threshold to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1161 call cmpU16 ; sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1162 btfss neg_flag ; below threshold depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1163 bra safety_stop_reset ; YES - arm safety stop and delete it from display if still shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1164
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1165 ; above "opt_safety_stop_end"?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1166 movff opt_safety_stop_end,WREG ; load safety stop end threshold [cbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1167 mullw .10 ; convert threshold from [cbar] to [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1168 MOVII PROD,sub_b ; move threshold to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1169 call cmpU16 ; sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1170 btfsc neg_flag ; above or at threshold depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1171 bra safety_stop_finish ; YES - finish with safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1172
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1173 ; above "opt_safety_stop_start"?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1174 movff opt_safety_stop_start,WREG ; load safety stop start threshold [cbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1175 mullw .10 ; convert threshold from [cbar] to [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1176 MOVII PROD,sub_b ; move threshold to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1177 call cmpU16 ; sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1178 btfss neg_flag ; above or at threshold depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1179 return ; NO - pause safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1180 tstfsz safety_stop_countdown ; YES - safety stop armed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1181 bsf safety_stop_enabled ; YES - enable safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1182 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1183
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1184 safety_stop_show:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1185 btfss safety_stop_enabled ; safety stop enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1186 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1187 dcfsnz safety_stop_countdown,F ; YES - decrement remaining stop time, reached zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1188 bra safety_stop_finish ; YES - finished with safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1189 bsf FLAG_TFT_safety_stop_show ; NO - request to show safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1190 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1191
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1192 safety_stop_finish:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1193 clrf safety_stop_countdown ; disarm safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1194 bcf safety_stop_enabled ; disable safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1195 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1196 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1197
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1198 safety_stop_reset:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1199 movff opt_safety_stop_length,safety_stop_countdown ; arm safety stop (load timer)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1200 incf safety_stop_countdown,F ; +1 because safety_stop_show does decrement first
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1201 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1202 return ; done
428
eccae727702f some cleanup
heinrichsweikamp
parents: 403
diff changeset
1203
104
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1204
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1205 ;=============================================================================
223579e905c3 Show a Safety Stop if enabled (Menu "Deco Parameters")
heinrichsweikamp
parents: 102
diff changeset
1206
0
heinrichsweikamp
parents:
diff changeset
1207 timeout_menuview:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1208 btfss trigger_timeout ; timeout occurred?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1209 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1210 goto menuview_toggle_reset ; YES - terminate the pre-menu and return
0
heinrichsweikamp
parents:
diff changeset
1211
heinrichsweikamp
parents:
diff changeset
1212 timeout_divemode_menu:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1213 btfss trigger_timeout ; timeout occurred?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1214 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1215 ;bra timeout_divemode_menu2 ; YES - clean up main menu and restore dive data
0
heinrichsweikamp
parents:
diff changeset
1216
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1217 global timeout_divemode_menu2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1218 timeout_divemode_menu2: ; called from divemenu_tree.asm
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1219 bcf dive_main_menu ; timeout, clear flag for dive mode menu shown
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1220 call TFT_clear_divemode_menu ; clear menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1221 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1222 bcf better_gas_blinking ; clear flag to have temperature updated once
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1223 bcf better_dil_blinking ; clear flag to have temperature updated once
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1224 bsf FLAG_TFT_temperature ; display temperature (or resettable dive time when in compass view)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1225
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1226 request_redraw_NDL_deco_data:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1227 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1228 return ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1229 btfss decostop_active ; NO - in deco mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1230 bra timeout_divemode_menu_ndl ; NO - show NDL again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1231 ;bra timeout_divemode_menu_deco ; YES - show deco again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1232
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1233 timeout_divemode_menu_deco:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1234 bsf FLAG_TFT_display_deco_mask ; show deco mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1235 bsf FLAG_TFT_display_deco ; show deco stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1236 bsf FLAG_TFT_display_tts ; show TTS time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1237 return ; done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1238
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1239 timeout_divemode_menu_ndl:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1240 bsf FLAG_TFT_display_ndl_mask ; show NDL mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1241 bsf FLAG_TFT_display_ndl ; show NDL time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1242 return ; done
0
heinrichsweikamp
parents:
diff changeset
1243
heinrichsweikamp
parents:
diff changeset
1244 timeout_divemode:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1245 btfsc dive_main_menu ; main dive menu shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1246 rcall timeout_divemode_menu ; YES - check the timeout for it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1247
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1248 btfsc dive_options_menu ; pre-menu shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1249 rcall timeout_menuview ; YES - check the timeout for it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1250
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1251 btfss divetime_longer_1min ; does dive already last for longer than one minute?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1252 return ; NO - suspend timeout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1253
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1254 btfsc FLAG_apnoe_mode ; in apnoe mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1255 bra timeout_divemode_apnoe ; YES - use apnoe timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1256
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1257 IFNDEF _DEBUG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1258 btfsc sensor_override_active ; in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1259 bra timeout_divemode_sim ; YES - use simulator timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1260 ;bra timeout_divemode_dive ; NO - use normal dive timeout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1261 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1262
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1263 timeout_divemode_dive:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1264 movff opt_diveTimeout,WREG ; get dive timeout in minutes into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1265 ;bra timeout_divemode_com_min
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1266
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1267 timeout_divemode_com_min:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1268 mullw .60 ; multiply with 60 to convert minutes in WREG to seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1269 MOVII PRODL,sub_a ; copy resulting seconds to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1270 timeout_divemode_com_sec:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1271 MOVII dive_timeout_timer,sub_b ; copy current timeout timer value to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1272 INCI dive_timeout_timer ; increment timeout timer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1273 call cmpU16 ; check sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1274 btfsc neg_flag ; result negative, i.e. timeout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1275 bcf divemode ; YES - terminate dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1276 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1277
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1278 timeout_divemode_apnoe:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1279 movlw apnoe_timeout ; get apnoe timeout in minutes into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1280 bra timeout_divemode_com_min ; continue with common part for minutes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1281
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1282 timeout_divemode_sim:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1283 MOVLI simulator_timeout,sub_a ; get simulator timeout in seconds directly into sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1284 bra timeout_divemode_com_sec ; continue with common part for seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1285
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1286
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1287 update_divemode60: ; tasks every full minute
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1288 bcf trigger_full_minute ; clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1289 call get_battery_voltage ; get battery voltage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1290 rcall set_powersafe ; check if battery is low
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1291 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1292 movlw .1 ; prepare to add backtrack data for 1 minute
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1293 btfsc cave_mode ; cave mode switched on?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1294 rcall update_backtrack ; YES - store backtracking data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1295 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1296 btfss sensor_override_active ; in simulator mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1297 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1298 movlw .20 ; YES - quite dive mode simulation after 21 * 256 sec = 89 min : 36 sec
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1299 cpfsgt total_divetime_secs+1 ; - timeout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1300 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1301 IFDEF _DEBUG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1302 return ; YES - but no timeout in debug mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1303 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1304 bra divemode_option1 ; YES - set depth to 0 m and "return"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1305
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1306 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1307
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1308 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1309
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1310 update_backtrack:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1311 btfsc dive_turned ; dive turned?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1312 return ; YES - done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1313 btfsc FLAG_backtrack_full ; NO - backtracking storage full?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1314 return ; YES - done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1315 movwf lo ; NO - store minutes to add in lo
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1316 lfsr FSR1,char_I_backtrack_depth ; - load FSR1 with base address of backtrack storage
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1317 movff char_I_backtrack_time,FSR1L ; - adjust FSR1 to last index
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1318 update_backtrack_loop:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1319 movff depth_meter,PREINC1 ; increment index and write current depth to backtrack storage
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1320 incfsz FSR1L,W ; increment index once more and dump to WREG, did a wrap-around occur (backtrack storage full)?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1321 bra update_backtrack_loop_1 ; NO - continue loop
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1322 bsf FLAG_backtrack_full ; YES - flag backtracking storage is full
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1323 return ; - done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1324 update_backtrack_loop_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1325 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
1326 bra update_backtrack_loop ; NO - loop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1327 movff FSR1L,char_I_backtrack_time ; YES - store updated index
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1328 return ; - done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1329
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1330 ENDIF
0
heinrichsweikamp
parents:
diff changeset
1331
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1332 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
1333
heinrichsweikamp
parents:
diff changeset
1334 global set_dive_modes
heinrichsweikamp
parents:
diff changeset
1335 set_dive_modes:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1336 SMOVII pressure_rel_cur,sub_a ; ISR-safe 2 byte copy of current relative pressure to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1337 bra set_dive_modes_1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1338 check_dive_modes:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1339 MOVII pressure_rel_cur_cached,sub_a; copy cached relative pressure to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1340 set_dive_modes_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1341 btfss high_altitude_mode ; in high altitude mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1342 bra set_dive_modes_norm ; NO - use normal start-dive threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1343 btfsc divetime_longer_1min ; YES - dive lasted longer than one minute?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1344 bra set_dive_modes_norm ; YES - this is a real dive -> use normal start-dive threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1345 ;bra set_dive_modes_high ; NO - use hight-altitude start-dive threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1346
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1347 ; high altitude start/end dive thresholds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1348 set_dive_modes_high:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1349 btfss count_divetime ; dive time counting, i.e. already in the dive?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1350 bra set_dive_modes_high_start ; NO - select start threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1351 ;bra set_dive_modes_high_end ; YES - select end threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1352
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1353 set_dive_modes_high_end:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1354 MOVLI dive_threshold_high_alt_end,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1355 bra set_dive_modes_comm
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1356
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1357 set_dive_modes_high_start:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1358 MOVLI dive_threshold_high_alt_start,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1359 bra set_dive_modes_comm
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1360
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1361 ; normal altitude start/end dive thresholds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1362 set_dive_modes_norm:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1363 btfss count_divetime ; dive time counting, i.e. already in the dive?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1364 bra set_dive_modes_norm_start ; NO - select start threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1365 ;bra set_dive_modes_norm_end ; YES - select end threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1366
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1367 set_dive_modes_norm_end:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1368 MOVLI dive_threshold_norm_alt_end,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1369 bra set_dive_modes_comm
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1370
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1371 set_dive_modes_norm_start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1372 MOVLI dive_threshold_norm_alt_start,sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1373 ;bra set_dive_modes_comm
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1374
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1375 set_dive_modes_comm:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1376 call cmpU16 ; sub_a - sub_b = pressure_rel_cur - start-dive threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1377 btfsc neg_flag ; pressure_rel_cur > dive_threshold, i.e. deeper than threshold?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1378 bra set_dive_modes_shallow ; NO - shallower than threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1379 btfsc divetime_longer_1min ; YES - dive lasted longer than one minute?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1380 CLRI dive_timeout_timer ; YES - reset timeout counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1381 bsf divemode ; - set dive mode flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1382 bsf count_divetime ; - count dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1383 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1384 set_dive_modes_shallow:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1385 bcf count_divetime ; NO - stop counting dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1386 btfss divetime_longer_1min ; - dive lasted longer than one minute?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1387 bcf divemode ; NO - quit dive mode as this was no real dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1388 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1389
0
heinrichsweikamp
parents:
diff changeset
1390
heinrichsweikamp
parents:
diff changeset
1391 set_powersafe:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1392 movlw battery_warn_level_36+1 ; get threshold for 3.6 Volt battery warning, incremented by 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1393 btfss battery_is_36v ; actually a 3.6 Volt battery detected?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1394 movlw battery_warn_level_15+1 ; NO - replace with 1.5 Volt battery warning, incremented by 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1395 cpfslt batt_percent ; current battery level > warning threshold ?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1396 return ; YES - ok, done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1397 movlw d'7' ; NO - set type of alarm = battery low
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1398 movwf alarm_type ; - copy to alarm register
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1399 bsf event_occured ; - set event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1400 movlw .0 ; - coding of brightness level ECO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1401 movff WREG,opt_brightness ; - set brightness to ECO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1402 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1403
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1404
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1405 clear_resettable_average_depth:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1406 ; prime the resettable average depth with 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1407 CLRI pressure_rel_avg_trip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1408 bra reset_resettable_average_depth1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1409
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1410 reset_resettable_average_depth:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1411 ; clear reset-average request
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1412 bcf request_reset_avg
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1413
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1414 ; prime the resettable average depth with the current relative pressure (depth)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1415 MOVII pressure_rel_cur_cached,pressure_rel_avg_trip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1416
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1417 reset_resettable_average_depth1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1418 ; clear the resettable depth accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1419 clrf pressure_rel_accu_trip+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1420 clrf pressure_rel_accu_trip+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1421 clrf pressure_rel_accu_trip+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1422 clrf pressure_rel_accu_trip+3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1423
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1424 ; clear the resettable time accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1425 CLRI divesecs_avg_trip
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1426 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1427
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1428
0
heinrichsweikamp
parents:
diff changeset
1429 calc_average_depth:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1430 ; 1. compute pressure_rel_cur_cached x 2, because this routine is called every 2nd second only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1431
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1432 ; copy current rel pressure to xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1433 MOVII pressure_rel_cur_cached,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1434
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1435 ; multiply rel pressure x 2 (via shift left)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1436 bcf STATUS,C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1437 rlcf xB+0,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1438 rlcf xB+1,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1439
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1440 ; 2a add (pressure_rel_cur_cached x 2) to the resettable depth accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1441 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1442 movf xB+0,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1443 addwf pressure_rel_accu_trip+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1444 movf xB+1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1445 addwfc pressure_rel_accu_trip+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1446 movlw .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1447 addwfc pressure_rel_accu_trip+2,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1448 addwfc pressure_rel_accu_trip+3,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1449
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1450 ; 2b add (pressure_rel_cur_cached x 2) to the total depth accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1451 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1452 movf xB+0,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1453 addwf pressure_rel_accu_total+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1454 movf xB+1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1455 addwfc pressure_rel_accu_total+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1456 movlw .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1457 addwfc pressure_rel_accu_total+2,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1458 addwfc pressure_rel_accu_total+3,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1459
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1460 ; 3a compute the resettable average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1461
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1462 ; get the accumulated depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1463 movff pressure_rel_accu_trip+0,xC+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1464 movff pressure_rel_accu_trip+1,xC+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1465 movff pressure_rel_accu_trip+2,xC+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1466 movff pressure_rel_accu_trip+3,xC+3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1467
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1468 ; get the accumulated time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1469 MOVII divesecs_avg_trip,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1470
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1471 ; divide accumulated depth by accumulated time
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1472 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1473
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1474 ; store result
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1475 MOVII xC,pressure_rel_avg_trip ; resettable average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1476 btfss count_divetime ; is dive time counted?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1477 return ; NO (e.g. too shallow)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1478
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1479 ; 3b compute the dive total average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1480
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1481 ; get accumulated depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1482 movff pressure_rel_accu_total+0,xC+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1483 movff pressure_rel_accu_total+1,xC+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1484 movff pressure_rel_accu_total+2,xC+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1485 movff pressure_rel_accu_total+3,xC+3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1486
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1487 ; get accumulated time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1488 MOVII divesecs_avg_total,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1489
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1490 ; divide accumulated depth by accumulated time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1491 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1492
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1493 ; store result
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1494 MOVII xC,pressure_rel_avg_total ; total dive average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1495
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1496 btfsc request_reset_avg ; shall reset the resettable average depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1497 rcall reset_resettable_average_depth ; YES - reset the resettable average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1498
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1499 TSTOSC opt_2ndDepthDisp ; drawing average depth instead of max depth?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1500 bsf FLAG_TFT_depth_maximum ; YES - flag to update display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1501
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1502 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1503 bsf FLAG_TFT_depth_maximum ; YES - flag to update display (needed for alternative layout)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1504
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1505 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1506
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1507
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1508 test_switches_divemode: ; checks switches in dive mode, called every second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1509 btfsc dive_main_menu ; dive mode menu shown?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1510 bra test_switches_divemode_menu ; YES - use menu processor
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1511 btfsc switch_left ; NO - left button pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1512 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
1513 btfss switch_right ; NO - right button pressed?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1514 return ; NO - done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1515 bcf switch_right ; YES - clear button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1516 tstfsz active_premenu ; - any pre-menu task selected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1517 bra test_switches_divemode1 ; YES - do option or menu tasks
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1518 bsf request_next_custview ; NO - request next custom view
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1519 return ; - done
0
heinrichsweikamp
parents:
diff changeset
1520
heinrichsweikamp
parents:
diff changeset
1521 test_switches_divemode_menu:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1522 btfsc switch_left ; left button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1523 bra test_switches_divemode_menu2 ; YES - move cursor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1524 btfsc switch_right ; NO - right button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1525 bra test_switches_divemode_menu3 ; YES - enter sub-menu or do something
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1526 btfss update_menu ; NO - shall update the menu?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1527 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1528 bcf update_menu ; YES - clear request
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1529 goto menu_draw_lines_divemode ; - redraw the menu (to update color coding) and return
0
heinrichsweikamp
parents:
diff changeset
1530
heinrichsweikamp
parents:
diff changeset
1531 test_switches_divemode_menu1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1532 clrf menu_pos_cur
0
heinrichsweikamp
parents:
diff changeset
1533 test_switches_divemode_menu2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1534 bcf switch_left
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1535 incf menu_pos_cur,F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1536 incf menu_pos_max,W ; menu_pos_max + 1 -> WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1537 cpfslt menu_pos_cur ; > menu_pos_max ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1538 bra test_switches_divemode_menu1 ; YES - set to 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1539 call TFT_show_menu_cursor_divemode ; update the cursor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1540 movlw divemode_timeout_mainmenu ; get timeout for main menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1541 call reset_timeout_time ; reset timeout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1542 return
0
heinrichsweikamp
parents:
diff changeset
1543
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1544 test_switches_divemode_menu3: ; enter sub-menu or do something
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1545 bcf switch_right
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1546 ; decf menu_pos_cur,F ; menu_processor needs 0-5...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1547 goto do_line_menu ; Warning! trashes STKPTR and returns to diveloop_menu_exit
0
heinrichsweikamp
parents:
diff changeset
1548
heinrichsweikamp
parents:
diff changeset
1549 test_switches_divemode1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1550 movlw divemode_timeout_premenu ; get timeout for pre-menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1551 call reset_timeout_time ; reset timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1552 movff active_premenu,WREG ; get number of active pre-menu
0
heinrichsweikamp
parents:
diff changeset
1553 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1554 bra divemode_option_gaschange ; switch to the the "better gas" / "better diluent"
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1555 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1556 bra divemode_option0 ; start/setup dive mode menu
0
heinrichsweikamp
parents:
diff changeset
1557 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1558 bra divemode_option1 ; quit simulation?
0
heinrichsweikamp
parents:
diff changeset
1559 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1560 bra divemode_option2 ; descent 1m
0
heinrichsweikamp
parents:
diff changeset
1561 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1562 bra divemode_option3 ; ascend 1m
0
heinrichsweikamp
parents:
diff changeset
1563 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1564 bra divemode_option4 ; quit apnoe mode
0
heinrichsweikamp
parents:
diff changeset
1565 dcfsnz WREG,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1566 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
1567 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1568 bra divemode_option6 ; +5 min simulation
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1569 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1570 IFDEF _compass
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1571 bra divemode_option7 ; store heading
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1572 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1573 return ; should never happen without compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1574 ENDIF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1575 dcfsnz WREG,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1576 bra divemode_option8 ; switch layout
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1577 return
0
heinrichsweikamp
parents:
diff changeset
1578
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1579
0
heinrichsweikamp
parents:
diff changeset
1580 gas_switched_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1581 bcf request_gaschange ; clear request flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1582 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1583 btfss request_back_to_loop ; is a switchback from OC bailout to loop requested?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1584 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1585 bcf request_back_to_loop ; YES - clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1586 movff active_dil,menu_pos_cur ; - reload last diluent
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1587 bra gas_switched_common1 ; - continue with common part
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1588 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1589 gas_switched_common0:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1590 tstfsz menu_pos_cur ; menu_pos_cur = 0 ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1591 bra gas_switched_common1 ; NO - valid gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1592 return ; YES - something went wrong, invalid gas, abort
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1593 gas_switched_common1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1594 movf menu_pos_cur,W ; get selected gas into WREG (1-6)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1595 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1596 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1597 bra gas_switched_common_OC ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1598 btfsc bailout_mode ; in bailout?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1599 bra gas_switched_common_OC ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1600 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
1601 rcall setup_dil_registers ; with WREG = diluent 1-6
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1602 rcall deco_setup_cc_diluents ; with WREG = diluent 1-6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1603 bra gas_switched_common3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1604 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1605 gas_switched_common_OC:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1606 rcall setup_gas_registers ; with WREG = Gas 1-6
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1607 rcall deco_setup_oc_gases ; with WREG = Gas 1-6
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1608 gas_switched_common3:
605
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1609 banksel int_O_breathed_ppO2
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1610 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
1611 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
1612 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
1613 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
1614 banksel common
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1615 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent
5ce603c29750 gas color coding fixed
heinrichsweikamp
parents: 604
diff changeset
1616 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
1617 ; set flags for profile recording
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1618 bsf event_occured ; set global event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1619 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1620 btfsc bailout_mode ; in bailout mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1621 bsf event_bailout ; YES - set gas change event due to bailout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1622 btfss bailout_mode ; in bailout mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1623 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1624 bsf event_gas_change ; NO - set gas change event (normal change)
0
heinrichsweikamp
parents:
diff changeset
1625 return
heinrichsweikamp
parents:
diff changeset
1626
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1627
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1628 ; Code to pass all parameters to the C code
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1629
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1630 global get_first_gas_to_WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1631 get_first_gas_to_WREG: ; gets first gas (1-5) into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1632 lfsr FSR1,opt_gas_type ; load base address of the gas types
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1633 clrf lo ; start with gas 0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1634 get_first_gas_to_WREG2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1635 movf lo,W ; set index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1636 movf PLUSW1,W ; get type of gas (0=Disabled, 1=First, 2=Travel, 3=Deco)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1637 sublw .1 ; is it of type First?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1638 bz get_first_gas_to_WREG3 ; YES - found the First gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1639 incf lo,F ; NO - increment index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1640 movlw NUM_GAS+1 ; - get highest index+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1641 cpfseq lo ; - all gases checked?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1642 bra get_first_gas_to_WREG2 ; NO - not yet
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1643 movlw .1 ; YES - default to gas 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1644 movff WREG,opt_gas_type+0 ; - force it to be of type First
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1645 return ; - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1646 get_first_gas_to_WREG3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1647 movf lo,W ; copy index of gas found to be the First to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1648 incf WREG,W ; turn index into gas number (0-4 -> 1-5)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1649 return ; done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1650
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1651 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1652
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1653 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1654
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1655 global get_first_dil_to_WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1656 get_first_dil_to_WREG: ; gets first dil (1-5) into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1657 lfsr FSR1,opt_dil_type ; load base address of the dil types
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1658 clrf lo ; start with dil 0
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1659 get_first_dil_to_WREG2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1660 movf lo,W ; set index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1661 movf PLUSW1,W ; get type of Dil (0=Disabled, 1=First, 2=Normal)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1662 sublw .1 ; is it of type First?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1663 bz get_first_dil_to_WREG3 ; YES - found the First dil
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1664 incf lo,F ; NO - increment index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1665 movlw NUM_GAS+1 ; - get highest index+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1666 cpfseq lo ; - dils checked?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1667 bra get_first_dil_to_WREG2 ; NO - not yet
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1668 movlw .1 ; YES - default to dil 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1669 movff WREG,opt_dil_type+0 ; - force it to be of type First
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1670 return ; - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1671 get_first_dil_to_WREG3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1672 movf lo,W ; copy index of dil found to be the First to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1673 incf WREG,W ; turn index into dil number (0-4 -> 1-5)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1674 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1675
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1676 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1677
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1678 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1679
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1680 global deco_setup_oc_gases
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1681 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
1682 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
1683 deco_setup_oc_gases_pre: ; entry point with lo preloaded
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1684 movff WREG,char_I_current_gas_num ; set gas to start with when doing the deco calculations
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1685 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1686 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1687 ; ---------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1688 ; 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
1689 ; opt_dil_O2_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1690 ; 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
1691 ; opt_dil_He_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1692 ; 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
1693 ; opt_dil_type res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1694 ; 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
1695 ; opt_dil_change res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1696 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1697 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1698 ; FSR2 will step through all char_I_deco_... vars
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1699 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
1700 rcall deco_setup_copy ; copy all OC O2 ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1701 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
1702 rcall deco_setup_copy ; copy all OC He ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1703 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
1704 rcall deco_setup_copy ; copy all gas types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1705 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
1706 rcall deco_setup_copy ; copy all gas change depths
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1707 ; switch to oc mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1708 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
1709 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1710 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
1711 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1712
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1713 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1714
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1715 IFDEF _ccr_pscr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1716
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1717 global deco_setup_cc_diluents
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1718 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
1719 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
1720 deco_setup_cc_diluents_pre: ; entry point with lo preloaded
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1721 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY --------------
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1722 bra deco_setup_oc_gases_pre ; YES - revert to setting up OC gases | This branch should never happen to be taken...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1723 movff WREG,char_I_current_gas_num ; NO - set diluent to start with when doing the deco calculations
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1724 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1725 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1726 ; ---------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1727 ; opt_gas_O2_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1728 ; 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
1729 ; opt_gas_He_ratio res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1730 ; 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
1731 ; opt_gas_type res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1732 ; 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
1733 ; opt_gas_change res NUM_GAS |
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1734 ; 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
1735 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1736 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio.
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1737 ; FSR2 will step through all char_I_deco_... vars.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1738 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
1739 rcall deco_setup_copy ; copy all dil O2 ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1740 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
1741 rcall deco_setup_copy ; copy all dil He ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1742 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
1743 rcall deco_setup_copy ; copy all dil types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1744 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
1745 rcall deco_setup_copy ; copy all dil change depths
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1746 ; switch to CCR / pSCR mode
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1747 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
1748 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1749 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1750 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
1751 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
1752 return
0
heinrichsweikamp
parents:
diff changeset
1753
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1754 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1755
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1756 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1757
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1758 deco_setup_copy:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1759 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
1760 deco_setup_copy_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1761 movff POSTINC1,POSTINC2 ; copy from (FSR1) to (FSR2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1762 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
1763 bra deco_setup_copy_loop ; NO - not yet, loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1764 return ; YES - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1765
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1766
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1767 global setup_gas_registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1768 setup_gas_registers: ; with currently breathed gas in WREG (1-5 or 6)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1769 movwf active_gas ; set as current gas
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1770 movlw .6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1771 cpfseq active_gas ; gas = gas6 ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1772 bra setup_gas_registers_15 ; NO - load gas 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1773 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1774 IFDEF _helium
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1775 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1776 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1777 movlw .3 ; declare gas6 as a deco gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1778 movff WREG,char_I_current_gas_type; copy gas type to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1779 movff depth_meter,char_I_gas6_depth;set current depth as change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1780 bra setup_gas_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1781 setup_gas_registers_15:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1782 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1783 decf active_gas,W ; set index to O2 ratio of current gas (1-5 -> 0-4)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1784 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1785 addlw .10 ; advance index from O2 ratio to He ratio
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1786 IFDEF _helium
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1787 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1788 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1789 addlw .10 ; advance index from He ratio to gas type
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1790 movff PLUSW1,char_I_current_gas_type ; copy gas type (0=Disabled, 1=First, 2=Travel, 3=Deco)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1791 setup_gas_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1792 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
1793 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
1794 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1795 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
1796 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
1797 return
137
28b057aa9f75 Simplify gas change
heinrichsweikamp
parents: 134
diff changeset
1798
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1799 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1800
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1801 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1802
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1803 global setup_dil_registers
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1804 setup_dil_registers: ; with currently breathed gas in WREG (1-5 or 6)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1805 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY --------------
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1806 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
1807 movwf active_dil ; set as current diluent
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1808 movlw .6
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1809 cpfseq active_dil ; diluent = gas6 ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1810 bra setup_dil_registers_15 ; NO - load diluent 1-5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1811 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1812 IFDEF _helium
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1813 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1814 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1815 movlw .2 ; declare gas6 as a normal diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1816 movff WREG,char_I_current_gas_type; copy gas type to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1817 movff depth_meter,char_I_gas6_depth;set current depth as change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1818 bra setup_dil_registers_com ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1819 setup_dil_registers_15:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1820 lfsr FSR1,opt_dil_O2_ratio ; load base address of diluent data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1821 decf active_dil,W ; set index to O2 ratio of current diluent (1-5 -> 0-4)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1822 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1823 addlw .10 ; advance index from O2 ratio to He ratio
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1824 IFDEF _helium
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1825 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1826 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1827 addlw .10 ; advance index from He ratio to diluent type
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1828 movff PLUSW1,char_I_current_gas_type ; copy diluent type (0=Disabled, 1=First, 2=Normal)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1829 setup_dil_registers_com:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1830 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
1831 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
1832 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1833 btfsc FLAG_pscr_mode ; check if we are in pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1834 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
1835 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
1836 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
1837 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1838
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1839 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1840
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1841 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1842
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1843 divemode_option_gaschange: ; switch to the "better gas" / "better diluent"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1844 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1845 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1846 bra divemode_option_gaschange_oc; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1847 btfsc bailout_mode ; in bailout?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1848 bra divemode_option_gaschange_oc; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1849 divemode_option_gaschange_loop: ; in CCR/pSCR mode and not in bailout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1850 movff best_dil_number,menu_pos_cur; NO - select best diluent
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1851 bcf better_dil_available ; - clear flag immediately
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1852 bra divemode_option_gaschange3 ; - continue with common part
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1853 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1854 divemode_option_gaschange_oc: ; in OC or bailout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1855 movff best_gas_number,menu_pos_cur; select best gas
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1856 bcf better_gas_available ; clear flag immediately
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1857 divemode_option_gaschange3 ; common part
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1858 bsf request_gaschange ; request a gas/diluent change
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1859 call menuview_toggle_reset ; terminate the pre-menu
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1860 return
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1861
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1862 global divemode_option0_return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1863 divemode_option0: ; start/setup dive mode menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1864 call TFT_clear_divemode_menu ; clear menu area
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1865 bcf dive_options_menu ; dive options menu is not shown anymore
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1866 call do_main_divemenu ; hand over to menu processor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1867 divemode_option0_return: ; return point for menu processor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1868 call TFT_show_menu_cursor_divemode ; show the cursor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1869 clrf active_premenu ; set pre-menu is not shown any more
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1870 bcf safety_stop_active ; set safety stop is not shown any more
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1871 bsf dive_main_menu ; set main menu is shown now
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1872 movlw divemode_timeout_mainmenu ; get timeout for main menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1873 call reset_timeout_time ; reload timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1874 goto diveloop_menu_exit ; go back to dive loop (menu processor resets STKPTR!)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1875
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1876 divemode_option1: ; quit simulation mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1877 clrf simulatormode_depth ; set target depth to zero
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1878 bsf quit_simulatormode ; request ISR to end simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1879 call menuview_toggle_reset ; terminate the pre-menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1880 btfsc FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1881 bcf divemode ; YES - force end of dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1882 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1883
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1884 divemode_option2: ; plus 1 meter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1885 movlw ostc_depth_max-1 ; load depth limit into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1886 cpfsgt simulatormode_depth ; simulated depth <= limit ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1887 incf simulatormode_depth,F ; YES - increment simulated depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1888 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1889
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1890 divemode_option3: ; minus 1 meter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1891 tstfsz simulatormode_depth ; simulated depth > 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1892 decf simulatormode_depth,F ; YES - decrement simulated depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1893 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1894
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1895 divemode_option4: ; quit apnoe mode (available while at the surface only)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1896 btfsc sensor_override_active ; in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1897 bra divemode_option1 ; YES - use simulator quit procedure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1898 bcf divemode ; NO - force end of dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1899 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1900
0
heinrichsweikamp
parents:
diff changeset
1901
heinrichsweikamp
parents:
diff changeset
1902 divemode_option5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1903 bsf request_reset_avg ; request reset of average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1904 goto menuview_toggle_reset ; terminate pre-menu and return
0
heinrichsweikamp
parents:
diff changeset
1905
216
973a0969e0ac NEW: On-board simulator can increase divetime in 5min steps
heinrichsweikamp
parents: 206
diff changeset
1906 divemode_option6:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1907 ; check for pending +5 request
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1908 movff char_I_sim_advance_time,WREG; get mailbox content
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1909 tstfsz WREG ; mailbox clear (=0) ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1910 return ; NO - still having a pending +5' request, refuse new request
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1911
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1912 ; advance tissues pressures and deco obligation by 5 minutes
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1913 movlw .5 ; + 5 minutes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1914 movff WREG,char_I_sim_advance_time; copy to mailbox
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1915 call restart_deco_engine ; condition deco engine to execute the +5 minutes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1916
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1917 ; stop dive time incrementing in ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1918 bcf count_divetime
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1919
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1920 ; add 5 minutes to counted_divetime_mins
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1921 ADDLI .5,counted_divetime_mins
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1922
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1923 ; add 5 minutes (300 seconds) to total_divetime_secs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1924 ADDLI .300,total_divetime_secs
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1925
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1926 ; continue dive time incrementing in ISR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1927 bsf count_divetime
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1928
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1929 ; add 5 minutes (300 seconds) to resettable time accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1930 ADDLI .300,divesecs_avg_trip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1931
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1932 ; add 5 minutes (300 seconds) to total time accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1933 ADDLI .300,divesecs_avg_total
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1934
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1935 ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1936 MOVII pressure_rel_cur_cached,xB
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1937 MOVLI .300,xA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1938 call mult16x16 ; xC = xA * xB
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1939
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1940 ; add to the resettable depth accumulator
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1941 movf xC+0,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1942 addwf pressure_rel_accu_trip+0,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1943 movf xC+1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1944 addwfc pressure_rel_accu_trip+1,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1945 movf xC+2,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1946 addwfc pressure_rel_accu_trip+2,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1947 movf xC+3,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1948 addwfc pressure_rel_accu_trip+3,F
604
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 ; add to the total depth accumulator
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1951 movf xC+0,w
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1952 addwf pressure_rel_accu_total+0,F
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1953 movf xC+1,w
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1954 addwfc pressure_rel_accu_total+1,F
386
3c55627d5f8f some cleanups, jump to 1.90 stable
heinrichsweikamp
parents: 385
diff changeset
1955 movf xC+2,w
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1956 addwfc pressure_rel_accu_total+2,F
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1957 movf xC+3,w
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1958 addwfc pressure_rel_accu_total+3,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1959
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1960 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1961 ; update backtracking data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1962 movlw .5 ; configure 5 minutes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1963 call update_backtrack ; add backtrack data for 5 minutes
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1964 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1965
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1966 ; goto menuview_toggle_reset ; terminate the pre-menu and return
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1967 return ; just return, leaving option avail for repeated selection
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1968
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1969 IFDEF _compass
254
5fe7aff622f3 preparations to set a course for the compass display
heinrichsweikamp
parents: 239
diff changeset
1970 divemode_option7:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1971 ; store heading for compass view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1972 MOVII compass_heading_shown,compass_bearing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1973 bsf compass_bearing_set ; set flag to show heading
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1974 goto menuview_toggle_reset ; terminate the pre-menu and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1975 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1976
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1977
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
1978 divemode_option8:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1979 call menuview_toggle_reset ; terminate the pre-menu
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1980 call TFT_ClearScreen ; clear the whole screen
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1981 btg alt_layout_active ; toggle layout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1982
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1983 bcf depth_warn_att_last ; set warning or attention on the depth not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1984 bcf depth_inverse_last ; set depth displayed in inverse as not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1985 bcf sign_shown ; set warning/attention/advice sign not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1986 bcf velocity_active_num ; set numerical vertical velocity display not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1987 bcf velocity_active_vsi ; set vertical vertical velocity display not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1988 bcf safety_stop_active ; set safety stop not shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1989
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1990 bsf FLAG_TFT_divemode_mask ; request redraw of dive screen mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1991 bsf FLAG_TFT_divetime ; request redraw of dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1992 bsf FLAG_TFT_depth_current ; request redraw of current depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1993 bsf FLAG_TFT_depth_maximum ; request redraw of maximum depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1994 bsf FLAG_TFT_active_gas_divemode; request redraw of gas and setpoint
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1995 bsf FLAG_TFT_customview_mask ; request redraw of custom view mask
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1996 bsf FLAG_TFT_temperature ; request redraw of temperature
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1997
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1998 goto request_redraw_NDL_deco_data; request redraw of NDL/deco data and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1999
0
heinrichsweikamp
parents:
diff changeset
2000
heinrichsweikamp
parents:
diff changeset
2001 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2002 ; 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
2003 ; 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
2004 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2005 ; 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
2006 ; 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
2007 ; 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
2008 ; 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
2009 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2010 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2011 ; 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
2012 ; - 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
2013 ; - 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
2014 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2015 ; in OC mode : - checks only gases for best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2016 ; - sets better_gas_available on OC gases
0
heinrichsweikamp
parents:
diff changeset
2017 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2018 global check_gas_best
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2019 check_gas_best:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2020 btfsc FLAG_gauge_mode ; in gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2021 return ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2022
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2023 MOVII pressure_abs_10,xA ; copy absolute pressure / 10 into xA:2, will be used by ppO2 min/max checks later
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2024
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2025 ; compute max. allowed deco ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2026 movff char_I_ppO2_max_deco,WREG ; max ppO2 [cbar] for deco phase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2027 mullw .100 ; compute max ppO2 * 100, result is in 0.1 mbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2028 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2029 MOVII PROD,ppO2_max_deco ; store as deco ppO2 max
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2030
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2031 ; compute max. allowed default ppO2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2032 movff char_O_deco_info,lo ; bank-safe copy of deco info vector
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2033 btfss lo,deco_mode ; is the ppO2 deco limit enabled?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2034 bra check_gas_best_1 ; NO - compute default ppO2 max
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2035 MOVII ppO2_max_deco,ppO2_max_default ; YES - copy default ppO2 max from deco max.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2036 bra check_gas_best_2 ; - continue with common part
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2037
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2038 check_gas_best_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2039 movff char_I_ppO2_max_work,WREG ; max ppO2 [cbar] for working phase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2040 mullw .100 ; compute max ppO2 * 100, result is in 0.1 mbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2041 ADDLI ppO2_margin_on_max,PROD ; add ppO2 margin on max value to compensate for surface pressures > 1000 hPa
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2042 MOVII PROD,ppO2_max_default ; store as default ppO2 max
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2043
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2044 check_gas_best_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2045
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2046 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2047
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2048 ; check dive mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2049 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2050 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
2051
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2052 check_gas_best_dil:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2053 ; set minimum ppO2 required
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2054 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
2055 btfsc FLAG_pscr_mode ; in pSCR mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2056 movff char_I_ppO2_min_loop,WREG ; YES - replace by min ppO2 for pure diluent in pSCR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2057 mullw .100 ; min ppO2 * 100, result in 0.1 mbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2058 MOVII PROD,ppO2_min ; store in ppO2_min
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2059 ; preset results to nothing found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2060 clrf best_gas_num ; initialize best diluent as 0 = nothing found yet
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2061 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2062 ; ; current diluent = 'gas6' ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2063 ; movlw .6 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2064 ; cpfseq active_dil ; using 'gas6' as current diluent?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2065 ; bra check_gas_best_dil0 ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2066 ; 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
2067 ;check_gas_best_dil0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2068 ; check all diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2069 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
2070 movff active_dil,lo ; number of currently used diluent
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2071 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
2072 ; original code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2073 clrf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2074 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2075 rcall check_gas_best_common ; check diluent 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2076 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2077 rcall check_gas_best_common ; check diluent 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2078 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2079 rcall check_gas_best_common ; check diluent 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2080 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2081 rcall check_gas_best_common ; check diluent 4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2082 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2083 rcall check_gas_best_common ; check diluent 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2084 ; alternative code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2085 ; movlw .5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2086 ; movwf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2087 ;check_gas_best_dil_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2088 ; rcall check_gas_best_common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2089 ; decfsz check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2090 ; bra check_gas_best_dil_loop
0
heinrichsweikamp
parents:
diff changeset
2091 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2092 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2093 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
2094 ; check if change advices shall be given in general
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2095 btfsc bailout_mode ; in bailout?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2096 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
2097 check_gas_best_dil1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2098 ; 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
2099 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
2100 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
2101 cpfseq active_dil ; is this the currently used diluent?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2102 bra check_gas_best_dil2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2103 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
2104 check_gas_best_dil2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2105 btfsc sp_fallback ; in fallback condition?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2106 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
2107 ; 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
2108 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
2109 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
2110 check_gas_best_dil3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2111 btfss better_dil_available ; shall a better diluent be signaled for?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2112 bcf better_dil_blinking ; NO - clear blinking flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2113 ; continue with checking for best bailout gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2114
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2115 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2116
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2117 check_gas_best_gas:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2118 ; set minimum ppO2 required
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2119 movff char_I_ppO2_min,WREG ; min ppO2 for OC and bailout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2120 mullw .100 ; min ppO2 * 100, result in 0.1 mbar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2121 MOVII PROD,ppO2_min ; store in ppO2_min
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2122 ; preset results to nothing found
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2123 clrf best_gas_num ; initialize best gas as 0 = nothing found yet
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2124 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2125 ; ; current gas = 'gas6' ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2126 ; movlw .6 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2127 ; cpfseq active_gas ; using 'gas6' as current gas?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2128 ; bra check_gas_best_gas0 ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2129 ; 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
2130 ;check_gas_best_gas0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2131 ; check all gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2132 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
2133 movff active_gas,lo ; number of currently used gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2134 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
2135 ; original code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2136 clrf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2137 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2138 rcall check_gas_best_common ; check gas 1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2139 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2140 rcall check_gas_best_common ; check gas 2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2141 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2142 rcall check_gas_best_common ; check gas 3
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2143 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2144 rcall check_gas_best_common ; check gas 4
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2145 incf check_gas_num,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2146 rcall check_gas_best_common ; check gas 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2147 ; alternative code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2148 ; movlw .5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2149 ; movwf check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2150 ;check_gas_best_gas_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2151 ; rcall check_gas_best_common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2152 ; decfsz check_gas_num
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2153 ; bra check_gas_best_gas_loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2154 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2155 ; store result
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2156 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
2157 ; check if change advices shall be given in general
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2158 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2159 bra check_gas_best_gas1 ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2160 btfsc bailout_mode ; in bailout?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2161 bra check_gas_best_gas1 ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2162 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
2163 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
2164 ; 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
2165 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
2166 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
2167 cpfseq active_gas ; is this the currently used gas?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2168 bra check_gas_best_gas2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2169 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
2170 check_gas_best_gas2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2171 ; 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
2172 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
2173 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
2174 check_gas_best_gas3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2175 btfss better_gas_available ; shall a better gas be signaled for?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2176 bcf better_gas_blinking ; NO - clear blinking flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2177 return
0
heinrichsweikamp
parents:
diff changeset
2178
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2179 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
2180 ; ; and current gas in lo (1-5)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2181 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2182 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2183 ; ---------------------------------------------------------------------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2184 ; 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
2185 ; 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
2186 ; opt_gas_He_ratio res 5 ; (not needed here)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2187 ; opt_dil_He_ratio res 5 ; (not needed here)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2188 ; 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
2189 ; 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
2190 ; 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
2191 ; 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
2192
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2193 ; get gas data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2194 decf check_gas_num,W ; (1-5) -> (0-4) into WREG to be used as index
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2195 movff PLUSW1,check_gas_O2_ratio ; copy O2 ratio (%) of current gas/dil to check_gas_O2_ratio
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2196 addlw .20 ; add offset of 20 bytes to index type in opt_gas_type/opt_dil_type
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2197 movff PLUSW1,check_gas_type ; copy type of current gas/dil to check_gas_type (0=disabled, 1=first, 2=travel/normal, 3=deco/-)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2198 addlw .10 ; add offset of 10 bytes to index change depth in opt_gas_change/opt_dil_change
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2199 movff PLUSW1,check_gas_depth ; copy change depth of current gas/dil to check_gas_depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2200 MOVII ppO2_max_default,sub_b ; select default ppO2 max for first / travel / normal gas
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2201 ; check if the gas is the current gas
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2202 movf check_gas_num,W ; get the number of the gas to be checked (1-5)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2203 cpfseq lo ; is this the currently used gas?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2204 bra check_gas_best_common0 ; NO - do the disabled & deco gas checks
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2205 bra check_gas_best_common3 ; YES - a gas in use overrides disabled and deco status
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2206 check_gas_best_common0:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2207 ; check if gas is available (i.e. not disabled)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2208 tstfsz check_gas_type ; type = disabled (0) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2209 bra check_gas_best_common1 ; NO - continue checks
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2210 return ; YES - skip disabled gases
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2211 check_gas_best_common1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2212 ; skip deco gases (type=3) if there are no stops, but include them when in bailout mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2213 movlw .3 ; coding for deco gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2214 cpfseq check_gas_type ; type = deco (3) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2215 bra check_gas_best_common3 ; NO - first or travel/normal then, ok to use
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2216 btfsc bailout_mode ; YES - in bailout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2217 bra check_gas_best_common2 ; YES - ok to use (using deco gases is always allowed when in bailout)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2218 TSTOSS opt_extended_stops ; NO - extended stops enables?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2219 bra check_gas_best_common1b ; NO
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2220 ;bra check_gas_best_common1a ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2221 check_gas_best_common1a:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2222 movff char_O_deco_info,WREG ; get deco info vector
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2223 btfss WREG,deco_mode ; are we in deco mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2224 return ; NO - skip deco gas while not in deco mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2225 bra check_gas_best_common2 ; YES - deco gases allowed
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2226 check_gas_best_common1b:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2227 btfss deco_region ; are we in the deco region?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2228 return ; NO - skip deco gas while not in the deco region
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2229 ;bra check_gas_best_common2 ; YES - deco gases allowed
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2230 check_gas_best_common2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2231 MOVII ppO2_max_deco,sub_b ; replace by ppO2 max for a deco gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2232 check_gas_best_common3:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2233 ; check if gas is usable, i.e. its change depth is below or equal to the current depth
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2234 movf depth_meter,W ; load current depth (in m) into WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2235 cpfslt check_gas_depth ; change depth of checked gas < (shallower than) current depth?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2236 bra check_gas_best_common4 ; NO - gas is usable
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2237 return ; YES - gas is not usable
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2238 check_gas_best_common4:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2239 ; 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
2240 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
2241 tstfsz WREG ; has a best gas candidate been found yet?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2242 bra check_gas_best_common5 ; YES - check if the new one is better than the one we have so far
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2243 bra check_gas_best_common6 ; NO - no need to do the above mentioned check
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2244 check_gas_best_common5:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2245 ; check if the change depth of the checked gas is <= (shallower or equal) the change depth of the best gas found so far
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2246 movf best_gas_depth,W ; load change depth of best gas so far into WREG
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2247 cpfsgt check_gas_depth ; change depth of checked gas > (deeper than) change depth of best gas so far?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2248 bra check_gas_best_common6 ; NO - this gas is better or equal, continue
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2249 return ; YES - this gas is not better than the best already found
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2250 check_gas_best_common6:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2251 ; check if the gas fits into the ppO2 limits
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2252 movff check_gas_O2_ratio,xB+0 ; xB = O2 ratio, xA is still loaded with (absolute pressure / 10)
69
50697bd41c54 +CHANGE: Some French Translations
heinrichsweikamp
parents: 55
diff changeset
2253 clrf xB+1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2254 call mult16x16 ; xC = O2 ratio * (absolute pressure / 10), result in 0.1 mbar
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2255 ; check for very high ppO2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2256 tstfsz xC+2 ; O2_ratio * absolute pressure / 10 > 65536, i.e. ppO2 > 6.55 bar ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2257 return ; YES - gas is not usable
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2258 btfsc xC+1,7 ; ppO2 > 3.30 bar ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2259 return ; YES - gas is not usable
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2260 MOVII xC,sub_a ; NO - gas may be usable
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2261 ; check for high ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2262 call cmpU16 ; sub_a - sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2263 btfss neg_flag ; within limit?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2264 return ; NO - too high, gas is not usable
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2265 ; check for low ppO2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2266 MOVII ppO2_min,sub_b ; copy minimum ppO2 to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2267 call cmpU16 ; sub_a - sub_b
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2268 btfsc neg_flag ; within limit?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2269 return ; NO - too low, gas is not usable
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2270 ; we have a (new) best gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2271 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
2272 movff check_gas_depth,best_gas_depth ; memorize its change depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2273 return
0
heinrichsweikamp
parents:
diff changeset
2274
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2275
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2276 ;=============================================================================
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2277 ; Check for Auto-SP
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2278 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2279 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2280
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2281 check_dive_autosp: ; check for Auto-SP
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2282 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2283 sublw .2 ; opt_ccr_mode = 2 (Auto SP)?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2284 bz check_dive_autosp2 ; YES - check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2285 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
2286 check_dive_autosp2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2287 ; Check SP2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2288 btfsc FLAG_SP2_used ; SP 2 used so far?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2289 bra check_dive_autosp3 ; YES - continue with SP 3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2290 movff opt_setpoint_change+1,lo ; NO - get depth in m
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2291 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2292 bra check_dive_autosp2a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2293 bra check_dive_autosp3 ; YES - continue with SP 3
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2294 check_dive_autosp2a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2295 decf lo,W ; SP change depth -1 -> WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2296 cpfsgt depth_meter ; current depth > change depth - 1 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2297 bra check_dive_autosp3 ; NO - continue with SP 3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2298 ; auto switch to SP2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2299 movff opt_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2300 rcall xmit_sp_set_flag ; - send SP to external devices
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2301 bsf FLAG_SP2_used ; - set SP 2 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2302 check_dive_autosp3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2303 ; Check SP3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2304 btfsc FLAG_SP3_used ; SP 3 used so far?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2305 bra check_dive_autosp4 ; YES - continue with SP 4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2306 movff opt_setpoint_change+2,lo ; NO - get depth in m
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2307 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2308 bra check_dive_autosp3a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2309 bra check_dive_autosp4 ; YES - continue with SP 4
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2310 check_dive_autosp3a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2311 decf lo,W ; SP change depth -1 -> WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2312 cpfsgt depth_meter ; current depth > change depth - 1 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2313 bra check_dive_autosp4 ; NO - continue with SP 4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2314 ; auto switch to SP3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2315 movff opt_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2316 rcall xmit_sp_set_flag ; - send SP to external devices
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2317 bsf FLAG_SP3_used ; - set SP 3 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2318 check_dive_autosp4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2319 ; Check SP4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2320 btfsc FLAG_SP4_used ; SP 4 used so far?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2321 bra check_dive_autosp5 ; YES - continue with SP 5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2322 movff opt_setpoint_change+3,lo ; NO - get depth in m
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2323 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2324 bra check_dive_autosp4a ; NO - continue
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2325 bra check_dive_autosp5 ; YES - continue with SP 5
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2326 check_dive_autosp4a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2327 decf lo,W ; SP change depth -1 -> WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2328 cpfsgt depth_meter ; current depth > change depth - 1 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2329 bra check_dive_autosp5 ; NO - continue with SP 5
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2330 ; auto switch to SP4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2331 movff opt_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2332 rcall xmit_sp_set_flag ; - send SP to external devices
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2333 bsf FLAG_SP4_used ; - set SP 4 used flag
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2334 check_dive_autosp5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2335 ; Check SP5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2336 btfsc FLAG_SP5_used ; SP 5 used so far?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2337 bra check_dive_autosp6 ; YES - done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2338 movff opt_setpoint_change+4,lo ; NO - get depth in m
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2339 tstfsz lo ; - SP change depth = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2340 bra check_dive_autosp5a ; NO - continue
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2341 bra check_dive_autosp6 ; YES - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2342 check_dive_autosp5a:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2343 decf lo,W ; SP change depth -1 -> WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2344 cpfsgt depth_meter ; current depth > change depth - 1 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2345 bra check_dive_autosp6 ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2346 ; auto switch to SP5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2347 movff opt_setpoint_cbar+4,char_I_const_ppO2 ; YES - use SP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2348 rcall xmit_sp_set_flag ; - send SP to external devices
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2349 bsf FLAG_SP5_used ; - set SP 5 used flag
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2350 check_dive_autosp6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2351 return
352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2352
5c6da9fa5cb0 add setpoint change to first sample in CCR mode
heinrichsweikamp
parents: 339
diff changeset
2353 xmit_sp_set_flag:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2354 IFDEF _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2355 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2356 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2357 bsf event_occured ; set global event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2358 bsf event_SP_change ; set setpoint event flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2359 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2360
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2361 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2362
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2363 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2364
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2365 set_logbook_marker:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2366 bcf request_set_marker ; clear request flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2367 movlw d'6' ; set type of alarm: manual marker
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2368 movwf alarm_type ; copy to alarm register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2369 bsf event_occured ; set event flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2370 return
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 337
diff changeset
2371
0
heinrichsweikamp
parents:
diff changeset
2372 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2373 ; Setup everything to enter dive mode
0
heinrichsweikamp
parents:
diff changeset
2374 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2375 global dive_boot_oc_bail
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2376 dive_boot_oc_bail:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2377 ; copy opt_gas_types into backup (for "lost gas" feature)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2378 movff opt_gas_type+0,opt_gas_type_backup+0 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2379 movff opt_gas_type+1,opt_gas_type_backup+1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2380 movff opt_gas_type+2,opt_gas_type_backup+2 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2381 movff opt_gas_type+3,opt_gas_type_backup+3 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2382 movff opt_gas_type+4,opt_gas_type_backup+4 ; 0=Disabled, 1=First, 2=Travel, 3=Deco
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2383 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2384
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2385 global dive_boot_oc
0
heinrichsweikamp
parents:
diff changeset
2386 dive_boot_oc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2387 ; set-up registers
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2388 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2389 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2390 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2391 return
0
heinrichsweikamp
parents:
diff changeset
2392
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2393 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2394
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2395 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2396
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2397 global dive_boot_cc
0
heinrichsweikamp
parents:
diff changeset
2398 dive_boot_cc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2399 ; copy opt_dil_types into backup (for "lost diluent" feature)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2400 movff opt_dil_type+0,opt_dil_type_backup+0 ; 0=Disabled, 1=First, 2=Normal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2401 movff opt_dil_type+1,opt_dil_type_backup+1 ; 0=Disabled, 1=First, 2=Normal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2402 movff opt_dil_type+2,opt_dil_type_backup+2 ; 0=Disabled, 1=First, 2=Normal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2403 movff opt_dil_type+3,opt_dil_type_backup+3 ; 0=Disabled, 1=First, 2=Normal
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2404 movff opt_dil_type+4,opt_dil_type_backup+4 ; 0=Disabled, 1=First, 2=Normal
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2405 ; set-up registers
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2406 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2407 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (with WREG = current diluent 1-5)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2408 rcall deco_setup_cc_diluents ; set-up of diluent list for deco calculations (with WREG = current diluent 1-5)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2409 ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2410 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2411
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2412
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2413 dive_boot_cc_part2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2414 ; revoke sensors from usage if they do not have a valid calibration
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2415 bsf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2416 bsf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2417 bsf use_O2_sensor3
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2418 btfss sensor1_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2419 bcf use_O2_sensor1
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2420 btfss sensor2_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2421 bcf use_O2_sensor2
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2422 btfss sensor3_calibrated_ok
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2423 bcf use_O2_sensor3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2424
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2425 IFDEF _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2426 ; check for external HUD/ppO2 Monitor
583
6636cbe64c6d optical input work
heinrichsweikamp
parents: 582
diff changeset
2427 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
2428 bra dive_boot_cc_part2_1 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2429 btfsc sensor1_active ; YES - copy valid flags from HUD/ppO2 Monitor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2430 bsf use_O2_sensor1 ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2431 btfsc sensor2_active ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2432 bsf use_O2_sensor2 ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2433 btfsc sensor3_active ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2434 bsf use_O2_sensor3 ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2435 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2436
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2437 dive_boot_cc_part2_1:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2438 ; 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
2439 ; 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
2440 btfss FLAG_pscr_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2441 bra dive_boot_cc_part2_2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2442 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
2443 sublw .2 ; opt_ccr_mode = 1 (Auto SP)?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2444 bnz dive_boot_cc_part2_2
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2445 movlw .0
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2446 movff WREG,opt_ccr_mode
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2447 dive_boot_cc_part2_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2448 bsf event_SP_change ; set setpoint event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2449
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2450 ; Start with SP1 (CCR) or 0 (pSCR) as default.
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2451 ; If in sensor mode, this value will be overwritten by calc_deko_divemode_sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2452 clrf WREG ; pre-load WREG with setpoint value 0 for pSCR calculated
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2453 btfsc FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2454 movff opt_setpoint_cbar+0,WREG ; YES - get value of setpoint 1 into WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2455 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2456 IFDEF _external_sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2457 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2458 goto calc_deko_divemode_sensor ; read & process sensor data (and return)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2459 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2460 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2461 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2462
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2463 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2464
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2465 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2466
0
heinrichsweikamp
parents:
diff changeset
2467 diveloop_boot:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2468 ; do the basic initialization
0
heinrichsweikamp
parents:
diff changeset
2469 call restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
2470
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2471 ; stop accelerometer and compass
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2472 call I2C_sleep_compass
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2473
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2474 ; do an early initialization of all deco engine output variables to
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2475 ; avoid glitches in the display outputs during deco engine start-up
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2476 call deco_init_output_vars; ; (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2477 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2478
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2479 ; reset max relative pressure (max depth)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2480 bsf reset_max_pressure ; request ISR to reset the max pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2481
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2482
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2483 IFDEF _min_depth_option
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2484 ; reset the resettable min/max relative pressure (trip-wise min/max depth)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2485 bsf reset_trip_pressure ; request ISR to reset the resettable min/max pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2486 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2487
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2488 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2489 ; initialize the cave mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2490 bsf cave_mode ; enable cave mode by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2491 movff opt_calc_asc_gasvolume,WREG ; get gas needs calculation mode (0= off, 1= on, 2= cave mode)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2492 xorlw .2 ; coding for cave mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2493 tstfsz WREG ; cave mode enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2494 bcf cave_mode ; NO - disable cave mode again
604
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 ; configure the deco engine
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2498 clrf hi ; start with everything disabled
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2499
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2500 TSTOSC opt_ZfactorUse ; shall use Z factors?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2501 bsf hi,DECO_Z_FACTOR_FLAG ; YES - enable Z factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2502
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2503 TSTOSC opt_extended_stops ; shall make extended stops?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2504 bsf hi,DECO_EXTENDED_STOPS ; YES - enable extended stops
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2505
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2506 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2507 btfsc tr_functions_activated ; TR functions activated?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2508 bsf hi,DECO_TR_FUNCTIONS ; YES - enable TR functions
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2509 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2510
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2511 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
2512
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2513 movff char_O_deco_status,lo ; bank-safe read
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2514 bsf lo,DECO_START_NORM ; set flag for doing a normal plan,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2515 bcf lo,DECO_START_ALT ; clear flag for doing an alternative plan,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2516 bsf lo,DECO_INITIALIZE ; set flag for initializing the deco engine
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2517 bcf lo,DECO_ASCENT_FLAG ; disable delayed ascent calculation
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2518 bcf lo,DECO_CALCULATOR_MODE ; deco engine not run from the deco calculator
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2519 movff lo,char_O_deco_status ; bank-safe copy back to deco engine
0
heinrichsweikamp
parents:
diff changeset
2520
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2521 ; disable "fast forward" function
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2522 movlw .0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2523 movff WREG,char_I_sim_advance_time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2524
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2525 ; write last stop depth to deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2526 movff opt_last_stop,char_I_depth_last_deco
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2527
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2528 ; initialize max depth for apnoe mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2529 CLRI apnoe_max_pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2530
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2531 ; reset minimum temperature, ISR-safe 2 byte copy
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2532 SMOVII temperature_cur,temperature_min
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2533
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2534 ; ISR-safe copy of start-of-dive date and time for logbook (6 bytes in total)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2535 SMOVSS rtc_year,start_year
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2536
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2537 MOVII int_O_CNS_current,CNS_start ; save current CNS at beginning of dive, but
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2538 bcf CNS_start+1,int_warning_flag ; without warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2539 bcf CNS_start+1,int_attention_flag ; without attention flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2540
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2541 ; save supersaturation at beginning of dive (only lower byte is used for value)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2542 movff int_O_lead_supersat+0,supersat_start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2543
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2544 clrf menu_pos_cur
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2545 clrf active_premenu ; reset to zero (0= no pre-menu task)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2546 bsf o2_sensors_agree ; initialize sensors disagree warning system
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2547
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2548 clrf safety_stop_countdown ; clear safety stop count-down
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2549
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2550 CLRI last_pressure_velocity ; initialize last pressure for velocity calculation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2551 CLRI dive_timeout_timer ; initialize timeout counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2552
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2553 movlw .1 ; initialize the sampling timer such that the 1st sampling ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2554 movwf sampling_timer ; ... trigger will be given as soon as possible
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2555
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2556 clrf message_page ; initialize message page counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2557 clrf alarm_type ; clear all alarms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2558
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2559 ; clear the total dive average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2560 CLRI pressure_rel_avg_total ; average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2561 CLRI divesecs_avg_total ; time accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2562 clrf pressure_rel_accu_total+0 ; depth accumulator
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2563 clrf pressure_rel_accu_total+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2564 clrf pressure_rel_accu_total+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2565 clrf pressure_rel_accu_total+3
604
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 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2568
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2569 btfss tr_functions_activated ; TR functions activated?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2570 bra diveloop_boot_0 ; NO - skip TR function initialization
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2571 ; YES - initialize TR function variables
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2572
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2573 banksel int_IO_pressure_value
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2574 clrf WREG ; clear WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2575 bsf WREG,int_not_avail_flag ; set WREG to coding for integer numbers -> data not available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2576 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2577 movwf int_IO_pressure_value+1 ; copy to high byte of 1st pressure reading value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2578 clrf int_IO_pressure_value+2 ; clear low byte of 2nd pressure reading value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2579 movwf int_IO_pressure_value+3 ; copy to high byte of 2nd pressure reading value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2580 clrf int_I_pressure_drop+0 ; clear low byte of 1st pressure drop value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2581 movwf int_I_pressure_drop+1 ; copy to high byte of 1st pressure drop value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2582 clrf int_I_pressure_drop+2 ; clear low byte of 2nd pressure drop value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2583 movwf int_I_pressure_drop+3 ; copy to high byte of 1st pressure drop value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2584 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
2585 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
2586 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
2587 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
2588 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
2589 clrf char_I_pressure_stat+1 ; clear status of 2nd pressure reading
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2590
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2591 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
2592 setf gas__last_1st ; invalidate last gas of 1st reading
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2593 setf gas__last_2nd ; invalidate last gas of 2nd reading
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2594
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2595 banksel common ; back to bank common
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2596
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2597 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2598
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2599
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2600 diveloop_boot_0:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2601 setf best_gas_number ; initialize best gas as not computed yet (255)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2602 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2603 setf best_dil_number ; initialize best diluent as not computed yet (255)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2604 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2605
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2606 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
2607
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2608 btfsc FLAG_oc_mode ; in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2609 rcall dive_boot_oc ; YES - add OC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2610
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2611 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2612 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2613 rcall dive_boot_cc ; YES - add CC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2614 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2615 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
2616
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2617 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2618 rcall dive_boot_cc ; YES - add CC mode settings
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2619 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2620 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2621 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2622
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2623 call ghostwriter_short_header ; write short header with dive number into profile memory
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2624 call init_recording_params ; set up all the divisors for dive data recording
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2625
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2626 ; setup gas selector flag (required to have better gas working)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2627 bsf is_diluent_menu ; default to using diluents
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2628 btfsc FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2629 bra diveloop_boot_3 ; YES - default was right
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2630 btfsc FLAG_pscr_mode ; in pSCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2631 bra diveloop_boot_3 ; YES - default was right
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2632 bcf is_diluent_menu ; NO to both - revert to using OC gases
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2633
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2634 diveloop_boot_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2635 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
2636 bcf LEDr ; switch off red LED
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2637
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2638 btfss sensor_override_active ; in simulator mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2639 call disable_rs232 ; NO - disable RS232
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2640
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2641 IFDEF _screendump
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2642 btfsc screen_dump_avail ; screen dump function enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2643 call enable_rs232 ; enable interface (also sets CPU speed to normal)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2644 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2645
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2646 clrf apnoe_surface_mins ; clear apnoe surface time, minutes (8 bit)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2647 clrf apnoe_surface_secs ; clear apnoe surface time, seconds (8 bit)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2648 clrf apnoe_dive_mins ; clear apnoe dive time, minutes (8 bit)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2649 clrf apnoe_dive_secs ; clear apnoe dive time, seconds (8 bit)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2650
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2651 return ; done with dive mode boot
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2652
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2653
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2654 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
2655
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2656 divemode_check_warnings:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2657 movlw .1 ; one message at a time in alternative layout
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2658 btfss alt_layout_active ; in alternative layout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2659 movlw .2 ; NO - two messages at a time in normal layout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2660 cpfsgt message_counter ; more than one (alt layout) / 2 (normal layout) messages currently active?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2661 bra divemode_check_warnings1 ; NO - update messages every second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2662
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2663 ; ; YES - update every 4 seconds:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2664 ; btfss timebase_1sec - on second 1 or 3 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2665 ; return ; NO - no update in this cycle
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2666 ; btfss timebase_2sec ; YES - on second 3 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2667 ; return ; NO - no update in this cycle
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2668 ; ;bra divemode_check_warnings1 ; YES - update messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2669
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2670 ; NO - update every 2 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2671 btfsc timebase_1sec ; - on even second?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2672 return ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2673 ;bra divemode_check_warnings1 ; YES - update messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2674
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2675 divemode_check_warnings1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2676 ; start a new message collection cycle
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2677 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
2678 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
2679 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
2680 clrf message_counter ; clear message counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2681
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2682 ; 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
2683
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2684 ; warnings for all modes
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2685 call check_warn_battery ; check if the battery level should be displayed/warned
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2686 rcall check_depth_limit ; check current depth against set depth limit
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2687 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
2688
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2689 btfsc FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2690 bra divemode_check_warnings2 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2691
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2692 btfsc FLAG_gauge_mode ; in gauge mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2693 bra divemode_check_warnings2 ; YES
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2694
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2695 ; warnings applicable only in deco modes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2696 rcall check_ppO2 ; check ppO2 and displays warning, if required
0
heinrichsweikamp
parents:
diff changeset
2697
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2698 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2699 btfss o2_sensors_agree ; are the sensor values within the threshold range?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2700 rcall check_warn_sensors_disagree ; NO - do further evaluation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2701 btfsc o2_sensors_agree ; are the sensor values within the threshold range?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2702 bcf o2_sensors_warning ; YES - clear flag for a new warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2703 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2704
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2705 rcall check_outside ; check of ZHL16 model violation
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2706
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2707 IFDEF _helium
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2708 rcall check_IBCD ; check for IBCD attention or warning
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2709 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2710
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2711 btfsc FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2712 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2713 btfsc FLAG_pscr_mode ; in pSCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2714 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2715
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2716 btfsc decostop_active ; in deco mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2717 rcall check_and_store_sat_violation; YES - sets warnings, if required
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2718
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2719 rcall check_mbubbles ; check for micro bubbles
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2720 rcall check_cns_violation ; check CNS value and display it, if required
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2721 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
2722 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
2723 rcall check_display_ftts ; show @+x time
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2724
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2725 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2726 btfsc cave_mode ; cave mode switched on?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2727 rcall check_cavemode ; YES - check cave mode status
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2728 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2729
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2730 btfsc use_aGF ; using alternative GF factors?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2731 rcall warn_agf ; YES - show memo
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2732
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2733 btfsc sp_fallback ; in fallback condition due to O2 sensor failure?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2734 rcall warn_fallback ; YES - show a warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2735
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2736 btfsc better_dil_available ; is a better diluent available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2737 rcall advice_gas_change ; YES - display an advice
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2738
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2739 btfsc better_gas_available ; is a better gas available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2740 rcall advice_gas_change ; YES - display an advice
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2741
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2742 divemode_check_warnings2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2743 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2744 btfss tr_functions_activated ; TR functions activated?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2745 bra divemode_check_warnings3 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2746 call check_tr_functions ; YES - check transmitter functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2747 call check_tr_messages ; - check SAC attention and switch advice
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2748 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2749
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2750 divemode_check_warnings3:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2751 ; Display / clear the advice, attention or warning icon
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2752 btfsc message_advice ; any message of level advice?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2753 bsf FLAG_TFT_sign_show ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2754 btfsc message_attention ; any message of level attention?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2755 bsf FLAG_TFT_sign_show ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2756 btfsc message_warning ; any message of level warning?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2757 bsf FLAG_TFT_sign_show ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2758 btfss FLAG_TFT_sign_show ; any message of above levels?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2759 bsf FLAG_TFT_sign_clear ; NO - clear sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2760
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2761 ; Increment message page number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2762 incf message_page,F ; increment page number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2763 bcf STATUS,C ; clear carry bit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2764 movf message_page,W ; get page number into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2765 btfss alt_layout_active ; in alternative layout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2766 rlcf WREG,W ; NO - each page can take two messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2767 cpfsgt message_counter ; number of actual messages > message capacity ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2768 clrf message_page ; NO - all messages could be shown, restart from first page next time
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2769
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2770 ; Clear both rows of messages if there is nothing to show at all
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2771 tstfsz message_counter ; any message to show?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2772 bra divemode_check_warnings4 ; YES - look if second row needs to be cleared
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2773 bsf FLAG_TFT_message_clear_both ; NO - request clearing of left-over messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2774 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2775
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2776 divemode_check_warnings4:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2777 ; Clear 2nd row of messages if there is nothing to show (on this page)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2778 btfss message_2nd_row_used ; does the 2nd row contain a message?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2779 bsf FLAG_TFT_message_clear_2nd ; NO - set flag to clear the 2nd row
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2780 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2781
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2782 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
2783
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2784 global check_warn_battery
0
heinrichsweikamp
parents:
diff changeset
2785 check_warn_battery:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2786 movlw battery_show_level+1 ; get threshold for showing battery level, incremented by 1
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2787 cpfslt batt_percent ; battery percentage ok?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2788 return ; YES - no display, no warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2789 ; Display Battery, but warn?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2790 movlw battery_warn_level_36+1 ; get threshold for 3.6 Volt battery warning, incremented by 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2791 btfss battery_is_36v ; actually a 3.6 Volt battery detected?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2792 movlw battery_warn_level_15+1 ; NO - replace with 1.5 Volt battery warning, incremented by 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2793 cpfsgt batt_percent ; battery percent below warning threshold?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2794 bsf message_warning ; YES - set warning flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2795 movlw index_clock_batt_surfpress ; index of custom view clock, battery and surface pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2796 cpfseq active_customview ; battery shown in custom view?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2797 bra check_warn_battery2 ; NO - show warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2798 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
2799 check_warn_battery2:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2800 incf message_counter,F ; increase counter
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2801 goto TFT_msg_batt_percent_divemode ; show percent (and return)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2802
513
heinrichsweikamp
parents: 507
diff changeset
2803
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2804 check_divetimeout:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2805 btfsc count_divetime ; is dive time counted?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2806 return ; YES - do nothing
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2807 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2808 goto TFT_divetimeout ; show timeout counter (and return)
55
448ba265fdae Change "O2" warning to "ppO2"
heinrichsweikamp
parents: 39
diff changeset
2809
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2810
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2811 check_ppO2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2812 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2813 btfsc FLAG_oc_mode ; are we in OC mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2814 bra check_ppO2_1 ; YES - continue with breathed gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2815 btfsc bailout_mode ; NO - in bailout?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2816 bra check_ppO2_1 ; YES - continue with breathed gas
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2817 ; CCR / pSCR mode - checks on pure diluent
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2818 MOVII int_O_pure_ppO2,mpr ; get value and attention/warning flags for the pure diluent
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2819 btfsc hi,int_warning_flag ; is there a ppO2 low or high warning on the pure diluent?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2820 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
2821 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
2822 rcall check_ppO2_da ; YES - show attention and return on next line
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2823 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2824 ; 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
2825 check_ppO2_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2826 MOVII int_O_breathed_ppO2,mpr ; get value and attention/warning flags for the breathed gas
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2827 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
2828 bra check_ppo2_display_a ; YES - set attention flag and show ppO2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2829 btfsc hi,int_low_flag ; breathed ppO2 too low?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2830 bra check_ppO2_low ; YES - record the warning and show ppO2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2831 btfsc hi,int_high_flag ; breathed ppO2 too high?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2832 bra check_ppO2_high ; YES - record the warning and show ppO2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2833 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
2834 return ; NO - no warnings, no show - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2835 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
2836 check_ppO2_low:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2837 movlw d'4' ; set type of alarm (ppO2 low)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2838 bra check_ppO2_common ; continue with common part
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2839 check_ppO2_high:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2840 movlw d'5' ; set type of alarm (ppO2 high)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2841 check_ppO2_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2842 movwf alarm_type ; copy alarm type to alarm register
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2843 bsf event_occured ; set event flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2844 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2845 check_ppO2_common_2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2846 btfsc FLAG_oc_mode ; are we in OC mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2847 bra check_ppo2_display ; YES - show
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2848 btfsc bailout_mode ; are we in bailout mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2849 bra check_ppo2_display ; YES - show
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2850 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
2851 check_ppo2_display_a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2852 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2853 check_ppo2_display:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2854 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2855 cpfseq active_customview ; ppO2 shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2856 bra check_ppO2_b ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2857 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
2858 check_ppO2_b:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2859 movlw index_pscr_info ; index of custom view with pSCR data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2860 cpfseq active_customview ; ppO2 shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2861 bra check_ppO2_d ; NO - show ppO2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2862 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
2863 check_ppO2_dw:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2864 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2865 check_ppO2_da:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2866 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
2867 check_ppO2_d:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2868 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2869 goto TFT_show_ppo2_warning ; show breathed gas or diluent ppO2 warning (and return)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2870
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2871
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2872 check_display_ftts:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2873 btfss count_divetime ; is dive time counted?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2874 return ; NO - omit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2875 movff char_I_extra_time,lo ; YES - get extra time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2876 tstfsz lo ; - extra time > 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2877 bra check_display_ftts_1 ; YES - continue checking bailout condition
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2878 return ; NO - done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2879 check_display_ftts_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2880 btfsc bailout_mode ; in bailout mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2881 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
2882 incf message_counter,F ; NO - increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2883 goto TFT_show_ftts ; - show @+x time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2884
376
e99bb91f6f92 CHANGE: Do not show ppO2 in warning area if already shown in custom view
heinrichsweikamp
parents: 352
diff changeset
2885
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2886 global check_cns_violation
0
heinrichsweikamp
parents:
diff changeset
2887 check_cns_violation:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2888 ; Check if CNS should be displayed
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2889 movff int_O_CNS_current+1,WREG ; get current CNS, high byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2890 btfsc WREG,int_warning_flag ; warning flag set?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2891 bra check_cns_violation_1 ; YES - issue warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2892 btfsc WREG,int_attention_flag ; NO - attention flag set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2893 bra check_cns_violation_2 ; YES - issue attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2894 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2895 check_cns_violation_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2896 bsf message_warning ; show warning sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2897 check_cns_violation_2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2898 bsf message_attention ; show attention sign
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2899 IFNDEF _helium
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2900 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2901 cpfseq active_customview ; CNS shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2902 bra check_cns_violation_3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2903 return ; YES - do not show twice (in custom view and in warning area)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2904 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2905 check_cns_violation_3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2906 movlw index_CNS ; index of custom view with CNS values
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2907 cpfseq active_customview ; CNS shown?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2908 bra check_cns_violation_4 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2909 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
2910 check_cns_violation_4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2911 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2912 goto TFT_show_cns ; show CNS (and return)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2913
0
heinrichsweikamp
parents:
diff changeset
2914
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2915 global check_eod_cns_violation ; check end-of-dive CNS values
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2916 check_eod_cns_violation:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2917 movff int_O_CNS_current+1,WREG ; get current CNS, high byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2918 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
2919 return ; YES - inhibit end-of-dive warning if current CNS is already in warning
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2920 movff int_O_CNS_norm+1,WREG ; get CNS at end of dive in normal plan, high byte
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2921 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2922 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
2923 btfsc WREG,int_warning_flag ; NO - flag for warning set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2924 bra check_eod_cns_violation2 ; YES - issue warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2925 check_eod_cns_violation1: ; NO - continue with checking the other CNS value
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2926 movff int_O_CNS_alt+1,WREG ; get CNS at end of dive in alternative plan, high byte
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2927 btfsc WREG,int_invalid_flag ; flag for invalid value set?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2928 return ; YES - done with CNS checking
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2929 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
2930 bra check_eod_cns_violation2 ; YES - issue warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2931 return ; NO - done with CNS checking
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2932 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
2933 bsf message_attention ; show attention sign
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2934 movlw index_CNS ; index of custom view with CNS values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2935 cpfseq active_customview ; CNS values shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2936 bra display_eod_cns_violation ; NO - issue textual warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2937 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
2938 display_eod_cns_violation:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2939 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2940 goto TFT_warning_eod_cns ; issue CNS at end-of-dive warning (and return)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2941
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2942
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2943 global check_and_store_sat_violation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2944 check_and_store_sat_violation:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2945 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2946 btfss WREG,int_warning_flag ; check if the warning flag is set
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2947 bra check_and_store_sat_violation2 ; NO - continue with checking for attention flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2948 movlw d'2' ; YES - set type of alarm
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2949 movwf alarm_type ; - copy to alarm register
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2950 bsf event_occured ; - set event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2951 bsf message_warning ; - set warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2952 bra check_and_store_sat_violation3 ; - show GF warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2953 check_and_store_sat_violation2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
2954 btfsc WREG,int_attention_flag ; check if the attention flag is set
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2955 bra check_and_store_sat_violation3 ; YES - show gf
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2956 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2957 bra check_and_store_sat_violation4 ; NO - continue checking of deco info
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2958 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2959 btfss WREG,IBCD_warning ; - is the IBCD warning flag set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2960 bra check_and_store_sat_violation4 ; NO - continue checking for deco info
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2961 check_and_store_sat_violation3: ; YES - show GF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2962 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2963 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2964 goto TFT_warning_sat ; show saturation (and return)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2965 check_and_store_sat_violation4: ; check for deco info
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2966 btfss divemode ; in dive mode?
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
2967 return ; NO - done, return
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2968 btfsc bailout_mode ; YES - in bailout mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2969 return ; YES - done, return (deco zone flag is not updated when in bailout mode)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2970 movff char_O_deco_info,WREG ; NO - get the deco info vector
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2971 btfss WREG,deco_zone ; check if the deco zone flag is set
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2972 return ; NO - done, return
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2973 btfsc use_aGF ; YES - using alternative GF factors?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2974 return ; YES - suppress deco zone info
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2975 btfsc alt_layout_active ; NO - in alternative layout?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2976 return ; YES - suppress deco zone info
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2977 incf message_counter,F ; NO - increase counter
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
2978 goto TFT_info_deco ; - show deco info
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2979
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2980
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2981 check_depth_limit:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2982 bcf depth_limit_exceeded ; clear warning flag by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2983 movff opt_max_depth,WREG ; get depth limit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2984 cpfsgt depth_meter ; current depth > depth limit?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2985 return ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2986 bsf depth_limit_exceeded ; YES - set warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2987 incf message_counter,F ; - increase counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2988 bsf message_warning ; - set warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2989 goto TFT_warning_depth ; - show warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2990
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
2991
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2992 check_outside:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2993 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
2994 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
2995 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2996 incf message_counter,F ; YES - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2997 bsf message_attention ; - show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
2998 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
2999 bsf message_warning ; - set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3000 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
3001
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3002
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3003 global check_mbubbles
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3004 check_mbubbles:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3005 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
3006 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
3007 bra check_mbubbles_warn ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3008 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
3009 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3010 check_mbubble_att ; YES - attention level
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3011 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3012 bsf message_attention ; show attention sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3013 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
3014 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
3015 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3016 bsf message_warning ; set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3017 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
3018
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3019 IFDEF _cave_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3020 check_cavemode:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3021 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3022 btfsc dive_turned ; dive turned?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3023 goto TFT_info_dive_turned ; YES - show info that dive is turned
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3024 btfsc FLAG_backtrack_full ; NO - is the backtracking storage full?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3025 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
3026 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
3027 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3028
0
heinrichsweikamp
parents:
diff changeset
3029 warn_agf:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3030 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3031 goto TFT_warning_agf ; show aGF reminder (and return)
145
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
3032
e3ac5b2021bc NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents: 138
diff changeset
3033 warn_fallback:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3034 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3035 bsf message_warning ; set warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3036 goto TFT_warning_fallback ; show fallback warning (and return)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3037
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3038 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3039
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3040 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3041
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3042 check_tr_messages:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3043 btfss count_divetime ; is the dive time counted, i.e. deeper than dive threshold?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3044 return ; NO - suppress messages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3045 movff int_O_SAC_measured+1,WREG ; YES - bank-safe copy of measured SAC rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3046 btfss WREG,int_attention_flag ; - attention flag set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3047 bra check_tr_messages2 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3048 btfsc WREG,int_not_avail_flag ; SAC rate available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3049 bra check_tr_messages2 ; NO - continue with swap advice
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3050 bsf message_attention ; YES - show attention sign
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3051 movlw index_pressures_SAC ; - index of custom view with SAC rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3052 cpfseq active_customview ; - SAC rate shown right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3053 bra check_tr_messages1 ; NO - show attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3054 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
3055 check_tr_messages1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3056 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3057 call TFT_attention_sac ; show SAC attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3058 check_tr_messages2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3059 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
3060 btfss WREG,ind_double_switch ; swap tank flag set?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3061 return ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3062 incf message_counter,F ; YES - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3063 bsf message_advice ; - show advice sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3064 goto TFT_advice_switch ; - show swap advice
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3065
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3066
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3067 check_tr_functions:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3068 clrf xmitter_flags_mesg ; set all messages as not shown yet
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3069 movlw index_pressures_SAC ; index of custom view pressure readings
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3070 cpfseq active_customview ; pressure readings shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3071 bra check_tr_functions_tr1 ; NO - continue with checking transmitter 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3072 bsf pres_customview_shown ; YES - suppress redraw by faking it has already been redrawn
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3073 check_tr_functions_tr1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3074 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
3075 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
3076 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
3077 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
3078 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
3079 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
3080 check_tr_functions_tr2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3081 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
3082 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
3083 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
3084 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
3085 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
3086 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
3087 check_tr_functions_show_xmtr:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3088 btfss show_transmitter_attention ; shall show transmitter attention message?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3089 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
3090 bsf message_attention ; YES - set flag for attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3091 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3092 call TFT_attention_transmitter ; - show transmitter attention message
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3093 check_tr_functions_show_warn:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3094 btfss show_pres_warning ; shall show pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3095 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
3096 bsf message_warning ; YES - set flag for warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3097 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3098 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
3099 check_tr_functions_show_att:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3100 btfss show_pres_attention ; shall show pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3101 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3102 bsf message_attention ; YES - set flag for attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3103 incf message_counter,F ; - increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3104 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
3105
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3106 check_tr_functions_helper1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3107 btfsc WREG,char_transmitter_lost ; transmitter 1 lost?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3108 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
3109 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
3110 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3111 check_tr_functions_helper1a:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3112 ; bsf show_transmitter_attention ; show transmitter attention
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3113 btfsc transmitter1_lost ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3114 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
3115 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
3116 bra check_tr_functions_show_cv ; - show custom view
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 check_tr_functions_helper2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3119 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
3120 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
3121 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
3122 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3123 check_tr_functions_helper2a:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3124 bsf show_transmitter_attention ; show transmitter attention
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3125 btfsc transmitter1_battery ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3126 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
3127 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
3128 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3129
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3130 check_tr_functions_helper3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3131 btfsc WREG,int_warning_flag ; transmitter 1 pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3132 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
3133 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
3134 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3135 check_tr_functions_helper3a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3136 bsf show_pres_warning ; show pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3137 btfsc transmitter1_pres_warn ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3138 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
3139 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
3140 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3141
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3142 check_tr_functions_helper4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3143 btfsc WREG,int_attention_flag ; transmitter 1 pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3144 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
3145 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
3146 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3147 check_tr_functions_helper4a
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3148 bsf show_pres_attention ; show pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3149 btfsc transmitter1_pres_att ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3150 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
3151 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
3152 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3153
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3154 check_tr_functions_helper5:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3155 btfsc WREG,char_transmitter_lost ; transmitter 2 lost?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3156 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
3157 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
3158 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3159 check_tr_functions_helper5a:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3160 ; bsf show_transmitter_attention ; show transmitter attention
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3161 btfsc transmitter2_lost ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3162 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
3163 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
3164 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3165
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3166 check_tr_functions_helper6:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3167 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
3168 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
3169 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
3170 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3171 check_tr_functions_helper6a:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3172 bsf show_transmitter_attention ; show transmitter attention
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3173 btfsc transmitter2_battery ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3174 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
3175 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
3176 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3177
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3178 check_tr_functions_helper7:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3179 btfsc WREG,int_warning_flag ; transmitter 2 pressure warning?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3180 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
3181 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
3182 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3183 check_tr_functions_helper7a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3184 bsf show_pres_warning ; show pressure warning
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3185 btfsc transmitter2_pres_warn ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3186 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
3187 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
3188 bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3189
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3190 check_tr_functions_helper8:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3191 btfsc WREG,int_attention_flag ; transmitter 2 pressure attention?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3192 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
3193 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
3194 return ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3195 check_tr_functions_helper8a
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3196 bsf show_pres_attention ; show pressure attention
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3197 btfsc transmitter2_pres_att ; is it a new message?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3198 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
3199 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
3200 ;bra check_tr_functions_show_cv ; - show custom view
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3201
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3202 check_tr_functions_show_cv:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3203 btfsc pres_customview_shown ; is the pressure readings custom view not shown yet?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3204 return ; NO - already shown, done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3205 bsf pres_customview_shown ; YES - mark as shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3206 movlw index_pressures_SAC-1 ; - custom view number one below pressure readings
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3207 movwf active_customview ; - set custom view number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3208 bsf request_next_custview ; - initiate toggle to desired custom view -> pressure readings view will be shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3209 return ; - done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3210
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3211 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3212
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3213 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3214
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3215 check_gas_needs_ascent:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3216 banksel int_O_gas_need_pres
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3217 movf int_O_gas_need_pres+1,W ; get high byte from pres need of 1st tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3218 iorwf int_O_gas_need_pres+3,W ; inclusive or with high byte from pres need of 2nd tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3219 iorwf int_O_gas_need_pres+5,W ; inclusive or with high byte from pres need of 3rd tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3220 iorwf int_O_gas_need_pres+7,W ; inclusive or with high byte from pres need of 4th tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3221 iorwf int_O_gas_need_pres+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
3222 banksel common
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3223 btfsc WREG,int_invalid_flag ; check if invalid flag is set
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3224 return ; YES - no further checking required
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3225 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3226 bra check_gas_needs_ascent_warn ; YES - generate a warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3227 btfsc WREG,int_attention_flag ; NO - check if any gas has a pres_need >= pres_fill * threshold
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3228 bra check_gas_needs_ascent_att ; YES - generate an attention
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3229 bcf gas_needs_attention ; NO - clear flag for a new attention
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3230 bcf gas_needs_warning ; - clear flag for a new warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3231 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3232
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3233 check_gas_needs_ascent_warn:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3234 bsf message_warning ; set warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3235 incf message_counter,F ; increase counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3236 btfsc gas_needs_warning ; is it a new warning?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3237 goto TFT_warning_gas_needs_warn ; NO - do not show the gas needs custom view again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3238 bsf gas_needs_warning ; YES - memorize it's an old now
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3239 movlw index_gas_needs_ascent-1 ; - custom view number one below gas needs view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3240 movwf active_customview ; - set custom view number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3241 bsf request_next_custview ; - initiate toggle to desired custom view -> gas needs view will be shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3242 goto TFT_warning_gas_needs_warn ; - show warning message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3243
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3244 check_gas_needs_ascent_att:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3245 bsf message_attention ; set attention flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3246 incf message_counter,F ; increase counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3247 btfsc gas_needs_attention ; is it a new attention?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3248 goto TFT_warning_gas_needs_att ; NO - do not show the gas needs custom view again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3249 bsf gas_needs_attention ; YES - memorize it's an old now
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3250 movlw index_gas_needs_ascent-1 ; - custom view number one below gas needs view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3251 movwf active_customview ; - set custom view number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3252 bsf request_next_custview ; - initiate toggle to desired custom view -> gas needs view will be shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3253 goto TFT_warning_gas_needs_att ; - show attention message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3254
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3255 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3256
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3257 IFDEF _external_sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3258
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3259 check_warn_sensors_disagree:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3260 incf message_counter,F ; increase counter
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3261 bsf message_warning ; set warning flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3262 btfsc o2_sensors_warning ; is it a new warning?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3263 goto TFT_warning_sensor_disagree ; NO - don't show sensor custom view again, just show sensor disagree warning and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3264 bsf o2_sensors_warning ; YES - memorize it's an old warning now
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3265 call show_sensors_custview ; - show sensors custom view
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3266 goto TFT_warning_sensor_disagree ; - show sensor disagree warning and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3267
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3268 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3269
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3270 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3271
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3272 IFDEF _helium
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3273
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3274 check_IBCD:
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3275 TSTOSS opt_enable_IBCD ; IBCD warning activated?
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3276 return ; NO - done
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3277 movff char_O_deco_warnings,WREG ; YES - get deco warnings vector
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3278 btfss WREG,IBCD_warning ; IBCD warning flag set?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3279 return ; NO - return
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3280 incf message_counter,F ; YES - increase counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3281 goto TFT_warning_IBCD ; write warning to display
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3282
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3283 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3284
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3285 ;=============================================================================
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3286
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3287 check_OC_gas_avail:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3288 tstfsz best_gas_number ; is a breathable OC (bailout) gas available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3289 return ; YES (>0) - a breathable gas is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3290 btfsc bailout_mode ; NO (=0) - in bailout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3291 return ; YES - suppress warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3292 incf message_counter,F ; NO - increase counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3293 bsf message_warning ; - set attention flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3294 goto TFT_warning_no_BO_gas ; - show waring (and return)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3295
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3296
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3297 advice_gas_change:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3298 bsf message_advice ; show advice sign
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3299 incf message_counter,F ; increase counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3300 goto TFT_advice_gas_change
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3301
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3302
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3303 global restart_deco_engine
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3304 global restart_deco_engine_wo_ceiling
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3305 restart_deco_engine:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3306 banksel int_O_ceiling ; switch to bank where the shared "_O_" variables are stored
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3307 bsf int_O_ceiling+1,char_invalid_flag ; invalidate ceiling (int_O_ceiling has its invalid flag on a char's position!)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3308
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3309 restart_deco_engine_wo_ceiling:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3310 banksel char_O_deco_gas ; switch to bank where the shared "_O_" variables are stored
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3311 bsf char_O_deco_gas+0,char_invalid_flag ; invalidate deco data (stop table data)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3312 bsf int_O_TTS_norm+1,int_invalid_flag ; invalidate ascent time (normal plan)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3313 bsf int_O_CNS_norm+1,int_invalid_flag ; invalidate CNS at end of dive in normal plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3314 ; restart deco engine:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3315 bcf char_O_deco_status,DECO_COMPLETED_NORM ; eventually clear flag stating completion of normal plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3316 bsf char_O_deco_status,DECO_COMPLETED_ALT ; fake we came from alternative plan to force normal plan to be done next
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3317
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3318 inval_alternative_plan_data:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3319 banksel int_O_TTS_alt ; switch to bank where the shared "_O_" variables are stored
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3320 bsf int_O_TTS_alt+1,int_invalid_flag ; invalidate ascent time (alternative plan)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3321 bsf int_O_CNS_alt+1,int_invalid_flag ; invalidate CNS at end of dive in alternative plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3322 bsf int_O_gas_need_pres+1,int_invalid_flag ; invalidate ascent gas needs
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3323
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3324 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3325 bsf int_O_pressure_need+1,int_not_avail_flag ; invalidate pressure needs to reading 1 (TR functions)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3326 bsf int_O_pressure_need+3,int_not_avail_flag ; invalidate pressure needs to reading 2 (TR functions)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3327 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3328
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3329 banksel common ; bank to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3330 bsf new_deco_data_avail ; set flag for new NDL and deco data available to have the display updated
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3331
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3332 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3333
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3334 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3335 ; Simulator Mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3336 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3337 global do_demo_divemode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 564
diff changeset
3338 do_demo_divemode:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3339
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3340 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3341 bsf simulatormode ; will restore tissue pressures and CNS value after simulator use
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
3342 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 555
diff changeset
3343
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3344 call TFT_ClearScreen ; blank screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3345 call option_save_all ; save all settings into EEPROM before starting simulation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3346 call deco_push_tissues_to_vault ; back-up the tissue pressures (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3347 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3348
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3349 ; set simulated target depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3350 movff char_I_bottom_depth,simulatormode_depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3351
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3352 ; set initial simulated depth (needed to overcome end-of-dive detection)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3353 banksel pressure_rel_sim
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3354 MOVLI simulator_startdepth,pressure_rel_sim
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3355 banksel common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3356
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3357 ; switch ISR pressure calculations to simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3358 bcf quit_simulatormode ; clear flag for fast abort request
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3359 bcf sensor_override_active ; make sure ISR mode switch confirmation is not older than from now on
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3360 bsf sensor_override_request ; request ISR to switch to simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3361 btfss sensor_override_active ; has the ISR confirmed switch to simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3362 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3363
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3364 ; branch into dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3365 bsf divemode ; activate dive mode (to be done after simulator mode is activated)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3366 goto diveloop ; branch to dive mode code
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3367
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
3368 END