annotate src/ghostwriter.asm @ 582:b455b31ce022

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