Mercurial > public > hwos_code
comparison src/divemode.asm @ 69:50697bd41c54
+CHANGE: Some French Translations
+CHANGE: Default Future TTS=0 (Disabled)
+NEW: Expand "gas change window" up to 1m below programmed
+ change depth (If ppO2 within user-set max. threshold)
+BUGFIX: Intermittent USB connection on MAC
author | heinrichsweikamp |
---|---|
date | Sun, 02 Feb 2014 20:19:53 +0100 |
parents | 448ba265fdae |
children | eb72c8865f47 |
comparison
equal
deleted
inserted
replaced
68:53b64c5472e1 | 69:50697bd41c54 |
---|---|
1000 movlw minimum_change_depth | 1000 movlw minimum_change_depth |
1001 cpfsgt lo ; Change depth>minimum_change_depth? | 1001 cpfsgt lo ; Change depth>minimum_change_depth? |
1002 return ; No, Change depth not deep enough, skip! | 1002 return ; No, Change depth not deep enough, skip! |
1003 movf xC+0,W ; load depth in m into WREG | 1003 movf xC+0,W ; load depth in m into WREG |
1004 cpfsgt lo ; gas_change_depth < current depth? | 1004 cpfsgt lo ; gas_change_depth < current depth? |
1005 return ; No, check next gas | 1005 bra check_gas_common3 ; No, check if we are within the better_gas_window_pos window |
1006 incf hi,W ; 1-5 | 1006 incf hi,W ; 1-5 |
1007 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available | 1007 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available |
1008 movlw better_gas_window | 1008 movlw better_gas_window_neg |
1009 subwf lo,W ; Change depth-better_gas_window | 1009 subwf lo,W ; Change depth-better_gas_window_neg |
1010 cpfslt xC+0 ; current depth<Change depth-better_gas_window? | 1010 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg? |
1011 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1011 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1012 return | 1012 return |
1013 | |
1014 check_gas_common3: | |
1015 incf hi,W ; 1-5 | |
1016 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available | |
1017 movlw better_gas_window_pos | |
1018 addwf lo,W ; Change depth+better_gas_window_pos | |
1019 cpfsgt xC+0 ; current depth>Change depth+better_gas_window_pos? | |
1020 bra check_gas_common4 ; Ok, now check the better gas ppO2<opt_ppO2_max | |
1021 return | |
1022 | |
1023 check_gas_common4: | |
1024 movf hi,W ; 0-4 | |
1025 lfsr FSR1,char_I_deco_N2_ratio | |
1026 movff PLUSW1,lo ; N2 ratio into lo | |
1027 lfsr FSR1,char_I_deco_He_ratio | |
1028 movff PLUSW1,xB+0 ; He ratio into xB+0 | |
1029 movf xB+0,W | |
1030 addwf lo,F | |
1031 movlw .101 | |
1032 bcf STATUS,C | |
1033 subfwb lo,F ; O2 ratio in lo | |
1034 | |
1035 SAFE_2BYTE_COPY amb_pressure, xA | |
1036 movlw d'10' | |
1037 movwf xB+0 | |
1038 clrf xB+1 | |
1039 call div16x16 ; xC=p_amb/10 | |
1040 movff xC+0,xA+0 | |
1041 movff xC+1,xA+1 | |
1042 movff lo,xB+0 ; =O2 ratio | |
1043 clrf xB+1 | |
1044 call mult16x16 ; lo * p_amb/10 | |
1045 | |
1046 ; Check very high ppO2 manually | |
1047 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? | |
1048 return ; Done. | |
1049 ; Check if ppO2>3,30bar | |
1050 btfsc xC+1,7 | |
1051 return ; Done. | |
1052 | |
1053 ; ; Check for low ppo2 | |
1054 ; movff xC+0,sub_b+0 | |
1055 ; movff xC+1,sub_b+1 | |
1056 ; movff opt_ppO2_min,WREG | |
1057 ; mullw d'100' ; opt_ppO2_min*100 | |
1058 ; movff PRODL,sub_a+0 | |
1059 ; movff PRODH,sub_a+1 | |
1060 ; call subU16 | |
1061 ; btfss neg_flag | |
1062 ; return ; Done (Too low). | |
1063 | |
1064 ;check if we are within our warning thresholds! | |
1065 movff xC+0,sub_b+0 | |
1066 movff xC+1,sub_b+1 | |
1067 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode | |
1068 addlw .1 ; e.g. >1.60 | |
1069 mullw d'100' ; opt_ppO2_max*100 | |
1070 movff PRODL,sub_a+0 | |
1071 movff PRODH,sub_a+1 | |
1072 call subU16 | |
1073 btfss neg_flag | |
1074 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
1075 return ; Done. | |
1013 | 1076 |
1014 check_dil_common: ; With Dil 0-4 in WREG | 1077 check_dil_common: ; With Dil 0-4 in WREG |
1015 btfsc better_gas_available ; Better Diluent already found? | 1078 btfsc better_gas_available ; Better Diluent already found? |
1016 return ; Yes, return | 1079 return ; Yes, return |
1017 lfsr FSR1,opt_dil_type ; 0=Disabled, 1=First, 2=Normal | 1080 lfsr FSR1,opt_dil_type ; 0=Disabled, 1=First, 2=Normal |
1035 cpfsgt lo ; gas_change_depth < current depth? | 1098 cpfsgt lo ; gas_change_depth < current depth? |
1036 return ; No, check next gas | 1099 return ; No, check next gas |
1037 incf hi,W ; 1-5 | 1100 incf hi,W ; 1-5 |
1038 addlw .5 ; 6-10 | 1101 addlw .5 ; 6-10 |
1039 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available | 1102 movwf better_gas_number ; number (1-5) of the "better gas" in divemode, =0: no better gas available |
1040 movlw better_gas_window | 1103 movlw better_gas_window_neg |
1041 subwf lo,W ; Change depth-better_gas_window | 1104 subwf lo,W ; Change depth-better_gas_window_neg |
1042 cpfslt xC+0 ; current depth<Change depth-better_gas_window? | 1105 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg? |
1043 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1106 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1044 return | 1107 return |
1045 | 1108 |
1046 ;============================================================================= | 1109 ;============================================================================= |
1047 ; Setup everything to enter divemode. | 1110 ; Setup everything to enter divemode. |
1307 | 1370 |
1308 ;check if we are within our warning thresholds! | 1371 ;check if we are within our warning thresholds! |
1309 movff xC+0,sub_b+0 | 1372 movff xC+0,sub_b+0 |
1310 movff xC+1,sub_b+1 | 1373 movff xC+1,sub_b+1 |
1311 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode | 1374 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode |
1375 addlw .1 ; e.g. >1.60 | |
1312 mullw d'100' ; opt_ppO2_max*100 | 1376 mullw d'100' ; opt_ppO2_max*100 |
1313 movff PRODL,sub_a+0 | 1377 movff PRODL,sub_a+0 |
1314 movff PRODH,sub_a+1 | 1378 movff PRODH,sub_a+1 |
1315 call subU16 | 1379 call subU16 |
1316 btfss neg_flag | 1380 btfss neg_flag |