Mercurial > public > hwos_code
annotate src/ghostwriter.asm @ 38:64976f1e0a1c
Show total divetime in apnea mode
author | mh@mh-THINK.fritz.box |
---|---|
date | Thu, 15 Aug 2013 13:30:05 +0200 |
parents | eca4a201d8cf |
children | e4e91fe8b09d |
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 | |
296 btfss realdive ; dive longer then one minute | |
297 goto ghostwriter_end_dive_common ; No, discard everything | |
298 | |
299 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | |
300 ifndef __DEBUG | |
301 btfsc simulatormode_active ; Are we in simulator mode? | |
302 goto ghostwriter_end_dive_common ; Yes, discard everything | |
303 endif | |
304 | |
35
eca4a201d8cf
change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents:
23
diff
changeset
|
305 btfsc FLAG_apnoe_mode ; In Apnoe mode? |
eca4a201d8cf
change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents:
23
diff
changeset
|
306 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
|
307 |
eca4a201d8cf
change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents:
23
diff
changeset
|
308 ; Dive finished (and longer then one minute) |
0 | 309 |
310 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | |
311 call apnoe_calc_maxdepth | |
312 | |
313 ; calculate desaturation time | |
314 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! | |
315 movff last_surfpressure_30min+1,int_I_pres_surface+1 | |
316 | |
317 call deco_calc_desaturation_time ; calculate desaturation time | |
318 movlb b'00000001' ; select ram bank 1 | |
319 movff int_O_desaturation_time+0, desaturation_time+0 | |
320 movff int_O_desaturation_time+1, desaturation_time+1 ; Buffer | |
321 call calc_deko_surfmode | |
322 rcall calculate_noflytime ; Calc NoFly time | |
323 | |
324 ; store header and ... | |
325 movlw 0xFD ; .... End-of-Profile Bytes | |
326 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
327 movlw 0xFD | |
328 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
329 movff ext_flash_address+0,ext_flash_log_pointer+0 | |
330 movff ext_flash_address+1,ext_flash_log_pointer+1 | |
331 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header | |
332 | |
333 ; Set to first address again to store dive length ext_flash_dive_counter:3 | |
334 clrf EEADRH ; Make sure to select eeprom bank 0 | |
335 read_int_eeprom .4 | |
336 movff EEDATA,ext_flash_address+0 | |
337 read_int_eeprom .5 | |
338 movff EEDATA,ext_flash_address+1 | |
339 read_int_eeprom .6 | |
340 movff EEDATA,ext_flash_address+2 | |
341 | |
342 incf_ext_flash_address_0x20 d'6' ; Skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header | |
343 ; Store dive length | |
344 movf ext_flash_dive_counter+0,W | |
6 | 345 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) |
0 | 346 movf ext_flash_dive_counter+1,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+2,W |
6 | 349 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) |
0 | 350 |
351 ; profile recording done. | |
352 | |
353 ; Load total number of dives | |
354 read_int_eeprom .2 | |
355 movff EEDATA,lo | |
356 read_int_eeprom .3 | |
357 movff EEDATA,hi | |
358 ; +1 increase total dive counter | |
359 incf lo,F | |
360 movlw d'0' | |
361 addwfc hi,F | |
362 ; Store new number in EEPROM | |
363 movff lo,EEDATA | |
364 write_int_eeprom .2 | |
365 movff hi,EEDATA | |
366 write_int_eeprom .3 | |
367 | |
368 decf lo,F ; -1 | |
369 ; Set ext_flash_address:3 to TOC entry of this dive | |
370 ; 1st: 200000h-200FFFh -> lo=0 | |
371 ; 2nd: 201000h-201FFFh -> lo=1 | |
372 ; 3rd: 202000h-202FFFh -> lo=2 | |
373 ; 255: 2FF000h-2FFFFFh -> lo=255 | |
374 | |
375 clrf ext_flash_address+0 | |
376 clrf ext_flash_address+1 | |
377 movlw 0x20 | |
378 movwf ext_flash_address+2 | |
379 movlw .16 | |
380 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | |
381 movf PRODL,W | |
382 addwf ext_flash_address+1,F | |
383 movf PRODH,W | |
384 addwfc ext_flash_address+2,F | |
385 | |
386 ; Now, write header | |
387 | |
388 movlw 0xFA ; Header start | |
389 rcall ghostwrite_byte_header ; (This call will also delete the 4kB TOC entry first) | |
390 movlw 0xFA | |
391 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
392 | |
393 ; store pointer to begin of diveprofile | |
394 read_int_eeprom .4 | |
395 movf EEDATA,W | |
396 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
397 read_int_eeprom .5 | |
398 movf EEDATA,W | |
399 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
400 read_int_eeprom .6 | |
401 movf EEDATA,W | |
402 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
403 | |
404 ; store pointer to end of diveprofile | |
405 movf ext_flash_log_pointer+0,W | |
406 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
407 movf ext_flash_log_pointer+1,W | |
408 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
409 movf ext_flash_log_pointer+2,W | |
410 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
411 | |
412 ; write rest of header | |
413 movlw logbook_profile_version ; Defined in ostc3.inc | |
414 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
415 | |
416 ; Store dive length | |
417 movf ext_flash_dive_counter+0,W | |
418 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
419 movf ext_flash_dive_counter+1,W | |
420 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
421 movf ext_flash_dive_counter+2,W | |
422 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
423 | |
424 movf year,W ; Date | |
425 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
426 movf month,W | |
427 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
428 movf day,W | |
429 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
430 movf hours,W ; End of dive time | |
431 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
432 movf mins,W | |
433 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
434 | |
435 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | |
436 bra end_dive1 ; Store normal depth | |
437 | |
438 movff apnoe_max_pressure+0,lo | |
439 movff apnoe_max_pressure+1,hi | |
440 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
441 movff lo,apnoe_max_pressure+0 | |
442 movff hi,apnoe_max_pressure+1 | |
443 | |
444 movf apnoe_max_pressure+0,W ; Max. depth | |
445 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
446 movf apnoe_max_pressure+1,W | |
447 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
448 bra end_dive2 ; skip normal max. depth | |
449 | |
450 end_dive1: | |
451 movff max_pressure+0,lo | |
452 movff max_pressure+1,hi | |
453 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | |
454 movff lo,max_pressure+0 | |
455 movff hi,max_pressure+1 | |
456 | |
457 movff max_pressure+0,WREG ; Max. depth | |
458 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
459 movff max_pressure+1,WREG | |
460 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
461 | |
462 end_dive2: | |
463 movf divemins+0,W ; divetime minutes | |
464 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
465 movf divemins+1,W | |
466 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
467 movf divesecs,W ; divetime seconds | |
468 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
469 movff minimum_temperature+0,WREG ; minimum temperature | |
470 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
471 movff minimum_temperature+1,WREG | |
472 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
473 movff last_surfpressure_30min+0,WREG ; airpressure before dive | |
474 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
475 movff last_surfpressure_30min+1,WREG | |
476 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
477 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes | |
478 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
479 movff int_O_desaturation_time+1,WREG | |
480 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
481 | |
482 btfss FLAG_ccr_mode ; In CCR mode... | |
483 bra end_dive_oc_gaslist ; No, write OC gases | |
484 ; Write Diluents... | |
485 movff opt_dil_O2_ratio+0,WREG | |
486 rcall ghostwrite_byte_header ; %O2 | |
487 movff opt_dil_He_ratio+0,WREG | |
488 rcall ghostwrite_byte_header ; %He | |
489 movff char_I_dil_change+0,WREG | |
490 rcall ghostwrite_byte_header ; Configured change depth in m | |
491 movff opt_dil_type+0,WREG | |
492 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
493 | |
494 movff opt_dil_O2_ratio+1,WREG | |
495 rcall ghostwrite_byte_header ; %O2 | |
496 movff opt_dil_He_ratio+1,WREG | |
497 rcall ghostwrite_byte_header ; %He | |
498 movff char_I_dil_change+1,WREG | |
499 rcall ghostwrite_byte_header ; Configured change depth in m | |
500 movff opt_dil_type+1,WREG | |
501 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
502 | |
503 movff opt_dil_O2_ratio+2,WREG | |
504 rcall ghostwrite_byte_header ; %O2 | |
505 movff opt_dil_He_ratio+2,WREG | |
506 rcall ghostwrite_byte_header ; %He | |
507 movff char_I_dil_change+2,WREG | |
508 rcall ghostwrite_byte_header ; Configured change depth in m | |
509 movff opt_dil_type+2,WREG | |
510 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
511 | |
512 movff opt_dil_O2_ratio+3,WREG | |
513 rcall ghostwrite_byte_header ; %O2 | |
514 movff opt_dil_He_ratio+3,WREG | |
515 rcall ghostwrite_byte_header ; %He | |
516 movff char_I_dil_change+3,WREG | |
517 rcall ghostwrite_byte_header ; Configured change depth in m | |
518 movff opt_dil_type+3,WREG | |
519 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
520 | |
521 movff opt_dil_O2_ratio+4,WREG | |
522 rcall ghostwrite_byte_header ; %O2 | |
523 movff opt_dil_He_ratio+4,WREG | |
524 rcall ghostwrite_byte_header ; %He | |
525 movff char_I_dil_change+4,WREG | |
526 rcall ghostwrite_byte_header ; Configured change depth in m | |
527 movff opt_dil_type+4,WREG | |
528 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | |
529 bra end_dive_oc_cc_common | |
530 | |
531 end_dive_oc_gaslist: ; OC Gases... | |
532 movff opt_gas_O2_ratio+0,WREG | |
533 rcall ghostwrite_byte_header ; %O2 | |
534 movff opt_gas_He_ratio+0,WREG | |
535 rcall ghostwrite_byte_header ; %He | |
536 movff char_I_deco_gas_change+0,WREG | |
537 rcall ghostwrite_byte_header ; Configured change depth in m | |
538 movff opt_gas_type+0,WREG | |
539 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
540 | |
541 movff opt_gas_O2_ratio+1,WREG | |
542 rcall ghostwrite_byte_header ; %O2 | |
543 movff opt_gas_He_ratio+1,WREG | |
544 rcall ghostwrite_byte_header ; %He | |
545 movff char_I_deco_gas_change+1,WREG | |
546 rcall ghostwrite_byte_header ; Configured change depth in m | |
547 movff opt_gas_type+1,WREG | |
548 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
549 | |
550 movff opt_gas_O2_ratio+2,WREG | |
551 rcall ghostwrite_byte_header ; %O2 | |
552 movff opt_gas_He_ratio+2,WREG | |
553 rcall ghostwrite_byte_header ; %He | |
554 movff char_I_deco_gas_change+2,WREG | |
555 rcall ghostwrite_byte_header ; Configured change depth in m | |
556 movff opt_gas_type+2,WREG | |
557 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
558 | |
559 movff opt_gas_O2_ratio+3,WREG | |
560 rcall ghostwrite_byte_header ; %O2 | |
561 movff opt_gas_He_ratio+3,WREG | |
562 rcall ghostwrite_byte_header ; %He | |
563 movff char_I_deco_gas_change+3,WREG | |
564 rcall ghostwrite_byte_header ; Configured change depth in m | |
565 movff opt_gas_type+3,WREG | |
566 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
567 | |
568 movff opt_gas_O2_ratio+4,WREG | |
569 rcall ghostwrite_byte_header ; %O2 | |
570 movff opt_gas_He_ratio+4,WREG | |
571 rcall ghostwrite_byte_header ; %He | |
572 movff char_I_deco_gas_change+4,WREG | |
573 rcall ghostwrite_byte_header ; Configured change depth in m | |
574 movff opt_gas_type+4,WREG | |
575 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | |
576 ; bra end_dive_oc_cc_common | |
577 | |
578 end_dive_oc_cc_common: | |
579 movlw softwareversion_x ; Firmware version | |
580 rcall ghostwrite_byte_header | |
581 movlw softwareversion_y | |
582 rcall ghostwrite_byte_header | |
583 movf batt_voltage+0,W ; Battery voltage | |
584 rcall ghostwrite_byte_header | |
585 movf batt_voltage+1,W | |
586 rcall ghostwrite_byte_header | |
587 | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
6
diff
changeset
|
588 movf samplingrate,W ; Sampling rate |
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
6
diff
changeset
|
589 btfsc FLAG_apnoe_mode ; Apnoe mode? |
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
6
diff
changeset
|
590 movlw samplingrate_apnoe ; Apnoe sampling rate |
0 | 591 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
592 | |
593 ; CNS at gebinning of dive | |
594 movff CNS_start+0,WREG | |
595 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
596 movff CNS_start+1,WREG | |
597 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
598 ; Gradient factor | |
599 movff GF_start,WREG | |
600 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
601 movff char_O_relative_gradient_GF,WREG | |
602 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
5 | 603 |
604 ; Logbook offset | |
605 call do_logoffset_common_read; Read into lo:hi | |
606 movf lo,W | |
0 | 607 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
5 | 608 movf hi,W |
0 | 609 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
5 | 610 |
611 ; Spare at Byte 60 | |
0 | 612 movlw 0xFF |
613 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
614 ; Store 5 Setpoints | |
615 movff char_I_setpoint_cbar+0,WREG | |
616 rcall ghostwrite_byte_header ; Setpoint in cbar | |
617 movff char_I_setpoint_change+0,WREG | |
618 rcall ghostwrite_byte_header ; Change depth | |
619 movff char_I_setpoint_cbar+1,WREG | |
620 rcall ghostwrite_byte_header ; Setpoint in cbar | |
621 movff char_I_setpoint_change+1,WREG | |
622 rcall ghostwrite_byte_header ; Change depth | |
623 movff char_I_setpoint_cbar+2,WREG | |
624 rcall ghostwrite_byte_header ; Setpoint in cbar | |
625 movff char_I_setpoint_change+2,WREG | |
626 rcall ghostwrite_byte_header ; Change depth | |
627 movff char_I_setpoint_cbar+3,WREG | |
628 rcall ghostwrite_byte_header ; Setpoint in cbar | |
629 movff char_I_setpoint_change+3,WREG | |
630 rcall ghostwrite_byte_header ; Change depth | |
631 movff char_I_setpoint_cbar+4,WREG | |
632 rcall ghostwrite_byte_header ; Setpoint in cbar | |
633 movff char_I_setpoint_change+4,WREG | |
634 rcall ghostwrite_byte_header ; Change depth | |
635 | |
636 movff opt_salinity,WREG ; Salinity (0-5%) | |
637 rcall ghostwrite_byte_header ; Store Salinity to Dive | |
638 | |
639 movff int_O_CNS_fraction+0,WREG ; copy into bank1 | |
640 rcall ghostwrite_byte_header; Stores CNS% | |
641 movff int_O_CNS_fraction+1,WREG ; copy into bank1 | |
642 rcall ghostwrite_byte_header; Stores CNS% | |
643 | |
644 movff avr_rel_pressure_total+0,WREG ; Average Depth | |
645 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
646 movff avr_rel_pressure_total+1,WREG ; Average Depth | |
647 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
648 | |
649 movff total_divetime_seconds+0,WREG ; Total dive time (Regardless of start_dive_threshold) | |
650 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
651 movff total_divetime_seconds+1,WREG ; Total dive time (Regardless of start_dive_threshold) | |
652 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
653 | |
654 movff char_I_GF_Low_percentage,WREG ; GF_lo | |
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_saturation_multiplier,WREG ; Saturation Multiplier | |
658 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
659 | |
660 movff char_I_GF_High_percentage,WREG ; GF_hi | |
661 movff char_I_deco_model,lo | |
662 decfsz lo,F ; jump over next line if char_I_deco_model == 1 | |
663 movff char_I_desaturation_multiplier,WREG ; Desaturation Multiplier | |
664 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
665 | |
666 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | |
667 rcall ghostwrite_byte_header; writes byte and increases address (no banking) | |
668 | |
669 read_int_eeprom .2 | |
670 movf EEDATA,W | |
671 rcall ghostwrite_byte_header ; Total dive counter, low | |
672 read_int_eeprom .3 | |
673 movf EEDATA,W | |
674 rcall ghostwrite_byte_header ; Total dive counter, high | |
675 | |
676 movff opt_dive_mode,WREG | |
677 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea | |
678 | |
679 ; Store all tissue data available | |
680 movlw .16 | |
681 movwf lo | |
682 lfsr FSR1,char_O_tissue_N2_saturation+0 | |
683 end_dive_store_tissues_N2: | |
684 movf POSTINC1,W | |
685 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
686 decfsz lo,F | |
687 bra end_dive_store_tissues_N2 ; No | |
688 | |
689 movlw .64 | |
690 movwf lo | |
691 lfsr FSR1,0x700;pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes | |
692 end_dive_store_tissues_N2_2: | |
693 movf POSTINC1,W | |
694 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
695 decfsz lo,F | |
696 bra end_dive_store_tissues_N2_2 ; No | |
697 | |
698 movlw .16 | |
699 movwf lo | |
700 lfsr FSR1,char_O_tissue_He_saturation+0 | |
701 end_dive_store_tissues_He: | |
702 movf POSTINC1,W | |
703 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
704 decfsz lo,F | |
705 bra end_dive_store_tissues_He ; No | |
706 | |
707 movlw .64 | |
708 movwf lo | |
709 lfsr FSR1,0x740;pres_tissue_He+0 ; 16*4Byte Float = 64Bytes | |
710 end_dive_store_tissues_He_2: | |
711 movf POSTINC1,W | |
712 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
713 decfsz lo,F | |
714 bra end_dive_store_tissues_He_2 ; No | |
715 | |
716 ; Some deco stuff | |
717 movff char_I_depth_last_deco,WREG ; last stop [m] | |
718 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
719 movff char_I_deco_distance,WREG ; assumed distance to shown stop | |
720 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
721 | |
722 ; Last HUD data | |
723 movff hud_battery_mv+0,WREG ; Last HUD battery value | |
724 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
725 movff hud_battery_mv+1,WREG ; Last HUD battery value | |
726 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
727 movff hud_status_byte,WREG ; Last HUD status | |
728 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
729 | |
730 ; Battery gauge registers [nAs] | |
731 movff battery_gauge+0,WREG ; Battery gauge register | |
732 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
733 movff battery_gauge+1,WREG ; Battery gauge register | |
734 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
735 movff battery_gauge+2,WREG ; Battery gauge register | |
736 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
737 movff battery_gauge+3,WREG ; Battery gauge register | |
738 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
739 movff battery_gauge+4,WREG ; Battery gauge register | |
740 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
741 movff battery_gauge+5,WREG ; Battery gauge register | |
742 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
743 | |
744 ; Header stop | |
745 movlw 0xFB | |
746 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
747 movlw 0xFB | |
748 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | |
749 | |
750 call divemode_store_statistics ; Store/update statistics for this unit | |
751 | |
752 clrf surface_interval+0 | |
753 clrf surface_interval+1 ; Clear surface interval timer | |
754 | |
755 ghostwriter_end_dive_common: | |
756 ; Update ext_flash_log_pointer into EEPROM | |
757 clrf EEADRH | |
758 movff ext_flash_log_pointer+0,EEDATA | |
759 write_int_eeprom .4 | |
760 movff ext_flash_log_pointer+1,EEDATA | |
761 write_int_eeprom .5 | |
762 movff ext_flash_log_pointer+2,EEDATA | |
763 write_int_eeprom .6 | |
764 | |
765 bcf simulatormode_active ; if we were in simulator mode | |
766 | |
767 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | |
768 ifndef __DEBUG | |
769 extern deco_pull_tissues_from_vault | |
770 btfsc restore_deco_data ; Restore decodata? | |
771 call deco_pull_tissues_from_vault | |
772 banksel common ; Bank1 | |
773 endif | |
774 call update_battery_registers ; update battery registers into EEPROM | |
775 goto surfloop ; and return to surfaceloop | |
776 | |
777 global ghostwriter_short_header | |
778 ghostwriter_short_header: ; Write short header with divenumber into profile memory | |
779 | |
780 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive) | |
781 clrf EEADRH ; Make sure to select eeprom bank 0 | |
782 read_int_eeprom .4 | |
783 movff EEDATA,ext_flash_address+0 | |
784 read_int_eeprom .5 | |
785 movff EEDATA,ext_flash_address+1 | |
786 read_int_eeprom .6 | |
787 movff EEDATA,ext_flash_address+2 | |
788 | |
789 ; Clear dive length counter | |
790 clrf ext_flash_dive_counter+0 | |
791 clrf ext_flash_dive_counter+1 | |
792 clrf ext_flash_dive_counter+2 | |
793 | |
794 ; Write short header with divenumber into profile memory | |
795 movlw 0xFA | |
796 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
797 movlw 0xFA | |
798 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
799 ; Load total number of dives (low byte only) | |
800 read_int_eeprom .2 | |
801 incf EEDATA,W ;+1 | |
802 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
803 read_int_eeprom .3 | |
804 movf EEDATA,W | |
805 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
806 movlw 0xFA | |
807 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
808 movlw 0xFA | |
809 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
810 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive) | |
811 incf_ext_flash_address_0x20 d'3' ; Skip Bytes in external flash (faster) | |
812 | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
6
diff
changeset
|
813 movf samplingrate,W ; Sampling rate |
0 | 814 btfsc FLAG_apnoe_mode ; Apnoe mode? |
815 movlw samplingrate_apnoe ; Apnoe sampling rate | |
816 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
817 | |
818 movlw .7 ; Number of divisors | |
819 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
820 | |
821 movlw .0 ; Type | |
822 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
823 movlw infolength_temperature | |
824 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
825 movlw div_temperature ; Divisor temperature | |
826 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
827 | |
828 movlw .1 ; Type | |
829 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
830 movlw infolength_deco | |
831 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
832 movlw div_deco ; Divisor decodata | |
833 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
834 | |
835 movlw .2 ; Type | |
836 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
837 movlw infolength_gf | |
838 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
839 movlw div_gf ; Divisor gf | |
840 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
841 | |
842 movlw .3 ; Type | |
843 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
844 movlw infolength_ppo2_sensors | |
845 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
846 movlw div_ppo2_sensors ; Divisor ppO2 | |
847 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
848 | |
849 movlw .4 ; Type | |
850 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
851 movlw infolength_decoplan | |
852 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
853 movlw div_decoplan ; Divisor debug | |
854 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
855 | |
856 movlw .5 ; Type | |
857 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
858 movlw infolength_cns | |
859 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
860 movlw div_cns ; Divisor CNS | |
861 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
862 | |
863 movlw .6 ; Type | |
864 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
865 movlw infolength_tank | |
866 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
867 movlw div_tank ; Divisor Tank | |
868 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | |
869 | |
870 return | |
871 | |
872 calculate_noflytime: | |
873 ; calculate nofly time | |
874 movff int_O_desaturation_time+0,xA+0 | |
875 movff int_O_desaturation_time+1,xA+1 | |
876 | |
877 btfsc xA+1,7 ; Is desat time negative ? | |
878 bra calculate_noflytime_3 ; Then surely not valid ! | |
879 | |
880 tstfsz xA+0 ; Desat=0? | |
881 bra calculate_noflytime2 | |
882 tstfsz xA+1 ; Desat=0? | |
883 bra calculate_noflytime2 | |
884 | |
885 calculate_noflytime_3: | |
886 ; Desaturation time = zero | |
887 clrf nofly_time+0 ; Clear nofly time | |
888 clrf nofly_time+1 ; Clear nofly time | |
889 return | |
890 | |
891 calculate_noflytime2: | |
892 movff xA+0,int_I_temp+0 | |
893 movff xA+1,int_I_temp+1 | |
894 movlw no_fly_time_ratio ; nofly_time_ratio | |
895 movff WREG,char_I_temp | |
896 call deco_calc_percentage | |
897 movlb b'00000001' ; select ram bank 1 | |
898 movff int_I_temp+0,xA+0 | |
899 movff int_I_temp+1,xA+1 | |
900 tstfsz xA+0 ; Desat=0? | |
901 bra calculate_noflytime_2_final | |
902 tstfsz xA+1 ; Desat=0? | |
903 bra calculate_noflytime_2_final | |
904 bra calculate_noflytime_3 | |
905 | |
906 calculate_noflytime_2_final: | |
907 movff xA+0,nofly_time+0 | |
908 movff xA+1,nofly_time+1 | |
909 return | |
910 | |
911 | |
912 divemode_store_statistics: ; Store/update statistics for this unit | |
913 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi | |
914 | |
915 tstfsz lo ; lo=0? | |
916 bra change_logbook_offset1 ; No, adjust offset | |
917 tstfsz hi ; hi=0? | |
918 bra change_logbook_offset1 ; No, adjust offset | |
919 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | |
920 change_logbook_offset1: | |
921 movlw d'1' | |
922 addwf lo | |
923 movlw d'0' | |
924 addwfc hi | |
925 rcall do_logoffset_common_write ; lo:hi -> EEPROM | |
926 change_logbook_offset2: | |
927 ; Add more here... | |
928 return | |
929 | |
930 global do_logoffset_common_write | |
931 do_logoffset_common_write: | |
932 movff lo,EEDATA | |
933 write_int_eeprom 0x0D | |
934 movff hi,EEDATA | |
935 write_int_eeprom 0x0E | |
936 return | |
937 | |
938 global do_logoffset_common_read | |
939 do_logoffset_common_read: | |
940 clrf EEADRH | |
941 read_int_eeprom 0x0D | |
942 movff EEDATA,lo | |
943 read_int_eeprom 0x0E | |
944 movff EEDATA,hi ; Existing logbook offset into lo:hi | |
945 return | |
946 | |
947 | |
948 global update_battery_registers | |
949 update_battery_registers: | |
950 ; save battery_gauge:6 into EEPROM 0x07-0x0C | |
951 clrf EEADRH | |
952 movff battery_gauge+0,EEDATA | |
953 write_int_eeprom 0x07 | |
954 movff battery_gauge+1,EEDATA | |
955 write_int_eeprom 0x08 | |
956 movff battery_gauge+2,EEDATA | |
957 write_int_eeprom 0x09 | |
958 movff battery_gauge+3,EEDATA | |
959 write_int_eeprom 0x0A | |
960 movff battery_gauge+4,EEDATA | |
961 write_int_eeprom 0x0B | |
962 movff battery_gauge+5,EEDATA | |
963 write_int_eeprom 0x0C | |
964 bcf onehourupdate ; Clear flag | |
965 return | |
966 | |
967 | |
968 END |