comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 415:d022c62a1df5

fixing issue with end-of-dive threshold in high-altitude mode simulator now works up to 120m depth fix internal logbook hung up on bad profile data
author heinrichsweikamp
date Sun, 17 Jul 2011 17:23:25 +0200
parents 46c1818ab589
children 3abf9d7dafae
comparison
equal deleted inserted replaced
414:dd4a1aa96232 415:d022c62a1df5
983 cpfseq active_gas ; is this gas currently selected? 983 cpfseq active_gas ; is this gas currently selected?
984 bra check_gas_change1x ; No... 984 bra check_gas_change1x ; No...
985 bra check_gas_change2 ; Yes, skip depth check 985 bra check_gas_change2 ; Yes, skip depth check
986 check_gas_change1x: 986 check_gas_change1x:
987 read_int_eeprom d'28' ; read gas_change_depth 987 read_int_eeprom d'28' ; read gas_change_depth
988 movlw d'3' 988 movlw minimum_change_depth
989 cpfsgt EEDATA ; Change depth>3m? 989 cpfsgt EEDATA ; Change depth>minimum_change_depth?
990 bra check_gas_change2 ; No, Change depth not deep enough, skip! 990 bra check_gas_change2 ; No, Change depth not deep enough, skip!
991 movf xC+0,W ; load depth in m into WREG 991 movf xC+0,W ; load depth in m into WREG
992 cpfsgt EEDATA ; gas_change_depth < current depth? 992 cpfsgt EEDATA ; gas_change_depth < current depth?
993 bra check_gas_change2 ; No, check next gas 993 bra check_gas_change2 ; No, check next gas
994 movlw d'3' 994 movlw better_gas_window
995 subwf EEDATA,W ; Change depth-3m 995 subwf EEDATA,W ; Change depth-better_gas_window
996 cpfslt xC+0 ; current depth<Change depth-3m? 996 cpfslt xC+0 ; current depth<Change depth-better_gas_window?
997 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 997 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
998 998
999 check_gas_change2: ; check gas2 999 check_gas_change2: ; check gas2
1000 btfss gaslist_active,1 ; check active flag 1000 btfss gaslist_active,1 ; check active flag
1001 bra check_gas_change3 ; skip inactive gases! 1001 bra check_gas_change3 ; skip inactive gases!
1003 cpfseq active_gas ; is this gas currently selected? 1003 cpfseq active_gas ; is this gas currently selected?
1004 bra check_gas_change2x ; No... 1004 bra check_gas_change2x ; No...
1005 bra check_gas_change3 ; Yes, skip depth check 1005 bra check_gas_change3 ; Yes, skip depth check
1006 check_gas_change2x: 1006 check_gas_change2x:
1007 read_int_eeprom d'29' ; read gas_change_depth 1007 read_int_eeprom d'29' ; read gas_change_depth
1008 movlw d'3' 1008 movlw minimum_change_depth
1009 cpfsgt EEDATA ; Change depth>3m? 1009 cpfsgt EEDATA ; Change depth>minimum_change_depth?
1010 bra check_gas_change3 ; No, Change depth not deep enough, skip! 1010 bra check_gas_change3 ; No, Change depth not deep enough, skip!
1011 movf xC+0,W ; load depth in m into WREG 1011 movf xC+0,W ; load depth in m into WREG
1012 cpfsgt EEDATA ; gas_change_depth < current depth? 1012 cpfsgt EEDATA ; gas_change_depth < current depth?
1013 bra check_gas_change3 ; No, check next gas 1013 bra check_gas_change3 ; No, check next gas
1014 movlw d'3' 1014 movlw better_gas_window
1015 subwf EEDATA,W ; Change depth-3m 1015 subwf EEDATA,W ; Change depth-better_gas_window
1016 cpfslt xC+0 ; current depth<Change depth-3m? 1016 cpfslt xC+0 ; current depth<Change depth-better_gas_window?
1017 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 1017 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
1018 1018
1019 check_gas_change3: ; check gas3 1019 check_gas_change3: ; check gas3
1020 btfss gaslist_active,2 ; check active flag 1020 btfss gaslist_active,2 ; check active flag
1021 bra check_gas_change4 ; skip inactive gases! 1021 bra check_gas_change4 ; skip inactive gases!
1023 cpfseq active_gas ; is this gas currently selected? 1023 cpfseq active_gas ; is this gas currently selected?
1024 bra check_gas_change3x ; No... 1024 bra check_gas_change3x ; No...
1025 bra check_gas_change4 ; Yes, skip depth check 1025 bra check_gas_change4 ; Yes, skip depth check
1026 check_gas_change3x: 1026 check_gas_change3x:
1027 read_int_eeprom d'30' ; read gas_change_depth 1027 read_int_eeprom d'30' ; read gas_change_depth
1028 movlw d'3' 1028 movlw minimum_change_depth
1029 cpfsgt EEDATA ; Change depth>3m? 1029 cpfsgt EEDATA ; Change depth>minimum_change_depth?
1030 bra check_gas_change4 ; No, Change depth not deep enough, skip! 1030 bra check_gas_change4 ; No, Change depth not deep enough, skip!
1031 movf xC+0,W ; load depth in m into WREG 1031 movf xC+0,W ; load depth in m into WREG
1032 cpfsgt EEDATA ; gas_change_depth < current depth? 1032 cpfsgt EEDATA ; gas_change_depth < current depth?
1033 bra check_gas_change4 ; No, check next gas 1033 bra check_gas_change4 ; No, check next gas
1034 movlw d'3' 1034 movlw better_gas_window
1035 subwf EEDATA,W ; Change depth-3m 1035 subwf EEDATA,W ; Change depth-better_gas_window
1036 cpfslt xC+0 ; current depth<Change depth-3m? 1036 cpfslt xC+0 ; current depth<Change depth-better_gas_window?
1037 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 1037 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
1038 1038
1039 check_gas_change4: ; check gas4 1039 check_gas_change4: ; check gas4
1040 btfss gaslist_active,3 ; check active flag 1040 btfss gaslist_active,3 ; check active flag
1041 bra check_gas_change5 ; skip inactive gases! 1041 bra check_gas_change5 ; skip inactive gases!
1043 cpfseq active_gas ; is this gas currently selected? 1043 cpfseq active_gas ; is this gas currently selected?
1044 bra check_gas_change4x ; No... 1044 bra check_gas_change4x ; No...
1045 bra check_gas_change5 ; Yes, skip depth check 1045 bra check_gas_change5 ; Yes, skip depth check
1046 check_gas_change4x: 1046 check_gas_change4x:
1047 read_int_eeprom d'31' ; read gas_change_depth 1047 read_int_eeprom d'31' ; read gas_change_depth
1048 movlw d'3' 1048 movlw minimum_change_depth
1049 cpfsgt EEDATA ; Change depth>3m? 1049 cpfsgt EEDATA ; Change depth>minimum_change_depth?
1050 bra check_gas_change5 ; No, Change depth not deep enough, skip! 1050 bra check_gas_change5 ; No, Change depth not deep enough, skip!
1051 movf xC+0,W ; load depth in m into WREG 1051 movf xC+0,W ; load depth in m into WREG
1052 cpfsgt EEDATA ; gas_change_depth < current depth? 1052 cpfsgt EEDATA ; gas_change_depth < current depth?
1053 bra check_gas_change5 ; No, check next gas 1053 bra check_gas_change5 ; No, check next gas
1054 movlw d'3' 1054 movlw better_gas_window
1055 subwf EEDATA,W ; Change depth-3m 1055 subwf EEDATA,W ; Change depth-better_gas_window
1056 cpfslt xC+0 ; current depth<Change depth-3m? 1056 cpfslt xC+0 ; current depth<Change depth-better_gas_window?
1057 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 1057 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
1058 1058
1059 check_gas_change5: ; check gas5 1059 check_gas_change5: ; check gas5
1060 btfss gaslist_active,4 ; check active flag 1060 btfss gaslist_active,4 ; check active flag
1061 bra check_gas_change6 ; skip inactive gases! 1061 bra check_gas_change6 ; skip inactive gases!
1063 cpfseq active_gas ; is this gas currently selected? 1063 cpfseq active_gas ; is this gas currently selected?
1064 bra check_gas_change5x ; No... 1064 bra check_gas_change5x ; No...
1065 bra check_gas_change6 ; Yes, skip depth check 1065 bra check_gas_change6 ; Yes, skip depth check
1066 check_gas_change5x: 1066 check_gas_change5x:
1067 read_int_eeprom d'32' ; read gas_change_depth 1067 read_int_eeprom d'32' ; read gas_change_depth
1068 movlw d'3' 1068 movlw minimum_change_depth
1069 cpfsgt EEDATA ; Change depth>3m? 1069 cpfsgt EEDATA ; Change depth>minimum_change_depth?
1070 bra check_gas_change6 ; No, Change depth not deep enough, skip! 1070 bra check_gas_change6 ; No, Change depth not deep enough, skip!
1071 movf xC+0,W ; load depth in m into WREG 1071 movf xC+0,W ; load depth in m into WREG
1072 cpfsgt EEDATA ; gas_change_depth < current depth? 1072 cpfsgt EEDATA ; gas_change_depth < current depth?
1073 bra check_gas_change6 ; No, check next gas 1073 bra check_gas_change6 ; No, check next gas
1074 movlw d'3' 1074 movlw better_gas_window
1075 subwf EEDATA,W ; Change depth-3m 1075 subwf EEDATA,W ; Change depth-better_gas_window
1076 cpfslt xC+0 ; current depth<Change depth-3m? 1076 cpfslt xC+0 ; current depth<Change depth-better_gas_window?
1077 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 1077 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
1078 1078
1079 check_gas_change6: ;Done 1079 check_gas_change6: ;Done
1080 call PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...) 1080 call PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...)
1081 return 1081 return
1554 movff sub_b+1,mintemp+1 1554 movff sub_b+1,mintemp+1
1555 return 1555 return
1556 1556
1557 set_dive_modes: 1557 set_dive_modes:
1558 btfsc high_altitude_mode ; In high altitude (Fly) mode? 1558 btfsc high_altitude_mode ; In high altitude (Fly) mode?
1559 bra set_dive_modes3 ; Yes 1559 bra set_dive_modes3 ; Yes!
1560 1560
1561 set_dive_modes0:
1561 GETCUSTOM8 .0 ; loads dive_threshold in WREG 1562 GETCUSTOM8 .0 ; loads dive_threshold in WREG
1562 movwf sub_a+0 ; dive_treshold is in cm 1563 movwf sub_a+0 ; dive_treshold is in cm
1563 clrf sub_a+1 1564 clrf sub_a+1
1565
1566 set_dive_modes1:
1564 SAFE_2BYTE_COPY rel_pressure, sub_b 1567 SAFE_2BYTE_COPY rel_pressure, sub_b
1565 call sub16 ; sub_c = sub_a - sub_b 1568 call sub16 ; sub_c = sub_a - sub_b
1566 1569
1567 btfss neg_flag 1570 btfss neg_flag
1568 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) 1571 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold)
1588 ; Yes, show divemode timeout 1591 ; Yes, show divemode timeout
1589 btfss dekostop_active ; Is a deco stop displayed? 1592 btfss dekostop_active ; Is a deco stop displayed?
1590 call PLED_divemode_timeout ; No, show the divemode timeout here... 1593 call PLED_divemode_timeout ; No, show the divemode timeout here...
1591 return 1594 return
1592 1595
1593 set_dive_modes3: 1596 set_dive_modes3: ; High-altitude mode
1594 movlw HIGH d'1075' ; hard-wired 1075mbar threshold 1597 btfsc realdive ; dive longer then one minute?
1598 bra set_dive_modes0 ; Yes -> this is a real dive -> Use CF00 threshold for ascend
1599
1600 movlw HIGH d'300' ; hard-wired 300cm threshold
1595 movwf sub_a+1 1601 movwf sub_a+1
1596 movlw LOW d'1075' ; hard-wired 1075mbar threshold 1602 movlw LOW d'300' ; hard-wired 300cm threshold
1597 movwf sub_a+0 1603 movwf sub_a+0
1598 SAFE_2BYTE_COPY rel_pressure, sub_b 1604 bra set_dive_modes1
1599 call sub16 ; sub_c = sub_a - sub_b 1605
1600
1601 btfss neg_flag
1602 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold)
1603
1604 bra set_dive_modes_common
1605
1606 set_powersafe: 1606 set_powersafe:
1607 btfsc low_battery_state ; battery warning alread active? 1607 btfsc low_battery_state ; battery warning alread active?
1608 bra set_powersafe2 ; Yes, but is it still required? 1608 bra set_powersafe2 ; Yes, but is it still required?
1609 ; battery voltage in mV (value*256+Lowbyte=actual treshold) 1609 ; battery voltage in mV (value*256+Lowbyte=actual treshold)
1610 movlw d'12' ; 3,328V 1610 movlw d'12' ; 3,328V