Mercurial > public > hwos_code
comparison src/surfmode.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | 54346c651b6a |
children | e81cf407261a |
comparison
equal
deleted
inserted
replaced
581:f5de1ff88814 | 582:b455b31ce022 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File surfmode.asm REFACTORED VERSION V2.94 | 3 ; File surfmode.asm REFACTORED VERSION V2.98 |
4 ; | 4 ; |
5 ; Surfacemode | 5 ; Surfacemode |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-08-07 : [mH] moving from OSTC code | 10 ; 2011-08-07 : [mH] moving from OSTC code |
11 | 11 |
12 #include "hwos.inc" ; Mandatory header | 12 #include "hwos.inc" ; Mandatory header |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | 13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c |
14 #include "start.inc" | 14 #include "start.inc" |
15 #include "tft.inc" | 15 #include "tft.inc" |
16 #include "tft_outputs.inc" | 16 #include "tft_outputs.inc" |
17 #include "isr.inc" | 17 #include "isr.inc" |
18 #include "adc_lightsensor.inc" | 18 #include "adc_lightsensor.inc" |
19 #include "menu_processor.inc" | 19 #include "menu_processor.inc" |
20 #include "strings.inc" | 20 #include "strings.inc" |
21 #include "sleepmode.inc" | 21 #include "sleepmode.inc" |
22 #include "wait.inc" ; speed_* | 22 #include "wait.inc" ; speed_* |
23 #include "external_flash.inc" | 23 #include "external_flash.inc" |
24 #include "customview.inc" | 24 #include "customview.inc" |
25 #include "divemode.inc" | 25 #include "divemode.inc" |
26 #include "mcp.inc" ; RX | 26 #include "mcp.inc" ; RX |
27 #include "i2c.inc" | 27 #include "i2c.inc" |
28 #include "comm.inc" | 28 #include "comm.inc" |
29 #include "eeprom_rs232.inc" | 29 #include "eeprom_rs232.inc" |
30 #include "calibrate.inc" | 30 #include "calibrate.inc" |
31 | 31 |
32 extern do_main_menu | 32 extern do_main_menu |
33 | 33 extern color_image |
34 #DEFINE menu_pos_row .215 | 34 |
35 #DEFINE menu_pos_column .1 | 35 |
36 #DEFINE view_row .215 | 36 ;---- Private local variables ------------------------------------------------- |
37 #DEFINE view_column .124 | 37 |
38 | 38 CBLOCK local1 ; max size is 16 Byte !!! |
39 gui CODE | 39 ; currently not used |
40 | 40 ENDC ; used: 0 byte, remaining: 16 byte |
41 | |
42 | |
43 #DEFINE menu_pos_row .215 | |
44 #DEFINE menu_pos_column .1 | |
45 #DEFINE view_row .215 | |
46 #DEFINE view_column .124 | |
47 | |
48 gui CODE | |
41 | 49 |
42 ;============================================================================= | 50 ;============================================================================= |
43 ; Boot tasks for all modes | 51 ; Boot tasks for all modes |
44 global surfloop | 52 global surfloop |
45 surfloop: | 53 surfloop: |
46 call speed_normal | 54 call speed_normal |
47 bcf no_sensor_int ; Normal pressure mode | 55 bcf no_sensor_int ; Normal pressure mode |
48 | 56 |
49 bcf LEDr | 57 bcf LEDr |
50 | 58 |
51 clrf CCP1CON ; stop PWM | 59 clrf CCP1CON ; stop PWM |
52 bcf PORTC,2 ; Pull PWM output to GND | 60 bcf PORTC,2 ; Pull PWM output to GND |
53 call TFT_boot ; Initialize TFT (includes clear screen) | 61 call TFT_boot ; Initialize TFT (includes clear screen) |
54 bcf restore_deco_data | 62 bcf restore_deco_data |
55 | 63 |
56 WIN_TOP .50 | 64 WIN_TOP .50 |
57 WIN_LEFT .10 | 65 WIN_LEFT .10 |
58 movlw LOW 0x1E000 | 66 movlw LOW 0x1E000 |
59 movwf TBLPTRL | 67 movwf TBLPTRL |
60 movlw HIGH 0x1E000 | 68 movlw HIGH 0x1E000 |
61 movwf TBLPTRH | 69 movwf TBLPTRH |
62 movlw UPPER 0x1E000 | 70 movlw UPPER 0x1E000 |
63 movwf TBLPTRU | 71 movwf TBLPTRU |
64 extern color_image | 72 call color_image ; Show logo |
65 call color_image ; Show logo | 73 |
66 | 74 WIN_TOP .100 |
67 WIN_TOP .100 | 75 WIN_LEFT .34 |
68 WIN_LEFT .34 | 76 extern ostc_logo_block |
69 extern ostc_logo_block | 77 movlw LOW ostc_logo_block |
70 movlw LOW(ostc_logo_block) | 78 movwf TBLPTRL |
71 movwf TBLPTRL | 79 movlw HIGH ostc_logo_block ; &0xFFFF |
72 movlw HIGH ostc_logo_block;&0xFFFF | 80 movwf TBLPTRH |
73 movwf TBLPTRH | 81 movlw UPPER ostc_logo_block |
74 movlw UPPER(ostc_logo_block) | 82 movwf TBLPTRU |
75 movwf TBLPTRU | 83 call color_image |
76 call color_image | 84 call TFT_Display_FadeIn ; Show splash |
77 call TFT_Display_FadeIn ; Show splash | 85 call TFT_serial ; Show serial and firmware version |
78 call TFT_serial ; Show serial and firmware version | 86 |
79 | 87 ;---- Do any useful initializes that takes time ------------------------- |
80 ;---- Do any usefull initializes that takes time ------------------------- | 88 call restart_set_modes_and_flags ; Sets deco mode flags |
81 call restart_set_modes_and_flags ; Sets decomode flags | |
82 bcf pressure_refresh | 89 bcf pressure_refresh |
83 call I2C_init_compass | 90 call I2C_init_compass |
84 call I2C_init_accelerometer | 91 call I2C_init_accelerometer |
85 clrf ext_flash_address+0 | 92 clrf ext_flash_address+0 |
86 clrf ext_flash_address+1 | 93 clrf ext_flash_address+1 |
87 clrf ext_flash_address+2 | 94 clrf ext_flash_address+2 |
88 | 95 |
89 movlw surface_sp ; in cbar | 96 movlw surface_sp ; in cbar |
90 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics | 97 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics |
91 | 98 |
92 clrf timeout_counter2 | 99 clrf timeout_counter2 |
93 clrf timeout_counter3 | 100 ; clrf timeout_counter3 ; not used / required [rl] |
94 bcf menubit ; clear menu flag | 101 bcf menubit ; clear menu flag |
95 bcf premenu | 102 bcf premenu |
96 clrf last_pressure+0 | 103 clrf last_pressure+0 |
97 clrf last_pressure+1 | 104 clrf last_pressure+1 |
98 bcf is_bailout ; =1: Bailout | 105 bcf is_bailout ; =1: Bailout |
99 bcf ccr_diluent_setup ; Use OC gases for gaslist routine | 106 bcf ccr_diluent_setup ; Use OC gases for gaslist routine |
100 | 107 |
101 bcf simulatormode_active ; Quit simulator mode (if active) | 108 bcf simulatormode_active ; Quit simulator mode (if active) |
102 | |
103 ; MOVE from here to below ## V2.94 | |
104 ; bcf switch_left | |
105 ; bcf switch_right | |
106 | 109 |
107 ;---- Fade to standard surface view -------------------------------------- | 110 ;---- Fade to standard surface view -------------------------------------- |
108 ; Wait 1 second | 111 ; Wait 1 second |
109 bcf onesecupdate | 112 bcf onesecupdate |
110 btfss onesecupdate | 113 btfss onesecupdate |
112 ; Wait 1 second | 115 ; Wait 1 second |
113 bcf onesecupdate | 116 bcf onesecupdate |
114 btfss onesecupdate | 117 btfss onesecupdate |
115 bra $-2 | 118 bra $-2 |
116 | 119 |
117 call TFT_Display_FadeOut ; Go to black screen | 120 call TFT_Display_FadeOut ; Go to black screen |
118 call TFT_ClearScreen ; Then change everything | 121 call TFT_ClearScreen ; Then change everything |
119 WIN_TOP .0 | 122 WIN_TOP .0 |
120 WIN_LEFT .0 | 123 WIN_LEFT .0 |
121 WIN_FONT FT_SMALL | 124 WIN_FONT FT_SMALL |
122 bcf win_invert ; Reset invert flag | 125 bcf win_invert ; Reset invert flag |
123 | 126 |
124 WIN_COLOR color_lightblue | 127 WIN_COLOR color_lightblue |
125 WIN_SMALL menu_pos_column,menu_pos_row | 128 WIN_SMALL menu_pos_column,menu_pos_row |
126 STRCPY_TEXT_PRINT tMenu ;"<Menu" | 129 STRCPY_TEXT_PRINT tMenu ;"<Menu" |
127 WIN_SMALL view_column,view_row | 130 WIN_SMALL view_column,view_row |
128 STRCPY_TEXT_PRINT tView ;"View>" | 131 STRCPY_TEXT_PRINT tView ;"View>" |
129 call TFT_standard_color | 132 call TFT_standard_color |
130 | 133 |
131 ; Logo | 134 ; Logo |
132 WIN_TOP .0 | 135 WIN_TOP .0 |
133 WIN_LEFT .70 | 136 WIN_LEFT .70 |
134 movlw LOW(ostc_logo_block) | 137 movlw LOW ostc_logo_block |
135 movwf TBLPTRL | 138 movwf TBLPTRL |
136 movlw HIGH ostc_logo_block;&0xFFFF | 139 movlw HIGH ostc_logo_block ; &0xFFFF |
137 movwf TBLPTRH | 140 movwf TBLPTRH |
138 movlw UPPER(ostc_logo_block) | 141 movlw UPPER ostc_logo_block |
139 movwf TBLPTRU | 142 movwf TBLPTRU |
140 call color_image | 143 call color_image |
141 | 144 |
142 call TFT_clock ; display time | 145 call TFT_clock ; display time |
143 call update_surfloop60 | 146 call update_surfloop60 |
144 call get_battery_voltage ; get battery voltage | 147 call get_battery_voltage ; get battery voltage |
145 call TFT_update_batt_voltage ; display battery voltage | 148 call TFT_update_batt_voltage ; display battery voltage |
146 call TFT_update_surf_press ; display surface pressure | 149 call TFT_update_surf_press ; display surface pressure |
147 call TFT_temp_surfmode ; Displays temperature | 150 call TFT_temp_surfmode ; Displays temperature |
148 call TFT_display_decotype_surface | 151 call TFT_display_decotype_surface |
149 | |
150 call calc_deko_divemode_sensor | 152 call calc_deko_divemode_sensor |
151 | 153 |
152 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | 154 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR |
153 tstfsz lo | 155 tstfsz lo |
154 bra surfloop_no_oc ; Not OC | 156 bra surfloop_no_oc ; Not OC |
155 call TFT_show_OC_startgas_surface; Show first gas and "OSTC2-like" active gases | 157 call TFT_show_OC_startgas_surface; Show first gas and "OSTC2-like" active gases |
156 surfloop_no_oc: | 158 surfloop_no_oc: |
157 movff customview_surfmode,menupos3 ; Reload last customview | 159 movff customview_surfmode,menupos3; Reload last customview |
158 call surf_customview_mask ; Update #menupos3 view | 160 call surf_customview_mask ; Update #menupos3 view |
159 | 161 |
160 call TFT_Display_FadeIn ; Display resulting surface screen. | 162 call TFT_Display_FadeIn ; Display resulting surface screen. |
161 | 163 |
162 ; MOVED from above to here ## V2.94 | |
163 bcf switch_left | 164 bcf switch_left |
164 bcf switch_right | 165 bcf switch_right |
165 | 166 |
166 ;---- Late initialisations ----------------------------------------------- | 167 ;---- Late initializations ----------------------------------------------- |
167 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine ## not used any more (!?) | 168 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine |
168 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values ## not used any more (!?) | 169 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values |
169 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | 170 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine |
170 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | 171 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values |
171 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure | 172 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure |
172 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure | 173 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure |
173 | 174 |
174 ; NEW ## no fly | |
175 movff opt_GF_low,char_I_GF_Low_percentage | 175 movff opt_GF_low,char_I_GF_Low_percentage |
176 movff opt_GF_high,char_I_GF_High_percentage | 176 movff opt_GF_high,char_I_GF_High_percentage |
177 | 177 |
178 ; Startup tasks for all modes | 178 ; Startup tasks for all modes |
179 ; Desaturation time needs: | 179 ; Desaturation time needs: |
180 ; int_I_pres_surface | 180 ; int_I_pres_surface |
181 ; char_I_desaturation_multiplier | 181 ; char_I_desaturation_multiplier |
182 call deco_calc_desaturation_time ; calculate desaturation time | 182 call deco_calc_desaturation_time ; calculate desaturation time |
183 | |
184 ; REPLACE ## (code unification) | |
185 ; movlb b'00000001' ; select ram bank 1 | |
186 ; BY | |
187 banksel common | 183 banksel common |
188 | 184 |
189 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 185 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) |
190 call enable_rs232 ; Also sets to speed_normal ... | 186 call enable_rs232 ; Also sets to speed_normal ... |
191 | 187 |
192 surfloop_loop: | 188 surfloop_loop: |
193 btfss onesecupdate ; do every second tasks? | 189 btfss onesecupdate ; do every second tasks? |
194 bra surfloop_loop2 ; no, loop | 190 bra surfloop_loop2 ; no, loop |
195 | 191 |
199 call TFT_clock ; update clock | 195 call TFT_clock ; update clock |
200 call timeout_surfmode ; check timeout | 196 call timeout_surfmode ; check timeout |
201 call get_battery_voltage ; get battery voltage | 197 call get_battery_voltage ; get battery voltage |
202 call TFT_update_batt_voltage ; display battery voltage | 198 call TFT_update_batt_voltage ; display battery voltage |
203 call set_dive_modes ; tests if depth>threshold | 199 call set_dive_modes ; tests if depth>threshold |
204 btfss secs,0 ; Every two seconds... | 200 btfss secs,0 ; Every two seconds... |
205 call TFT_temp_surfmode ; Displays temperature | 201 call TFT_temp_surfmode ; Displays temperature |
206 btfss secs,0 ; Every two seconds... | 202 btfss secs,0 ; Every two seconds... |
207 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them | 203 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them |
208 bcf onesecupdate ; every second tasks done | 204 bcf onesecupdate ; every second tasks done |
209 | 205 |
210 surfloop_loop2: | 206 surfloop_loop2: |
211 ; Tasks approx. every 50ms for all modes | 207 ; Tasks approx. every 50ms for all modes |
212 call test_switches_surfmode ; check switches | 208 call test_switches_surfmode ; check switches |
213 call TFT_debug_output | 209 call TFT_debug_output |
214 | 210 |
226 btfsc pressure_refresh ; new pressure available? | 222 btfsc pressure_refresh ; new pressure available? |
227 call TFT_update_surf_press ; display surface pressure | 223 call TFT_update_surf_press ; display surface pressure |
228 bcf pressure_refresh ; until new pressure is available | 224 bcf pressure_refresh ; until new pressure is available |
229 | 225 |
230 ; Updates every 1/4 second | 226 ; Updates every 1/4 second |
231 btfss quarter_second_update | 227 btfss quarter_second_update |
232 bra surfloop_loop2b | 228 bra surfloop_loop2b |
233 | 229 |
234 bcf quarter_second_update | 230 bcf quarter_second_update |
235 | 231 |
236 call calc_deko_divemode_sensor | 232 ; Update Sensors |
237 | 233 call calc_deko_divemode_sensor |
238 btfsc FLAG_ccr_mode ; In CCR mode? | 234 |
239 bra surfloop_loop2a1 ; Yes. | 235 btfsc FLAG_ccr_mode ; In CCR mode? |
240 btfss FLAG_pscr_mode ; In PSCR mode? | 236 bra surfloop_loop2a1 ; Yes. |
241 bra surfloop_loop2a ; No, skip | 237 btfss FLAG_pscr_mode ; In PSCR mode? |
242 | 238 bra surfloop_loop2a ; No, skip |
243 surfloop_loop2a1: | 239 |
244 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | 240 surfloop_loop2a1: |
245 sublw .1 ; opt_ccr_mode = 1 (Sensor)? | 241 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP |
246 bnz surfloop_loop2a ; No, skip | 242 sublw .1 ; opt_ccr_mode = 1 (Sensor)? |
247 | 243 bnz surfloop_loop2a ; No, skip |
248 call TFT_surface_sensor ; ...update sensor data in surface mode | 244 |
249 call TFT_sensor_surface_warning ; Show a warning arrow-down behind sensor readings when sensor is end-of-life | 245 call TFT_surface_sensor ; ...update sensor data in surface mode |
250 movlw .9 | 246 call TFT_sensor_surface_warning ; Show a warning arrow-down behind sensor readings when sensor is end-of-life |
251 cpfseq menupos3 ; in Sensor mV surface custom view? | 247 movlw .9 |
252 bra surfloop_loop2a ; No | 248 cpfseq menupos3 ; in Sensor mV surface custom view? |
253 extern TFT_sensor_mV | 249 bra surfloop_loop2a ; No |
254 call TFT_sensor_mV ; Yes, update mV readings (Each 1/4 second and not each second as in customview.asm) | 250 extern TFT_sensor_mV |
251 call TFT_sensor_mV ; Yes, update mV readings (Each 1/4 second and not each second as in customview.asm) | |
255 | 252 |
256 surfloop_loop2a: | 253 surfloop_loop2a: |
257 movlw .6 | 254 movlw .6 |
258 cpfseq menupos3 ; in compass view? | 255 cpfseq menupos3 ; in compass view? |
259 bra surfloop_loop2b ; No | 256 bra surfloop_loop2b ; No |
260 extern TFT_surface_compass_heading | 257 extern TFT_surface_compass_heading |
261 call TFT_surface_compass_heading ; Yes, update compass heading value | 258 call TFT_surface_compass_heading ; Yes, update compass heading value |
262 | 259 |
263 surfloop_loop2b: | 260 surfloop_loop2b: |
264 btfsc toggle_customview ; Next view? | 261 btfsc toggle_customview ; Next view? |
265 call surf_customview_toggle ; Yes, show next customview (and delete this flag) | 262 call surf_customview_toggle ; Yes, show next customview (and delete this flag) |
266 | 263 |
267 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | 264 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) |
268 bra surfloop_loop3 | 265 bra surfloop_loop3 |
269 | 266 |
270 ; DELETE - In surface mode, only charing is available now - but now you can see the charging status :-) ## USB | 267 ;btfsc vusb_in ; USB plugged in? |
271 ; To do USB communication, you now need to be in menu or logbook mode | 268 ;call comm_mode ; Start COMM mode |
272 ;btfsc vusb_in ; USB plugged in? | 269 |
273 ;call comm_mode ; Start COMM mode | 270 bra surfloop_loop4 |
274 | 271 |
275 bra surfloop_loop4 | |
276 surfloop_loop3: | 272 surfloop_loop3: |
277 btfss vusb_in ; USB (still) plugged in? | 273 btfss vusb_in ; USB (still) plugged in? |
278 bcf enable_screen_dumps ; No, clear flag | 274 bcf enable_screen_dumps ; No, clear flag |
279 call rs232_get_byte | 275 call rs232_get_byte |
280 btfsc rs232_recieve_overflow | 276 btfsc rs232_receive_overflow |
281 bra surfloop_loop4 | 277 bra surfloop_loop4 |
282 movlw "l" | 278 movlw "l" |
283 cpfseq RCREG1 | 279 cpfseq RCREG1 |
284 bra surfloop_loop4 | 280 bra surfloop_loop4 |
285 call TFT_dump_screen ; Dump the screen contents | 281 call TFT_dump_screen ; Dump the screen contents |
282 | |
286 surfloop_loop4: | 283 surfloop_loop4: |
287 btfsc sleepmode ; Sleepmode active? | 284 btfss sleepmode ; shall we go into sleepmode? |
288 goto sleeploop ; Yes, switch into sleepmode! | 285 bra surfloop_loop ; NO - loop in surfacemode |
289 | 286 movff menupos3,customview_surfmode; YES - save last customview |
290 bra surfloop_loop ; loop surfacemode | 287 goto sleeploop ; switch into sleepmode |
288 | |
291 | 289 |
292 update_surfloop60: | 290 update_surfloop60: |
293 ; One minute tasks for all modes | 291 ; One minute tasks for all modes |
294 call TFT_date ; Update date | 292 call TFT_date ; Update date |
295 | 293 |
296 ; REPLACE ## no fly 2 | 294 call deco_calc_dive_interval_1min; calculate deco in surface mode. int_I_pres_surface gets updated by |
297 ; call calc_deko_surfmode ; calculate desaturation time every minute | 295 call deco_calc_desaturation_time ; TFT_update_surf_press when amb_pressure has changed by >= 10 mbar |
298 ; BY | |
299 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode. int_I_pres_surface gets updated by | |
300 call deco_calc_desaturation_time ; TFT_update_surf_press when amb_pressure has changed by >= 10 mbar | |
301 banksel common | 296 banksel common |
302 | 297 |
303 ; NEW ## deco engine | |
304 ; update tissue diagram if it is on display | 298 ; update tissue diagram if it is on display |
305 movlw .5 ; number of tissue custom view | 299 movlw .5 ; number of tissue custom view |
306 cpfseq menupos3 ; is this the current customview? | 300 cpfseq menupos3 ; is this the current customview? |
307 bra update_surfloop60_1 ; NO | 301 bra update_surfloop60_1 ; NO |
308 call TFT_standard_color ; YES - set standard color | 302 call TFT_standard_color ; YES - set standard color |
309 call TFT_surface_tissues ; show tissue diagram | 303 call TFT_surface_tissues ; show tissue diagram |
304 | |
310 update_surfloop60_1: | 305 update_surfloop60_1: |
311 | |
312 ; NEW ## no fly | |
313 ; update last dive info if it is on display | 306 ; update last dive info if it is on display |
314 movlw .8 ; number of the last dive info customview | 307 movlw .8 ; number of the last dive info customview |
315 cpfseq menupos3 ; is this the current customview? | 308 cpfseq menupos3 ; is this the current customview? |
316 bra update_surfloop60_2 ; NO | 309 bra update_surfloop60_2 ; NO |
317 call TFT_standard_color ; YES - set standard color | 310 call TFT_standard_color ; YES - set standard color |
318 call TFT_surface_lastdive ; show last dive infos | 311 call TFT_surface_lastdive ; show last dive infos |
312 | |
319 update_surfloop60_2: | 313 update_surfloop60_2: |
320 | 314 bcf oneminupdate |
321 bcf oneminupdate | 315 return |
322 return | 316 |
323 | 317 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation |
324 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation | |
325 surfmode_check_for_warnings: | 318 surfmode_check_for_warnings: |
326 | 319 bcf warning_active ; Clear flag |
327 ; DELETE ## (screen flicker) | 320 clrf warning_counter ; Clear counter |
328 ; movf warning_counter_backup,W | 321 |
329 ; cpfseq warning_counter ; warning_counter_backup = warning_counter? | 322 ; Warnings for all modes |
330 ; call TFT_clear_warning_text ; No, clear all warnings | 323 call check_warn_battery ; Check if the battery level should be displayed/warned |
331 ; movff warning_counter,warning_counter_backup ; copy warning_counter | 324 |
332 | 325 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode |
333 bcf warning_active ; Clear flag | 326 bra surfmode_check_for_warnings2 |
334 clrf warning_counter ; Clear counter | 327 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode |
335 | 328 bra surfmode_check_for_warnings2 |
336 ; Warnings for all modes | 329 |
337 call check_warn_battery ; Check if the battery level should be displayed/warned | 330 ; Warnings only in deco modes |
338 | 331 rcall surfmode_check_for_desat ; Check if desat time should be shown |
339 ; DELETE HERE... ## (general fix) | 332 rcall surfmode_check_for_nofly ; Check if nofly time should be shown |
340 ; rcall surfmode_check_for_nofly ; Check if nofly time should be shown | 333 call check_cns_violation ; Check CNS value and display it, if required |
341 ; rcall surfmode_check_for_desat ; Check if desat time should be shown | 334 call check_and_store_gf_violation; Check GF value and display it, if required |
342 | 335 |
343 ; DELETE - surface interval is now shown in last dive custom view, not as "warning" any more ## no fly | 336 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings |
344 ; rcall surfmode_check_for_interval ; Check if surface interval should be shown | 337 btfsc WREG,mbubble_warning_lock ; do we have a microbubbles warning? |
345 | |
346 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode | |
347 bra surfmode_check_for_warnings2 | |
348 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode | |
349 bra surfmode_check_for_warnings2 | |
350 | |
351 ; Warnings only in deco modes | |
352 | |
353 ; ...INSERT HERE ## (general fix) - desat and no-fly time belong to deco modes | |
354 rcall surfmode_check_for_desat ; Check if desat time should be shown | |
355 rcall surfmode_check_for_nofly ; Check if nofly time should be shown | |
356 | |
357 call check_cns_violation ; Check CNS value and display it, if required | |
358 call check_and_store_gf_violation ; Check GF value and display it, if required | |
359 | |
360 ; NEW ## microbubbles | |
361 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings | |
362 btfsc WREG,mbubble_warning_lock ; do we have a microbubbles warning? | |
363 extern warn_mbubbles | 338 extern warn_mbubbles |
364 call warn_mbubbles ; YES | 339 call warn_mbubbles ; YES |
365 | 340 |
366 surfmode_check_for_warnings2: | 341 surfmode_check_for_warnings2: |
367 ; Setup warning_page number | 342 ; Setup warning_page number |
368 incf warning_page,F | 343 incf warning_page,F |
369 bcf STATUS,C | 344 bcf STATUS,C |
370 rlcf warning_page,W ; *2 | 345 rlcf warning_page,W ; *2 |
371 cpfsgt warning_counter ; > warning_counter | 346 cpfsgt warning_counter ; > warning_counter |
372 clrf warning_page ; No, clear | 347 clrf warning_page ; No, clear |
373 | 348 |
374 ; NEW ## (screen flicker) | 349 ; Clear both rows of warnings if there is nothing to show at all |
375 ; Clear both rows of warnings if there is nothing to show at all | 350 tstfsz warning_counter ; any warnings? |
376 tstfsz warning_counter ; any warnings? | 351 bra surfmode_check_for_warnings3; YES - look if second row needs to be cleared |
377 bra surfmode_check_for_warnings3 ; YES - look if second row needs to be cleared | 352 call TFT_clear_warning_text ; NO - clear complete warnings area |
378 call TFT_clear_warning_text ; NO - clear complete warnings area | 353 return |
379 return | 354 |
380 surfmode_check_for_warnings3: | 355 surfmode_check_for_warnings3: |
381 | 356 ; Clear 2nd row of warnings if there is nothing to show (on this page) |
382 ; Clear 2nd row of warnings if there is nothing to show (on this page) | 357 btfss second_row_warning ; =1: The second row contains a warning |
383 btfss second_row_warning ; =1: The second row contains a warning | 358 call TFT_clear_warning_text_2nd_row ; No, clear this row |
384 call TFT_clear_warning_text_2nd_row ; No, clear this row | 359 return ; Done. |
385 return ; Done. | |
386 | |
387 ; DELETE - surface interval is now shown in last dive custom view, not as "warning" any more ## no fly | |
388 ; | |
389 ;surfmode_check_for_interval: | |
390 ; movf surface_interval+0,W ; Is interval null ? | |
391 ; iorwf surface_interval+1,W | |
392 ; bnz surfmode_check_for_interval2 ; No | |
393 ; return | |
394 ;surfmode_check_for_interval2: | |
395 ; incf warning_counter,F ; increase counter | |
396 ; call TFT_interval | |
397 ; return | |
398 | |
399 | 360 |
400 surfmode_check_for_desat: | 361 surfmode_check_for_desat: |
401 ; REPLACE ## no fly | |
402 ; movf desaturation_time+0,W ; Is nofly null ? | |
403 ; iorwf desaturation_time+1,W | |
404 ; BY | |
405 banksel int_O_desaturation_time | 362 banksel int_O_desaturation_time |
406 movf int_O_desaturation_time+0,W ; Is nofly null ? | 363 movf int_O_desaturation_time+0,W ; is nofly-time null ? |
407 iorwf int_O_desaturation_time+1,W | 364 iorwf int_O_desaturation_time+1,W |
408 | 365 banksel common |
409 bnz surfmode_check_for_desat2 ; No | 366 bnz surfmode_check_for_desat_1 ; NO |
410 | 367 return |
411 ; NEW ## no fly | 368 surfmode_check_for_desat_1: ; YES |
412 banksel common | 369 incf warning_counter,F ; increase counter |
413 | 370 call TFT_desaturation_time ; show desaturation time |
414 return | 371 return |
415 | |
416 surfmode_check_for_desat2: | |
417 ; NEW ## no fly | |
418 banksel common | |
419 | |
420 incf warning_counter,F ; increase counter | |
421 call TFT_desaturation_time | |
422 return | |
423 | 372 |
424 surfmode_check_for_nofly: | 373 surfmode_check_for_nofly: |
425 ; REPLACE ## no fly | |
426 ; movf nofly_time+0,W ; Is nofly null ? | |
427 ; iorwf nofly_time+1,W | |
428 ; BY | |
429 banksel int_O_nofly_time | 374 banksel int_O_nofly_time |
430 movf int_O_nofly_time+0,W ; Is nofly null ? | 375 movf int_O_nofly_time+0,W ; is nofly-time null ? |
431 iorwf int_O_nofly_time+1,W | 376 iorwf int_O_nofly_time+1,W |
432 | |
433 bnz surfmode_check_for_nofly2 ; No... | |
434 | |
435 ; NEW ## no fly | |
436 banksel common | 377 banksel common |
437 | 378 bnz surfmode_check_for_nofly_1 ; No... |
438 return | 379 return |
439 | 380 surfmode_check_for_nofly_1: ; YES |
440 surfmode_check_for_nofly2: | 381 incf warning_counter,F ; increase counter |
441 ; NEW ## no fly | 382 call TFT_nofly_time ; show nofly-time |
442 banksel common | 383 return |
443 | |
444 incf warning_counter,F ; increase counter | |
445 call TFT_nofly_time | |
446 return | |
447 | 384 |
448 | 385 |
449 ;============================================================================= | 386 ;============================================================================= |
450 | 387 |
451 ; DELETE - not used any more ## no fly | 388 test_switches_surfmode: ; checks switches in surfacemode |
452 ; global calc_deko_surfmode | |
453 ;calc_deko_surfmode: | |
454 ; | |
455 ; ; DELETE - deco_calc_wo_deco_step_1_min uses int_I_pres_surface, not int_I_pres_respiration ## no fly | |
456 ; ; SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine | |
457 ; | |
458 ; call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode | |
459 ; | |
460 ; ; NEW ## no fly | |
461 ; ; call deco_calc_desaturation_time | |
462 ; | |
463 ; banksel common | |
464 ; return | |
465 | |
466 test_switches_surfmode: ; checks switches in surfacemode | |
467 btfsc switch_right | 389 btfsc switch_right |
468 bra test_switches_surfmode2 | 390 bra test_switches_surfmode2 |
469 btfsc switch_left | 391 btfsc switch_left |
470 bra test_switches_surfmode3 | 392 bra test_switches_surfmode3 |
471 | 393 ; No button pressed |
472 ; No button press | |
473 return | 394 return |
474 | 395 |
475 test_switches_surfmode3: | 396 test_switches_surfmode3: |
476 movlw .6 | 397 movlw .6 |
477 cpfseq menupos3 ; in compass view? | 398 cpfseq menupos3 ; in compass view? |
478 bra test_switches_surfmode3a ; No | 399 bra test_switches_surfmode3a ; No |
479 | 400 |
480 btfsc premenu ; already shown "Bearing" | 401 btfsc premenu ; already shown "Bearing" |
481 bra test_switches_surfmode3b ; Yes, remove it | 402 bra test_switches_surfmode3b ; Yes, remove it |
482 | 403 |
483 extern TFT_surf_set_bearing | 404 extern TFT_surf_set_bearing |
484 call TFT_surf_set_bearing ; Yes. | 405 call TFT_surf_set_bearing ; Yes. |
485 bcf switch_left | 406 bcf switch_left |
486 return | 407 return |
487 | 408 |
488 test_switches_surfmode3a: | 409 test_switches_surfmode3a: |
489 bcf switch_left | 410 bcf switch_left |
490 bsf menubit ; Enter Menu! | 411 bsf menubit ; Enter Menu! |
491 return | 412 return |
492 | 413 |
493 test_switches_surfmode3b: | 414 test_switches_surfmode3b: |
494 ; Clear "Heading?" | 415 ; Clear "Heading?" |
495 WIN_BOX_BLACK .158,.190, .15, .99 ; top, bottom, left, right | 416 WIN_BOX_BLACK .158,.190, .15, .99 ; top, bottom, left, right |
496 bcf premenu | 417 bcf premenu |
497 bcf switch_left | 418 bcf switch_left |
498 return | 419 return |
499 | 420 |
500 test_switches_surfmode2: | 421 test_switches_surfmode2: |
501 movlw .6 | 422 movlw .6 |
502 cpfseq menupos3 ; in compass view? | 423 cpfseq menupos3 ; in compass view? |
503 bra test_switches_surfmode2a ; No | 424 bra test_switches_surfmode2a ; No |
504 btfss premenu ; "Heading?" shown? | 425 btfss premenu ; "Heading?" shown? |
505 bra test_switches_surfmode2a ; No | 426 bra test_switches_surfmode2a ; No |
506 ; Set new heading | 427 ; Set new heading |
507 bcf premenu | 428 bcf premenu |
508 bsf compass_bearing_set | 429 bsf compass_bearing_set |
509 movff compass_heading_shown+0,compass_bearing+0 | 430 movff compass_heading_shown+0,compass_bearing+0 |
510 movff compass_heading_shown+1,compass_bearing+1 | 431 movff compass_heading_shown+1,compass_bearing+1 |
511 bcf switch_right | 432 bcf switch_right |
512 return | 433 return |
513 | 434 |
514 test_switches_surfmode2a: | 435 test_switches_surfmode2a: |
515 bcf switch_right | 436 bcf switch_right |
516 bsf toggle_customview | 437 bsf toggle_customview |
517 bcf premenu | 438 bcf premenu |
518 clrf timeout_counter2 ; and reset timeout | 439 clrf timeout_counter2 ; and reset timeout |
519 return | 440 return |
520 | 441 |
521 global timeout_surfmode | 442 global timeout_surfmode |
522 timeout_surfmode: | 443 timeout_surfmode: |
523 movlw timeout_surfacemode ; [s] Default timeout | 444 movlw timeout_surfacemode ; [s] Default timeout |
524 btfsc menu_show_sensors2 ; In the "Calibrate" menu? | 445 btfsc menu_show_sensors2 ; In the "Calibrate" menu? |
525 movlw timeout_calibrate_menu ; [s] CCR Calibrate Menu timeout | 446 movlw timeout_calibrate_menu ; [s] CCR Calibrate Menu timeout |
526 btfsc menubit ; in Menu? | 447 btfsc menubit ; in Menu? |
527 bra timeout_testmode ; No, done. | 448 bra timeout_testmode ; No, done. |
528 ; Must be in surface mode | 449 ; Must be in surface mode |
529 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | 450 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
530 bra timeout_testmode ; No, not CCR | 451 bra timeout_testmode ; No, not CCR |
531 movlw timeout_ccr_surface ; [s] CCR Surface mode timeout | 452 movlw timeout_ccr_surface ; [s] CCR Surface mode timeout |
532 | 453 |
533 global timeout_testmode | 454 global timeout_testmode |
534 timeout_testmode: | 455 timeout_testmode: |
535 incf timeout_counter2,F ; increase timeout counter | 456 incf timeout_counter2,F ; increase timeout counter |
536 cpfsgt timeout_counter2 ; Compare with timeout_counter2 | 457 cpfsgt timeout_counter2 ; Compare with timeout limit |
537 return ; return, no timeout | 458 return ; return, no timeout |
538 bsf sleepmode ; Set Flag | 459 bsf sleepmode ; Set Flag |
539 return ; Return | 460 return ; Return |
540 | 461 |
541 END | 462 END |