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