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