Mercurial > public > hwos_code
comparison src/divemode.asm @ 656:8af5aefbcdaf default tip
Update to 3.31 beta
| author | heinrichsweikamp |
|---|---|
| date | Thu, 27 Nov 2025 18:32:58 +0100 |
| parents | 75e90cd0c2c3 |
| children |
comparison
equal
deleted
inserted
replaced
| 655:c7b7b8a358cd | 656:8af5aefbcdaf |
|---|---|
| 79 #DEFINE FLAG_TFT_active_gas_divemode TFT_output_flags_1,2 ; =1: show active gas and dive mode | 79 #DEFINE FLAG_TFT_active_gas_divemode TFT_output_flags_1,2 ; =1: show active gas and dive mode |
| 80 #DEFINE FLAG_TFT_apnoe_surface_time TFT_output_flags_1,3 ; =1: show apnoe mode surface time | 80 #DEFINE FLAG_TFT_apnoe_surface_time TFT_output_flags_1,3 ; =1: show apnoe mode surface time |
| 81 #DEFINE FLAG_TFT_depth_maximum_apnoe TFT_output_flags_1,4 ; =1: show maximum depth of last apnoe dive | 81 #DEFINE FLAG_TFT_depth_maximum_apnoe TFT_output_flags_1,4 ; =1: show maximum depth of last apnoe dive |
| 82 #DEFINE FLAG_TFT_clear_apnoe_surface TFT_output_flags_1,5 ; =1: clear apnoe mode surface data from screen | 82 #DEFINE FLAG_TFT_clear_apnoe_surface TFT_output_flags_1,5 ; =1: clear apnoe mode surface data from screen |
| 83 #DEFINE FLAG_TFT_apnoe_divetime TFT_output_flags_1,6 ; =1: show apnoe mode dive times | 83 #DEFINE FLAG_TFT_apnoe_divetime TFT_output_flags_1,6 ; =1: show apnoe mode dive times |
| 84 #DEFINE FLAG_TFT_temperature TFT_output_flags_1,7 ; =1: show temperature (or resettable dive time when in compass view) | 84 #DEFINE FLAG_TFT_temperature TFT_output_flags_1,7 ; =1: show/redraw temperature |
| 85 | 85 |
| 86 ; TFT_output_flags_2 - phase 2: every second - before deco calculations, deco modes only | 86 ; TFT_output_flags_2 - phase 2: every second - before deco calculations, deco modes only |
| 87 #DEFINE FLAG_TFT_divemode_mask TFT_output_flags_2,0 ; =1: show dive mode mask | 87 #DEFINE FLAG_TFT_divemode_mask TFT_output_flags_2,0 ; =1: show dive mode mask |
| 88 #DEFINE FLAG_TFT_divetime TFT_output_flags_2,1 ; =1: show dive time | 88 #DEFINE FLAG_TFT_divetime TFT_output_flags_2,1 ; =1: show dive time |
| 89 #DEFINE FLAG_TFT_safety_stop_show TFT_output_flags_2,2 ; =1: show safety stop | 89 #DEFINE FLAG_TFT_safety_stop_show TFT_output_flags_2,2 ; =1: show safety stop |
| 240 bcf trigger_quarter_second ; YES - clear flag | 240 bcf trigger_quarter_second ; YES - clear flag |
| 241 | 241 |
| 242 movlw .4 ; 62,5ms * 4 = 1/4 second | 242 movlw .4 ; 62,5ms * 4 = 1/4 second |
| 243 movff WREG,isr_tmr7_helper ; to make sure at least 1/4 will pass before trigger_quarter_second is re-set | 243 movff WREG,isr_tmr7_helper ; to make sure at least 1/4 will pass before trigger_quarter_second is re-set |
| 244 | 244 |
| 245 IFDEF _compass | |
| 246 movlw index_compass_dm ; index of compass view | |
| 247 cpfseq active_customview ; in compass view? | |
| 248 bra diveloop_loop_quarter_1 ; NO - continue with tasks 1/4 second | |
| 249 call TFT_dive_compass_heading ; YES - update compass heading value | |
| 250 btfsc compass_bearing_set ; is a bearing set? | |
| 251 call TFT_dive_compass_extras ; YES, Update Stopwatch display in compass mode | |
| 252 ENDIF | |
| 253 | |
| 254 diveloop_loop_quarter_1: | |
| 245 btfss press_sensor_type ; New sensor found? | 255 btfss press_sensor_type ; New sensor found? |
| 246 bra diveloop_loop_0 ; No - continue | 256 bra diveloop_loop_0 ; No - continue |
| 247 | 257 |
| 248 ; Handle new pressure sensor every 1/4 second | 258 ; Handle new pressure sensor every 1/4 second |
| 249 btfsc ms5837_state ; =0: result of temperature is in the ADC | 259 btfsc ms5837_state ; =0: result of temperature is in the ADC |
| 257 diveloop_loop_0: | 267 diveloop_loop_0: |
| 258 btfsc trigger_full_second ; new 1/1 second? | 268 btfsc trigger_full_second ; new 1/1 second? |
| 259 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second | 269 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second |
| 260 btfsc trigger_half_second ; NO - new 1/2 second? | 270 btfsc trigger_half_second ; NO - new 1/2 second? |
| 261 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second | 271 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second |
| 262 | 272 |
| 263 ; tasks every round except every 1/1 or 1/2 second | 273 ; tasks every round except every 1/1 or 1/2 second |
| 264 IFDEF _compass | 274 |
| 265 movlw index_compass_dm ; index of compass view | |
| 266 cpfseq active_customview ; in compass view? | |
| 267 bra diveloop_loop_11 ; NO - continue with tasks every round | |
| 268 call TFT_dive_compass_heading ; YES - update compass heading value | |
| 269 bsf FLAG_TFT_temperature ; - redraw temperature (will show resettable dive time now) | |
| 270 ENDIF | |
| 271 bra diveloop_loop_11 ; - continue tasks every round | 275 bra diveloop_loop_11 ; - continue tasks every round |
| 272 | 276 |
| 273 diveloop_loop_1: | 277 diveloop_loop_1: |
| 274 ; tasks every 1/2 second | 278 ; tasks every 1/2 second |
| 275 bcf trigger_half_second ; clear flag | 279 bcf trigger_half_second ; clear flag |
| 347 ; adjust auto-setpoint | 351 ; adjust auto-setpoint |
| 348 btfsc FLAG_ccr_mode ; in CCR mode? | 352 btfsc FLAG_ccr_mode ; in CCR mode? |
| 349 call check_dive_autosp ; YES - check for Auto-SP | 353 call check_dive_autosp ; YES - check for Auto-SP |
| 350 ENDIF | 354 ENDIF |
| 351 | 355 |
| 352 IFDEF _external_sensor | 356 IFDEF _external_sensor_eccr |
| 353 btfsc FLAG_ccr_mode ; in CCR mode? | 357 btfsc FLAG_ccr_mode ; in CCR mode? |
| 354 rcall calc_deko_divemode_sensor ; YES - process sensor readings | 358 rcall calc_deko_divemode_sensor ; YES - process sensor readings |
| 355 btfsc FLAG_pscr_mode ; in pSCR mode? | 359 btfsc FLAG_pscr_mode ; in pSCR mode? |
| 356 rcall calc_deko_divemode_sensor ; YES - process sensor readings | 360 rcall calc_deko_divemode_sensor ; YES - process sensor readings |
| 357 ENDIF | 361 ENDIF |
| 404 call configure_sac_calculation ; - set up SAC calculation | 408 call configure_sac_calculation ; - set up SAC calculation |
| 405 ENDIF | 409 ENDIF |
| 406 | 410 |
| 407 diveloop_loop_6: | 411 diveloop_loop_6: |
| 408 ; deco mode tasks every 1/1 second | 412 ; deco mode tasks every 1/1 second |
| 413 INCI divesecs_compass_trip ; increment the compass stopwatch | |
| 409 INCI divesecs_avg_trip ; increment the resettable dive time | 414 INCI divesecs_avg_trip ; increment the resettable dive time |
| 410 INCI divesecs_avg_total ; increment the total dive time | 415 INCI divesecs_avg_total ; increment the total dive time |
| 411 | 416 |
| 412 btfsc FLAG_gauge_mode ; in gauge mode? | 417 btfsc FLAG_gauge_mode ; in gauge mode? |
| 413 bra diveloop_loop_7 ; YES - skip deco calculations | 418 bra diveloop_loop_7 ; YES - skip deco calculations |
| 617 btfsc FLAG_TFT_depth_maximum ; shall show max depth? | 622 btfsc FLAG_TFT_depth_maximum ; shall show max depth? |
| 618 call TFT_show_max_depth ; YES - display max depth | 623 call TFT_show_max_depth ; YES - display max depth |
| 619 btfsc FLAG_TFT_active_gas_divemode ; shall show active gas and dive mode? | 624 btfsc FLAG_TFT_active_gas_divemode ; shall show active gas and dive mode? |
| 620 call TFT_show_active_gas_divemode ; YES - display gas, setpoint and mode | 625 call TFT_show_active_gas_divemode ; YES - display gas, setpoint and mode |
| 621 btfsc FLAG_TFT_temperature ; shall show temperature? | 626 btfsc FLAG_TFT_temperature ; shall show temperature? |
| 622 call TFT_show_temp_divemode ; YES - display temperature (or resettable dive time) | 627 call TFT_show_temp_divemode ; YES - display temperature |
| 623 | 628 |
| 624 btfsc FLAG_TFT_apnoe_surface_time ; shall show apnoe mode surface time? | 629 btfsc FLAG_TFT_apnoe_surface_time ; shall show apnoe mode surface time? |
| 625 call TFT_show_apnoe_surface ; YES - show apnoe mode surface time | 630 call TFT_show_apnoe_surface ; YES - show apnoe mode surface time |
| 626 btfsc FLAG_TFT_depth_maximum_apnoe ; shall show max. depth of last dive? | 631 btfsc FLAG_TFT_depth_maximum_apnoe ; shall show max. depth of last dive? |
| 627 call TFT_show_apnoe_max_depth ; YES - show max. depth of last dive | 632 call TFT_show_apnoe_max_depth ; YES - show max. depth of last dive |
| 974 | 979 |
| 975 return ; done | 980 return ; done |
| 976 | 981 |
| 977 | 982 |
| 978 IFDEF _ccr_pscr | 983 IFDEF _ccr_pscr |
| 979 IFDEF _external_sensor | 984 IFDEF _external_sensor_eccr |
| 980 | 985 |
| 981 ;----------------------------------------------------------------------------- | 986 ;----------------------------------------------------------------------------- |
| 982 ; Process Sensor Readings | 987 ; Process Sensor Readings |
| 983 ; | 988 ; |
| 984 global calc_deko_divemode_sensor | 989 global calc_deko_divemode_sensor |
| 985 calc_deko_divemode_sensor: | 990 calc_deko_divemode_sensor: |
| 986 btfsc ext_input_optical ; do we have an optical interface? | 991 btfsc ext_input_optical ; do we have an optical interface? |
| 992 bra calc_deko_divemode_sensor_opt ; YES - process received data | |
| 993 btfsc ext_s8_full_digital ; are we in external S8 full digital mode? | |
| 987 bra calc_deko_divemode_sensor_opt ; YES - process received data | 994 bra calc_deko_divemode_sensor_opt ; YES - process received data |
| 988 btfss ext_input_s8_ana ; NO - do we have a S8/analog interface? | 995 btfss ext_input_s8_ana ; NO - do we have a S8/analog interface? |
| 989 return ; NO - nothing to do, done | 996 return ; NO - nothing to do, done |
| 990 TSTOSS opt_s8_mode ; YES - shall use S8 interface? | 997 TSTOSS opt_s8_mode ; YES - shall use S8 interface? |
| 991 bra calc_deko_divemode_sensor_ana ; - NO - use analog interface | 998 bra calc_deko_divemode_sensor_ana ; - NO - use analog interface |
| 1333 ; movlw sensor_voting_logic_threshold ; load threshold in 0.01 bar | 1340 ; movlw sensor_voting_logic_threshold ; load threshold in 0.01 bar |
| 1334 ; cpfsgt lo ; deviation > threshold ? | 1341 ; cpfsgt lo ; deviation > threshold ? |
| 1335 ; retlw .0 ; NO - within range | 1342 ; retlw .0 ; NO - within range |
| 1336 ; retlw .1 ; YES - out of range | 1343 ; retlw .1 ; YES - out of range |
| 1337 | 1344 |
| 1338 ENDIF ; _external_sensor | 1345 ENDIF ; _external_sensor_eccr |
| 1339 ENDIF ; _ccr_pscr | 1346 ENDIF ; _ccr_pscr |
| 1340 | 1347 |
| 1341 | 1348 |
| 1342 IFDEF _cave_mode | 1349 IFDEF _cave_mode |
| 1343 | 1350 |
| 1885 cpfseq active_customview ; - compare with current custom view, equal? | 1892 cpfseq active_customview ; - compare with current custom view, equal? |
| 1886 call dive_customview_recall ; NO - redraw previous custom view | 1893 call dive_customview_recall ; NO - redraw previous custom view |
| 1887 | 1894 |
| 1888 divemenu_cleanup_1: | 1895 divemenu_cleanup_1: |
| 1889 bsf FLAG_TFT_active_gas_divemode; request redraw of gas/setpoint/diluent | 1896 bsf FLAG_TFT_active_gas_divemode; request redraw of gas/setpoint/diluent |
| 1890 bsf FLAG_TFT_temperature ; request redraw of temperature (or resettable dive) | 1897 bsf FLAG_TFT_temperature ; request redraw of temperature |
| 1891 bcf better_gas_blinking ; stop better gas cue | 1898 bcf better_gas_blinking ; stop better gas cue |
| 1892 bcf better_dil_blinking ; stop better dil cue | 1899 bcf better_dil_blinking ; stop better dil cue |
| 1893 ;bra request_redraw_NDL_deco_data; request redraw of NDL/deco data and return | 1900 ;bra request_redraw_NDL_deco_data; request redraw of NDL/deco data and return |
| 1894 | 1901 |
| 1895 | 1902 |
| 2310 ; item 11: set bearing | 2317 ; item 11: set bearing |
| 2311 ; | 2318 ; |
| 2312 IFDEF _compass | 2319 IFDEF _compass |
| 2313 divemode_option_course: | 2320 divemode_option_course: |
| 2314 MOVII compass_heading_shown,compass_bearing | 2321 MOVII compass_heading_shown,compass_bearing |
| 2322 CLRI divesecs_compass_trip | |
| 2315 bsf compass_bearing_set ; set flag to show heading | 2323 bsf compass_bearing_set ; set flag to show heading |
| 2316 goto menuview_toggle_reset ; terminate the pre-menu and return | 2324 goto menuview_toggle_reset ; terminate the pre-menu and return |
| 2317 ENDIF | 2325 ENDIF |
| 2318 | 2326 |
| 2319 | 2327 |
| 2356 ADDLI .300,total_divetime_secs ; add 5 minutes (300 seconds) to total_divetime_secs | 2364 ADDLI .300,total_divetime_secs ; add 5 minutes (300 seconds) to total_divetime_secs |
| 2357 bsf count_divetime ; continue dive time incrementing in ISR | 2365 bsf count_divetime ; continue dive time incrementing in ISR |
| 2358 | 2366 |
| 2359 ADDLI .300,divesecs_avg_trip ; add 5 minutes (300 seconds) to resettable time accumulator | 2367 ADDLI .300,divesecs_avg_trip ; add 5 minutes (300 seconds) to resettable time accumulator |
| 2360 ADDLI .300,divesecs_avg_total ; add 5 minutes (300 seconds) to total time accumulator | 2368 ADDLI .300,divesecs_avg_total ; add 5 minutes (300 seconds) to total time accumulator |
| 2369 ADDLI .300,divesecs_compass_trip ; add 5 minutes (300 seconds) to compass stopwatch accumulator | |
| 2361 | 2370 |
| 2362 MOVII pressure_rel_cur_cached,xB ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min) | 2371 MOVII pressure_rel_cur_cached,xB ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min) |
| 2363 MOVLI .300,xA ; ... | 2372 MOVLI .300,xA ; ... |
| 2364 call mult16x16 ; xC = xA * xB | 2373 call mult16x16 ; xC = xA * xB |
| 2365 | 2374 |
| 2847 | 2856 |
| 2848 ;----------------------------------------------------------------------------- | 2857 ;----------------------------------------------------------------------------- |
| 2849 ; Helper Function - transmit new Setpoint to external Electronics and flag Change | 2858 ; Helper Function - transmit new Setpoint to external Electronics and flag Change |
| 2850 ; | 2859 ; |
| 2851 xmit_sp_set_flag: | 2860 xmit_sp_set_flag: |
| 2852 IFDEF _external_sensor | 2861 IFDEF _external_sensor_eccr |
| 2853 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | 2862 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
| 2854 ENDIF | 2863 ENDIF |
| 2855 bsf event_occured ; set global event flag | 2864 bsf event_occured ; set global event flag |
| 2856 bsf event_SP_change ; set setpoint event flag | 2865 bsf event_SP_change ; set setpoint event flag |
| 2857 return | 2866 return |
| 3126 | 3135 |
| 3127 bsf use_O2_sensor3 | 3136 bsf use_O2_sensor3 |
| 3128 btfss sensor3_calibrated_ok | 3137 btfss sensor3_calibrated_ok |
| 3129 bcf use_O2_sensor3 | 3138 bcf use_O2_sensor3 |
| 3130 | 3139 |
| 3131 IFDEF _external_sensor | 3140 IFDEF _external_sensor_eccr |
| 3132 ; check for external HUD/ppO2 Monitor | 3141 ; check for external HUD/ppO2 Monitor |
| 3133 btfss ext_input_optical ; do we have an optical input? | 3142 btfss ext_input_optical ; do we have an optical input? |
| 3143 bra dive_boot_cc_part2_1 ; NO | |
| 3144 btfss ext_s8_full_digital ; are we in external S8 full digital mode? | |
| 3134 bra dive_boot_cc_part2_1 ; NO | 3145 bra dive_boot_cc_part2_1 ; NO |
| 3135 btfsc sensor1_active ; YES - process flags from HUD/ppO2 Monitor | 3146 btfsc sensor1_active ; YES - process flags from HUD/ppO2 Monitor |
| 3136 bsf use_O2_sensor1 ; - ... | 3147 bsf use_O2_sensor1 ; - ... |
| 3137 btfsc sensor2_active ; - ... | 3148 btfsc sensor2_active ; - ... |
| 3138 bsf use_O2_sensor2 ; - ... | 3149 bsf use_O2_sensor2 ; - ... |
| 3158 clrf WREG ; pre-load WREG with setpoint value 0 for pSCR calculated | 3169 clrf WREG ; pre-load WREG with setpoint value 0 for pSCR calculated |
| 3159 btfsc FLAG_ccr_mode ; in CCR mode? | 3170 btfsc FLAG_ccr_mode ; in CCR mode? |
| 3160 movff opt_setpoint_cbar+0,WREG ; YES - get value of setpoint 1 into WREG | 3171 movff opt_setpoint_cbar+0,WREG ; YES - get value of setpoint 1 into WREG |
| 3161 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine | 3172 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine |
| 3162 | 3173 |
| 3163 IFDEF _external_sensor | 3174 IFDEF _external_sensor_eccr |
| 3164 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | 3175 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
| 3165 goto calc_deko_divemode_sensor ; process sensor readings and return | 3176 goto calc_deko_divemode_sensor ; process sensor readings and return |
| 3166 ELSE | 3177 ELSE |
| 3167 return ; done | 3178 return ; done |
| 3168 ENDIF | 3179 ENDIF |
| 3296 CLRI divesecs_avg_total ; time accumulator | 3307 CLRI divesecs_avg_total ; time accumulator |
| 3297 clrf pressure_rel_accu_total+0 ; depth accumulator | 3308 clrf pressure_rel_accu_total+0 ; depth accumulator |
| 3298 clrf pressure_rel_accu_total+1 ; ... | 3309 clrf pressure_rel_accu_total+1 ; ... |
| 3299 clrf pressure_rel_accu_total+2 ; ... | 3310 clrf pressure_rel_accu_total+2 ; ... |
| 3300 clrf pressure_rel_accu_total+3 ; ... | 3311 clrf pressure_rel_accu_total+3 ; ... |
| 3312 | |
| 3313 ; IFDEF _compass | |
| 3314 ; CLRI divesecs_compass_trip ; time accumulator for the compass stopwatch (Not really needed, it's not shown until it's reset with the 1st. course set) | |
| 3315 ; ENDIF | |
| 3301 | 3316 |
| 3302 IFDEF _rx_functions | 3317 IFDEF _rx_functions |
| 3303 | 3318 |
| 3304 btfss tr_functions_activated ; TR functions activated? | 3319 btfss tr_functions_activated ; TR functions activated? |
| 3305 bra diveloop_boot_0 ; NO - skip TR function initialization | 3320 bra diveloop_boot_0 ; NO - skip TR function initialization |
| 3437 ENDIF | 3452 ENDIF |
| 3438 | 3453 |
| 3439 rcall check_display_ftts ; show fTTS time (or cave mode cTTS) | 3454 rcall check_display_ftts ; show fTTS time (or cave mode cTTS) |
| 3440 rcall check_ppO2 ; check ppO2 | 3455 rcall check_ppO2 ; check ppO2 |
| 3441 | 3456 |
| 3442 IFDEF _external_sensor | 3457 IFDEF _external_sensor_eccr |
| 3443 rcall check_ext_sensors ; check external sensors | 3458 rcall check_ext_sensors ; check external sensors |
| 3444 ENDIF | 3459 ENDIF |
| 3445 | 3460 |
| 3446 rcall check_outside ; check of ZHL16 model violation | 3461 rcall check_outside ; check of ZHL16 model violation |
| 3447 | 3462 |
| 4305 check_gas_needs_mesg: | 4320 check_gas_needs_mesg: |
| 4306 incf message_counter,F ; increase message counter | 4321 incf message_counter,F ; increase message counter |
| 4307 goto TFT_message_gas_needs ; show message for gas needs and return | 4322 goto TFT_message_gas_needs ; show message for gas needs and return |
| 4308 | 4323 |
| 4309 | 4324 |
| 4310 IFDEF _external_sensor | 4325 IFDEF _external_sensor_eccr |
| 4311 | 4326 |
| 4312 ;----------------------------------------------------------------------------- | 4327 ;----------------------------------------------------------------------------- |
| 4313 ; Check external Sensors for Loss and Divergence | 4328 ; Check external Sensors for Loss and Divergence |
| 4314 ; | 4329 ; |
| 4315 check_ext_sensors: | 4330 check_ext_sensors: |
| 4384 | 4399 |
| 4385 check_ext_sensors_diverg_mesg: | 4400 check_ext_sensors_diverg_mesg: |
| 4386 incf message_counter,F ; increase message counter | 4401 incf message_counter,F ; increase message counter |
| 4387 goto TFT_message_divergence ; show message and return | 4402 goto TFT_message_divergence ; show message and return |
| 4388 | 4403 |
| 4389 ENDIF ; _external_sensor | 4404 ENDIF ; _external_sensor_eccr |
| 4390 | 4405 |
| 4391 | 4406 |
| 4392 ;============================================================================= | 4407 ;============================================================================= |
| 4393 dmode5 CODE | 4408 dmode5 CODE |
| 4394 ;============================================================================= | 4409 ;============================================================================= |
