annotate src/surfmode.asm @ 230:f6548e8f06f5

Bugfix: Check for divemode before checking for menu
author mh@mh-THINK
date Fri, 20 Feb 2015 00:15:22 +0100
parents 8c11f60193be
children fe9d88fee09f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File surfmode.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Surfacemode
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-07 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
14 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "isr.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "adc_lightsensor.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "menu_processor.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "sleepmode.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "wait.inc" ; speed_*
heinrichsweikamp
parents:
diff changeset
23 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
24 #include "customview.inc"
heinrichsweikamp
parents:
diff changeset
25 #include "divemode.inc"
heinrichsweikamp
parents:
diff changeset
26 #include "mcp.inc" ; RX
heinrichsweikamp
parents:
diff changeset
27 #include "i2c.inc"
heinrichsweikamp
parents:
diff changeset
28 #include "comm.inc"
heinrichsweikamp
parents:
diff changeset
29 #include "eeprom_rs232.inc"
113
heinrichsweikamp
parents: 76
diff changeset
30 #include "calibrate.inc"
0
heinrichsweikamp
parents:
diff changeset
31
213
3b5df65d53fc layout changes
heinrichsweikamp
parents: 205
diff changeset
32 extern do_main_menu
3b5df65d53fc layout changes
heinrichsweikamp
parents: 205
diff changeset
33
0
heinrichsweikamp
parents:
diff changeset
34 #DEFINE menu_pos_row .215
213
3b5df65d53fc layout changes
heinrichsweikamp
parents: 205
diff changeset
35 #DEFINE menu_pos_column .1
0
heinrichsweikamp
parents:
diff changeset
36 #DEFINE view_row .215
heinrichsweikamp
parents:
diff changeset
37 #DEFINE view_column .124
heinrichsweikamp
parents:
diff changeset
38
heinrichsweikamp
parents:
diff changeset
39 gui CODE
heinrichsweikamp
parents:
diff changeset
40
heinrichsweikamp
parents:
diff changeset
41
heinrichsweikamp
parents:
diff changeset
42 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
43 ; Boot tasks for all modes
heinrichsweikamp
parents:
diff changeset
44 global surfloop
heinrichsweikamp
parents:
diff changeset
45 surfloop:
heinrichsweikamp
parents:
diff changeset
46 call speed_normal
heinrichsweikamp
parents:
diff changeset
47 bcf no_sensor_int ; Normal pressure mode
heinrichsweikamp
parents:
diff changeset
48
heinrichsweikamp
parents:
diff changeset
49 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
50 bcf PORTC,2 ; Pull PWM output to GND
heinrichsweikamp
parents:
diff changeset
51 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
52 bcf restore_deco_data
heinrichsweikamp
parents:
diff changeset
53
heinrichsweikamp
parents:
diff changeset
54 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
55 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
56 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
57 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
58 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
59 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
60 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
61 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
62 extern color_image
heinrichsweikamp
parents:
diff changeset
63 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
64
heinrichsweikamp
parents:
diff changeset
65 WIN_TOP .100
heinrichsweikamp
parents:
diff changeset
66 WIN_LEFT .34
heinrichsweikamp
parents:
diff changeset
67 extern ostc3_logo_block
heinrichsweikamp
parents:
diff changeset
68 movlw LOW(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
69 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
70 movlw HIGH ostc3_logo_block;&0xFFFF
heinrichsweikamp
parents:
diff changeset
71 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
72 movlw UPPER(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
73 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
74 call color_image
heinrichsweikamp
parents:
diff changeset
75 call TFT_Display_FadeIn ; Show splash
heinrichsweikamp
parents:
diff changeset
76 call TFT_serial ; Show serial and firmware version
heinrichsweikamp
parents:
diff changeset
77
heinrichsweikamp
parents:
diff changeset
78 ;---- Do any usefull initializes that takes time -------------------------
heinrichsweikamp
parents:
diff changeset
79 call restart_set_modes_and_flags ; Sets decomode flags
heinrichsweikamp
parents:
diff changeset
80 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
81 call I2C_init_compass
heinrichsweikamp
parents:
diff changeset
82 call I2C_init_accelerometer
heinrichsweikamp
parents:
diff changeset
83 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
84 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
85 clrf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
86
226
8c11f60193be button config (cR)
heinrichsweikamp
parents: 221
diff changeset
87 btfsc cr_hardware
221
90923a081ae7 minor: configure buttons during splash screen
heinrichsweikamp
parents: 213
diff changeset
88 call piezo_config ; Configure buttons
90923a081ae7 minor: configure buttons during splash screen
heinrichsweikamp
parents: 213
diff changeset
89
0
heinrichsweikamp
parents:
diff changeset
90 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
91 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
92 bcf menubit ; clear menu flag
heinrichsweikamp
parents:
diff changeset
93 clrf last_pressure+0
heinrichsweikamp
parents:
diff changeset
94 clrf last_pressure+1
heinrichsweikamp
parents:
diff changeset
95 bcf is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
96 bcf ccr_diluent_setup ; Use OC gases for gaslist routine
heinrichsweikamp
parents:
diff changeset
97
heinrichsweikamp
parents:
diff changeset
98 bcf simulatormode_active ; Quit simulator mode (if active)
heinrichsweikamp
parents:
diff changeset
99 bcf switch_left
heinrichsweikamp
parents:
diff changeset
100 bcf switch_right
heinrichsweikamp
parents:
diff changeset
101 bcf LEDg
heinrichsweikamp
parents:
diff changeset
102 bcf LEDr
heinrichsweikamp
parents:
diff changeset
103
heinrichsweikamp
parents:
diff changeset
104 ;---- Fade to standard surface view --------------------------------------
heinrichsweikamp
parents:
diff changeset
105 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
106 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
107 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
108 bra $-2
heinrichsweikamp
parents:
diff changeset
109 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
110 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
111 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
112 bra $-2
heinrichsweikamp
parents:
diff changeset
113
heinrichsweikamp
parents:
diff changeset
114 call TFT_Display_FadeOut ; Go to black screen
heinrichsweikamp
parents:
diff changeset
115 call TFT_ClearScreen ; Then change everything
heinrichsweikamp
parents:
diff changeset
116 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
117 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
118 WIN_FONT FT_SMALL
189
e79bc535ef9e ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents: 188
diff changeset
119 bcf win_invert ; Reset invert flag
0
heinrichsweikamp
parents:
diff changeset
120
heinrichsweikamp
parents:
diff changeset
121 WIN_COLOR color_lightblue
heinrichsweikamp
parents:
diff changeset
122 WIN_SMALL menu_pos_column,menu_pos_row
heinrichsweikamp
parents:
diff changeset
123 STRCPY_TEXT_PRINT tMenu ;"<Menu"
heinrichsweikamp
parents:
diff changeset
124 WIN_SMALL view_column,view_row
heinrichsweikamp
parents:
diff changeset
125 STRCPY_TEXT_PRINT tView ;"View>"
heinrichsweikamp
parents:
diff changeset
126 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
127
48
7c7d7644ca37 Time and Date in normal (Not tiny) font
heinrichsweikamp
parents: 39
diff changeset
128 ; Logo
0
heinrichsweikamp
parents:
diff changeset
129 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
130 WIN_LEFT .70
heinrichsweikamp
parents:
diff changeset
131 movlw LOW(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
132 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
133 movlw HIGH ostc3_logo_block;&0xFFFF
heinrichsweikamp
parents:
diff changeset
134 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
135 movlw UPPER(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
136 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
137 call color_image
heinrichsweikamp
parents:
diff changeset
138
158
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
139 call TFT_clock ; display time
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
140 call update_surfloop60
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
141 call get_battery_voltage ; get battery voltage
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
142 call TFT_update_batt_voltage ; display battery voltage
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
143 call TFT_update_surf_press ; display surface pressure
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
144 call TFT_temp_surfmode ; Displays temperature
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
145 call TFT_display_decotype_surface
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
146 movff customview_surfmode,menupos3 ; Reload last customview
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
147 call surf_customview_mask ; Update #menupos3 view
0
heinrichsweikamp
parents:
diff changeset
148
heinrichsweikamp
parents:
diff changeset
149 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
150
heinrichsweikamp
parents:
diff changeset
151 ;---- Late initialisations -----------------------------------------------
heinrichsweikamp
parents:
diff changeset
152 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
153 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
154 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
155 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
156 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
157 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
158
158
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
159 ; Startup tasks for all modes
0
heinrichsweikamp
parents:
diff changeset
160 ; Desaturation time needs:
heinrichsweikamp
parents:
diff changeset
161 ; int_I_pres_surface
heinrichsweikamp
parents:
diff changeset
162 ; char_I_desaturation_multiplier
heinrichsweikamp
parents:
diff changeset
163 call deco_calc_desaturation_time ; calculate desaturation time
heinrichsweikamp
parents:
diff changeset
164 movlb b'00000001' ; select ram bank 1
heinrichsweikamp
parents:
diff changeset
165
heinrichsweikamp
parents:
diff changeset
166 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
167 call enable_rs232 ; Also sets to speed_normal ...
heinrichsweikamp
parents:
diff changeset
168
heinrichsweikamp
parents:
diff changeset
169 surfloop_loop:
heinrichsweikamp
parents:
diff changeset
170 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
171 bra surfloop_loop2 ; no, loop
heinrichsweikamp
parents:
diff changeset
172
heinrichsweikamp
parents:
diff changeset
173 ; One Second tasks for all modes
heinrichsweikamp
parents:
diff changeset
174 call speed_normal
heinrichsweikamp
parents:
diff changeset
175 call TFT_debug_output
heinrichsweikamp
parents:
diff changeset
176 call TFT_clock ; update clock
heinrichsweikamp
parents:
diff changeset
177 call timeout_surfmode ; check timeout
heinrichsweikamp
parents:
diff changeset
178 call get_battery_voltage ; get battery voltage
heinrichsweikamp
parents:
diff changeset
179 call TFT_update_batt_voltage ; display battery voltage
heinrichsweikamp
parents:
diff changeset
180 call set_dive_modes ; tests if depth>threshold
heinrichsweikamp
parents:
diff changeset
181 btfss secs,0 ; Every two seconds...
heinrichsweikamp
parents:
diff changeset
182 call TFT_temp_surfmode ; Displays temperature
heinrichsweikamp
parents:
diff changeset
183 btfss secs,0 ; Every two seconds...
heinrichsweikamp
parents:
diff changeset
184 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them
heinrichsweikamp
parents:
diff changeset
185
heinrichsweikamp
parents:
diff changeset
186 bcf onesecupdate ; every second tasks done
heinrichsweikamp
parents:
diff changeset
187
heinrichsweikamp
parents:
diff changeset
188 surfloop_loop2:
heinrichsweikamp
parents:
diff changeset
189 ; Tasks approx. every 50ms for all modes
heinrichsweikamp
parents:
diff changeset
190 call test_switches_surfmode ; check switches
heinrichsweikamp
parents:
diff changeset
191
heinrichsweikamp
parents:
diff changeset
192 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
193 btfsc oneminupdate ; do every minute tasks
heinrichsweikamp
parents:
diff changeset
194 call update_surfloop60 ; yes, e.g. update time and date
heinrichsweikamp
parents:
diff changeset
195
heinrichsweikamp
parents:
diff changeset
196 ; Mode tasks
230
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
197 btfsc divemode ; Divemode active?
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
198 goto diveloop ; Yes, switch into Divemode!
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
199
0
heinrichsweikamp
parents:
diff changeset
200 btfsc menubit ; Menu?
heinrichsweikamp
parents:
diff changeset
201 goto do_main_menu ; Menu!
heinrichsweikamp
parents:
diff changeset
202
heinrichsweikamp
parents:
diff changeset
203 btfsc pressure_refresh ; new pressure available?
heinrichsweikamp
parents:
diff changeset
204 call TFT_update_surf_press ; display surface pressure
heinrichsweikamp
parents:
diff changeset
205 bcf pressure_refresh ; until new pressure is available
heinrichsweikamp
parents:
diff changeset
206
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
207 ; Updates every 1/4 second
0
heinrichsweikamp
parents:
diff changeset
208 btfss quarter_second_update
heinrichsweikamp
parents:
diff changeset
209 bra surfloop_loop2a
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
210
0
heinrichsweikamp
parents:
diff changeset
211 bcf quarter_second_update
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
212 ; Update Sensors
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
213
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
214 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
215 call check_sensors ; Set enable/disable flags
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
216 btfsc FLAG_ccr_mode ; In CCR mode...
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
217 call TFT_surface_sensor ; ...update sensor data in surface mode
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
218
0
heinrichsweikamp
parents:
diff changeset
219 movlw .6
heinrichsweikamp
parents:
diff changeset
220 cpfseq menupos3 ; in compass view?
heinrichsweikamp
parents:
diff changeset
221 bra surfloop_loop2a ; No
heinrichsweikamp
parents:
diff changeset
222 call TFT_surface_compass_heading ; Yes, update compass heading value
heinrichsweikamp
parents:
diff changeset
223
heinrichsweikamp
parents:
diff changeset
224 surfloop_loop2a:
heinrichsweikamp
parents:
diff changeset
225 btfsc toggle_customview ; Next view?
heinrichsweikamp
parents:
diff changeset
226 call surf_customview_toggle ; Yes, show next customview (and delete this flag)
heinrichsweikamp
parents:
diff changeset
227
heinrichsweikamp
parents:
diff changeset
228 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
229 bra surfloop_loop3
heinrichsweikamp
parents:
diff changeset
230 btfsc vusb_in ; USB plugged in?
113
heinrichsweikamp
parents: 76
diff changeset
231 call comm_mode ; Start COMM mode
0
heinrichsweikamp
parents:
diff changeset
232 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
233 surfloop_loop3:
heinrichsweikamp
parents:
diff changeset
234 btfss vusb_in ; USB (still) plugged in?
heinrichsweikamp
parents:
diff changeset
235 bcf enable_screen_dumps ; No, clear flag
heinrichsweikamp
parents:
diff changeset
236 call rs232_get_byte
heinrichsweikamp
parents:
diff changeset
237 btfsc rs232_recieve_overflow
heinrichsweikamp
parents:
diff changeset
238 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
239 movlw "l"
heinrichsweikamp
parents:
diff changeset
240 cpfseq RCREG1
heinrichsweikamp
parents:
diff changeset
241 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
242 call TFT_dump_screen ; Dump the screen contents
heinrichsweikamp
parents:
diff changeset
243 surfloop_loop4:
heinrichsweikamp
parents:
diff changeset
244 btfsc sleepmode ; Sleepmode active?
heinrichsweikamp
parents:
diff changeset
245 goto sleeploop ; Yes, switch into sleepmode!
heinrichsweikamp
parents:
diff changeset
246
heinrichsweikamp
parents:
diff changeset
247 bra surfloop_loop ; loop surfacemode
heinrichsweikamp
parents:
diff changeset
248
heinrichsweikamp
parents:
diff changeset
249 update_surfloop60:
heinrichsweikamp
parents:
diff changeset
250 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
251 call TFT_date ; Update date
heinrichsweikamp
parents:
diff changeset
252 call calc_deko_surfmode ; calculate desaturation every minute
heinrichsweikamp
parents:
diff changeset
253 bcf oneminupdate
heinrichsweikamp
parents:
diff changeset
254 return
heinrichsweikamp
parents:
diff changeset
255
heinrichsweikamp
parents:
diff changeset
256 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation
heinrichsweikamp
parents:
diff changeset
257 surfmode_check_for_warnings:
heinrichsweikamp
parents:
diff changeset
258 movf warning_counter_backup,W
heinrichsweikamp
parents:
diff changeset
259 cpfseq warning_counter ; warning_counter_backup = warning_counter?
heinrichsweikamp
parents:
diff changeset
260 call TFT_clear_warning_text ; No, clear all warnings
heinrichsweikamp
parents:
diff changeset
261 movff warning_counter,warning_counter_backup ; copy warning_counter
heinrichsweikamp
parents:
diff changeset
262
heinrichsweikamp
parents:
diff changeset
263 bcf warning_active ; Clear flag
heinrichsweikamp
parents:
diff changeset
264 clrf warning_counter ; Clear counter
heinrichsweikamp
parents:
diff changeset
265
heinrichsweikamp
parents:
diff changeset
266 ; Warnings for all modes
heinrichsweikamp
parents:
diff changeset
267 call check_warn_battery ; Check if the battery level should be displayed/warned
205
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
268 rcall surfmode_check_for_nofly ; Check if nofly time should be shown
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
269 rcall surfmode_check_for_desat ; Check if desat time should be shown
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
270 rcall surfmode_check_for_interval ; Check if surface interval should be shown
0
heinrichsweikamp
parents:
diff changeset
271
heinrichsweikamp
parents:
diff changeset
272 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
273 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
274 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
275 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
276
heinrichsweikamp
parents:
diff changeset
277 ; Warnings only in deco modes
heinrichsweikamp
parents:
diff changeset
278 call check_cns_violation ; Check CNS value and display it, if required
heinrichsweikamp
parents:
diff changeset
279 call check_and_store_gf_violation ; Check GF value and display it, if required
heinrichsweikamp
parents:
diff changeset
280
heinrichsweikamp
parents:
diff changeset
281 surfmode_check_for_warnings2:
heinrichsweikamp
parents:
diff changeset
282 ; Setup warning_page number
heinrichsweikamp
parents:
diff changeset
283 incf warning_page,F
heinrichsweikamp
parents:
diff changeset
284 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
285 rlcf warning_page,W ; *2
heinrichsweikamp
parents:
diff changeset
286 cpfsgt warning_counter ; > warning_counter
heinrichsweikamp
parents:
diff changeset
287 clrf warning_page ; No, clear
heinrichsweikamp
parents:
diff changeset
288
heinrichsweikamp
parents:
diff changeset
289 ; Clear 2nd row of warnings if there is nothing to show (on this page)
heinrichsweikamp
parents:
diff changeset
290 btfss second_row_warning ; =1: The second row contains a warning
heinrichsweikamp
parents:
diff changeset
291 call TFT_clear_warning_text_2nd_row ; No, clear this row
heinrichsweikamp
parents:
diff changeset
292 return ; Done.
heinrichsweikamp
parents:
diff changeset
293
heinrichsweikamp
parents:
diff changeset
294 surfmode_check_for_interval:
heinrichsweikamp
parents:
diff changeset
295 movf surface_interval+0,W ; Is interval null ?
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
296 iorwf surface_interval+1,W
0
heinrichsweikamp
parents:
diff changeset
297 bnz surfmode_check_for_interval2 ; No
heinrichsweikamp
parents:
diff changeset
298 return
heinrichsweikamp
parents:
diff changeset
299 surfmode_check_for_interval2:
heinrichsweikamp
parents:
diff changeset
300 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
301 call TFT_interval
heinrichsweikamp
parents:
diff changeset
302 return
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304
heinrichsweikamp
parents:
diff changeset
305 surfmode_check_for_desat:
heinrichsweikamp
parents:
diff changeset
306 movf desaturation_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
307 iorwf desaturation_time+1,W
heinrichsweikamp
parents:
diff changeset
308 bnz surfmode_check_for_desat2 ; No
heinrichsweikamp
parents:
diff changeset
309 return
heinrichsweikamp
parents:
diff changeset
310 surfmode_check_for_desat2:
heinrichsweikamp
parents:
diff changeset
311 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
312 call TFT_desaturation_time
heinrichsweikamp
parents:
diff changeset
313 return
heinrichsweikamp
parents:
diff changeset
314
heinrichsweikamp
parents:
diff changeset
315 surfmode_check_for_nofly:
heinrichsweikamp
parents:
diff changeset
316 movf nofly_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
317 iorwf nofly_time+1,W
heinrichsweikamp
parents:
diff changeset
318 bnz surfmode_check_for_nofly2 ; No...
heinrichsweikamp
parents:
diff changeset
319 return
heinrichsweikamp
parents:
diff changeset
320 surfmode_check_for_nofly2:
heinrichsweikamp
parents:
diff changeset
321 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
322 call TFT_nofly_time
heinrichsweikamp
parents:
diff changeset
323 return
heinrichsweikamp
parents:
diff changeset
324
heinrichsweikamp
parents:
diff changeset
325
heinrichsweikamp
parents:
diff changeset
326 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
327 global calc_deko_surfmode
heinrichsweikamp
parents:
diff changeset
328 calc_deko_surfmode:
heinrichsweikamp
parents:
diff changeset
329 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
330 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
heinrichsweikamp
parents:
diff changeset
331 banksel common
heinrichsweikamp
parents:
diff changeset
332 return
heinrichsweikamp
parents:
diff changeset
333
heinrichsweikamp
parents:
diff changeset
334 test_switches_surfmode: ; checks switches in surfacemode
heinrichsweikamp
parents:
diff changeset
335 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
336 bra test_switches_surfmode2
heinrichsweikamp
parents:
diff changeset
337 btfsc switch_left
heinrichsweikamp
parents:
diff changeset
338 bra test_switches_surfmode3
heinrichsweikamp
parents:
diff changeset
339
heinrichsweikamp
parents:
diff changeset
340 ; No button press
heinrichsweikamp
parents:
diff changeset
341 return
heinrichsweikamp
parents:
diff changeset
342
heinrichsweikamp
parents:
diff changeset
343 test_switches_surfmode3:
heinrichsweikamp
parents:
diff changeset
344 bcf switch_left
heinrichsweikamp
parents:
diff changeset
345 bsf menubit ; Enter Menu!
heinrichsweikamp
parents:
diff changeset
346 return
heinrichsweikamp
parents:
diff changeset
347
heinrichsweikamp
parents:
diff changeset
348 test_switches_surfmode2:
heinrichsweikamp
parents:
diff changeset
349 bcf switch_right
heinrichsweikamp
parents:
diff changeset
350 bsf toggle_customview
heinrichsweikamp
parents:
diff changeset
351 clrf timeout_counter2 ; and reset timeout
heinrichsweikamp
parents:
diff changeset
352 return
heinrichsweikamp
parents:
diff changeset
353
heinrichsweikamp
parents:
diff changeset
354 global timeout_surfmode
heinrichsweikamp
parents:
diff changeset
355 timeout_surfmode:
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
356 movlw timeout_surfacemode ; [s] Default timeout
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 158
diff changeset
357 btfsc menu_show_sensors2 ; In the "Calibrate" menu?
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
358 movlw timeout_calibrate_menu ; [s] CCR Calibrate Menu timeout
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
359 btfsc menubit ; in Menu?
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
360 bra timeout_testmode ; No, done.
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
361 ; Must be in surface mode
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
362 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
363 bra timeout_testmode ; No, not CCR
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
364 movlw timeout_ccr_surface ; [s] CCR Surface mode timeout
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
365
0
heinrichsweikamp
parents:
diff changeset
366 global timeout_testmode
heinrichsweikamp
parents:
diff changeset
367 timeout_testmode:
heinrichsweikamp
parents:
diff changeset
368 incf timeout_counter2,F ; increase timeout counter
heinrichsweikamp
parents:
diff changeset
369 cpfsgt timeout_counter2 ; Compare with timeout_counter2
heinrichsweikamp
parents:
diff changeset
370 return ; return, no timeout
heinrichsweikamp
parents:
diff changeset
371 bsf sleepmode ; Set Flag
heinrichsweikamp
parents:
diff changeset
372 return ; Return
heinrichsweikamp
parents:
diff changeset
373
heinrichsweikamp
parents:
diff changeset
374 END