annotate src/ghostwriter.asm @ 569:fea63a20c1c5

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