comparison src/divemode.asm @ 428:eccae727702f

some cleanup
author heinrichsweikamp
date Wed, 15 Jun 2016 12:26:48 +0200
parents 6e60012bb3fc
children 23b58c4bc6aa
comparison
equal deleted inserted replaced
427:ceb1b7329dce 428:eccae727702f
229 rcall set_actual_ppo2 ; Set char_I_actual_ppO2 229 rcall set_actual_ppo2 ; Set char_I_actual_ppO2
230 clrf WREG 230 clrf WREG
231 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode. 231 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode.
232 call deco_calc_CNS_fraction ; calculate CNS 232 call deco_calc_CNS_fraction ; calculate CNS
233 movlb b'00000001' ; rambank 1 selected 233 movlb b'00000001' ; rambank 1 selected
234
235 ; Check for a gas change 234 ; Check for a gas change
236 rcall check_gas_change ; Checks if a better gas should be selected (by user) 235 bra check_gas_change ; Checks if a better gas should be selected (by user) and return...
237
238 return
239 236
240 global set_actual_ppo2 237 global set_actual_ppo2
241 set_actual_ppo2: ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2) 238 set_actual_ppo2: ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2)
242 btfsc divemode ; in divemode 239 btfsc divemode ; in divemode
243 bra set_actual_ppo2_dive ; Yes 240 bra set_actual_ppo2_dive ; Yes
290 btfsc use_O2_sensor2 287 btfsc use_O2_sensor2
291 bsf voting_logic_sensor2 288 bsf voting_logic_sensor2
292 btfsc use_O2_sensor3 289 btfsc use_O2_sensor3
293 bsf voting_logic_sensor3 290 bsf voting_logic_sensor3
294 rcall divemode_setup_sensor_values ; Setup sensor values 291 rcall divemode_setup_sensor_values ; Setup sensor values
295 call check_sensors ; Check O2 sensor thresholds for fallback 292 goto check_sensors ; Check O2 sensor thresholds for fallback customview_minute
296 return
297 293
298 calc_deko_divemode2: 294 calc_deko_divemode2:
299 bcf twosecupdate 295 bcf twosecupdate
300 296
301 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode 297 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
340 336
341 ; Copy for profile recording 337 ; Copy for profile recording
342 clrf decodata+0 338 clrf decodata+0
343 movff char_O_nullzeit,decodata+1 ; NDL 339 movff char_O_nullzeit,decodata+1 ; NDL
344 340
345 call TFT_display_ndl ; display no deco limit 341 goto TFT_display_ndl ; display no deco limit, and return...
346 return
347 342
348 calc_deko_divemode3: 343 calc_deko_divemode3:
349 btfss decostop_active ; Already in deco mode ? 344 btfss decostop_active ; Already in deco mode ?
350 call TFT_display_deko_mask ; No, clear nostop time, display decodata 345 call TFT_display_deko_mask ; No, clear nostop time, display decodata
351 bsf decostop_active ; Set flag (again) 346 bsf decostop_active ; Set flag (again)
507 ; rrcf divA+0,F ; /2 502 ; rrcf divA+0,F ; /2
508 ; movff old_velocity+0,WREG 503 ; movff old_velocity+0,WREG
509 ; addwf divA+0,F ; add old speed 504 ; addwf divA+0,F ; add old speed
510 ; bcf STATUS,C 505 ; bcf STATUS,C
511 ; rrcf divA+0,F ; /2 506 ; rrcf divA+0,F ; /2
512 call TFT_display_velocity ; With divA+0 = m/min... 507 goto TFT_display_velocity ; With divA+0 = m/min..., and return...
513 return
514 508
515 509
516 ;============================================================================= 510 ;=============================================================================
517 511
518 set_reset_safety_stop: ; Set flags for safety stop and/or reset safety stop 512 set_reset_safety_stop: ; Set flags for safety stop and/or reset safety stop
575 reset_safety_stop2: 569 reset_safety_stop2:
576 bcf show_safety_stop ; Clear flag 570 bcf show_safety_stop ; Clear flag
577 btfss safety_stop_active ; Safety stop shown 571 btfss safety_stop_active ; Safety stop shown
578 return ; No, don't delete it 572 return ; No, don't delete it
579 bcf safety_stop_active ; Clear flag 573 bcf safety_stop_active ; Clear flag
580 call TFT_clear_safety_stop ; Clear safety stop 574 goto TFT_clear_safety_stop ; Clear safety stop, and return...
581 return 575
582 576
583 ;============================================================================= 577 ;=============================================================================
584 578
585 timeout_menuview: 579 timeout_menuview:
586 decfsz timeout_counter3,F ; timeout for menuview 580 decfsz timeout_counter3,F ; timeout for menuview
604 btfss decostop_active ; In deco mode ? 598 btfss decostop_active ; In deco mode ?
605 bra timeout_divemode_menu_ndl ; No, show NDL again 599 bra timeout_divemode_menu_ndl ; No, show NDL again
606 ; Show deco 600 ; Show deco
607 call TFT_display_deko_mask ; clear nostop time, display decodata 601 call TFT_display_deko_mask ; clear nostop time, display decodata
608 call TFT_display_deko 602 call TFT_display_deko
609 call TFT_show_TTS_divemode 603 goto TFT_show_TTS_divemode; and return...
610 return 604
611 timeout_divemode_menu_ndl: ; Show NDL 605 timeout_divemode_menu_ndl: ; Show NDL
612 call TFT_display_ndl_mask ; Clear deco data, display nostop time 606 call TFT_display_ndl_mask ; Clear deco data, display nostop time
613 call TFT_display_ndl 607 goto TFT_display_ndl; and return...
614 return
615 608
616 timeout_divemode: 609 timeout_divemode:
617 btfsc divemode_menu ; Divemode menu active? 610 btfsc divemode_menu ; Divemode menu active?
618 rcall timeout_divemode_menu ; Yes, check the timeout for it... 611 rcall timeout_divemode_menu ; Yes, check the timeout for it...
619 612
708 btfss neg_flag 701 btfss neg_flag
709 return 702 return
710 ; max_pressure<rel_pressure 703 ; max_pressure<rel_pressure
711 movff sub_b+0,max_pressure+0 704 movff sub_b+0,max_pressure+0
712 movff sub_b+1,max_pressure+1 705 movff sub_b+1,max_pressure+1
713 call TFT_max_pressure ; No, use normal max. depth 706 goto TFT_max_pressure ; No, use normal max. depth; and return...
714 return
715 707
716 set_min_temp: 708 set_min_temp:
717 movff minimum_temperature+0,sub_a+0 709 movff minimum_temperature+0,sub_a+0
718 movff minimum_temperature+1,sub_a+1 710 movff minimum_temperature+1,sub_a+1
719 SAFE_2BYTE_COPY temperature,sub_b 711 SAFE_2BYTE_COPY temperature,sub_b
848 840
849 test_switches_divemode: ; checks switches in divemode 841 test_switches_divemode: ; checks switches in divemode
850 btfsc divemode_menu ; Divemode menu shown? 842 btfsc divemode_menu ; Divemode menu shown?
851 bra test_switches_divemode_menu ; Yes, use menu processor 843 bra test_switches_divemode_menu ; Yes, use menu processor
852 btfsc switch_left 844 btfsc switch_left
853 bra test_switches_divemode2 ; Enter button pressed, check if we need to do something 845 goto menuview_toggle ; Menu or Simulator tasks; and return...; bra test_switches_divemode2 ; Enter button pressed, check if we need to do something
854 btfss switch_right 846 btfss switch_right
855 return ; No button press 847 return ; No button press
856 tstfsz menupos2 ; any option shown? 848 tstfsz menupos2 ; any option shown?
857 bra test_switches_divemode1 ; Yes, do option tasks 849 bra test_switches_divemode1 ; Yes, do option tasks
858 bsf toggle_customview ; No, toggle custom view 850 bsf toggle_customview ; No, toggle custom view
907 bra divemode_option6 ; +5mins simulation 899 bra divemode_option6 ; +5mins simulation
908 dcfsnz WREG,F 900 dcfsnz WREG,F
909 bra divemode_option7 ; Store heading 901 bra divemode_option7 ; Store heading
910 return 902 return
911 903
912 test_switches_divemode2: 904 ;test_switches_divemode2:
913 call menuview_toggle ; Menu or Simulator tasks 905 ; goto menuview_toggle ; Menu or Simulator tasks; and return...
914 return 906 ; return
915 907
916 gas_switched_common: 908 gas_switched_common:
917 bcf divemode_gaschange ; Clear flag 909 bcf divemode_gaschange ; Clear flag
918 910
919 tstfsz menupos ; menupos=0? 911 tstfsz menupos ; menupos=0?
1103 call deco_calc_hauptroutine ; calc_tissue 1095 call deco_calc_hauptroutine ; calc_tissue
1104 movlb .1 1096 movlb .1
1105 decfsz up,F ; Done? 1097 decfsz up,F ; Done?
1106 bra divemode_option6_2 ; Not yet 1098 bra divemode_option6_2 ; Not yet
1107 bsf divemode2 ; continue divetime 1099 bsf divemode2 ; continue divetime
1108 call menuview_toggle_reset 1100 goto menuview_toggle_reset ; and return...
1109 return
1110 1101
1111 divemode_option7: 1102 divemode_option7:
1112 ; Store heading for compass view 1103 ; Store heading for compass view
1113 movff compass_heading_shown+0,compass_bearing+0 1104 movff compass_heading_shown+0,compass_bearing+0
1114 movff compass_heading_shown+1,compass_bearing+1 1105 movff compass_heading_shown+1,compass_bearing+1
1115 bsf compass_bearing_set ; set flag 1106 bsf compass_bearing_set ; set flag
1116 call menuview_toggle_reset ; Done. 1107 goto menuview_toggle_reset ; Done and return...
1117 return
1118 1108
1119 divemode_simulator_check_limits: 1109 divemode_simulator_check_limits:
1120 ; Check limits (150m and 0m) 1110 ; Check limits (150m and 0m)
1121 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m). 1111 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m).
1122 subwf sim_pressure+0,W 1112 subwf sim_pressure+0,W
1194 check_gas_change_exit: 1184 check_gas_change_exit:
1195 btfss better_gas_available ; Is a better gas available 1185 btfss better_gas_available ; Is a better gas available
1196 bcf blinking_better_gas ; No, Clear blinking flag 1186 bcf blinking_better_gas ; No, Clear blinking flag
1197 btfss better_gas_available ; Is a better gas available 1187 btfss better_gas_available ; Is a better gas available
1198 clrf better_gas_number ; No, Clear better_gas_number (For gaslist display) 1188 clrf better_gas_number ; No, Clear better_gas_number (For gaslist display)
1199 call TFT_active_gas_divemode ; Display gas/Setpoint 1189 goto TFT_active_gas_divemode ; Display gas/Setpoint and return...
1200 return
1201 1190
1202 check_gas_common: ; With Gas 0-4 in WREG 1191 check_gas_common: ; With Gas 0-4 in WREG
1203 btfsc better_gas_available ; Better Gas already found? 1192 btfsc better_gas_available ; Better Gas already found?
1204 return ; Yes, return 1193 return ; Yes, return
1205 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco 1194 lfsr FSR1,opt_gas_type ; 0=Disabled, 1=First, 2=Travel, 3=Deco
1448 movff WREG,char_I_first_gas ; Copy for compatibility 1437 movff WREG,char_I_first_gas ; Copy for compatibility
1449 rcall setup_dil_registers ; With WREG=Gas 0-4 1438 rcall setup_dil_registers ; With WREG=Gas 0-4
1450 banksel char_I_first_gas 1439 banksel char_I_first_gas
1451 incf char_I_first_gas,F ; 0-4 -> 1-5 1440 incf char_I_first_gas,F ; 0-4 -> 1-5
1452 banksel common 1441 banksel common
1453 call calc_deko_divemode_sensor ; External sensor stuff 1442 goto calc_deko_divemode_sensor ; External sensor stuff and return...
1454 return
1455 1443
1456 diveloop_boot: 1444 diveloop_boot:
1457 call restart_set_modes_and_flags 1445 call restart_set_modes_and_flags
1458 1446
1459 call I2C_sleep_accelerometer ; Stop accelerometer 1447 call I2C_sleep_accelerometer ; Stop accelerometer