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