annotate src/ghostwriter.asm @ 601:08a0162d3ca1

Fix false CNS readings in logbook
author heinrichsweikamp
date Tue, 14 Aug 2018 11:01:47 +0200
parents b455b31ce022
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
3 ; File ghostwriter.asm REFACTORED VERSION 2.98
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Ghostwriter (Log profile recorder)
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-11-27 : [mH] Creation
heinrichsweikamp
parents:
diff changeset
11
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
12 #include "hwos.inc" ; Mandatory header
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
14 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
15 #include "surfmode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
16 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
17 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
18 #include "isr.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
19 #include "tft_outputs.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
20 #include "divemode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
21 #include "rtc.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
22
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
23
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
24 ;---- Private local variables -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
25
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
26 CBLOCK local2 ; max size is 16 Byte !!!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
27 divisor_temperature ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
28 divisor_deco ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
29 divisor_gf ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
30 divisor_ppo2_sensors ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
31 divisor_decoplan ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
32 divisor_cns ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
33 divisor_tank ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
34 ProfileFlagByte ; used to store events
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
35 ENDC ; used: 8 byte, remaining: 8 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
36
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
37
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
38 ghostwriter CODE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
39
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
40 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
41
0
heinrichsweikamp
parents:
diff changeset
42
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
43 global init_recording_params ; Initialize profile recording parameters
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
44 init_recording_params:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
45 movff samplingrate,samplesecs_value; to avoid EEPROM access in the ISR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
46 movlw div_temperature
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
47 movwf divisor_temperature ; load divisors for profile storage
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
48 movlw div_deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
49 movwf divisor_deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
50 movlw div_gf
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
51 movwf divisor_gf
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
52 movlw div_ppo2_sensors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
53 movwf divisor_ppo2_sensors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
54 movlw div_decoplan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
55 movwf divisor_decoplan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
56 movlw div_cns
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
57 movwf divisor_cns
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
58 movlw div_tank
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
59 movwf divisor_tank
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
60 btfss FLAG_apnoe_mode ; In Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
61 bra init_recording_params_1 ; NO
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
62 movlw samplingrate_apnoe ; YES - overwrite some parameters in Apnoe mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
63 movwf samplesecs_value ; to avoid EEPROM access in the ISR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
64 init_recording_params_1:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
65 btfsc FLAG_ccr_mode ; in CCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
66 bra init_recording_params_2 ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
67 btfsc FLAG_pscr_mode ; in pSCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
68 bra init_recording_params_2 ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
69 ; in OC Mode, disable ppO2 logging
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
70 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
71 movwf divisor_ppo2_sensors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
72 init_recording_params_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
73 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
74
0
heinrichsweikamp
parents:
diff changeset
75
heinrichsweikamp
parents:
diff changeset
76 global store_dive_data
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
77 store_dive_data:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
78 bcf store_sample ; clear flag
0
heinrichsweikamp
parents:
diff changeset
79
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
80 ifndef __DEBUG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
81 btfsc simulatormode_active ; Are we in simulator mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
82 return ; Yes, discard everything
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
83 endif
0
heinrichsweikamp
parents:
diff changeset
84
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
85 btfsc FLAG_apnoe_mode ; In Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
86 return ; Yes, discard everything
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
87
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
88 SAFE_2BYTE_COPY rel_pressure, lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
89 movf lo,W ; store depth with every sample
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
90 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
91 movf hi,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
92 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
93
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
94 ; First, find out how many bytes will append to this sample....
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
95 clrf ProfileFlagByte ; clear number of bytes to append
0
heinrichsweikamp
parents:
diff changeset
96
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
97 ; Check Extended informations
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
98 decfsz divisor_temperature,W ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
99 bra check_extended1
0
heinrichsweikamp
parents:
diff changeset
100 movlw infolength_temperature
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
101 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
102 check_extended1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
103 decfsz divisor_deco,W ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
104 bra check_extended2
0
heinrichsweikamp
parents:
diff changeset
105 movlw infolength_deco
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
106 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
107 check_extended2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
108 decfsz divisor_gf,W ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
109 bra check_extended3
0
heinrichsweikamp
parents:
diff changeset
110 movlw infolength_gf
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
111 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
112 check_extended3:
heinrichsweikamp
parents:
diff changeset
113 decfsz divisor_ppo2_sensors,W ; Check divisor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
114 bra check_extended4
0
heinrichsweikamp
parents:
diff changeset
115 movlw infolength_ppo2_sensors
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
116 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
117 check_extended4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
118 decfsz divisor_decoplan,W ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
119 bra check_extended5
0
heinrichsweikamp
parents:
diff changeset
120 movlw infolength_decoplan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
121 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
122 check_extended5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
123 decfsz divisor_cns,W ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
124 bra check_extended6
0
heinrichsweikamp
parents:
diff changeset
125 movlw infolength_cns
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
126 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
127 check_extended6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
128 decfsz divisor_tank,W ; Check divisor
0
heinrichsweikamp
parents:
diff changeset
129 bra check_extended7
heinrichsweikamp
parents:
diff changeset
130 movlw infolength_tank
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
131 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
132 check_extended7:
heinrichsweikamp
parents:
diff changeset
133
heinrichsweikamp
parents:
diff changeset
134 ; Second, check global event flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
135 btfss event_occured ; Check global event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
136 bra store_dive_data3 ; No Event
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
137
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
138 incf ProfileFlagByte,F ; add one byte (The EventByte1)
0
heinrichsweikamp
parents:
diff changeset
139
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
140 clrf EventByte1 ; reset EventByte1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
141 clrf EventByte2 ; reset EventByte2
0
heinrichsweikamp
parents:
diff changeset
142
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
143 movf AlarmType,W ; Type of Alarm Bit 0-3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
144 addwf EventByte1,F ; Copy to EventByte1 Bit 0-3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
145 clrf AlarmType ; Reset AlarmType
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
146
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
147 ; Third, check events and add additional bytes
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
148 btfss gas6_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
149 bra check_event2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
150 movlw d'2' ; Information length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
151 addwf ProfileFlagByte,F ; add to ProfileFlagByte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
152 bsf EventByte1,4 ; Also set Flag in EventByte1!
0
heinrichsweikamp
parents:
diff changeset
153 check_event2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
154 btfss stored_gas_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
155 bra check_event3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
156 movlw d'1' ; Information length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157 addwf ProfileFlagByte,F ; add to ProfileFlagByte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
158 bsf EventByte1,5 ; Also set Flag in EventByte1!
0
heinrichsweikamp
parents:
diff changeset
159 check_event3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
160 btfss setpoint_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
161 bra check_event4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
162 movlw d'1' ; Information length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
163 addwf ProfileFlagByte,F ; add to ProfileFlagByte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
164 bsf EventByte1,6 ; Also set Flag in EventByte1!
0
heinrichsweikamp
parents:
diff changeset
165 check_event4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
166 btfss bailoutgas_event ; =1: bailout was selected or a gas change during bailout
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
167 bra check_event5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
168 movlw d'2' ; Information length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
169 addwf ProfileFlagByte,F ; add to ProfileFlagByte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
170 bsf EventByte2,0 ; set flag in EventByte2!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
171 bsf EventByte1,7 ; =1: Another EventByte1 is available
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
172
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
173 check_event5:
0
heinrichsweikamp
parents:
diff changeset
174 ; more events?
heinrichsweikamp
parents:
diff changeset
175
heinrichsweikamp
parents:
diff changeset
176 store_dive_data3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
177 btfsc EventByte1,7 ; =1: Another EventByte1 is available
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
178 incf ProfileFlagByte,F ; add one byte (The EventByte2)
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
179
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
180 btfsc event_occured ; Check global event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
181 bsf ProfileFlagByte,7 ; Set EventByte1 Flag in ProfileFlagByte
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
182
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
183 movf ProfileFlagByte,W ; finally, write ProfileFlagByte!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
184 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
185
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
186 btfss event_occured ; Check global event flag (again)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
187 bra store_dive_data4 ; No Event
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
188
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
189 ; Store the EventByte(s) + additional bytes now
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
190 movf EventByte1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
191 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
192
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
193 movf EventByte2,W ; Write second event byte...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
194 btfsc EventByte1,7 ; =1: Another EventByte1 is available
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
195 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
196
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
197 btfss gas6_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
198 bra store_dive_data3b
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
199 movff char_I_O2_ratio,WREG ; store gas 6 o2 ratio
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
200 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
201 movff char_I_He_ratio,WREG ; store gas 6 He ratio
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
202 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
203 bcf gas6_changed ; Clear this event
0
heinrichsweikamp
parents:
diff changeset
204 store_dive_data3b:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
205 btfss stored_gas_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
206 bra store_dive_data3c
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
207 movf active_gas,W ; Store active gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
208 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
209 bcf stored_gas_changed ; Clear this event
0
heinrichsweikamp
parents:
diff changeset
210 store_dive_data3c:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
211 btfss setpoint_changed ; Check flag
0
heinrichsweikamp
parents:
diff changeset
212 bra store_dive_data3d
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
213 movff char_I_const_ppO2,WREG ; store setpoint
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
214 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
215 bcf setpoint_changed ; Clear this event
0
heinrichsweikamp
parents:
diff changeset
216 store_dive_data3d:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
217 btfss bailoutgas_event ; Check flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
218 bra store_dive_data4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
219 movff char_I_O2_ratio,WREG ; store O2 ratio of bailout gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
220 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
221 movff char_I_He_ratio,WREG ; store He ratio of bailout gas
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
222 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
223 bcf bailoutgas_event ; Clear this event
0
heinrichsweikamp
parents:
diff changeset
224
heinrichsweikamp
parents:
diff changeset
225 store_dive_data4:
heinrichsweikamp
parents:
diff changeset
226 ; Store extended informations
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
227 decfsz divisor_temperature,F ; Check divisor
0
heinrichsweikamp
parents:
diff changeset
228 bra store_extended1
heinrichsweikamp
parents:
diff changeset
229 rcall store_dive_temperature
heinrichsweikamp
parents:
diff changeset
230 store_extended1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
231 decfsz divisor_deco,F ; Check divisor
0
heinrichsweikamp
parents:
diff changeset
232 bra store_extended2
heinrichsweikamp
parents:
diff changeset
233 rcall store_dive_decodata
heinrichsweikamp
parents:
diff changeset
234 store_extended2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
235 decfsz divisor_gf,F ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
236 bra store_extended3
0
heinrichsweikamp
parents:
diff changeset
237 rcall store_dive_gf
heinrichsweikamp
parents:
diff changeset
238 store_extended3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
239 decfsz divisor_ppo2_sensors,F ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
240 bra store_extended4
0
heinrichsweikamp
parents:
diff changeset
241 rcall store_dive_ppO2_sensors
heinrichsweikamp
parents:
diff changeset
242 store_extended4:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
243 decfsz divisor_decoplan,F ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
244 bra store_extended5
0
heinrichsweikamp
parents:
diff changeset
245 rcall store_dive_decoplan
heinrichsweikamp
parents:
diff changeset
246 store_extended5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
247 decfsz divisor_cns,F ; Check divisor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
248 bra store_extended6
0
heinrichsweikamp
parents:
diff changeset
249 rcall store_dive_cns
heinrichsweikamp
parents:
diff changeset
250 store_extended6:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
251 decfsz divisor_tank,F ; Check divisor
0
heinrichsweikamp
parents:
diff changeset
252 bra store_extended7
heinrichsweikamp
parents:
diff changeset
253 rcall store_dive_tank
heinrichsweikamp
parents:
diff changeset
254 store_extended7:
heinrichsweikamp
parents:
diff changeset
255
heinrichsweikamp
parents:
diff changeset
256 ; The next block is required to take care of "store never"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
257 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
258 clrf divisor_temperature ; And clear register again, so it will never reach zero...
0
heinrichsweikamp
parents:
diff changeset
259 btfsc divisor_deco,7
heinrichsweikamp
parents:
diff changeset
260 clrf divisor_deco
heinrichsweikamp
parents:
diff changeset
261 btfsc divisor_gf,7
heinrichsweikamp
parents:
diff changeset
262 clrf divisor_gf
heinrichsweikamp
parents:
diff changeset
263 btfsc divisor_ppo2_sensors,7
heinrichsweikamp
parents:
diff changeset
264 clrf divisor_ppo2_sensors
heinrichsweikamp
parents:
diff changeset
265 btfsc divisor_decoplan,7
heinrichsweikamp
parents:
diff changeset
266 clrf divisor_decoplan
heinrichsweikamp
parents:
diff changeset
267 btfsc divisor_cns,7
heinrichsweikamp
parents:
diff changeset
268 clrf divisor_cns
heinrichsweikamp
parents:
diff changeset
269 btfsc divisor_tank,7
heinrichsweikamp
parents:
diff changeset
270 clrf divisor_tank
heinrichsweikamp
parents:
diff changeset
271
heinrichsweikamp
parents:
diff changeset
272 store_dive_data5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
273 bcf event_occured ; Clear the global event flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
274 clrf EventByte1 ; reset EventByte1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
275 clrf EventByte2 ; reset EventByte2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
276 return ; Done. (Sample with all informations written to external flash)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
277
0
heinrichsweikamp
parents:
diff changeset
278 store_dive_cns:
heinrichsweikamp
parents:
diff changeset
279 movff int_O_CNS_fraction+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
281 movff int_O_CNS_fraction+1,WREG
601
08a0162d3ca1 Fix false CNS readings in logbook
heinrichsweikamp
parents: 582
diff changeset
282 bcf WREG,int_warning_flag ; clear warning flag
08a0162d3ca1 Fix false CNS readings in logbook
heinrichsweikamp
parents: 582
diff changeset
283 bcf WREG,int_attention_flag ; clear attention flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
284 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
285 movlw div_cns
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
286 movwf divisor_cns ; Reload divisor from CF
0
heinrichsweikamp
parents:
diff changeset
287 return
heinrichsweikamp
parents:
diff changeset
288
heinrichsweikamp
parents:
diff changeset
289 store_dive_tank:
heinrichsweikamp
parents:
diff changeset
290 movlw div_tank
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
291 movwf divisor_tank ; Reload divisor from CF
0
heinrichsweikamp
parents:
diff changeset
292 return
heinrichsweikamp
parents:
diff changeset
293
heinrichsweikamp
parents:
diff changeset
294 store_dive_decoplan:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
295 ; Store the deco plan
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
296 lfsr FSR1,char_O_deco_time_for_log+.0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
297 movlw .15
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
298 movwf lo
0
heinrichsweikamp
parents:
diff changeset
299 store_dive_decoplan_loop:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
300 movf POSTINC1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
301 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
302 decfsz lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
303 bra store_dive_decoplan_loop
0
heinrichsweikamp
parents:
diff changeset
304 movlw div_decoplan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
305 movwf divisor_decoplan ; Reload divisor from CF
0
heinrichsweikamp
parents:
diff changeset
306 return
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 store_dive_ppO2_sensors:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
309 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
310 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
311 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
312 movf lo,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
313 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
314 movf hi,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
315 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
316
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
317 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
318 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
319 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
320 movf lo,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
321 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
322 movf hi,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
323 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
324
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
325 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
326 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
327 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
328 movf lo,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
329 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
330 movf hi,W ; in 0.1mV steps
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
331 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
332
heinrichsweikamp
parents:
diff changeset
333 movlw div_ppo2_sensors
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
334 movwf divisor_ppo2_sensors ; Reload divisor
0
heinrichsweikamp
parents:
diff changeset
335 return
heinrichsweikamp
parents:
diff changeset
336
heinrichsweikamp
parents:
diff changeset
337 store_dive_gf:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
338 movff int_O_gradient_factor+0,WREG; gradient factor absolute (range is limited to 255, only lower byte used for value)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
339 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
340 movlw div_gf
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
341 movwf divisor_gf ; Reload divisor
0
heinrichsweikamp
parents:
diff changeset
342 return
heinrichsweikamp
parents:
diff changeset
343
heinrichsweikamp
parents:
diff changeset
344 store_dive_decodata:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
345 ; Check if deco stops are necessary
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
346 movff char_O_first_deco_depth,WREG; get ceiling
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
347 tstfsz WREG ; ceiling < 0m (aka in deco) ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
348 bra store_dive_decodata_deco ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
349 ; NO - within NDL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
350 clrf WREG ; =0: no stop dive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
351 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
352 movff char_O_nullzeit,WREG ; remaining NDL time
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
353 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
354 bra store_dive_decodata_common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
355 store_dive_decodata_deco:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
356 ; YES - in deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
357 movff char_O_first_deco_depth,WREG; ceiling in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
358 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
359 movff char_O_first_deco_time,WREG ; length of first stop in minutes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
360 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
361 store_dive_decodata_common:
0
heinrichsweikamp
parents:
diff changeset
362 movlw div_deco
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
363 movwf divisor_deco ; Reload divisor
0
heinrichsweikamp
parents:
diff changeset
364 return
heinrichsweikamp
parents:
diff changeset
365
heinrichsweikamp
parents:
diff changeset
366 store_dive_temperature:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
367 SAFE_2BYTE_COPY temperature,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
368 movf lo,W ; append temperature to current sample!
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
369 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
370 movf hi,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
371 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
372 movlw div_temperature
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
373 movwf divisor_temperature ; Reload divisor
0
heinrichsweikamp
parents:
diff changeset
374 return
heinrichsweikamp
parents:
diff changeset
375
heinrichsweikamp
parents:
diff changeset
376 ghostwrite_byte_header:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
377 goto write_byte_ext_flash_plus_header ; (This call will also delete the 4kB TOC entry first)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
378 ; returns...
0
heinrichsweikamp
parents:
diff changeset
379
heinrichsweikamp
parents:
diff changeset
380 ghostwrite_byte_profile:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
381 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
382 ; returns...
0
heinrichsweikamp
parents:
diff changeset
383
heinrichsweikamp
parents:
diff changeset
384 global ghostwriter_end_dive
heinrichsweikamp
parents:
diff changeset
385 ghostwriter_end_dive:
heinrichsweikamp
parents:
diff changeset
386 movff ext_flash_address+0,ext_flash_log_pointer+0
heinrichsweikamp
parents:
diff changeset
387 movff ext_flash_address+1,ext_flash_log_pointer+1
heinrichsweikamp
parents:
diff changeset
388 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header
heinrichsweikamp
parents:
diff changeset
389
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
390 movff menupos3,customview_divemode ; store last custom view
39
e4e91fe8b09d remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents: 35
diff changeset
391
0
heinrichsweikamp
parents:
diff changeset
392 btfss realdive ; dive longer then one minute
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
393 goto ghostwriter_end_dive_common ; No, discard everything
0
heinrichsweikamp
parents:
diff changeset
394
heinrichsweikamp
parents:
diff changeset
395 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
396 ifndef __DEBUG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
397 btfsc simulatormode_active ; Are we in simulator mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
398 goto ghostwriter_end_dive_common_sim ; Yes, discard everything
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
399 endif
0
heinrichsweikamp
parents:
diff changeset
400
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
401 btfsc FLAG_apnoe_mode ; In Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
402 goto ghostwriter_end_dive_common ; Yes, discard everything
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
403
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
404 ; Dive finished (and longer then one minute)
0
heinrichsweikamp
parents:
diff changeset
405
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
406 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives
0
heinrichsweikamp
parents:
diff changeset
407 call apnoe_calc_maxdepth
heinrichsweikamp
parents:
diff changeset
408
heinrichsweikamp
parents:
diff changeset
409 ; calculate desaturation time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
410 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine !
0
heinrichsweikamp
parents:
diff changeset
411 movff last_surfpressure_30min+1,int_I_pres_surface+1
heinrichsweikamp
parents:
diff changeset
412
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
413 call deco_calc_dive_interval_1min ; calculate deco in surface mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
414 call deco_calc_desaturation_time ; calculate desaturation time
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
415 banksel common ; select ram bank 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
416
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
417 movlw 0xFD ; .... End-of-Profile Bytes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
418 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
419 movlw 0xFD
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
420 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash
0
heinrichsweikamp
parents:
diff changeset
421 movff ext_flash_address+0,ext_flash_log_pointer+0
heinrichsweikamp
parents:
diff changeset
422 movff ext_flash_address+1,ext_flash_log_pointer+1
heinrichsweikamp
parents:
diff changeset
423 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header
heinrichsweikamp
parents:
diff changeset
424
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
425 ; Set to first address again to store dive length ext_flash_dive_counter:3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
426 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6
0
heinrichsweikamp
parents:
diff changeset
427
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
428 incf_ext_flash_address_0x20 d'6' ; Skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
429 ; Store dive length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
430 movf ext_flash_dive_counter+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
431 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
432 movf ext_flash_dive_counter+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
433 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
434 movf ext_flash_dive_counter+2,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
435 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page
0
heinrichsweikamp
parents:
diff changeset
436
heinrichsweikamp
parents:
diff changeset
437 ; profile recording done.
heinrichsweikamp
parents:
diff changeset
438
heinrichsweikamp
parents:
diff changeset
439 ; Load total number of dives
heinrichsweikamp
parents:
diff changeset
440 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
441 movff EEDATA,lo
heinrichsweikamp
parents:
diff changeset
442 read_int_eeprom .3
heinrichsweikamp
parents:
diff changeset
443 movff EEDATA,hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
444 ; +1 ; increase total dive counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
445 infsnz lo,F
147
fdd4e30846ae some cleanup
heinrichsweikamp
parents: 139
diff changeset
446 incf hi,F
0
heinrichsweikamp
parents:
diff changeset
447 ; Store new number in EEPROM
heinrichsweikamp
parents:
diff changeset
448 movff lo,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
449 write_int_eeprom .2
0
heinrichsweikamp
parents:
diff changeset
450 movff hi,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
451 write_int_eeprom .3
0
heinrichsweikamp
parents:
diff changeset
452
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
453 decf lo,F ; -1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
454
0
heinrichsweikamp
parents:
diff changeset
455 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
456 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
457 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
458 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
459 ; 255: 2FF000h-2FFFFFh -> lo=255
heinrichsweikamp
parents:
diff changeset
460
heinrichsweikamp
parents:
diff changeset
461 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
462 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
463 movlw 0x20
heinrichsweikamp
parents:
diff changeset
464 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
465 movlw .16
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
466 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
0
heinrichsweikamp
parents:
diff changeset
467 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
468 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
469 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
470 addwfc ext_flash_address+2,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
471
0
heinrichsweikamp
parents:
diff changeset
472 ; Now, write header
heinrichsweikamp
parents:
diff changeset
473
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
474 movlw 0xFA ; Header start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
475 rcall ghostwrite_byte_header ; (This call will also delete the 4kB TOC entry first)
0
heinrichsweikamp
parents:
diff changeset
476 movlw 0xFA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
477 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
478
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
479 ; store pointer to begin of dive profile
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
480 read_int_eeprom .4
0
heinrichsweikamp
parents:
diff changeset
481 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
482 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
483 read_int_eeprom .5
0
heinrichsweikamp
parents:
diff changeset
484 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
485 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
486 read_int_eeprom .6
0
heinrichsweikamp
parents:
diff changeset
487 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
488 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
489
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
490 ; store pointer to end of dive profile
0
heinrichsweikamp
parents:
diff changeset
491 movf ext_flash_log_pointer+0,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
492 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
493 movf ext_flash_log_pointer+1,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
494 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
495 movf ext_flash_log_pointer+2,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
496 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
497
heinrichsweikamp
parents:
diff changeset
498 ; write rest of header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
499 movlw logbook_profile_version ; Defined in hwos.inc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
500 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
501
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
502 ; Store dive length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
503 movf ext_flash_dive_counter+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
504 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
505 movf ext_flash_dive_counter+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
506 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
507 movf ext_flash_dive_counter+2,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
508 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
509
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
510 movff start_year,WREG ; Date
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
511 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
389
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 279
diff changeset
512 movff start_month,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
513 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
389
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 279
diff changeset
514 movff start_day,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
515 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
516 movff start_hours,WREG ; Start of dive time
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
517 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
389
9175429bdeba CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
heinrichsweikamp
parents: 279
diff changeset
518 movff start_mins,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
519 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
520
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
521 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
522 bra end_dive1 ; Store normal depth
0
heinrichsweikamp
parents:
diff changeset
523
heinrichsweikamp
parents:
diff changeset
524 movff apnoe_max_pressure+0,lo
heinrichsweikamp
parents:
diff changeset
525 movff apnoe_max_pressure+1,hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
526 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
0
heinrichsweikamp
parents:
diff changeset
527 movff lo,apnoe_max_pressure+0
heinrichsweikamp
parents:
diff changeset
528 movff hi,apnoe_max_pressure+1
heinrichsweikamp
parents:
diff changeset
529
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
530 movf apnoe_max_pressure+0,W ; Max. depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
531 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
532 movf apnoe_max_pressure+1,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
533 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
534 bra end_dive2 ; skip normal max. depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
535
0
heinrichsweikamp
parents:
diff changeset
536 end_dive1:
heinrichsweikamp
parents:
diff changeset
537 movff max_pressure+0,lo
heinrichsweikamp
parents:
diff changeset
538 movff max_pressure+1,hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
539 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
0
heinrichsweikamp
parents:
diff changeset
540 movff lo,max_pressure+0
heinrichsweikamp
parents:
diff changeset
541 movff hi,max_pressure+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
542
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
543 movff max_pressure+0,WREG ; Max. depth
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
544 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
545 movff max_pressure+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
546 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
547
heinrichsweikamp
parents:
diff changeset
548 end_dive2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
549 movf divemins+0,W ; dive time minutes
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
550 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
551 movf divemins+1,W
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
552 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
553 movf divesecs,W ; dive time seconds
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
554 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
555 movff minimum_temperature+0,WREG ; minimum temperature
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
556 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
557 movff minimum_temperature+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
558 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
559 movff last_surfpressure_30min+0,WREG ; air pressure before dive
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
560 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
561 movff last_surfpressure_30min+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
562 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
563 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
564 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
565 movff int_O_desaturation_time+1,WREG
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
566 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
567
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
568 btfss FLAG_ccr_mode ; In CCR mode...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
569 bra end_dive_oc_gaslist ; No, write OC gases
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
570 ; Write Diluents...
0
heinrichsweikamp
parents:
diff changeset
571 movff opt_dil_O2_ratio+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
572 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
573 movff opt_dil_He_ratio+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
574 rcall ghostwrite_byte_header ; %He
0
heinrichsweikamp
parents:
diff changeset
575 movff char_I_dil_change+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
576 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
577 movff opt_dil_type+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
578 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal
0
heinrichsweikamp
parents:
diff changeset
579
heinrichsweikamp
parents:
diff changeset
580 movff opt_dil_O2_ratio+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
581 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
582 movff opt_dil_He_ratio+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
583 rcall ghostwrite_byte_header ; %He
0
heinrichsweikamp
parents:
diff changeset
584 movff char_I_dil_change+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
585 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
586 movff opt_dil_type+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
587 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal
0
heinrichsweikamp
parents:
diff changeset
588
heinrichsweikamp
parents:
diff changeset
589 movff opt_dil_O2_ratio+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
590 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
591 movff opt_dil_He_ratio+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
592 rcall ghostwrite_byte_header ; %He
0
heinrichsweikamp
parents:
diff changeset
593 movff char_I_dil_change+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
594 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
595 movff opt_dil_type+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
596 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal
0
heinrichsweikamp
parents:
diff changeset
597
heinrichsweikamp
parents:
diff changeset
598 movff opt_dil_O2_ratio+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
599 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
600 movff opt_dil_He_ratio+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
601 rcall ghostwrite_byte_header ; %He
0
heinrichsweikamp
parents:
diff changeset
602 movff char_I_dil_change+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
603 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
604 movff opt_dil_type+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
605 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal
0
heinrichsweikamp
parents:
diff changeset
606
heinrichsweikamp
parents:
diff changeset
607 movff opt_dil_O2_ratio+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
608 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
609 movff opt_dil_He_ratio+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
610 rcall ghostwrite_byte_header ; %He
0
heinrichsweikamp
parents:
diff changeset
611 movff char_I_dil_change+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
612 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
613 movff opt_dil_type+4,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
614 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
615 bra end_dive_oc_cc_common
0
heinrichsweikamp
parents:
diff changeset
616
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
617 end_dive_oc_gaslist: ; OC Gases...
0
heinrichsweikamp
parents:
diff changeset
618 movff opt_gas_O2_ratio+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
619 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
620 movff opt_gas_He_ratio+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
621 rcall ghostwrite_byte_header ; %He
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 39
diff changeset
622 movff opt_OC_bail_gas_change+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
623 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
624 movff opt_gas_type+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
625 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco
0
heinrichsweikamp
parents:
diff changeset
626
heinrichsweikamp
parents:
diff changeset
627 movff opt_gas_O2_ratio+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
628 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
629 movff opt_gas_He_ratio+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
630 rcall ghostwrite_byte_header ; %He
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 39
diff changeset
631 movff opt_OC_bail_gas_change+1,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
632 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
633 movff opt_gas_type+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
634 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco
0
heinrichsweikamp
parents:
diff changeset
635
heinrichsweikamp
parents:
diff changeset
636 movff opt_gas_O2_ratio+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
637 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
638 movff opt_gas_He_ratio+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
639 rcall ghostwrite_byte_header ; %He
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 39
diff changeset
640 movff opt_OC_bail_gas_change+2,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
641 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
642 movff opt_gas_type+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
643 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco
0
heinrichsweikamp
parents:
diff changeset
644
heinrichsweikamp
parents:
diff changeset
645 movff opt_gas_O2_ratio+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
646 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
647 movff opt_gas_He_ratio+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
648 rcall ghostwrite_byte_header ; %He
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 39
diff changeset
649 movff opt_OC_bail_gas_change+3,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
650 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
651 movff opt_gas_type+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
652 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco
0
heinrichsweikamp
parents:
diff changeset
653
heinrichsweikamp
parents:
diff changeset
654 movff opt_gas_O2_ratio+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
655 rcall ghostwrite_byte_header ; %O2
0
heinrichsweikamp
parents:
diff changeset
656 movff opt_gas_He_ratio+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
657 rcall ghostwrite_byte_header ; %He
97
53a99a2dc6a1 CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents: 39
diff changeset
658 movff opt_OC_bail_gas_change+4,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
659 rcall ghostwrite_byte_header ; Configured change depth in m
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
660 movff opt_gas_type+4,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
661 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
662 ; bra end_dive_oc_cc_common
0
heinrichsweikamp
parents:
diff changeset
663
heinrichsweikamp
parents:
diff changeset
664 end_dive_oc_cc_common:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
665 movlw softwareversion_x ; Firmware version
0
heinrichsweikamp
parents:
diff changeset
666 rcall ghostwrite_byte_header
heinrichsweikamp
parents:
diff changeset
667 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
668 rcall ghostwrite_byte_header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
669 movf batt_voltage+0,W ; Battery voltage
0
heinrichsweikamp
parents:
diff changeset
670 rcall ghostwrite_byte_header
heinrichsweikamp
parents:
diff changeset
671 movf batt_voltage+1,W
heinrichsweikamp
parents:
diff changeset
672 rcall ghostwrite_byte_header
heinrichsweikamp
parents:
diff changeset
673
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
674 movf samplingrate,W ; Sampling rate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
675 btfsc FLAG_apnoe_mode ; Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
676 movlw samplingrate_apnoe ; Apnoe sampling rate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
677 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
678
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
679 ; CNS at beginning of dive
0
heinrichsweikamp
parents:
diff changeset
680 movff CNS_start+0,WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
681 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
682 movff CNS_start+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
683 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
684 ; Gradient factor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
685 movff GF_start,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
686 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
687 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
688 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
689
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
690 ; Logbook offset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
691 call do_logoffset_common_read ; Read into lo:hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
692 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
693 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
694 movf hi,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
695 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
696
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
697 ; Battery info at Byte 59
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
698 movf batt_percent,W ; 0-100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
699 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
700 ; Store 5 Setpoints
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
701 movff char_I_setpoint_cbar+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
702 rcall ghostwrite_byte_header ; Setpoint in cbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
703 movff char_I_setpoint_change+0,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
704 rcall ghostwrite_byte_header ; Change depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
705 movff char_I_setpoint_cbar+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
706 rcall ghostwrite_byte_header ; Setpoint in cbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
707 movff char_I_setpoint_change+1,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
708 rcall ghostwrite_byte_header ; Change depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
709 movff char_I_setpoint_cbar+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
710 rcall ghostwrite_byte_header ; Setpoint in cbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
711 movff char_I_setpoint_change+2,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
712 rcall ghostwrite_byte_header ; Change depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
713 movff char_I_setpoint_cbar+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
714 rcall ghostwrite_byte_header ; Setpoint in cbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
715 movff char_I_setpoint_change+3,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
716 rcall ghostwrite_byte_header ; Change depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
717 movff char_I_setpoint_cbar+4,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
718 rcall ghostwrite_byte_header ; Setpoint in cbar
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
719 movff char_I_setpoint_change+4,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
720 rcall ghostwrite_byte_header ; Change depth
0
heinrichsweikamp
parents:
diff changeset
721
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
722 movff opt_salinity,WREG ; Salinity (0-4%)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
723 rcall ghostwrite_byte_header ; Store Salinity to Dive
0
heinrichsweikamp
parents:
diff changeset
724
heinrichsweikamp
parents:
diff changeset
725 movff int_O_CNS_fraction+0,WREG ; copy into bank1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
726 rcall ghostwrite_byte_header ; Stores CNS%
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
727 movff int_O_CNS_fraction+1,WREG ; copy into bank1
601
08a0162d3ca1 Fix false CNS readings in logbook
heinrichsweikamp
parents: 582
diff changeset
728 bcf WREG,int_warning_flag ; clear warning flag
08a0162d3ca1 Fix false CNS readings in logbook
heinrichsweikamp
parents: 582
diff changeset
729 bcf WREG,int_attention_flag ; clear attention flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
730 rcall ghostwrite_byte_header ; Stores CNS%
0
heinrichsweikamp
parents:
diff changeset
731
437
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 389
diff changeset
732 movff avg_rel_pressure_total+0,WREG ; Average Depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
733 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
437
23b58c4bc6aa CHANGE: Language fixes, 2.08 release
heinrichsweikamp
parents: 389
diff changeset
734 movff avg_rel_pressure_total+1,WREG ; Average Depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
735 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
736
heinrichsweikamp
parents:
diff changeset
737 movff total_divetime_seconds+0,WREG ; Total dive time (Regardless of start_dive_threshold)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
738 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
739 movff total_divetime_seconds+1,WREG ; Total dive time (Regardless of start_dive_threshold)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
740 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
741
heinrichsweikamp
parents:
diff changeset
742 movff char_I_GF_Low_percentage,WREG ; GF_lo
heinrichsweikamp
parents:
diff changeset
743 movff char_I_deco_model,lo
heinrichsweikamp
parents:
diff changeset
744 decfsz lo,F ; jump over next line if char_I_deco_model == 1
heinrichsweikamp
parents:
diff changeset
745 movff char_I_saturation_multiplier,WREG ; Saturation Multiplier
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
746 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
747
heinrichsweikamp
parents:
diff changeset
748 movff char_I_GF_High_percentage,WREG ; GF_hi
heinrichsweikamp
parents:
diff changeset
749 movff char_I_deco_model,lo
heinrichsweikamp
parents:
diff changeset
750 decfsz lo,F ; jump over next line if char_I_deco_model == 1
heinrichsweikamp
parents:
diff changeset
751 movff char_I_desaturation_multiplier,WREG ; Desaturation Multiplier
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
752 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
753
heinrichsweikamp
parents:
diff changeset
754 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
755 rcall ghostwrite_byte_header ; writes byte and increases address (no banking)
0
heinrichsweikamp
parents:
diff changeset
756
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
757 read_int_eeprom .2
0
heinrichsweikamp
parents:
diff changeset
758 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
759 rcall ghostwrite_byte_header ; Total dive counter, low
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
760 read_int_eeprom .3
0
heinrichsweikamp
parents:
diff changeset
761 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
762 rcall ghostwrite_byte_header ; Total dive counter, high
0
heinrichsweikamp
parents:
diff changeset
763
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
764 movff opt_dive_mode,WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
765 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
0
heinrichsweikamp
parents:
diff changeset
766
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
767 ; Store all tissue data available
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
768 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
769 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
770 lfsr FSR1,char_O_tissue_N2_saturation+0
0
heinrichsweikamp
parents:
diff changeset
771 end_dive_store_tissues_N2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
772 movf POSTINC1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
773 bcf WREG,7 ; clear flag bit for ongassing/offgassing
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
774 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
775 decfsz lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
776 bra end_dive_store_tissues_N2 ; No
0
heinrichsweikamp
parents:
diff changeset
777
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
778 movlw .64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
779 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
780 lfsr FSR1,0x700 ; pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes
0
heinrichsweikamp
parents:
diff changeset
781 end_dive_store_tissues_N2_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
782 movf POSTINC1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
783 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
784 decfsz lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
785 bra end_dive_store_tissues_N2_2 ; No
0
heinrichsweikamp
parents:
diff changeset
786
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
787 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
788 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
789 lfsr FSR1,char_O_tissue_He_saturation+0
0
heinrichsweikamp
parents:
diff changeset
790 end_dive_store_tissues_He:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
791 movf POSTINC1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
792 bcf WREG,7 ; clear flag bit for ongassing/offgassing
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
793 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
794 decfsz lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
795 bra end_dive_store_tissues_He ; No
0
heinrichsweikamp
parents:
diff changeset
796
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
797 movlw .64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
798 movwf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
799 lfsr FSR1,0x740 ; pres_tissue_He+0 ; 16*4Byte Float = 64Bytes
0
heinrichsweikamp
parents:
diff changeset
800 end_dive_store_tissues_He_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
801 movf POSTINC1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
802 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
803 decfsz lo,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
804 bra end_dive_store_tissues_He_2 ; No
0
heinrichsweikamp
parents:
diff changeset
805
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
806 ; Some deco stuff
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
807 movff char_I_depth_last_deco,WREG ; last stop [m]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
808 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
809 movff char_I_deco_distance,WREG ; assumed distance to shown stop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
810 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
811
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
812 ; Last HUD data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
813 movff hud_battery_mv+0,WREG ; Last HUD battery value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
814 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
815 movff hud_battery_mv+1,WREG ; Last HUD battery value
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
816 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
817 movff hud_status_byte,WREG ; Last HUD status
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
818 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
819
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
820 ; Battery gauge registers [nAs]
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
821 movff battery_gauge+0,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
822 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
823 movff battery_gauge+1,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
824 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
825 movff battery_gauge+2,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
826 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
827 movff battery_gauge+3,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
828 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
829 movff battery_gauge+4,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
830 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
831 movff battery_gauge+5,WREG ; Battery gauge register
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
832 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
833
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
834 ; Header stop
0
heinrichsweikamp
parents:
diff changeset
835 movlw 0xFB
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
836 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
837 movlw 0xFB
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
838 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
839
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
840 call divemode_store_statistics ; Store/update statistics for this unit
0
heinrichsweikamp
parents:
diff changeset
841
heinrichsweikamp
parents:
diff changeset
842 clrf surface_interval+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
843 clrf surface_interval+1 ; Clear surface interval timer
0
heinrichsweikamp
parents:
diff changeset
844
heinrichsweikamp
parents:
diff changeset
845 ghostwriter_end_dive_common:
heinrichsweikamp
parents:
diff changeset
846 ; Update ext_flash_log_pointer into EEPROM
heinrichsweikamp
parents:
diff changeset
847 clrf EEADRH
heinrichsweikamp
parents:
diff changeset
848 movff ext_flash_log_pointer+0,EEDATA
heinrichsweikamp
parents:
diff changeset
849 write_int_eeprom .4
heinrichsweikamp
parents:
diff changeset
850 movff ext_flash_log_pointer+1,EEDATA
heinrichsweikamp
parents:
diff changeset
851 write_int_eeprom .5
heinrichsweikamp
parents:
diff changeset
852 movff ext_flash_log_pointer+2,EEDATA
heinrichsweikamp
parents:
diff changeset
853 write_int_eeprom .6
heinrichsweikamp
parents:
diff changeset
854
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
855 bcf simulatormode_active ; if we were in simulator mode
0
heinrichsweikamp
parents:
diff changeset
856
heinrichsweikamp
parents:
diff changeset
857 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
858 ifndef __DEBUG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
859 extern deco_pull_tissues_from_vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
860 btfsc restore_deco_data ; Restore decodata?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
861 call deco_pull_tissues_from_vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
862 banksel common ; Bank1
0
heinrichsweikamp
parents:
diff changeset
863 endif
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
864 call update_battery_registers ; update battery registers into EEPROM
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
865 goto surfloop ; and return to surface loop
0
heinrichsweikamp
parents:
diff changeset
866
166
30ebaf72170d BUGFIX: Flip compass with flipped screen, too
heinrichsweikamp
parents: 147
diff changeset
867 ghostwriter_end_dive_common_sim:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
868 tstfsz surface_interval+0 ; Was interval zero?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
869 bra ghostwriter_end_dive_common_sim2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
870 tstfsz surface_interval+1 ; Was interval zero?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
871 bra ghostwriter_end_dive_common_sim2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
872 bra ghostwriter_end_dive_common ; Yes, done.
174
932e91074bdb CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents: 170
diff changeset
873
932e91074bdb CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents: 170
diff changeset
874 ghostwriter_end_dive_common_sim2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
875 movf divemins+0,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
876 addwf surface_interval+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
877 movf divemins+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
878 addwfc surface_interval+1 ; Add simulated dive time to surface interval
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
879 bra ghostwriter_end_dive_common
166
30ebaf72170d BUGFIX: Flip compass with flipped screen, too
heinrichsweikamp
parents: 147
diff changeset
880
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
881 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
882 clrf EEADRH ; Make sure to select EEPROM bank 0
0
heinrichsweikamp
parents:
diff changeset
883 read_int_eeprom .4
heinrichsweikamp
parents:
diff changeset
884 movff EEDATA,ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
885 read_int_eeprom .5
heinrichsweikamp
parents:
diff changeset
886 movff EEDATA,ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
887 read_int_eeprom .6
heinrichsweikamp
parents:
diff changeset
888 movff EEDATA,ext_flash_address+2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
889 return
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
890
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
891 ghostwriter_short_header_init: ; Proceed one page forward
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
892 clrf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
893 write_int_eeprom .4 ; ext_flash_address+0 = 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
894 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
895 addwf ext_flash_address+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
896 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
897 addwfc ext_flash_address+2,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
898 movlw 0x20
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
899 cpfseq ext_flash_address+2 ; at address 0x200000?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
900 bra ghostwriter_short_header_init2 ; No
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
901 clrf ext_flash_address+2 ; Yes, rollover to 0x000000
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
902 ghostwriter_short_header_init2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
903 movlw 0xF0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
904 andwf ext_flash_address+1,F ; keep higher nibble, set lower nibble to 0
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
905
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
906 movff ext_flash_address+1,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
907 write_int_eeprom .5 ; Write new pointer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
908 movff ext_flash_address+2,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
909 write_int_eeprom .6 ; Write new pointer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
910 bra ghostwriter_short_header2 ; Done.
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
911
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
912 global ghostwriter_short_header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
913 ghostwriter_short_header: ; Write short header with dive number into profile memory
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
914 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
915 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
916
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
917 ; The following code is used to write a clean new dive after the previous hasn't been
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
918 ; stored correctly. e.g. after a battery fail during the dive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
919 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
920 incfsz ext_flash_rw,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
921 bra ghostwriter_short_header_init ; Not 0xFF -> init page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
922 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
923 incfsz ext_flash_rw,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
924 bra ghostwriter_short_header_init ; Not 0xFF -> init page
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
925
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
926 ghostwriter_short_header2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
927 ; All ok, reload the pointer and start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
928 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6
0
heinrichsweikamp
parents:
diff changeset
929
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
930 ; Clear dive length counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
931 clrf ext_flash_dive_counter+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
932 clrf ext_flash_dive_counter+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
933 clrf ext_flash_dive_counter+2
0
heinrichsweikamp
parents:
diff changeset
934
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
935 ; Write short header with dive number into profile memory
0
heinrichsweikamp
parents:
diff changeset
936 movlw 0xFA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
937 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
938 movlw 0xFA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
939 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
940 ; Load total number of dives (low byte only)
heinrichsweikamp
parents:
diff changeset
941 read_int_eeprom .2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
942 incf EEDATA,W ;+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
943 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
944 read_int_eeprom .3
heinrichsweikamp
parents:
diff changeset
945 movf EEDATA,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
946 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
947 movlw 0xFA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
948 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
949 movlw 0xFA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
950 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
278
dfac47ac2e1d BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents: 275
diff changeset
951
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
952 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
953 ; Writing 0xFF three times here is mandatory
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
954 ; - 0xFF can be overwritten after the dive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
955 ; - ghostwrite_byte_profile takes care of 4kB Page switching
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
956 ; - fixes an issue when we are at exactly 0xXXX000 here...
278
dfac47ac2e1d BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents: 275
diff changeset
957
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
958 movlw 0xFF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
959 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
960 movlw 0xFF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
961 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
962 movlw 0xFF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
963 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase)
0
heinrichsweikamp
parents:
diff changeset
964
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
965 movf samplingrate,W ; Sampling rate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
966 btfsc FLAG_apnoe_mode ; Apnoe mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
967 movlw samplingrate_apnoe ; Apnoe sampling rate
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
968 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
969
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
970 movlw .7 ; Number of divisors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
971 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
972
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
973 movlw .0 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
974 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
975 movlw infolength_temperature
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
976 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
977 movlw div_temperature ; Divisor temperature
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
978 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
979
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
980 movlw .1 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
981 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
982 movlw infolength_deco
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
983 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
984 movlw div_deco ; Divisor deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
985 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
986
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
987 movlw .2 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
988 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
989 movlw infolength_gf
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
990 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
991 movlw div_gf ; Divisor gf
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
992 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
993
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
994 movlw .3 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
995 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
996 movlw infolength_ppo2_sensors
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
997 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
998 movlw div_ppo2_sensors ; Divisor ppO2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
999 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1000 movlw .0 ; No ppO2 data in OC mode
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1001 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1002
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1003 movlw .4 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1004 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1005 movlw infolength_decoplan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1006 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1007 movlw div_decoplan ; Divisor debug
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1008 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1009
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1010 movlw .5 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1011 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1012 movlw infolength_cns
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1013 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1014 movlw div_cns ; Divisor CNS
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1015 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1016
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1017 movlw .6 ; Type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1018 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1019 movlw infolength_tank
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1020 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1021 movlw div_tank ; Divisor Tank
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1022 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1023
heinrichsweikamp
parents:
diff changeset
1024 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1025
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1026 divemode_store_statistics: ; Store/update statistics for this unit
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1027 call vault_decodata_into_eeprom ; update deco data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1028 call do_logoffset_common_read ; Existing logbook offset into lo:hi
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1029
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1030 tstfsz lo ; lo=0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1031 bra change_logbook_offset1 ; No, adjust offset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1032 tstfsz hi ; hi=0?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1033 bra change_logbook_offset1 ; No, adjust offset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1034 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1035
0
heinrichsweikamp
parents:
diff changeset
1036 change_logbook_offset1:
heinrichsweikamp
parents:
diff changeset
1037 movlw d'1'
heinrichsweikamp
parents:
diff changeset
1038 addwf lo
heinrichsweikamp
parents:
diff changeset
1039 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1040 addwfc hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1041 call do_logoffset_common_write ; lo:hi -> EEPROM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1042
0
heinrichsweikamp
parents:
diff changeset
1043 change_logbook_offset2:
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1044 ; Clear lastdive:4
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1045 banksel lastdive_time+0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1046 clrf lastdive_time+0
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1047 clrf lastdive_time+1
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1048 clrf lastdive_time+2
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1049 clrf lastdive_time+3
503
4542d03f748a NEW: Last Dive customviews in surface mode with divetime, depth and interval
heinrichsweikamp
parents: 490
diff changeset
1050 movff divemins+0,lastdive_duration+0
4542d03f748a NEW: Last Dive customviews in surface mode with divetime, depth and interval
heinrichsweikamp
parents: 490
diff changeset
1051 movff divemins+1,lastdive_duration+1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1052 movff divesecs, lastdive_duration+2
503
4542d03f748a NEW: Last Dive customviews in surface mode with divetime, depth and interval
heinrichsweikamp
parents: 490
diff changeset
1053 movff max_pressure+0,lastdive_maxdepth+0
4542d03f748a NEW: Last Dive customviews in surface mode with divetime, depth and interval
heinrichsweikamp
parents: 490
diff changeset
1054 movff max_pressure+1,lastdive_maxdepth+1
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1055 banksel common
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1056
0
heinrichsweikamp
parents:
diff changeset
1057 ; Add more here...
heinrichsweikamp
parents:
diff changeset
1058 return
heinrichsweikamp
parents:
diff changeset
1059
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1060 END