annotate src/surfmode.asm @ 71:4f83366fb943

1.13 beta start
author heinrichsweikamp
date Tue, 04 Feb 2014 13:18:37 +0100
parents ec4d8503ec45
children a5ea132770db
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"
heinrichsweikamp
parents:
diff changeset
30
heinrichsweikamp
parents:
diff changeset
31 #DEFINE menu_pos_row .215
heinrichsweikamp
parents:
diff changeset
32 #DEFINE menu_pos_column .0
heinrichsweikamp
parents:
diff changeset
33 #DEFINE view_row .215
heinrichsweikamp
parents:
diff changeset
34 #DEFINE view_column .124
heinrichsweikamp
parents:
diff changeset
35
heinrichsweikamp
parents:
diff changeset
36 extern do_main_menu
heinrichsweikamp
parents:
diff changeset
37
heinrichsweikamp
parents:
diff changeset
38 gui CODE
heinrichsweikamp
parents:
diff changeset
39
heinrichsweikamp
parents:
diff changeset
40
heinrichsweikamp
parents:
diff changeset
41 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
42 ; Boot tasks for all modes
heinrichsweikamp
parents:
diff changeset
43 global surfloop
heinrichsweikamp
parents:
diff changeset
44 surfloop:
heinrichsweikamp
parents:
diff changeset
45 call speed_normal
heinrichsweikamp
parents:
diff changeset
46 bcf no_sensor_int ; Normal pressure mode
heinrichsweikamp
parents:
diff changeset
47
heinrichsweikamp
parents:
diff changeset
48 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
49 bcf PORTC,2 ; Pull PWM output to GND
heinrichsweikamp
parents:
diff changeset
50 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
51 bcf restore_deco_data
heinrichsweikamp
parents:
diff changeset
52
heinrichsweikamp
parents:
diff changeset
53 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
54 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
55 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
56 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
57 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
58 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
59 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
60 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
61 extern color_image
heinrichsweikamp
parents:
diff changeset
62 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
63
heinrichsweikamp
parents:
diff changeset
64 WIN_TOP .100
heinrichsweikamp
parents:
diff changeset
65 WIN_LEFT .34
heinrichsweikamp
parents:
diff changeset
66 extern ostc3_logo_block
heinrichsweikamp
parents:
diff changeset
67 movlw LOW(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
68 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
69 movlw HIGH ostc3_logo_block;&0xFFFF
heinrichsweikamp
parents:
diff changeset
70 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
71 movlw UPPER(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
72 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
73 call color_image
heinrichsweikamp
parents:
diff changeset
74 call TFT_Display_FadeIn ; Show splash
heinrichsweikamp
parents:
diff changeset
75 call TFT_serial ; Show serial and firmware version
heinrichsweikamp
parents:
diff changeset
76
heinrichsweikamp
parents:
diff changeset
77 ;---- Do any usefull initializes that takes time -------------------------
heinrichsweikamp
parents:
diff changeset
78 call restart_set_modes_and_flags ; Sets decomode flags
heinrichsweikamp
parents:
diff changeset
79 ; call speed_fastest
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
heinrichsweikamp
parents:
diff changeset
87 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
88 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
89 bcf premenu ; clear premenu flag
heinrichsweikamp
parents:
diff changeset
90 bcf menubit ; clear menu flag
heinrichsweikamp
parents:
diff changeset
91 clrf last_pressure+0
heinrichsweikamp
parents:
diff changeset
92 clrf last_pressure+1
heinrichsweikamp
parents:
diff changeset
93 bcf is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
94 bcf ccr_diluent_setup ; Use OC gases for gaslist routine
heinrichsweikamp
parents:
diff changeset
95
heinrichsweikamp
parents:
diff changeset
96 bcf simulatormode_active ; Quit simulator mode (if active)
heinrichsweikamp
parents:
diff changeset
97 bcf switch_left
heinrichsweikamp
parents:
diff changeset
98 bcf switch_right
heinrichsweikamp
parents:
diff changeset
99 bcf LEDg
heinrichsweikamp
parents:
diff changeset
100 bcf LEDr
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 ;---- Fade to standard surface view --------------------------------------
heinrichsweikamp
parents:
diff changeset
103 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
104 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
105 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
106 bra $-2
heinrichsweikamp
parents:
diff changeset
107 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
108 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
109 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
110 bra $-2
heinrichsweikamp
parents:
diff changeset
111
heinrichsweikamp
parents:
diff changeset
112 call TFT_Display_FadeOut ; Go to black screen
heinrichsweikamp
parents:
diff changeset
113 call TFT_ClearScreen ; Then change everything
heinrichsweikamp
parents:
diff changeset
114 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
115 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
116 WIN_FONT FT_SMALL
heinrichsweikamp
parents:
diff changeset
117 WIN_INVERT .0 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
118
heinrichsweikamp
parents:
diff changeset
119 ; call TFT_user_image ; Show the user image/text
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
heinrichsweikamp
parents:
diff changeset
128 call TFT_clock ; display time
heinrichsweikamp
parents:
diff changeset
129 call update_surfloop60
heinrichsweikamp
parents:
diff changeset
130 call get_battery_voltage ; get battery voltage
heinrichsweikamp
parents:
diff changeset
131 call TFT_update_batt_voltage ; display battery voltage
heinrichsweikamp
parents:
diff changeset
132 call TFT_update_surf_press ; display surface pressure
heinrichsweikamp
parents:
diff changeset
133 call TFT_temp_surfmode ; Displays temperature
heinrichsweikamp
parents:
diff changeset
134 call TFT_display_decotype_surface
39
e4e91fe8b09d remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents: 0
diff changeset
135 movff customview_surfmode,menupos3 ; Reload last customview
0
heinrichsweikamp
parents:
diff changeset
136 call surf_customview_mask ; Update #menupos3 view
heinrichsweikamp
parents:
diff changeset
137
48
7c7d7644ca37 Time and Date in normal (Not tiny) font
heinrichsweikamp
parents: 39
diff changeset
138 ; Logo
0
heinrichsweikamp
parents:
diff changeset
139 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
140 WIN_LEFT .70
heinrichsweikamp
parents:
diff changeset
141 movlw LOW(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
142 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
143 movlw HIGH ostc3_logo_block;&0xFFFF
heinrichsweikamp
parents:
diff changeset
144 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
145 movlw UPPER(ostc3_logo_block)
heinrichsweikamp
parents:
diff changeset
146 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
147 call color_image
heinrichsweikamp
parents:
diff changeset
148
heinrichsweikamp
parents:
diff changeset
149 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode
heinrichsweikamp
parents:
diff changeset
150 bra surfloop1
heinrichsweikamp
parents:
diff changeset
151 btfsc FLAG_gauge_mode ; Ignore in Gauge mode
heinrichsweikamp
parents:
diff changeset
152 bra surfloop1
heinrichsweikamp
parents:
diff changeset
153
heinrichsweikamp
parents:
diff changeset
154 surfloop1:
heinrichsweikamp
parents:
diff changeset
155 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
156
heinrichsweikamp
parents:
diff changeset
157 ;---- Late initialisations -----------------------------------------------
heinrichsweikamp
parents:
diff changeset
158 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
159 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
160 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
161 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
162 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
163 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
164
heinrichsweikamp
parents:
diff changeset
165 extern do_demo_divemode
heinrichsweikamp
parents:
diff changeset
166 ; goto do_demo_divemode
heinrichsweikamp
parents:
diff changeset
167
heinrichsweikamp
parents:
diff changeset
168 ; Startup tasks for all modes
heinrichsweikamp
parents:
diff changeset
169 ; Desaturation time needs:
heinrichsweikamp
parents:
diff changeset
170 ; int_I_pres_surface
heinrichsweikamp
parents:
diff changeset
171 ; char_I_desaturation_multiplier
heinrichsweikamp
parents:
diff changeset
172 call deco_calc_desaturation_time ; calculate desaturation time
heinrichsweikamp
parents:
diff changeset
173 movlb b'00000001' ; select ram bank 1
heinrichsweikamp
parents:
diff changeset
174
heinrichsweikamp
parents:
diff changeset
175 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
176 call enable_rs232 ; Also sets to speed_normal ...
heinrichsweikamp
parents:
diff changeset
177
heinrichsweikamp
parents:
diff changeset
178 surfloop_loop:
heinrichsweikamp
parents:
diff changeset
179 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
180 bra surfloop_loop2 ; no, loop
heinrichsweikamp
parents:
diff changeset
181
heinrichsweikamp
parents:
diff changeset
182 ; One Second tasks for all modes
heinrichsweikamp
parents:
diff changeset
183 call speed_normal
heinrichsweikamp
parents:
diff changeset
184 call TFT_debug_output
heinrichsweikamp
parents:
diff changeset
185 call TFT_clock ; update clock
heinrichsweikamp
parents:
diff changeset
186 call timeout_surfmode ; check timeout
heinrichsweikamp
parents:
diff changeset
187 call get_battery_voltage ; get battery voltage
heinrichsweikamp
parents:
diff changeset
188 call TFT_update_batt_voltage ; display battery voltage
heinrichsweikamp
parents:
diff changeset
189 call timeout_premenu ; timeout premenu
heinrichsweikamp
parents:
diff changeset
190 call set_dive_modes ; tests if depth>threshold
heinrichsweikamp
parents:
diff changeset
191 btfss secs,0 ; Every two seconds...
heinrichsweikamp
parents:
diff changeset
192 call TFT_temp_surfmode ; Displays temperature
heinrichsweikamp
parents:
diff changeset
193 btfss secs,0 ; Every two seconds...
heinrichsweikamp
parents:
diff changeset
194 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them
heinrichsweikamp
parents:
diff changeset
195
heinrichsweikamp
parents:
diff changeset
196 btfsc FLAG_ccr_mode ; In CCR mode...
heinrichsweikamp
parents:
diff changeset
197 call TFT_surface_hud ; ...update HUD data in surface mode
heinrichsweikamp
parents:
diff changeset
198
heinrichsweikamp
parents:
diff changeset
199 bcf onesecupdate ; every second tasks done
heinrichsweikamp
parents:
diff changeset
200
heinrichsweikamp
parents:
diff changeset
201 surfloop_loop2:
heinrichsweikamp
parents:
diff changeset
202 ; Tasks approx. every 50ms for all modes
heinrichsweikamp
parents:
diff changeset
203 call test_switches_surfmode ; check switches
heinrichsweikamp
parents:
diff changeset
204 call speed_normal
heinrichsweikamp
parents:
diff changeset
205
heinrichsweikamp
parents:
diff changeset
206 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
207 btfsc oneminupdate ; do every minute tasks
heinrichsweikamp
parents:
diff changeset
208 call update_surfloop60 ; yes, e.g. update time and date
heinrichsweikamp
parents:
diff changeset
209
heinrichsweikamp
parents:
diff changeset
210 ; Mode tasks
heinrichsweikamp
parents:
diff changeset
211 btfsc menubit ; Menu?
heinrichsweikamp
parents:
diff changeset
212 goto do_main_menu ; Menu!
heinrichsweikamp
parents:
diff changeset
213
heinrichsweikamp
parents:
diff changeset
214 btfsc pressure_refresh ; new pressure available?
heinrichsweikamp
parents:
diff changeset
215 call TFT_update_surf_press ; display surface pressure
heinrichsweikamp
parents:
diff changeset
216 bcf pressure_refresh ; until new pressure is available
heinrichsweikamp
parents:
diff changeset
217
heinrichsweikamp
parents:
diff changeset
218 btfss quarter_second_update
heinrichsweikamp
parents:
diff changeset
219 bra surfloop_loop2a
heinrichsweikamp
parents:
diff changeset
220 bcf quarter_second_update
heinrichsweikamp
parents:
diff changeset
221 movlw .6
heinrichsweikamp
parents:
diff changeset
222 cpfseq menupos3 ; in compass view?
heinrichsweikamp
parents:
diff changeset
223 bra surfloop_loop2a ; No
heinrichsweikamp
parents:
diff changeset
224 call TFT_surface_compass_heading ; Yes, update compass heading value
heinrichsweikamp
parents:
diff changeset
225
heinrichsweikamp
parents:
diff changeset
226 surfloop_loop2a:
heinrichsweikamp
parents:
diff changeset
227 btfsc toggle_customview ; Next view?
heinrichsweikamp
parents:
diff changeset
228 call surf_customview_toggle ; Yes, show next customview (and delete this flag)
heinrichsweikamp
parents:
diff changeset
229
heinrichsweikamp
parents:
diff changeset
230 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
231 bra surfloop_loop3
heinrichsweikamp
parents:
diff changeset
232 btfsc vusb_in ; USB plugged in?
heinrichsweikamp
parents:
diff changeset
233 goto comm_mode ; Start COMM mode
heinrichsweikamp
parents:
diff changeset
234 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
235 surfloop_loop3:
heinrichsweikamp
parents:
diff changeset
236 btfss vusb_in ; USB (still) plugged in?
heinrichsweikamp
parents:
diff changeset
237 bcf enable_screen_dumps ; No, clear flag
heinrichsweikamp
parents:
diff changeset
238 call rs232_get_byte
heinrichsweikamp
parents:
diff changeset
239 btfsc rs232_recieve_overflow
heinrichsweikamp
parents:
diff changeset
240 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
241 movlw "l"
heinrichsweikamp
parents:
diff changeset
242 cpfseq RCREG1
heinrichsweikamp
parents:
diff changeset
243 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
244 call TFT_dump_screen ; Dump the screen contents
heinrichsweikamp
parents:
diff changeset
245 surfloop_loop4:
heinrichsweikamp
parents:
diff changeset
246 btfsc divemode ; Divemode active?
heinrichsweikamp
parents:
diff changeset
247 goto diveloop ; Yes, switch into Divemode!
heinrichsweikamp
parents:
diff changeset
248 btfsc sleepmode ; Sleepmode active?
heinrichsweikamp
parents:
diff changeset
249 goto sleeploop ; Yes, switch into sleepmode!
heinrichsweikamp
parents:
diff changeset
250
heinrichsweikamp
parents:
diff changeset
251 bra surfloop_loop ; loop surfacemode
heinrichsweikamp
parents:
diff changeset
252
heinrichsweikamp
parents:
diff changeset
253 update_surfloop60:
heinrichsweikamp
parents:
diff changeset
254 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
255 call TFT_date ; Update date
heinrichsweikamp
parents:
diff changeset
256 call calc_deko_surfmode ; calculate desaturation every minute
heinrichsweikamp
parents:
diff changeset
257 bcf oneminupdate
heinrichsweikamp
parents:
diff changeset
258 return
heinrichsweikamp
parents:
diff changeset
259
heinrichsweikamp
parents:
diff changeset
260 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation
heinrichsweikamp
parents:
diff changeset
261 surfmode_check_for_warnings:
heinrichsweikamp
parents:
diff changeset
262 movf warning_counter_backup,W
heinrichsweikamp
parents:
diff changeset
263 cpfseq warning_counter ; warning_counter_backup = warning_counter?
heinrichsweikamp
parents:
diff changeset
264 call TFT_clear_warning_text ; No, clear all warnings
heinrichsweikamp
parents:
diff changeset
265 movff warning_counter,warning_counter_backup ; copy warning_counter
heinrichsweikamp
parents:
diff changeset
266
heinrichsweikamp
parents:
diff changeset
267 bcf warning_active ; Clear flag
heinrichsweikamp
parents:
diff changeset
268 clrf warning_counter ; Clear counter
heinrichsweikamp
parents:
diff changeset
269
heinrichsweikamp
parents:
diff changeset
270 ; Warnings for all modes
heinrichsweikamp
parents:
diff changeset
271 call check_warn_battery ; Check if the battery level should be displayed/warned
heinrichsweikamp
parents:
diff changeset
272 call surfmode_check_for_nofly ; Check if nofly time should be shown
heinrichsweikamp
parents:
diff changeset
273 call surfmode_check_for_desat ; Check if desat time should be shown
heinrichsweikamp
parents:
diff changeset
274 call surfmode_check_for_interval ; Check if surface interval should be shown
heinrichsweikamp
parents:
diff changeset
275
heinrichsweikamp
parents:
diff changeset
276 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
277 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
278 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
279 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
280
heinrichsweikamp
parents:
diff changeset
281 ; Warnings only in deco modes
heinrichsweikamp
parents:
diff changeset
282 call check_cns_violation ; Check CNS value and display it, if required
heinrichsweikamp
parents:
diff changeset
283 call check_and_store_gf_violation ; Check GF value and display it, if required
heinrichsweikamp
parents:
diff changeset
284
heinrichsweikamp
parents:
diff changeset
285 surfmode_check_for_warnings2:
heinrichsweikamp
parents:
diff changeset
286 ; Setup warning_page number
heinrichsweikamp
parents:
diff changeset
287 incf warning_page,F
heinrichsweikamp
parents:
diff changeset
288 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
289 rlcf warning_page,W ; *2
heinrichsweikamp
parents:
diff changeset
290 cpfsgt warning_counter ; > warning_counter
heinrichsweikamp
parents:
diff changeset
291 clrf warning_page ; No, clear
heinrichsweikamp
parents:
diff changeset
292
heinrichsweikamp
parents:
diff changeset
293 ; Clear 2nd row of warnings if there is nothing to show (on this page)
heinrichsweikamp
parents:
diff changeset
294 btfss second_row_warning ; =1: The second row contains a warning
heinrichsweikamp
parents:
diff changeset
295 call TFT_clear_warning_text_2nd_row ; No, clear this row
heinrichsweikamp
parents:
diff changeset
296 return ; Done.
heinrichsweikamp
parents:
diff changeset
297
heinrichsweikamp
parents:
diff changeset
298 surfmode_check_for_interval:
heinrichsweikamp
parents:
diff changeset
299 movf surface_interval+0,W ; Is interval null ?
heinrichsweikamp
parents:
diff changeset
300 iorwf surface_interval+0,W
heinrichsweikamp
parents:
diff changeset
301 bnz surfmode_check_for_interval2 ; No
heinrichsweikamp
parents:
diff changeset
302 return
heinrichsweikamp
parents:
diff changeset
303 surfmode_check_for_interval2:
heinrichsweikamp
parents:
diff changeset
304 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
305 call TFT_interval
heinrichsweikamp
parents:
diff changeset
306 return
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308
heinrichsweikamp
parents:
diff changeset
309 surfmode_check_for_desat:
heinrichsweikamp
parents:
diff changeset
310 movf desaturation_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
311 iorwf desaturation_time+1,W
heinrichsweikamp
parents:
diff changeset
312 bnz surfmode_check_for_desat2 ; No
heinrichsweikamp
parents:
diff changeset
313 return
heinrichsweikamp
parents:
diff changeset
314 surfmode_check_for_desat2:
heinrichsweikamp
parents:
diff changeset
315 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
316 call TFT_desaturation_time
heinrichsweikamp
parents:
diff changeset
317 return
heinrichsweikamp
parents:
diff changeset
318
heinrichsweikamp
parents:
diff changeset
319 surfmode_check_for_nofly:
heinrichsweikamp
parents:
diff changeset
320 movf nofly_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
321 iorwf nofly_time+1,W
heinrichsweikamp
parents:
diff changeset
322 bnz surfmode_check_for_nofly2 ; No...
heinrichsweikamp
parents:
diff changeset
323 return
heinrichsweikamp
parents:
diff changeset
324 surfmode_check_for_nofly2:
heinrichsweikamp
parents:
diff changeset
325 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
326 call TFT_nofly_time
heinrichsweikamp
parents:
diff changeset
327 return
heinrichsweikamp
parents:
diff changeset
328
heinrichsweikamp
parents:
diff changeset
329
heinrichsweikamp
parents:
diff changeset
330 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
331 global calc_deko_surfmode
heinrichsweikamp
parents:
diff changeset
332 calc_deko_surfmode:
heinrichsweikamp
parents:
diff changeset
333 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
334 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
heinrichsweikamp
parents:
diff changeset
335 banksel common
heinrichsweikamp
parents:
diff changeset
336 return
heinrichsweikamp
parents:
diff changeset
337
heinrichsweikamp
parents:
diff changeset
338 timeout_premenu:
heinrichsweikamp
parents:
diff changeset
339 btfsc premenu ; is "<Menu" displayed?
heinrichsweikamp
parents:
diff changeset
340 bra timeout_premenu1 ; Yes
heinrichsweikamp
parents:
diff changeset
341 return
heinrichsweikamp
parents:
diff changeset
342
heinrichsweikamp
parents:
diff changeset
343 timeout_premenu1:
heinrichsweikamp
parents:
diff changeset
344 incf timeout_counter3,F ; Yes...
heinrichsweikamp
parents:
diff changeset
345 movlw d'2'
heinrichsweikamp
parents:
diff changeset
346 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
heinrichsweikamp
parents:
diff changeset
347 return ; No!
heinrichsweikamp
parents:
diff changeset
348
heinrichsweikamp
parents:
diff changeset
349 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
heinrichsweikamp
parents:
diff changeset
350
heinrichsweikamp
parents:
diff changeset
351 WIN_SMALL menu_pos_column,menu_pos_row
heinrichsweikamp
parents:
diff changeset
352 WIN_COLOR color_lightblue
heinrichsweikamp
parents:
diff changeset
353 STRCPY_TEXT_PRINT tMenu ; "<Menu"
heinrichsweikamp
parents:
diff changeset
354 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
355 clrf timeout_counter3 ; Also clear timeout
heinrichsweikamp
parents:
diff changeset
356 bcf switch_left ; and debounce switches
heinrichsweikamp
parents:
diff changeset
357 bcf switch_right
heinrichsweikamp
parents:
diff changeset
358 return
heinrichsweikamp
parents:
diff changeset
359
heinrichsweikamp
parents:
diff changeset
360 test_switches_surfmode: ; checks switches in surfacemode
heinrichsweikamp
parents:
diff changeset
361 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
362 bra test_switches_surfmode2
heinrichsweikamp
parents:
diff changeset
363 btfsc switch_left
heinrichsweikamp
parents:
diff changeset
364 bra test_switches_surfmode3
heinrichsweikamp
parents:
diff changeset
365
heinrichsweikamp
parents:
diff changeset
366 ; No button press
heinrichsweikamp
parents:
diff changeset
367 return
heinrichsweikamp
parents:
diff changeset
368
heinrichsweikamp
parents:
diff changeset
369 test_switches_surfmode3:
heinrichsweikamp
parents:
diff changeset
370 bcf switch_left
heinrichsweikamp
parents:
diff changeset
371 btfss premenu
heinrichsweikamp
parents:
diff changeset
372 bra test_switches_surfmode4
heinrichsweikamp
parents:
diff changeset
373 bsf menubit ; Enter Menu!
heinrichsweikamp
parents:
diff changeset
374 return
heinrichsweikamp
parents:
diff changeset
375
heinrichsweikamp
parents:
diff changeset
376 test_switches_surfmode4:
heinrichsweikamp
parents:
diff changeset
377 WIN_COLOR color_lightblue
heinrichsweikamp
parents:
diff changeset
378 WIN_SMALL view_column,view_row
heinrichsweikamp
parents:
diff changeset
379 STRCPY_TEXT_PRINT tView ;"View"
heinrichsweikamp
parents:
diff changeset
380 WIN_SMALL menu_pos_column,menu_pos_row
heinrichsweikamp
parents:
diff changeset
381 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
382 WIN_INVERT .1 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
383 STRCPY_TEXT_PRINT tMenu ;"<Menu"
heinrichsweikamp
parents:
diff changeset
384 WIN_INVERT .0 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
385 bsf premenu
heinrichsweikamp
parents:
diff changeset
386 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
387 return
heinrichsweikamp
parents:
diff changeset
388
heinrichsweikamp
parents:
diff changeset
389 test_switches_surfmode2:
heinrichsweikamp
parents:
diff changeset
390 bcf switch_right
heinrichsweikamp
parents:
diff changeset
391 bsf toggle_customview
heinrichsweikamp
parents:
diff changeset
392 clrf timeout_counter2 ; and reset timeout
heinrichsweikamp
parents:
diff changeset
393 return
heinrichsweikamp
parents:
diff changeset
394
heinrichsweikamp
parents:
diff changeset
395 test_switches_surfmode5:
heinrichsweikamp
parents:
diff changeset
396 WIN_SMALL menu_pos_column,menu_pos_row
heinrichsweikamp
parents:
diff changeset
397 WIN_COLOR color_lightblue
heinrichsweikamp
parents:
diff changeset
398 STRCPY_TEXT_PRINT tMenu ;"<Menu"
heinrichsweikamp
parents:
diff changeset
399 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
400 bcf premenu
heinrichsweikamp
parents:
diff changeset
401 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
402 return
heinrichsweikamp
parents:
diff changeset
403
heinrichsweikamp
parents:
diff changeset
404 global timeout_surfmode
heinrichsweikamp
parents:
diff changeset
405 timeout_surfmode:
heinrichsweikamp
parents:
diff changeset
406 movlw timeout_surfacemode ; [s]
heinrichsweikamp
parents:
diff changeset
407 global timeout_testmode
heinrichsweikamp
parents:
diff changeset
408 timeout_testmode:
heinrichsweikamp
parents:
diff changeset
409 incf timeout_counter2,F ; increase timeout counter
heinrichsweikamp
parents:
diff changeset
410 cpfsgt timeout_counter2 ; Compare with timeout_counter2
heinrichsweikamp
parents:
diff changeset
411 return ; return, no timeout
heinrichsweikamp
parents:
diff changeset
412 bsf sleepmode ; Set Flag
heinrichsweikamp
parents:
diff changeset
413 return ; Return
heinrichsweikamp
parents:
diff changeset
414
heinrichsweikamp
parents:
diff changeset
415 END