Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 129:06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Total Average Depth (Non-Resetable)
Some Display fixes in Divemode
Bugfix Timeout reset in Surfacemode
author | Heinrichsweikamp |
---|---|
date | Tue, 04 Jan 2011 16:32:28 +0100 |
parents | 4f9f477bb452 |
children | 03df42de03e1 |
comparison
equal
deleted
inserted
replaced
127:245de99d1d15 | 129:06c4899ddb4b |
---|---|
1272 movff hi,EEDATA | 1272 movff hi,EEDATA |
1273 call write_eeprom ; Highbyte | 1273 call write_eeprom ; Highbyte |
1274 | 1274 |
1275 change_logbook_offset2: | 1275 change_logbook_offset2: |
1276 bcf LED_blue | 1276 bcf LED_blue |
1277 clrf surface_interval+0 | |
1278 clrf surface_interval+1 ; Clear surface interval timer | |
1277 | 1279 |
1278 end_dive_common: | 1280 end_dive_common: |
1279 bcf simulatormode_active ; if we were in simulator mode | 1281 bcf simulatormode_active ; if we were in simulator mode |
1280 | 1282 |
1281 btfsc restore_deco_data ; Restore decodata? | 1283 btfsc restore_deco_data ; Restore decodata? |
1282 call simulator_restore_tissue_data ; Yes! | 1284 call simulator_restore_tissue_data ; Yes! |
1283 | 1285 |
1284 call deco_gradient_array | 1286 call deco_gradient_array |
1285 movlb b'00000001' ; select ram bank 1 | 1287 movlb b'00000001' ; select ram bank 1 |
1286 | 1288 |
1287 btfss restore_deco_data ; Restore decodata? | |
1288 goto surfloop ; and return to surfaceloop | |
1289 ;new 1.71beta: | |
1290 clrf surface_interval+0 | |
1291 clrf surface_interval+1 ; Clear surface interval timer | |
1292 goto surfloop ; and return to surfaceloop | 1289 goto surfloop ; and return to surfaceloop |
1293 | 1290 |
1294 timeout_divemode: | 1291 timeout_divemode: |
1295 btfss realdive ; Dive longer then one minute | 1292 btfss realdive ; Dive longer then one minute |
1296 return | 1293 return |
1462 btfsc reset_average_depth ; Reset the Avewrage depth? | 1459 btfsc reset_average_depth ; Reset the Avewrage depth? |
1463 rcall reset_average1 ; Reset the resettable average depth | 1460 rcall reset_average1 ; Reset the resettable average depth |
1464 | 1461 |
1465 ; 1. Add new 2xdepth to the Sum of depths registers | 1462 ; 1. Add new 2xdepth to the Sum of depths registers |
1466 movff rel_pressure+0,b0_lo | 1463 movff rel_pressure+0,b0_lo |
1467 movff rel_pressure+1,b0_hi | 1464 movff rel_pressure+1,b0_hi ; Buffer... |
1468 | 1465 |
1469 movf b0_lo,w | 1466 movf b0_lo,w |
1470 addwf average_depth_hold+0,F | 1467 addwf average_depth_hold+0,F |
1471 movf b0_hi,w | 1468 movf b0_hi,w |
1472 addwfc average_depth_hold+1,F | 1469 addwfc average_depth_hold+1,F |
1480 addwfc average_depth_hold+1,F | 1477 addwfc average_depth_hold+1,F |
1481 movlw d'0' | 1478 movlw d'0' |
1482 addwfc average_depth_hold+2,F | 1479 addwfc average_depth_hold+2,F |
1483 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | 1480 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar |
1484 | 1481 |
1482 ; Do the same for the _total registers (Non-Resettable) | |
1483 movf b0_lo,w | |
1484 addwf average_depth_hold_total+0,F | |
1485 movf b0_hi,w | |
1486 addwfc average_depth_hold_total+1,F | |
1487 movlw d'0' | |
1488 addwfc average_depth_hold_total+2,F | |
1489 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1490 | |
1491 movf b0_lo,w | |
1492 addwf average_depth_hold_total+0,F | |
1493 movf b0_hi,w | |
1494 addwfc average_depth_hold_total+1,F | |
1495 movlw d'0' | |
1496 addwfc average_depth_hold_total+2,F | |
1497 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1498 | |
1485 ; 2. Compute Average Depth on base of average_divesecs:2 | 1499 ; 2. Compute Average Depth on base of average_divesecs:2 |
1486 | |
1487 movff average_divesecs+0,xB+0 | 1500 movff average_divesecs+0,xB+0 |
1488 movff average_divesecs+1,xB+1 ; Copy | 1501 movff average_divesecs+1,xB+1 ; Copy |
1489 movff average_depth_hold+0,xC+0 | 1502 movff average_depth_hold+0,xC+0 |
1490 movff average_depth_hold+1,xC+1 | 1503 movff average_depth_hold+1,xC+1 |
1491 movff average_depth_hold+2,xC+2 | 1504 movff average_depth_hold+2,xC+2 |
1492 movff average_depth_hold+3,xC+3 | 1505 movff average_depth_hold+3,xC+3 |
1493 | 1506 |
1494 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 1507 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
1495 movff xC+0,avr_rel_pressure+0 | 1508 movff xC+0,avr_rel_pressure+0 |
1496 movff xC+1,avr_rel_pressure+1 | 1509 movff xC+1,avr_rel_pressure+1 |
1510 | |
1511 ; Compute Total Average Depth on base of divemins:2 and divesecs | |
1512 movff divemins+0,xA+0 | |
1513 movff divemins+1,xA+1 | |
1514 movlw d'60' | |
1515 movwf xB+0 | |
1516 clrf xB+1 | |
1517 call mult16x16 ; xC:4=xA:2*xB:2 | |
1518 movf divesecs,W | |
1519 addwf xC+0,F | |
1520 movlw d'0' | |
1521 addwfc xC+1,F | |
1522 movlw d'3' ; 2+1 | |
1523 btfss divesecs,0 ; divesecs even? | |
1524 movlw d'2' ; Yes, do not add +1 | |
1525 addwf xC+0,F | |
1526 movlw d'0' | |
1527 addwfc xC+1,F | |
1528 ; Ignore xC+2 and xC+3. Total Average will only work up to divetime=1092:16 | |
1529 movff xC+0,xB+0 | |
1530 movff xC+1,xB+1 ; Copy | |
1531 movff average_depth_hold_total+0,xC+0 | |
1532 movff average_depth_hold_total+1,xC+1 | |
1533 movff average_depth_hold_total+2,xC+2 | |
1534 movff average_depth_hold_total+3,xC+3 | |
1535 | |
1536 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
1537 movff xC+0,avr_rel_pressure_total+0 | |
1538 movff xC+1,avr_rel_pressure_total+1 | |
1539 | |
1497 return | 1540 return |
1498 | 1541 |
1499 reset_average1: | 1542 reset_average1: |
1500 clrf average_depth_hold+0 | 1543 clrf average_depth_hold+0 |
1501 clrf average_depth_hold+1 | 1544 clrf average_depth_hold+1 |
1538 clrf timeout_counter ; takes care of the timeout | 1581 clrf timeout_counter ; takes care of the timeout |
1539 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature | 1582 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature |
1540 clrf AlarmType ; Clear all alarms | 1583 clrf AlarmType ; Clear all alarms |
1541 bcf event_occured ; clear flag | 1584 bcf event_occured ; clear flag |
1542 rcall reset_average1 ; Reset the resettable average depth | 1585 rcall reset_average1 ; Reset the resettable average depth |
1586 clrf average_depth_hold_total+0 | |
1587 clrf average_depth_hold_total+1 | |
1588 clrf average_depth_hold_total+2 | |
1589 clrf average_depth_hold_total+3 ; Clear Non-Resettable Average | |
1543 bcf depth_greater_100m ; clear flag | 1590 bcf depth_greater_100m ; clear flag |
1544 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) | 1591 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) |
1545 bcf dekostop_active | 1592 bcf dekostop_active |
1546 bcf is_bailout ;=1: CC mode, but bailout active! | 1593 bcf is_bailout ;=1: CC mode, but bailout active! |
1547 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1594 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |