annotate src/surfmode.asm @ 524:d2e52e6e1604

menu work
author heinrichsweikamp
date Sat, 05 Aug 2017 10:58:40 +0200
parents bef07a837a60
children d36f9fca10ae
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
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
12 #include "hwos.inc" ; Mandatory header
505
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
14 #include "start.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
15 #include "tft.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
16 #include "tft_outputs.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
17 #include "isr.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
18 #include "adc_lightsensor.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
19 #include "menu_processor.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
20 #include "strings.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
21 #include "sleepmode.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
22 #include "wait.inc" ; speed_*
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
23 #include "external_flash.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
24 #include "customview.inc"
bef07a837a60 BUGFIX: Reset to MOD in Diluent Menu did reset Setpoint change depth
heinrichsweikamp
parents: 487
diff changeset
25 #include "divemode.inc"
0
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
245
416723c8ccd8 use single-byte hardware flag (again)
heinrichsweikamp
parents: 235
diff changeset
49 bcf LEDg
416723c8ccd8 use single-byte hardware flag (again)
heinrichsweikamp
parents: 235
diff changeset
50 bcf LEDr
416723c8ccd8 use single-byte hardware flag (again)
heinrichsweikamp
parents: 235
diff changeset
51
0
heinrichsweikamp
parents:
diff changeset
52 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
53 bcf PORTC,2 ; Pull PWM output to GND
heinrichsweikamp
parents:
diff changeset
54 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
55 bcf restore_deco_data
heinrichsweikamp
parents:
diff changeset
56
heinrichsweikamp
parents:
diff changeset
57 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
58 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
59 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
60 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
61 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
62 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
63 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
64 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
65 extern color_image
heinrichsweikamp
parents:
diff changeset
66 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
67
heinrichsweikamp
parents:
diff changeset
68 WIN_TOP .100
heinrichsweikamp
parents:
diff changeset
69 WIN_LEFT .34
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
70 extern ostc_logo_block
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
71 movlw LOW(ostc_logo_block)
0
heinrichsweikamp
parents:
diff changeset
72 movwf TBLPTRL
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
73 movlw HIGH ostc_logo_block;&0xFFFF
0
heinrichsweikamp
parents:
diff changeset
74 movwf TBLPTRH
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
75 movlw UPPER(ostc_logo_block)
0
heinrichsweikamp
parents:
diff changeset
76 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
77 call color_image
heinrichsweikamp
parents:
diff changeset
78 call TFT_Display_FadeIn ; Show splash
heinrichsweikamp
parents:
diff changeset
79 call TFT_serial ; Show serial and firmware version
heinrichsweikamp
parents:
diff changeset
80
heinrichsweikamp
parents:
diff changeset
81 ;---- Do any usefull initializes that takes time -------------------------
heinrichsweikamp
parents:
diff changeset
82 call restart_set_modes_and_flags ; Sets decomode flags
heinrichsweikamp
parents:
diff changeset
83 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
84 call I2C_init_compass
heinrichsweikamp
parents:
diff changeset
85 call I2C_init_accelerometer
heinrichsweikamp
parents:
diff changeset
86 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
87 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
88 clrf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
89
354
043890f06bce some cleanups
heinrichsweikamp
parents: 352
diff changeset
90 movlw surface_sp ; in cbar
043890f06bce some cleanups
heinrichsweikamp
parents: 352
diff changeset
91 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics
221
90923a081ae7 minor: configure buttons during splash screen
heinrichsweikamp
parents: 213
diff changeset
92
0
heinrichsweikamp
parents:
diff changeset
93 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
94 clrf timeout_counter3
heinrichsweikamp
parents:
diff changeset
95 bcf menubit ; clear menu flag
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
96 bcf premenu
0
heinrichsweikamp
parents:
diff changeset
97 clrf last_pressure+0
heinrichsweikamp
parents:
diff changeset
98 clrf last_pressure+1
heinrichsweikamp
parents:
diff changeset
99 bcf is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
100 bcf ccr_diluent_setup ; Use OC gases for gaslist routine
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 bcf simulatormode_active ; Quit simulator mode (if active)
heinrichsweikamp
parents:
diff changeset
103 bcf switch_left
heinrichsweikamp
parents:
diff changeset
104 bcf switch_right
heinrichsweikamp
parents:
diff changeset
105
heinrichsweikamp
parents:
diff changeset
106 ;---- Fade to standard surface view --------------------------------------
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 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
112 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
113 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
114 bra $-2
heinrichsweikamp
parents:
diff changeset
115
heinrichsweikamp
parents:
diff changeset
116 call TFT_Display_FadeOut ; Go to black screen
heinrichsweikamp
parents:
diff changeset
117 call TFT_ClearScreen ; Then change everything
heinrichsweikamp
parents:
diff changeset
118 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
119 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
120 WIN_FONT FT_SMALL
189
e79bc535ef9e ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents: 188
diff changeset
121 bcf win_invert ; Reset invert flag
0
heinrichsweikamp
parents:
diff changeset
122
heinrichsweikamp
parents:
diff changeset
123 WIN_COLOR color_lightblue
heinrichsweikamp
parents:
diff changeset
124 WIN_SMALL menu_pos_column,menu_pos_row
heinrichsweikamp
parents:
diff changeset
125 STRCPY_TEXT_PRINT tMenu ;"<Menu"
heinrichsweikamp
parents:
diff changeset
126 WIN_SMALL view_column,view_row
heinrichsweikamp
parents:
diff changeset
127 STRCPY_TEXT_PRINT tView ;"View>"
heinrichsweikamp
parents:
diff changeset
128 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
129
48
7c7d7644ca37 Time and Date in normal (Not tiny) font
heinrichsweikamp
parents: 39
diff changeset
130 ; Logo
0
heinrichsweikamp
parents:
diff changeset
131 WIN_TOP .0
heinrichsweikamp
parents:
diff changeset
132 WIN_LEFT .70
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
133 movlw LOW(ostc_logo_block)
0
heinrichsweikamp
parents:
diff changeset
134 movwf TBLPTRL
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
135 movlw HIGH ostc_logo_block;&0xFFFF
0
heinrichsweikamp
parents:
diff changeset
136 movwf TBLPTRH
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 256
diff changeset
137 movlw UPPER(ostc_logo_block)
0
heinrichsweikamp
parents:
diff changeset
138 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
139 call color_image
heinrichsweikamp
parents:
diff changeset
140
158
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
141 call TFT_clock ; display time
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
142 call update_surfloop60
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
143 call get_battery_voltage ; get battery voltage
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
144 call TFT_update_batt_voltage ; display battery voltage
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
145 call TFT_update_surf_press ; display surface pressure
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
146 call TFT_temp_surfmode ; Displays temperature
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
147 call TFT_display_decotype_surface
375
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 354
diff changeset
148 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 354
diff changeset
149 call check_sensors ; Set enable/disable flags
234
57155164faad Show OSTC2-like active gas boxes in surface mode
heinrichsweikamp
parents: 233
diff changeset
150
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 476
diff changeset
151 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
232
fe9d88fee09f show start gas in OC mode permanently
mh@mh-THINK
parents: 230
diff changeset
152 tstfsz lo
fe9d88fee09f show start gas in OC mode permanently
mh@mh-THINK
parents: 230
diff changeset
153 bra surfloop_no_oc ; Not OC
234
57155164faad Show OSTC2-like active gas boxes in surface mode
heinrichsweikamp
parents: 233
diff changeset
154 call TFT_show_OC_startgas_surface; Show first gas and "OSTC2-like" active gases
232
fe9d88fee09f show start gas in OC mode permanently
mh@mh-THINK
parents: 230
diff changeset
155 surfloop_no_oc:
158
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
156 movff customview_surfmode,menupos3 ; Reload last customview
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
157 call surf_customview_mask ; Update #menupos3 view
0
heinrichsweikamp
parents:
diff changeset
158
heinrichsweikamp
parents:
diff changeset
159 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
160
heinrichsweikamp
parents:
diff changeset
161 ;---- Late initialisations -----------------------------------------------
heinrichsweikamp
parents:
diff changeset
162 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
163 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
164 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
165 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values
heinrichsweikamp
parents:
diff changeset
166 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
167 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure
heinrichsweikamp
parents:
diff changeset
168
158
683321c09cfa nicer boot into surfacemode
heinrichsweikamp
parents: 145
diff changeset
169 ; Startup tasks for all modes
0
heinrichsweikamp
parents:
diff changeset
170 ; Desaturation time needs:
heinrichsweikamp
parents:
diff changeset
171 ; int_I_pres_surface
heinrichsweikamp
parents:
diff changeset
172 ; char_I_desaturation_multiplier
heinrichsweikamp
parents:
diff changeset
173 call deco_calc_desaturation_time ; calculate desaturation time
heinrichsweikamp
parents:
diff changeset
174 movlb b'00000001' ; select ram bank 1
heinrichsweikamp
parents:
diff changeset
175
heinrichsweikamp
parents:
diff changeset
176 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
177 call enable_rs232 ; Also sets to speed_normal ...
heinrichsweikamp
parents:
diff changeset
178
heinrichsweikamp
parents:
diff changeset
179 surfloop_loop:
heinrichsweikamp
parents:
diff changeset
180 btfss onesecupdate ; do every second tasks?
heinrichsweikamp
parents:
diff changeset
181 bra surfloop_loop2 ; no, loop
heinrichsweikamp
parents:
diff changeset
182
heinrichsweikamp
parents:
diff changeset
183 ; One Second tasks for all modes
heinrichsweikamp
parents:
diff changeset
184 call speed_normal
487
heinrichsweikamp
parents: 485
diff changeset
185 ;call TFT_debug_output
0
heinrichsweikamp
parents:
diff changeset
186 call TFT_clock ; update clock
heinrichsweikamp
parents:
diff changeset
187 call timeout_surfmode ; check timeout
heinrichsweikamp
parents:
diff changeset
188 call get_battery_voltage ; get battery voltage
heinrichsweikamp
parents:
diff changeset
189 call TFT_update_batt_voltage ; display battery voltage
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 bcf onesecupdate ; every second tasks done
heinrichsweikamp
parents:
diff changeset
197
heinrichsweikamp
parents:
diff changeset
198 surfloop_loop2:
heinrichsweikamp
parents:
diff changeset
199 ; Tasks approx. every 50ms for all modes
heinrichsweikamp
parents:
diff changeset
200 call test_switches_surfmode ; check switches
487
heinrichsweikamp
parents: 485
diff changeset
201 call TFT_debug_output
0
heinrichsweikamp
parents:
diff changeset
202
heinrichsweikamp
parents:
diff changeset
203 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
204 btfsc oneminupdate ; do every minute tasks
heinrichsweikamp
parents:
diff changeset
205 call update_surfloop60 ; yes, e.g. update time and date
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 ; Mode tasks
230
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
208 btfsc divemode ; Divemode active?
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
209 goto diveloop ; Yes, switch into Divemode!
f6548e8f06f5 Bugfix: Check for divemode before checking for menu
mh@mh-THINK
parents: 226
diff changeset
210
0
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
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
218 ; Updates every 1/4 second
0
heinrichsweikamp
parents:
diff changeset
219 btfss quarter_second_update
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
220 bra surfloop_loop2b
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
221
0
heinrichsweikamp
parents:
diff changeset
222 bcf quarter_second_update
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
223
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
224 ; Update Sensors
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
225 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
226 call check_sensors ; Set enable/disable flags
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 480
diff changeset
227 btfsc FLAG_ccr_mode ; In CCR mode?
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 480
diff changeset
228 bra surfloop_loop2a1 ; Yes.
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 480
diff changeset
229 btfss FLAG_pscr_mode ; In PSCR mode?
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
230 bra surfloop_loop2a ; No, skip
485
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 480
diff changeset
231
18e047102e49 3.14 BETA release
heinrichsweikamp
parents: 480
diff changeset
232 surfloop_loop2a1:
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
233 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
234 sublw .1 ; opt_ccr_mode = 1 (Sensor)?
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
235 bnz surfloop_loop2a ; No, skip
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
236
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
237 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
238
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
239 surfloop_loop2a:
0
heinrichsweikamp
parents:
diff changeset
240 movlw .6
heinrichsweikamp
parents:
diff changeset
241 cpfseq menupos3 ; in compass view?
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
242 bra surfloop_loop2b ; No
256
5b4ef0b9090d place compass display code into compass_ops.asm
heinrichsweikamp
parents: 245
diff changeset
243 extern TFT_surface_compass_heading
0
heinrichsweikamp
parents:
diff changeset
244 call TFT_surface_compass_heading ; Yes, update compass heading value
heinrichsweikamp
parents:
diff changeset
245
476
7c10557c248e no sensors in surface mode if the computer has no sensor inputs
heinrichsweikamp
parents: 382
diff changeset
246 surfloop_loop2b:
0
heinrichsweikamp
parents:
diff changeset
247 btfsc toggle_customview ; Next view?
heinrichsweikamp
parents:
diff changeset
248 call surf_customview_toggle ; Yes, show next customview (and delete this flag)
heinrichsweikamp
parents:
diff changeset
249
heinrichsweikamp
parents:
diff changeset
250 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
251 bra surfloop_loop3
heinrichsweikamp
parents:
diff changeset
252 btfsc vusb_in ; USB plugged in?
113
heinrichsweikamp
parents: 76
diff changeset
253 call comm_mode ; Start COMM mode
0
heinrichsweikamp
parents:
diff changeset
254 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
255 surfloop_loop3:
heinrichsweikamp
parents:
diff changeset
256 btfss vusb_in ; USB (still) plugged in?
heinrichsweikamp
parents:
diff changeset
257 bcf enable_screen_dumps ; No, clear flag
heinrichsweikamp
parents:
diff changeset
258 call rs232_get_byte
heinrichsweikamp
parents:
diff changeset
259 btfsc rs232_recieve_overflow
heinrichsweikamp
parents:
diff changeset
260 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
261 movlw "l"
heinrichsweikamp
parents:
diff changeset
262 cpfseq RCREG1
heinrichsweikamp
parents:
diff changeset
263 bra surfloop_loop4
heinrichsweikamp
parents:
diff changeset
264 call TFT_dump_screen ; Dump the screen contents
heinrichsweikamp
parents:
diff changeset
265 surfloop_loop4:
heinrichsweikamp
parents:
diff changeset
266 btfsc sleepmode ; Sleepmode active?
heinrichsweikamp
parents:
diff changeset
267 goto sleeploop ; Yes, switch into sleepmode!
heinrichsweikamp
parents:
diff changeset
268
heinrichsweikamp
parents:
diff changeset
269 bra surfloop_loop ; loop surfacemode
heinrichsweikamp
parents:
diff changeset
270
heinrichsweikamp
parents:
diff changeset
271 update_surfloop60:
heinrichsweikamp
parents:
diff changeset
272 ; One minute tasks for all modes
heinrichsweikamp
parents:
diff changeset
273 call TFT_date ; Update date
heinrichsweikamp
parents:
diff changeset
274 call calc_deko_surfmode ; calculate desaturation every minute
heinrichsweikamp
parents:
diff changeset
275 bcf oneminupdate
heinrichsweikamp
parents:
diff changeset
276 return
heinrichsweikamp
parents:
diff changeset
277
heinrichsweikamp
parents:
diff changeset
278 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation
heinrichsweikamp
parents:
diff changeset
279 surfmode_check_for_warnings:
heinrichsweikamp
parents:
diff changeset
280 movf warning_counter_backup,W
heinrichsweikamp
parents:
diff changeset
281 cpfseq warning_counter ; warning_counter_backup = warning_counter?
heinrichsweikamp
parents:
diff changeset
282 call TFT_clear_warning_text ; No, clear all warnings
heinrichsweikamp
parents:
diff changeset
283 movff warning_counter,warning_counter_backup ; copy warning_counter
heinrichsweikamp
parents:
diff changeset
284
heinrichsweikamp
parents:
diff changeset
285 bcf warning_active ; Clear flag
heinrichsweikamp
parents:
diff changeset
286 clrf warning_counter ; Clear counter
heinrichsweikamp
parents:
diff changeset
287
heinrichsweikamp
parents:
diff changeset
288 ; Warnings for all modes
heinrichsweikamp
parents:
diff changeset
289 call check_warn_battery ; Check if the battery level should be displayed/warned
205
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
290 rcall surfmode_check_for_nofly ; Check if nofly time should be shown
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
291 rcall surfmode_check_for_desat ; Check if desat time should be shown
618191753d2b Preparations for 1.7
heinrichsweikamp
parents: 204
diff changeset
292 rcall surfmode_check_for_interval ; Check if surface interval should be shown
0
heinrichsweikamp
parents:
diff changeset
293
heinrichsweikamp
parents:
diff changeset
294 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
295 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
296 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
heinrichsweikamp
parents:
diff changeset
297 bra surfmode_check_for_warnings2
heinrichsweikamp
parents:
diff changeset
298
heinrichsweikamp
parents:
diff changeset
299 ; Warnings only in deco modes
heinrichsweikamp
parents:
diff changeset
300 call check_cns_violation ; Check CNS value and display it, if required
heinrichsweikamp
parents:
diff changeset
301 call check_and_store_gf_violation ; Check GF value and display it, if required
heinrichsweikamp
parents:
diff changeset
302
heinrichsweikamp
parents:
diff changeset
303 surfmode_check_for_warnings2:
heinrichsweikamp
parents:
diff changeset
304 ; Setup warning_page number
heinrichsweikamp
parents:
diff changeset
305 incf warning_page,F
heinrichsweikamp
parents:
diff changeset
306 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
307 rlcf warning_page,W ; *2
heinrichsweikamp
parents:
diff changeset
308 cpfsgt warning_counter ; > warning_counter
heinrichsweikamp
parents:
diff changeset
309 clrf warning_page ; No, clear
heinrichsweikamp
parents:
diff changeset
310
heinrichsweikamp
parents:
diff changeset
311 ; Clear 2nd row of warnings if there is nothing to show (on this page)
heinrichsweikamp
parents:
diff changeset
312 btfss second_row_warning ; =1: The second row contains a warning
heinrichsweikamp
parents:
diff changeset
313 call TFT_clear_warning_text_2nd_row ; No, clear this row
heinrichsweikamp
parents:
diff changeset
314 return ; Done.
heinrichsweikamp
parents:
diff changeset
315
heinrichsweikamp
parents:
diff changeset
316 surfmode_check_for_interval:
heinrichsweikamp
parents:
diff changeset
317 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
318 iorwf surface_interval+1,W
0
heinrichsweikamp
parents:
diff changeset
319 bnz surfmode_check_for_interval2 ; No
heinrichsweikamp
parents:
diff changeset
320 return
heinrichsweikamp
parents:
diff changeset
321 surfmode_check_for_interval2:
heinrichsweikamp
parents:
diff changeset
322 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
323 call TFT_interval
heinrichsweikamp
parents:
diff changeset
324 return
heinrichsweikamp
parents:
diff changeset
325
heinrichsweikamp
parents:
diff changeset
326
heinrichsweikamp
parents:
diff changeset
327 surfmode_check_for_desat:
heinrichsweikamp
parents:
diff changeset
328 movf desaturation_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
329 iorwf desaturation_time+1,W
heinrichsweikamp
parents:
diff changeset
330 bnz surfmode_check_for_desat2 ; No
heinrichsweikamp
parents:
diff changeset
331 return
heinrichsweikamp
parents:
diff changeset
332 surfmode_check_for_desat2:
heinrichsweikamp
parents:
diff changeset
333 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
334 call TFT_desaturation_time
heinrichsweikamp
parents:
diff changeset
335 return
heinrichsweikamp
parents:
diff changeset
336
heinrichsweikamp
parents:
diff changeset
337 surfmode_check_for_nofly:
heinrichsweikamp
parents:
diff changeset
338 movf nofly_time+0,W ; Is nofly null ?
heinrichsweikamp
parents:
diff changeset
339 iorwf nofly_time+1,W
heinrichsweikamp
parents:
diff changeset
340 bnz surfmode_check_for_nofly2 ; No...
heinrichsweikamp
parents:
diff changeset
341 return
heinrichsweikamp
parents:
diff changeset
342 surfmode_check_for_nofly2:
heinrichsweikamp
parents:
diff changeset
343 incf warning_counter,F ; increase counter
heinrichsweikamp
parents:
diff changeset
344 call TFT_nofly_time
heinrichsweikamp
parents:
diff changeset
345 return
heinrichsweikamp
parents:
diff changeset
346
heinrichsweikamp
parents:
diff changeset
347
heinrichsweikamp
parents:
diff changeset
348 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
349 global calc_deko_surfmode
heinrichsweikamp
parents:
diff changeset
350 calc_deko_surfmode:
heinrichsweikamp
parents:
diff changeset
351 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine
heinrichsweikamp
parents:
diff changeset
352 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
heinrichsweikamp
parents:
diff changeset
353 banksel common
heinrichsweikamp
parents:
diff changeset
354 return
heinrichsweikamp
parents:
diff changeset
355
heinrichsweikamp
parents:
diff changeset
356 test_switches_surfmode: ; checks switches in surfacemode
heinrichsweikamp
parents:
diff changeset
357 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
358 bra test_switches_surfmode2
heinrichsweikamp
parents:
diff changeset
359 btfsc switch_left
heinrichsweikamp
parents:
diff changeset
360 bra test_switches_surfmode3
heinrichsweikamp
parents:
diff changeset
361
heinrichsweikamp
parents:
diff changeset
362 ; No button press
heinrichsweikamp
parents:
diff changeset
363 return
heinrichsweikamp
parents:
diff changeset
364
heinrichsweikamp
parents:
diff changeset
365 test_switches_surfmode3:
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
366 movlw .6
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
367 cpfseq menupos3 ; in compass view?
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
368 bra test_switches_surfmode3a ; No
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
369
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
370 btfsc premenu ; already shown "Bearing"
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
371 bra test_switches_surfmode3b ; Yes, remove it
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
372
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
373 extern TFT_surf_set_bearing
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
374 call TFT_surf_set_bearing ; Yes.
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
375 bcf switch_left
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
376 return
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
377
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
378 test_switches_surfmode3a:
0
heinrichsweikamp
parents:
diff changeset
379 bcf switch_left
heinrichsweikamp
parents:
diff changeset
380 bsf menubit ; Enter Menu!
heinrichsweikamp
parents:
diff changeset
381 return
heinrichsweikamp
parents:
diff changeset
382
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
383 test_switches_surfmode3b:
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
384 ; Clear "Heading?"
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
385 WIN_BOX_BLACK .158,.190, .15, .99 ; top, bottom, left, right
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
386 bcf premenu
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
387 bcf switch_left
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
388 return
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
389
0
heinrichsweikamp
parents:
diff changeset
390 test_switches_surfmode2:
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
391 movlw .6
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
392 cpfseq menupos3 ; in compass view?
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
393 bra test_switches_surfmode2a ; No
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
394 btfss premenu ; "Heading?" shown?
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
395 bra test_switches_surfmode2a ; No
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
396 ; Set new heading
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
397 bcf premenu
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
398 bsf compass_bearing_set
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
399 movff compass_heading_shown+0,compass_bearing+0
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
400 movff compass_heading_shown+1,compass_bearing+1
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
401 bcf switch_right
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
402 return
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
403
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
404 test_switches_surfmode2a:
0
heinrichsweikamp
parents:
diff changeset
405 bcf switch_right
heinrichsweikamp
parents:
diff changeset
406 bsf toggle_customview
382
6f3530eb48f9 allow compass bearing on surface
heinrichsweikamp
parents: 375
diff changeset
407 bcf premenu
0
heinrichsweikamp
parents:
diff changeset
408 clrf timeout_counter2 ; and reset timeout
heinrichsweikamp
parents:
diff changeset
409 return
heinrichsweikamp
parents:
diff changeset
410
heinrichsweikamp
parents:
diff changeset
411 global timeout_surfmode
heinrichsweikamp
parents:
diff changeset
412 timeout_surfmode:
188
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
413 movlw timeout_surfacemode ; [s] Default timeout
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 158
diff changeset
414 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
415 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
416 btfsc menubit ; in Menu?
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
417 bra timeout_testmode ; No, done.
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
418 ; Must be in surface mode
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
419 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
420 bra timeout_testmode ; No, not CCR
ebc28381f17d NEW: Show Bailout Gas List in Surface mode (CCR Modes)
heinrichsweikamp
parents: 187
diff changeset
421 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
422
0
heinrichsweikamp
parents:
diff changeset
423 global timeout_testmode
heinrichsweikamp
parents:
diff changeset
424 timeout_testmode:
heinrichsweikamp
parents:
diff changeset
425 incf timeout_counter2,F ; increase timeout counter
heinrichsweikamp
parents:
diff changeset
426 cpfsgt timeout_counter2 ; Compare with timeout_counter2
heinrichsweikamp
parents:
diff changeset
427 return ; return, no timeout
heinrichsweikamp
parents:
diff changeset
428 bsf sleepmode ; Set Flag
heinrichsweikamp
parents:
diff changeset
429 return ; Return
heinrichsweikamp
parents:
diff changeset
430
heinrichsweikamp
parents:
diff changeset
431 END