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