Mercurial > public > hwos_code
comparison src/ghostwriter.asm @ 133:939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
NEW: Store tissue load, date and time, surface interval, desat. time and nofly time every hour and reload them after battery change
author | heinrichsweikamp |
---|---|
date | Mon, 14 Jul 2014 15:17:07 +0200 |
parents | dc44aa645549 |
children | 4574aed5cd4c |
comparison
equal
deleted
inserted
replaced
132:ec0b1e829399 | 133:939f1e83c4c2 |
---|---|
11 | 11 |
12 #include "ostc3.inc" ; Mandatory header | 12 #include "ostc3.inc" ; Mandatory header |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | 13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c |
14 #include "external_flash.inc" | 14 #include "external_flash.inc" |
15 #include "surfmode.inc" | 15 #include "surfmode.inc" |
16 #include "eeprom_rs232.inc" | 16 #include "eeprom_rs232.inc" |
17 #include "strings.inc" | 17 #include "strings.inc" |
18 #include "isr.inc" | 18 #include "isr.inc" |
19 #include "tft_outputs.inc" | 19 #include "tft_outputs.inc" |
20 #include "divemode.inc" | 20 #include "divemode.inc" |
21 #include "rtc.inc" | |
21 | 22 |
22 ghostwriter CODE | 23 ghostwriter CODE |
23 | 24 |
24 global store_dive_data | 25 global store_dive_data |
25 store_dive_data: ; 5 seconds gone | 26 store_dive_data: ; 5 seconds gone |
942 movff xA+1,nofly_time+1 | 943 movff xA+1,nofly_time+1 |
943 return | 944 return |
944 | 945 |
945 | 946 |
946 divemode_store_statistics: ; Store/update statistics for this unit | 947 divemode_store_statistics: ; Store/update statistics for this unit |
948 rcall vault_decodata_into_eeprom ; update deco data | |
947 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi | 949 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi |
948 | 950 |
949 tstfsz lo ; lo=0? | 951 tstfsz lo ; lo=0? |
950 bra change_logbook_offset1 ; No, adjust offset | 952 bra change_logbook_offset1 ; No, adjust offset |
951 tstfsz hi ; hi=0? | 953 tstfsz hi ; hi=0? |
997 write_int_eeprom 0x0C | 999 write_int_eeprom 0x0C |
998 bcf onehourupdate ; Clear flag | 1000 bcf onehourupdate ; Clear flag |
999 return | 1001 return |
1000 | 1002 |
1001 | 1003 |
1004 global vault_decodata_into_eeprom | |
1005 vault_decodata_into_eeprom: | |
1006 ; Vault in EEPROM 512...1023 | |
1007 ; Write 0xAA at 512 to indicate valid data in vault | |
1008 ; Store last time/date | |
1009 ; Store 0x700 to 0x780 (pres_tissue_N2 and pres_tissue_He) | |
1010 movlw LOW .512 ; =0 | |
1011 movwf EEADR | |
1012 movlw HIGH .512 ; =2 | |
1013 movwf EEADRH | |
1014 movlw 0xAA | |
1015 movwf EEDATA | |
1016 write_int_eeprom .0 | |
1017 ; Store date/time | |
1018 movff year,EEDATA | |
1019 write_int_eeprom .1 | |
1020 movff month,EEDATA | |
1021 write_int_eeprom .2 | |
1022 movff day,EEDATA | |
1023 write_int_eeprom .3 | |
1024 movff hours,EEDATA | |
1025 write_int_eeprom .4 | |
1026 movff mins,EEDATA | |
1027 write_int_eeprom .5 | |
1028 movff secs,EEDATA | |
1029 write_int_eeprom .6 | |
1030 | |
1031 movff int_O_CNS_fraction+0,EEDATA | |
1032 write_int_eeprom .7 | |
1033 movff int_O_CNS_fraction+1,EEDATA | |
1034 write_int_eeprom .8 | |
1035 movff desaturation_time+0,EEDATA | |
1036 write_int_eeprom .9 | |
1037 movff desaturation_time+1,EEDATA | |
1038 write_int_eeprom .10 | |
1039 movff surface_interval+0,EEDATA | |
1040 write_int_eeprom .11 | |
1041 movff surface_interval+1,EEDATA | |
1042 write_int_eeprom .12 | |
1043 movff char_O_gradient_factor,EEDATA | |
1044 write_int_eeprom .13 | |
1045 movff nofly_time+0,EEDATA | |
1046 write_int_eeprom .14 | |
1047 movff nofly_time+1,EEDATA | |
1048 write_int_eeprom .15 | |
1049 | |
1050 ; Tissue data from 16 to 144 | |
1051 movlw .16 | |
1052 movwf EEADR | |
1053 movlw .128 | |
1054 movwf lo | |
1055 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | |
1056 vault_decodata_into_eeprom2: | |
1057 movff POSTINC1,EEDATA | |
1058 call write_eeprom ; EEDATA into EEPROM@EEADR | |
1059 incf EEADR,F | |
1060 decfsz lo,F ; All done? | |
1061 bra vault_decodata_into_eeprom2 ; No | |
1062 clrf EEADRH | |
1063 return | |
1064 | |
1065 global restore_decodata_from_eeprom | |
1066 restore_decodata_from_eeprom: | |
1067 movlw LOW .512 ; =0 | |
1068 movwf EEADR | |
1069 movlw HIGH .512 ; =2 | |
1070 movwf EEADRH | |
1071 | |
1072 ; Restore date/time | |
1073 read_int_eeprom .1 | |
1074 movff EEDATA,year | |
1075 read_int_eeprom .2 | |
1076 movff EEDATA,month | |
1077 read_int_eeprom .3 | |
1078 movff EEDATA,day | |
1079 read_int_eeprom .4 | |
1080 movff EEDATA,hours | |
1081 read_int_eeprom .5 | |
1082 movff EEDATA,mins | |
1083 read_int_eeprom .6 | |
1084 movff EEDATA,secs | |
1085 call rtc_set_rtc | |
1086 | |
1087 read_int_eeprom .7 | |
1088 movff EEDATA,int_O_CNS_fraction+0 | |
1089 read_int_eeprom .8 | |
1090 movff EEDATA,int_O_CNS_fraction+1 | |
1091 read_int_eeprom .9 | |
1092 movff EEDATA,desaturation_time+0 | |
1093 read_int_eeprom .10 | |
1094 movff EEDATA,desaturation_time+1 | |
1095 read_int_eeprom .11 | |
1096 movff EEDATA,surface_interval+0 | |
1097 read_int_eeprom .12 | |
1098 movff EEDATA,surface_interval+1 | |
1099 read_int_eeprom .13 | |
1100 movff EEDATA,char_O_gradient_factor | |
1101 read_int_eeprom .14 | |
1102 movff EEDATA,nofly_time+0 | |
1103 read_int_eeprom .15 | |
1104 movff EEDATA,nofly_time+1 | |
1105 | |
1106 ; Tissue data from 16 to 144 | |
1107 movlw .16 | |
1108 movwf EEADR | |
1109 movlw .128 | |
1110 movwf lo | |
1111 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | |
1112 restore_decodata_from_eeprom2: | |
1113 call read_eeprom ; EEPROM@EEADR into EEDATA | |
1114 movff EEDATA,POSTINC1 | |
1115 incf EEADR,F | |
1116 decfsz lo,F ; All done? | |
1117 bra restore_decodata_from_eeprom2 ; No | |
1118 clrf EEADRH | |
1119 return | |
1120 | |
1121 | |
1002 END | 1122 END |