Mercurial > public > hwos_code
comparison src/ghostwriter.asm @ 560:b7eb98dbd800
bump to 2.96beta (REFACTORED VERSION)
author | heinrichsweikamp |
---|---|
date | Wed, 31 Jan 2018 19:39:37 +0100 |
parents | cf68fe0c3002 |
children | b455b31ce022 |
comparison
equal
deleted
inserted
replaced
559:9cb967d844f0 | 560:b7eb98dbd800 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File ghostwriter.asm | 3 ; File ghostwriter.asm REFACTORED VERSION 2.94 |
4 ; | 4 ; |
5 ; Ghostwriter (Log profile recorder) | 5 ; Ghostwriter (Log profile recorder) |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
21 #include "rtc.inc" | 21 #include "rtc.inc" |
22 | 22 |
23 ghostwriter CODE | 23 ghostwriter CODE |
24 | 24 |
25 global store_dive_data | 25 global store_dive_data |
26 store_dive_data: ; 5 seconds gone | 26 store_dive_data: |
27 bcf store_sample ; update only any 5 seconds | 27 bcf store_sample ; clear flag |
28 | 28 |
29 ifndef __DEBUG | 29 ifndef __DEBUG |
30 btfsc simulatormode_active ; Are we in simulator mode? | 30 btfsc simulatormode_active ; Are we in simulator mode? |
31 return ; Yes, discard everything | 31 return ; Yes, discard everything |
32 endif | 32 endif |
91 | 91 |
92 movf AlarmType,W ; Type of Alarm Bit 0-3 | 92 movf AlarmType,W ; Type of Alarm Bit 0-3 |
93 addwf EventByte,F ; Copy to EventByte Bit 0-3 | 93 addwf EventByte,F ; Copy to EventByte Bit 0-3 |
94 clrf AlarmType ; Reset AlarmType | 94 clrf AlarmType ; Reset AlarmType |
95 | 95 |
96 ; Third, check events and add aditional bytes | 96 ; Third, check events and add additional bytes |
97 btfss gas6_changed ; Check flag | 97 btfss gas6_changed ; Check flag |
98 bra check_event2 | 98 bra check_event2 |
99 movlw d'2' ; Information length | 99 movlw d'2' ; Information length |
100 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 100 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
101 bsf EventByte,4 ; Also set Flag in EventByte! | 101 bsf EventByte,4 ; Also set Flag in EventByte! |
255 return | 255 return |
256 | 256 |
257 store_dive_ppO2_sensors: | 257 store_dive_ppO2_sensors: |
258 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps) | 258 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps) |
259 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 259 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
260 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modifified via ISR during the two writes here... | 260 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
261 movf lo,W ; in 0.1mV steps | 261 movf lo,W ; in 0.1mV steps |
262 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 262 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
263 movf hi,W ; in 0.1mV steps | 263 movf hi,W ; in 0.1mV steps |
264 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 264 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
265 | 265 |
266 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps) | 266 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps) |
267 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 267 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
268 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modifified via ISR during the two writes here... | 268 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
269 movf lo,W ; in 0.1mV steps | 269 movf lo,W ; in 0.1mV steps |
270 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 270 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
271 movf hi,W ; in 0.1mV steps | 271 movf hi,W ; in 0.1mV steps |
272 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 272 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
273 | 273 |
274 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps) | 274 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps) |
275 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 275 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
276 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modifified via ISR during the two writes here... | 276 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
277 movf lo,W ; in 0.1mV steps | 277 movf lo,W ; in 0.1mV steps |
278 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 278 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
279 movf hi,W ; in 0.1mV steps | 279 movf hi,W ; in 0.1mV steps |
280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
281 | 281 |
282 movlw div_ppo2_sensors | 282 movlw div_ppo2_sensors |
283 movwf divisor_ppo2_sensors ; Reload divisor | 283 movwf divisor_ppo2_sensors ; Reload divisor |
284 return | 284 return |
285 | 285 |
286 store_dive_gf: | 286 store_dive_gf: |
287 movff char_O_gradient_factor,WREG ; gradient factor absolute | 287 movff int_O_gradient_factor+0,WREG ; gradient factor absolute (range is limited to 255, only lower byte used for value) |
288 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 288 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
289 movlw div_gf | 289 movlw div_gf |
290 movwf divisor_gf ; Reload divisor | 290 movwf divisor_gf ; Reload divisor |
291 return | 291 return |
292 | 292 |
293 store_dive_decodata: | 293 store_dive_decodata: |
344 | 344 |
345 ; calculate desaturation time | 345 ; calculate desaturation time |
346 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! | 346 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! |
347 movff last_surfpressure_30min+1,int_I_pres_surface+1 | 347 movff last_surfpressure_30min+1,int_I_pres_surface+1 |
348 | 348 |
349 call deco_calc_desaturation_time ; calculate desaturation time | 349 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode |
350 movlb b'00000001' ; select ram bank 1 | 350 |
351 movff int_O_desaturation_time+0, desaturation_time+0 | 351 call deco_calc_desaturation_time ; calculate desaturation time |
352 movff int_O_desaturation_time+1, desaturation_time+1 ; Buffer | 352 movlb b'00000001' ; select ram bank 1 |
353 call calc_deko_surfmode | 353 |
354 rcall calculate_noflytime ; Calc NoFly time | |
355 | |
356 ; store header and ... | |
357 movlw 0xFD ; .... End-of-Profile Bytes | 354 movlw 0xFD ; .... End-of-Profile Bytes |
358 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 355 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
359 movlw 0xFD | 356 movlw 0xFD |
360 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 357 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
361 movff ext_flash_address+0,ext_flash_log_pointer+0 | 358 movff ext_flash_address+0,ext_flash_log_pointer+0 |
424 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 421 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
425 read_int_eeprom .6 | 422 read_int_eeprom .6 |
426 movf EEDATA,W | 423 movf EEDATA,W |
427 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 424 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
428 | 425 |
429 ; store pointer to end of diveprofile | 426 ; store pointer to end of diveprofile |
430 movf ext_flash_log_pointer+0,W | 427 movf ext_flash_log_pointer+0,W |
431 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 428 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
432 movf ext_flash_log_pointer+1,W | 429 movf ext_flash_log_pointer+1,W |
433 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 430 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
434 movf ext_flash_log_pointer+2,W | 431 movf ext_flash_log_pointer+2,W |
477 movff max_pressure+1,hi | 474 movff max_pressure+1,hi |
478 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 475 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
479 movff lo,max_pressure+0 | 476 movff lo,max_pressure+0 |
480 movff hi,max_pressure+1 | 477 movff hi,max_pressure+1 |
481 | 478 |
482 movff max_pressure+0,WREG ; Max. depth | 479 movff max_pressure+0,WREG ; Max. depth |
483 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 480 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
484 movff max_pressure+1,WREG | 481 movff max_pressure+1,WREG |
485 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 482 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
486 | 483 |
487 end_dive2: | 484 end_dive2: |
488 movf divemins+0,W ; divetime minutes | 485 movf divemins+0,W ; divetime minutes |
489 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 486 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
490 movf divemins+1,W | 487 movf divemins+1,W |
491 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 488 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
492 movf divesecs,W ; divetime seconds | 489 movf divesecs,W ; divetime seconds |
493 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 490 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
494 movff minimum_temperature+0,WREG ; minimum temperature | 491 movff minimum_temperature+0,WREG ; minimum temperature |
495 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 492 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
496 movff minimum_temperature+1,WREG | 493 movff minimum_temperature+1,WREG |
497 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 494 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
498 movff last_surfpressure_30min+0,WREG ; airpressure before dive | 495 movff last_surfpressure_30min+0,WREG ; airpressure before dive |
499 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 496 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
500 movff last_surfpressure_30min+1,WREG | 497 movff last_surfpressure_30min+1,WREG |
501 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 498 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
502 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes | 499 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes |
503 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 500 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
504 movff int_O_desaturation_time+1,WREG | 501 movff int_O_desaturation_time+1,WREG |
505 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 502 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
506 | 503 |
507 btfss FLAG_ccr_mode ; In CCR mode... | 504 btfss FLAG_ccr_mode ; In CCR mode... |
508 bra end_dive_oc_gaslist ; No, write OC gases | 505 bra end_dive_oc_gaslist ; No, write OC gases |
509 ; Write Diluents... | 506 ; Write Diluents... |
510 movff opt_dil_O2_ratio+0,WREG | 507 movff opt_dil_O2_ratio+0,WREG |
599 movff opt_gas_type+4,WREG | 596 movff opt_gas_type+4,WREG |
600 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 597 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
601 ; bra end_dive_oc_cc_common | 598 ; bra end_dive_oc_cc_common |
602 | 599 |
603 end_dive_oc_cc_common: | 600 end_dive_oc_cc_common: |
604 movlw softwareversion_x ; Firmware version | 601 movlw softwareversion_x ; Firmware version |
605 rcall ghostwrite_byte_header | 602 rcall ghostwrite_byte_header |
606 movlw softwareversion_y | 603 movlw softwareversion_y |
607 rcall ghostwrite_byte_header | 604 rcall ghostwrite_byte_header |
608 movf batt_voltage+0,W ; Battery voltage | 605 movf batt_voltage+0,W ; Battery voltage |
609 rcall ghostwrite_byte_header | 606 rcall ghostwrite_byte_header |
610 movf batt_voltage+1,W | 607 movf batt_voltage+1,W |
611 rcall ghostwrite_byte_header | 608 rcall ghostwrite_byte_header |
612 | 609 |
613 movf samplingrate,W ; Sampling rate | 610 movf samplingrate,W ; Sampling rate |
621 movff CNS_start+1,WREG | 618 movff CNS_start+1,WREG |
622 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 619 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
623 ; Gradient factor | 620 ; Gradient factor |
624 movff GF_start,WREG | 621 movff GF_start,WREG |
625 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 622 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
626 movff char_O_gradient_factor,WREG | 623 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use |
627 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 624 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
628 | 625 |
629 ; Logbook offset | 626 ; Logbook offset |
630 call do_logoffset_common_read; Read into lo:hi | 627 call do_logoffset_common_read; Read into lo:hi |
631 movf lo,W | 628 movf lo,W |
705 movlw .16 | 702 movlw .16 |
706 movwf lo | 703 movwf lo |
707 lfsr FSR1,char_O_tissue_N2_saturation+0 | 704 lfsr FSR1,char_O_tissue_N2_saturation+0 |
708 end_dive_store_tissues_N2: | 705 end_dive_store_tissues_N2: |
709 movf POSTINC1,W | 706 movf POSTINC1,W |
707 bcf WREG,7 ; clear flag bit for ongassing/offgassing | |
710 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 708 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
711 decfsz lo,F | 709 decfsz lo,F |
712 bra end_dive_store_tissues_N2 ; No | 710 bra end_dive_store_tissues_N2 ; No |
713 | 711 |
714 movlw .64 | 712 movlw .64 |
715 movwf lo | 713 movwf lo |
716 lfsr FSR1,0x700;pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes | 714 lfsr FSR1,0x700;pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes |
717 end_dive_store_tissues_N2_2: | 715 end_dive_store_tissues_N2_2: |
718 movf POSTINC1,W | 716 movf POSTINC1,W |
719 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 717 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
720 decfsz lo,F | 718 decfsz lo,F |
721 bra end_dive_store_tissues_N2_2 ; No | 719 bra end_dive_store_tissues_N2_2 ; No |
723 movlw .16 | 721 movlw .16 |
724 movwf lo | 722 movwf lo |
725 lfsr FSR1,char_O_tissue_He_saturation+0 | 723 lfsr FSR1,char_O_tissue_He_saturation+0 |
726 end_dive_store_tissues_He: | 724 end_dive_store_tissues_He: |
727 movf POSTINC1,W | 725 movf POSTINC1,W |
726 bcf WREG,7 ; clear flag bit for ongassing/offgassing | |
728 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 727 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
729 decfsz lo,F | 728 decfsz lo,F |
730 bra end_dive_store_tissues_He ; No | 729 bra end_dive_store_tissues_He ; No |
731 | 730 |
732 movlw .64 | 731 movlw .64 |
733 movwf lo | 732 movwf lo |
734 lfsr FSR1,0x740;pres_tissue_He+0 ; 16*4Byte Float = 64Bytes | 733 lfsr FSR1,0x740;pres_tissue_He+0 ; 16*4Byte Float = 64Bytes |
735 end_dive_store_tissues_He_2: | 734 end_dive_store_tissues_He_2: |
736 movf POSTINC1,W | 735 movf POSTINC1,W |
737 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 736 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
738 decfsz lo,F | 737 decfsz lo,F |
739 bra end_dive_store_tissues_He_2 ; No | 738 bra end_dive_store_tissues_He_2 ; No |
766 movff battery_gauge+5,WREG ; Battery gauge register | 765 movff battery_gauge+5,WREG ; Battery gauge register |
767 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 766 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
768 | 767 |
769 ; Header stop | 768 ; Header stop |
770 movlw 0xFB | 769 movlw 0xFB |
771 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 770 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
772 movlw 0xFB | 771 movlw 0xFB |
773 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 772 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
774 | 773 |
775 call divemode_store_statistics ; Store/update statistics for this unit | 774 call divemode_store_statistics ; Store/update statistics for this unit |
776 | 775 |
777 clrf surface_interval+0 | 776 clrf surface_interval+0 |
778 clrf surface_interval+1 ; Clear surface interval timer | 777 clrf surface_interval+1 ; Clear surface interval timer |
779 | 778 |
780 ghostwriter_end_dive_common: | 779 ghostwriter_end_dive_common: |
781 ; Update ext_flash_log_pointer into EEPROM | 780 ; Update ext_flash_log_pointer into EEPROM |
782 clrf EEADRH | 781 clrf EEADRH |
783 movff ext_flash_log_pointer+0,EEDATA | 782 movff ext_flash_log_pointer+0,EEDATA |
785 movff ext_flash_log_pointer+1,EEDATA | 784 movff ext_flash_log_pointer+1,EEDATA |
786 write_int_eeprom .5 | 785 write_int_eeprom .5 |
787 movff ext_flash_log_pointer+2,EEDATA | 786 movff ext_flash_log_pointer+2,EEDATA |
788 write_int_eeprom .6 | 787 write_int_eeprom .6 |
789 | 788 |
790 bcf simulatormode_active ; if we were in simulator mode | 789 bcf simulatormode_active ; if we were in simulator mode |
791 | 790 |
792 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | 791 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
793 ifndef __DEBUG | 792 ifndef __DEBUG |
794 extern deco_pull_tissues_from_vault | 793 extern deco_pull_tissues_from_vault |
795 btfsc restore_deco_data ; Restore decodata? | 794 btfsc restore_deco_data ; Restore decodata? |
796 call deco_pull_tissues_from_vault | 795 call deco_pull_tissues_from_vault |
797 banksel common ; Bank1 | 796 banksel common ; Bank1 |
798 endif | 797 endif |
799 call update_battery_registers ; update battery registers into EEPROM | 798 call update_battery_registers ; update battery registers into EEPROM |
800 goto surfloop ; and return to surfaceloop | 799 goto surfloop ; and return to surfaceloop |
801 | 800 |
802 ghostwriter_end_dive_common_sim: | 801 ghostwriter_end_dive_common_sim: |
803 tstfsz surface_interval+0 ; Was interval zero? | 802 tstfsz surface_interval+0 ; Was interval zero? |
804 bra ghostwriter_end_dive_common_sim2 ; No | 803 bra ghostwriter_end_dive_common_sim2 ; No |
805 tstfsz surface_interval+1 ; Was interval zero? | 804 tstfsz surface_interval+1 ; Was interval zero? |
806 bra ghostwriter_end_dive_common_sim2 ; No | 805 bra ghostwriter_end_dive_common_sim2 ; No |
807 bra ghostwriter_end_dive_common ; Yes, done. | 806 bra ghostwriter_end_dive_common ; Yes, done. |
808 | 807 |
809 ghostwriter_end_dive_common_sim2: | 808 ghostwriter_end_dive_common_sim2: |
810 movf divemins+0,W | 809 movf divemins+0,W |
811 addwf surface_interval+0,F | 810 addwf surface_interval+0,F |
812 movf divemins+1,W | 811 movf divemins+1,W |
813 addwfc surface_interval+1 ; Add simulated divetime to surface interval | 812 addwfc surface_interval+1 ; Add simulated divetime to surface interval |
814 bra ghostwriter_end_dive_common | 813 bra ghostwriter_end_dive_common |
815 | 814 |
816 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6 | 815 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6 |
817 clrf EEADRH ; Make sure to select eeprom bank 0 | 816 clrf EEADRH ; Make sure to select eeprom bank 0 |
818 read_int_eeprom .4 | 817 read_int_eeprom .4 |
955 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 954 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
956 movlw div_tank ; Divisor Tank | 955 movlw div_tank ; Divisor Tank |
957 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 956 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
958 | 957 |
959 return | 958 return |
960 | |
961 calculate_noflytime: | |
962 ; calculate nofly time | |
963 movff int_O_desaturation_time+0,xA+0 | |
964 movff int_O_desaturation_time+1,xA+1 | |
965 | |
966 btfsc xA+1,7 ; Is desat time negative ? | |
967 bra calculate_noflytime_3 ; Then surely not valid ! | |
968 | |
969 tstfsz xA+0 ; Desat=0? | |
970 bra calculate_noflytime2 | |
971 tstfsz xA+1 ; Desat=0? | |
972 bra calculate_noflytime2 | |
973 | |
974 calculate_noflytime_3: | |
975 ; Desaturation time = zero | |
976 clrf nofly_time+0 ; Clear nofly time | |
977 clrf nofly_time+1 ; Clear nofly time | |
978 return | |
979 | |
980 calculate_noflytime2: | |
981 movff xA+0,int_I_temp+0 | |
982 movff xA+1,int_I_temp+1 | |
983 movlw no_fly_time_ratio ; nofly_time_ratio | |
984 movff WREG,char_I_temp | |
985 call deco_calc_percentage | |
986 movlb b'00000001' ; select ram bank 1 | |
987 movff int_I_temp+0,xA+0 | |
988 movff int_I_temp+1,xA+1 | |
989 tstfsz xA+0 ; Desat=0? | |
990 bra calculate_noflytime_2_final | |
991 tstfsz xA+1 ; Desat=0? | |
992 bra calculate_noflytime_2_final | |
993 bra calculate_noflytime_3 | |
994 | |
995 calculate_noflytime_2_final: | |
996 movff xA+0,nofly_time+0 | |
997 movff xA+1,nofly_time+1 | |
998 return | |
999 | |
1000 | |
1001 divemode_store_statistics: ; Store/update statistics for this unit | 959 divemode_store_statistics: ; Store/update statistics for this unit |
1002 rcall vault_decodata_into_eeprom ; update deco data | 960 rcall vault_decodata_into_eeprom ; update deco data |
1003 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi | 961 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi |
1004 | 962 |
1005 tstfsz lo ; lo=0? | 963 tstfsz lo ; lo=0? |
1101 | 1059 |
1102 movff int_O_CNS_fraction+0,EEDATA | 1060 movff int_O_CNS_fraction+0,EEDATA |
1103 write_int_eeprom .7 | 1061 write_int_eeprom .7 |
1104 movff int_O_CNS_fraction+1,EEDATA | 1062 movff int_O_CNS_fraction+1,EEDATA |
1105 write_int_eeprom .8 | 1063 write_int_eeprom .8 |
1106 movff desaturation_time+0,EEDATA | 1064 movff int_O_desaturation_time+0,EEDATA |
1107 write_int_eeprom .9 | 1065 write_int_eeprom .9 |
1108 movff desaturation_time+1,EEDATA | 1066 movff int_O_desaturation_time+1,EEDATA |
1109 write_int_eeprom .10 | 1067 write_int_eeprom .10 |
1110 movff surface_interval+0,EEDATA | 1068 movff surface_interval+0,EEDATA |
1111 write_int_eeprom .11 | 1069 write_int_eeprom .11 |
1112 movff surface_interval+1,EEDATA | 1070 movff surface_interval+1,EEDATA |
1113 write_int_eeprom .12 | 1071 write_int_eeprom .12 |
1114 movff char_O_gradient_factor,EEDATA | 1072 movff int_O_gradient_factor+0,EEDATA ; value limited to 255, only lower byte in use for value |
1115 write_int_eeprom .13 | 1073 write_int_eeprom .13 |
1116 movff nofly_time+0,EEDATA | 1074 movff int_O_nofly_time+0,EEDATA |
1117 write_int_eeprom .14 | 1075 write_int_eeprom .14 |
1118 movff nofly_time+1,EEDATA | 1076 movff int_O_nofly_time+1,EEDATA |
1119 write_int_eeprom .15 | 1077 write_int_eeprom .15 |
1120 | 1078 |
1121 ; Tissue data from 16 to 144 | 1079 ; Tissue data from 16 to 144 |
1122 movlw .16 | 1080 movlw .16 |
1123 movwf EEADR | 1081 movwf EEADR |
1124 movlw .128 | 1082 movlw .128 |
1125 movwf lo | 1083 movwf lo |
1126 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | 1084 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes |
1127 vault_decodata_into_eeprom2: | 1085 vault_decodata_into_eeprom2: |
1128 movff POSTINC1,EEDATA | 1086 movff POSTINC1,EEDATA |
1129 call write_eeprom ; EEDATA into EEPROM@EEADR | 1087 call write_eeprom ; EEDATA into EEPROM@EEADR |
1130 incf EEADR,F | 1088 incf EEADR,F |
1131 decfsz lo,F ; All done? | 1089 decfsz lo,F ; All done? |
1158 read_int_eeprom .7 | 1116 read_int_eeprom .7 |
1159 movff EEDATA,int_O_CNS_fraction+0 | 1117 movff EEDATA,int_O_CNS_fraction+0 |
1160 read_int_eeprom .8 | 1118 read_int_eeprom .8 |
1161 movff EEDATA,int_O_CNS_fraction+1 | 1119 movff EEDATA,int_O_CNS_fraction+1 |
1162 read_int_eeprom .9 | 1120 read_int_eeprom .9 |
1163 movff EEDATA,desaturation_time+0 | 1121 movff EEDATA,int_O_desaturation_time+0 |
1164 read_int_eeprom .10 | 1122 read_int_eeprom .10 |
1165 movff EEDATA,desaturation_time+1 | 1123 movff EEDATA,int_O_desaturation_time+1 |
1166 read_int_eeprom .11 | 1124 read_int_eeprom .11 |
1167 movff EEDATA,surface_interval+0 | 1125 movff EEDATA,surface_interval+0 |
1168 read_int_eeprom .12 | 1126 read_int_eeprom .12 |
1169 movff EEDATA,surface_interval+1 | 1127 movff EEDATA,surface_interval+1 |
1170 read_int_eeprom .13 | 1128 read_int_eeprom .13 |
1171 movff EEDATA,char_O_gradient_factor | 1129 movff EEDATA,int_O_gradient_factor+0 |
1172 read_int_eeprom .14 | 1130 read_int_eeprom .14 |
1173 movff EEDATA,nofly_time+0 | 1131 movff EEDATA,int_O_nofly_time+0 |
1174 read_int_eeprom .15 | 1132 read_int_eeprom .15 |
1175 movff EEDATA,nofly_time+1 | 1133 movff EEDATA,int_O_nofly_time+1 |
1176 | 1134 |
1177 ; Tissue data from 16 to 144 | 1135 ; Tissue data from 16 to 144 |
1178 movlw .16 | 1136 movlw .16 |
1179 movwf EEADR | 1137 movwf EEADR |
1180 movlw .128 | 1138 movlw .128 |
1181 movwf lo | 1139 movwf lo |
1182 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | 1140 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes |
1183 restore_decodata_from_eeprom2: | 1141 restore_decodata_from_eeprom2: |
1184 call read_eeprom ; EEPROM@EEADR into EEDATA | 1142 call read_eeprom ; EEPROM@EEADR into EEDATA |
1185 movff EEDATA,POSTINC1 | 1143 movff EEDATA,POSTINC1 |
1186 incf EEADR,F | 1144 incf EEADR,F |
1187 decfsz lo,F ; All done? | 1145 decfsz lo,F ; All done? |
1188 bra restore_decodata_from_eeprom2 ; No | 1146 bra restore_decodata_from_eeprom2 ; No |
1189 clrf EEADRH | 1147 clrf EEADRH |
1190 return | 1148 return |
1191 | 1149 |
1192 | 1150 |