Mercurial > public > hwos_code
comparison src/divemode.asm @ 338:2811932b4e99
NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
author | heinrichsweikamp |
---|---|
date | Fri, 03 Jul 2015 14:47:04 +0200 |
parents | 508d7fb98b34 |
children | 692903c50788 |
comparison
equal
deleted
inserted
replaced
337:508d7fb98b34 | 338:2811932b4e99 |
---|---|
101 btfsc divemode_gaschange ; Gas switch flag set? | 101 btfsc divemode_gaschange ; Gas switch flag set? |
102 rcall gas_switched_common ; Yes | 102 rcall gas_switched_common ; Yes |
103 | 103 |
104 btfsc toggle_gf ; =1: Toggle GF/aGF | 104 btfsc toggle_gf ; =1: Toggle GF/aGF |
105 rcall divemodemode_togglegf ; Toggle aGF/GF | 105 rcall divemodemode_togglegf ; Toggle aGF/GF |
106 | |
107 btfsc FLAG_ccr_mode ; In CCR mode... | |
108 call check_dive_autosp ; ...check for Auto-SP | |
106 | 109 |
107 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays | 110 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays |
108 | 111 |
109 diveloop_loop3: | 112 diveloop_loop3: |
110 rcall test_switches_divemode ; Check switches in divemode | 113 rcall test_switches_divemode ; Check switches in divemode |
1262 subwf lo,W ; Change depth-better_gas_window_neg | 1265 subwf lo,W ; Change depth-better_gas_window_neg |
1263 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg? | 1266 cpfslt xC+0 ; current depth<Change depth-better_gas_window_neg? |
1264 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1267 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1265 return | 1268 return |
1266 | 1269 |
1270 | |
1271 ;============================================================================= | |
1272 ; Check for Auto-SP | |
1273 ; | |
1274 check_dive_autosp: ; Check for Auto-SP | |
1275 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | |
1276 sublw .2 ; opt_ccr_mode = 2 (Auto SP)? | |
1277 bz check_dive_autosp2 ; Yes, check | |
1278 return ; No, return for Sensor or Fixed mode | |
1279 check_dive_autosp2: | |
1280 SAFE_2BYTE_COPY rel_pressure,xA | |
1281 movlw d'100' | |
1282 movwf xB+0 | |
1283 clrf xB+1 | |
1284 call div16x16 ; compute depth in full m -> result in xC+0 | |
1285 ; Check SP2 | |
1286 btfsc sp2_switched ;=1: This setpoint has been autoselected already | |
1287 bra check_dive_autosp3 ; Skip check | |
1288 movff char_I_setpoint_change+1,lo ; Get depth in m | |
1289 tstfsz lo ; =0? | |
1290 bra $+4 ; No, continue | |
1291 bra check_dive_autosp3 ; Skip check | |
1292 decf lo,W ; -1 -> WREG | |
1293 cpfsgt xC+0 ; Compare with depth | |
1294 bra check_dive_autosp3 ; lower depth, do not switch | |
1295 ; auto switch to SP2 | |
1296 movff char_I_setpoint_cbar+1, char_I_const_ppO2 ; Use SetPoint | |
1297 bsf setpoint_changed ; Set flag (For profile) | |
1298 bsf event_occured ; Set global event byte | |
1299 bsf sp2_switched ; Set flag | |
1300 check_dive_autosp3: | |
1301 ; Check SP3 | |
1302 btfsc sp3_switched ;=1: This setpoint has been autoselected already | |
1303 bra check_dive_autosp4 ; Skip check | |
1304 movff char_I_setpoint_change+2,lo ; Get depth in m | |
1305 tstfsz lo ; =0? | |
1306 bra $+4 ; No, continue | |
1307 bra check_dive_autosp4 ; Skip check | |
1308 decf lo,W ; -1 -> WREG | |
1309 cpfsgt xC+0 ; Compare with depth | |
1310 bra check_dive_autosp4 ; lower depth, do not switch | |
1311 ; auto switch to SP3 | |
1312 movff char_I_setpoint_cbar+2, char_I_const_ppO2 ; Use SetPoint | |
1313 bsf setpoint_changed ; Set flag (For profile) | |
1314 bsf event_occured ; Set global event byte | |
1315 bsf sp3_switched ; Set flag | |
1316 check_dive_autosp4: | |
1317 ; Check SP4 | |
1318 btfsc sp4_switched ;=1: This setpoint has been autoselected already | |
1319 bra check_dive_autosp5 ; Skip check | |
1320 movff char_I_setpoint_change+3,lo ; Get depth in m | |
1321 tstfsz lo ; =0? | |
1322 bra $+4 ; No, continue | |
1323 bra check_dive_autosp5 ; Skip check | |
1324 decf lo,W ; -1 -> WREG | |
1325 cpfsgt xC+0 ; Compare with depth | |
1326 bra check_dive_autosp5 ; lower depth, do not switch | |
1327 ; auto switch to SP4 | |
1328 movff char_I_setpoint_cbar+3, char_I_const_ppO2 ; Use SetPoint | |
1329 bsf setpoint_changed ; Set flag (For profile) | |
1330 bsf event_occured ; Set global event byte | |
1331 bsf sp4_switched ; Set flag | |
1332 check_dive_autosp5: | |
1333 ; Check SP5 | |
1334 btfsc sp5_switched ;=1: This setpoint has been autoselected already | |
1335 bra check_dive_autosp6 ; Skip check | |
1336 movff char_I_setpoint_change+4,lo ; Get depth in m | |
1337 tstfsz lo ; =0? | |
1338 bra $+4 ; No, continue | |
1339 bra check_dive_autosp6 ; Skip check | |
1340 decf lo,W ; -1 -> WREG | |
1341 cpfsgt xC+0 ; Compare with depth | |
1342 bra check_dive_autosp6 ; lower depth, do not switch | |
1343 ; auto switch to SP5 | |
1344 movff char_I_setpoint_cbar+4, char_I_const_ppO2 ; Use SetPoint | |
1345 bsf setpoint_changed ; Set flag (For profile) | |
1346 bsf event_occured ; Set global event byte | |
1347 bsf sp5_switched ; Set flag | |
1348 check_dive_autosp6: | |
1349 return | |
1350 | |
1267 ;============================================================================= | 1351 ;============================================================================= |
1268 ; Setup everything to enter divemode. | 1352 ; Setup everything to enter divemode. |
1269 ; | 1353 ; |
1270 | |
1271 dive_boot_oc: | 1354 dive_boot_oc: |
1272 extern get_first_gas_to_WREG | 1355 extern get_first_gas_to_WREG |
1273 call get_first_gas_to_WREG ; Gets first gas (0-4) into WREG | 1356 call get_first_gas_to_WREG ; Gets first gas (0-4) into WREG |
1274 movff WREG,char_I_first_gas ; Copy for compatibility | 1357 movff WREG,char_I_first_gas ; Copy for compatibility |
1275 rcall setup_gas_registers ; With WREG=Gas 0-4 | 1358 rcall setup_gas_registers ; With WREG=Gas 0-4 |
1286 bsf voting_logic_sensor1 | 1369 bsf voting_logic_sensor1 |
1287 bsf voting_logic_sensor2 | 1370 bsf voting_logic_sensor2 |
1288 bsf voting_logic_sensor3 | 1371 bsf voting_logic_sensor3 |
1289 rcall divemode_setup_sensor_values ; setup sensor values | 1372 rcall divemode_setup_sensor_values ; setup sensor values |
1290 | 1373 |
1374 ; Setup first SP for Fixed or Auto mode | |
1291 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor | 1375 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor |
1292 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1) | 1376 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1) |
1377 bcf sp2_switched ; =1: This setpoint has been autoselected already | |
1378 bcf sp3_switched ; =1: This setpoint has been autoselected already | |
1379 bcf sp4_switched ; =1: This setpoint has been autoselected already | |
1380 bcf sp5_switched ; =1: This setpoint has been autoselected already | |
1381 | |
1293 extern get_first_dil_to_WREG | 1382 extern get_first_dil_to_WREG |
1294 call get_first_dil_to_WREG ; Gets first gas (0-4) into WREG | 1383 call get_first_dil_to_WREG ; Gets first gas (0-4) into WREG |
1295 movff WREG,char_I_first_gas ; Copy for compatibility | 1384 movff WREG,char_I_first_gas ; Copy for compatibility |
1296 rcall setup_dil_registers ; With WREG=Gas 0-4 | 1385 rcall setup_dil_registers ; With WREG=Gas 0-4 |
1297 banksel char_I_first_gas | 1386 banksel char_I_first_gas |