annotate src/ghostwriter.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents ca4556fb60b9
children cd58f7fc86db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
3 ; File ghostwriter.asm combined next generation V3.03.1
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 "tft_outputs.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
19 #include "divemode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
20 #include "rtc.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
21
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
22
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
23 extern deco_pull_tissues_from_vault
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
24
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
25
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
26 ; private local Variables
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
27
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
28 CBLOCK local3 ; max size is 16 Byte !!!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
29 divisor_temperature ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
30 divisor_deco ; divisor used to time the sampling of dive data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
31 divisor_supersat ; divisor used to time the sampling of dive data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
32 divisor_ppo2_sensors ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
33 divisor_decoplan ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
34 divisor_cns ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
35 divisor_tank ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
36 ProfileFlagByte ; used to store events
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
37 ENDC ; used: 8 byte, remaining: 8 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
38
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
39
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
40 ghostwriter CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
41
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
42 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
43
0
heinrichsweikamp
parents:
diff changeset
44
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
45 global init_recording_params ; initialize profile recording parameters
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
46 init_recording_params:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
47 movlw div_temperature ; get divisor for temperature storage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
48 movwf divisor_temperature ; initialize divisor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
49
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
50 movlw div_deco ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
51 movwf divisor_deco ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
52
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
53 movlw div_gf
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
54 movwf divisor_supersat
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
55
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
56 movlw div_decoplan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
57 movwf divisor_decoplan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
58
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
59 movlw div_cns
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
60 movwf divisor_cns
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
61
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
62 movlw div_tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
63 movwf divisor_tank
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
64
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
65 IFDEF _external_sensor
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
66 movlw div_ppo2_sensors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
67 movwf divisor_ppo2_sensors
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
68
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
69 btfsc FLAG_ccr_mode ; in CCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
70 bra init_recording_params_2 ; YES
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
71 btfsc FLAG_pscr_mode ; in pSCR mode?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
72 bra init_recording_params_2 ; YES
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
73 ; in all modes but CCR and pSCR, disable ppO2 logging
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
74 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
75 movwf divisor_ppo2_sensors
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
76 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
77
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
78 init_recording_params_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
79 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
80
0
heinrichsweikamp
parents:
diff changeset
81
heinrichsweikamp
parents:
diff changeset
82 global store_dive_data
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
83 store_dive_data:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
84 bcf trigger_sample_divedata ; clear flag
0
heinrichsweikamp
parents:
diff changeset
85
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
86 ifndef _DEBUG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
87 btfsc sensor_override_active ; in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
88 return ; YES - no dive data stored in simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
89 endif
0
heinrichsweikamp
parents:
diff changeset
90
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
91 btfss FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
92 bra store_dive_data_1 ; NO - proceed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
93 TSTOSS opt_store_apnoe_dive ; YES - logging in apnoe mode enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
94 return ; NO - done
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
95
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
96 store_dive_data_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
97 ; Store depth with every sample
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
98 movf pressure_rel_cur_cached+0,W ; get depth (relative pressure), low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
99 rcall ghostwrite_byte_profile ; store to profile in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
100 movf pressure_rel_cur_cached+1,W ; get depth (relative pressure), high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
101 rcall ghostwrite_byte_profile ; store to profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
102
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
103 ; First, find out how many bytes will be appended to this sample set
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
104 clrf ProfileFlagByte ; clear number of bytes to append
0
heinrichsweikamp
parents:
diff changeset
105
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
106 ; Check Extended Information
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
107 decfsz divisor_temperature,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
108 bra check_extended1 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
109 movlw infolength_temperature ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
110 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
111 check_extended1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
112 decfsz divisor_deco,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
113 bra check_extended2 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
114 movlw infolength_deco ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
115 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
116 check_extended2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
117 decfsz divisor_supersat,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
118 bra check_extended3 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
119 movlw infolength_gf ; YES - get length of extra data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
120 addwf ProfileFlagByte,F ; add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
121 check_extended3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
122 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
123 decfsz divisor_ppo2_sensors,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
124 bra check_extended4 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
125 movlw infolength_ppo2_sensors ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
126 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
127 ENDIF
0
heinrichsweikamp
parents:
diff changeset
128 check_extended4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
129 decfsz divisor_decoplan,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
130 bra check_extended5 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
131 movlw infolength_decoplan ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
132 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
133 check_extended5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
134 decfsz divisor_cns,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
135 bra check_extended6 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
136 movlw infolength_cns ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
137 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
138 check_extended6:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
139 decfsz divisor_tank,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
140 bra check_extended7 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
141 movlw infolength_tank ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
142 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
143 check_extended7:
heinrichsweikamp
parents:
diff changeset
144
heinrichsweikamp
parents:
diff changeset
145 ; Second, check global event flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
146 btfss event_occured ; check global event flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
147 bra store_dive_data3 ; no event
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
148
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
149 incf ProfileFlagByte,F ; add one byte (the event byte 1)
0
heinrichsweikamp
parents:
diff changeset
150
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
151 clrf event_byte1 ; reset event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
152 clrf event_byte2 ; reset event byte 2
0
heinrichsweikamp
parents:
diff changeset
153
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
154 movf alarm_type,W ; type of alarm Bit 0-3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
155 addwf event_byte1,F ; copy to event byte 1, bit 0-3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
156 clrf alarm_type ; reset alarm type
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
158 ; Third, check events and add additional bytes
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
159 btfss event_gas_change_gas6 ; did a change to gas 6 occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
160 bra check_event2 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
161 movlw d'2' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
162 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
163 bsf event_byte1,4 ; - set flag in event byte 1
0
heinrichsweikamp
parents:
diff changeset
164 check_event2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
165 btfss event_gas_change ; did a gas change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
166 bra check_event3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
167 movlw d'1' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
168 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
169 bsf event_byte1,5 ; - set flag in event byte 1
0
heinrichsweikamp
parents:
diff changeset
170 check_event3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
171 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
172 btfss event_SP_change ; did a setpoint change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
173 bra check_event4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
174 movlw d'1' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
175 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
176 bsf event_byte1,6 ; - set flag in event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
177 ENDIF
0
heinrichsweikamp
parents:
diff changeset
178 check_event4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
179 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
180 btfss event_bailout ; did a gas change due to bailout occur?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
181 bra check_event5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
182 movlw d'2' ; information length
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
183 addwf ProfileFlagByte,F ; add to ProfileFlagByte
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
184 bsf event_byte2,0 ; set flag in event byte 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
185 bsf event_byte1,7 ; =1: another event byte is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
186 ENDIF
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
187
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
188 check_event5:
0
heinrichsweikamp
parents:
diff changeset
189 ; more events?
heinrichsweikamp
parents:
diff changeset
190
heinrichsweikamp
parents:
diff changeset
191 store_dive_data3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
192 btfsc event_byte1,7 ; =1: another event byte is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
193 incf ProfileFlagByte,F ; add one byte (the event byte 2)
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
194
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
195 btfsc event_occured ; check global event flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
196 bsf ProfileFlagByte,7 ; set event byte 1 flag in ProfileFlagByte
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
197
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
198 movf ProfileFlagByte,W ; finally, write ProfileFlagByte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
199 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
200
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
201 btfss event_occured ; check global event flag (again)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
202 bra store_dive_data4 ; no event
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
203
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
204 ; Store the EventByte(s) + additional bytes now
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
205 movf event_byte1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
206 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
207 movf event_byte2,W ; write second event byte...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
208 btfsc event_byte1,7 ; =1: another event byte is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
209 rcall ghostwrite_byte_profile ; store that information
0
heinrichsweikamp
parents:
diff changeset
210
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
211 btfss event_gas_change_gas6 ; did a change to gas 6 occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
212 bra store_dive_data3b ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
213 movff char_I_O2_ratio,WREG ; YES - get gas 6 O2 ratio
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
214 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
215 IFDEF _helium
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
216 movff char_I_He_ratio,WREG ; - get gas 6 He ratio
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
217 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
218 clrf WREG ; - He ratio is zero
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
219 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
220 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
221 bcf event_gas_change_gas6 ; - clear event flag
0
heinrichsweikamp
parents:
diff changeset
222 store_dive_data3b:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
223 btfss event_gas_change ; did a gas change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
224 bra store_dive_data3c ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
225 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
226 movf active_dil,W ; YES - store active diluent (default, may be overwritten soon)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
227 btfsc FLAG_oc_mode ; - in OC mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
228 movf active_gas,W ; YES - get active gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
229 btfsc bailout_mode ; - in bailout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
230 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
231 movf active_gas,W ; YES - get active OC = bailout gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
232 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
233 bcf event_gas_change ; - clear event flag
0
heinrichsweikamp
parents:
diff changeset
234 store_dive_data3c:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
235 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
236 btfss event_SP_change ; did a setpoint change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
237 bra store_dive_data3d ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
238 movff char_I_const_ppO2,WREG ; YES - get setpoint
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
239 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
240 bcf event_SP_change ; - clear event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
241 ENDIF
0
heinrichsweikamp
parents:
diff changeset
242 store_dive_data3d:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
243 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
244 btfss event_bailout ; did a gas change due to bailout occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
245 bra store_dive_data4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
246 movff char_I_O2_ratio,WREG ; YES - get O2 ratio of bailout gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
247 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
248 IFDEF _helium
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
249 movff char_I_He_ratio,WREG ; - get He ratio of bailout gas
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
250 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
251 clrf WREG ; - He ratio is zero
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
252 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
253 rcall ghostwrite_byte_profile ; - store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
254 bcf event_bailout ; - clear event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
255 ENDIF ; _ccr_pscr
0
heinrichsweikamp
parents:
diff changeset
256 store_dive_data4:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
257 ; Store extended information
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
258 decfsz divisor_temperature,F ; time to store a temperature sample ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
259 bra store_extended1 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
260 rcall store_dive_temperature ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
261 store_extended1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
262 decfsz divisor_deco,F ; time to store the current deco data?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
263 bra store_extended2 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
264 rcall store_dive_decodata ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
265 store_extended2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
266 decfsz divisor_supersat,F ; time to store the current supersaturation ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
267 bra store_extended3 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
268 rcall store_dive_supersat ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
269 store_extended3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
270 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
271 decfsz divisor_ppo2_sensors,F ; decrement divisor, did it became 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
272 bra store_extended4 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
273 rcall store_dive_ppO2_sensors ; YES - store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
274 ENDIF
0
heinrichsweikamp
parents:
diff changeset
275 store_extended4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
276 decfsz divisor_decoplan,F ; decrement divisor, did it became 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
277 bra store_extended5 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
278 rcall store_dive_decoplan ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
279 store_extended5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
280 decfsz divisor_cns,F ; decrement divisor, did it became 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
281 bra store_extended6 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
282 rcall store_dive_cns ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
283 store_extended6:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
284 decfsz divisor_tank,F ; decrement divisor, did it became 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
285 bra store_extended7 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
286 rcall store_dive_tank ; YES - store data
0
heinrichsweikamp
parents:
diff changeset
287 store_extended7:
heinrichsweikamp
parents:
diff changeset
288
heinrichsweikamp
parents:
diff changeset
289 ; The next block is required to take care of "store never"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
290 btfsc divisor_temperature,7 ; test highest bit (register must have been zero before the "decfsz" command!)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
291 clrf divisor_temperature ; and clear register again, so it will never reach zero...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
292
0
heinrichsweikamp
parents:
diff changeset
293 btfsc divisor_deco,7
heinrichsweikamp
parents:
diff changeset
294 clrf divisor_deco
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
295
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
296 btfsc divisor_supersat,7
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
297 clrf divisor_supersat
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
298
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
299 IFDEF _external_sensor
0
heinrichsweikamp
parents:
diff changeset
300 btfsc divisor_ppo2_sensors,7
heinrichsweikamp
parents:
diff changeset
301 clrf divisor_ppo2_sensors
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
302 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
303
0
heinrichsweikamp
parents:
diff changeset
304 btfsc divisor_decoplan,7
heinrichsweikamp
parents:
diff changeset
305 clrf divisor_decoplan
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
306
0
heinrichsweikamp
parents:
diff changeset
307 btfsc divisor_cns,7
heinrichsweikamp
parents:
diff changeset
308 clrf divisor_cns
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
309
0
heinrichsweikamp
parents:
diff changeset
310 btfsc divisor_tank,7
heinrichsweikamp
parents:
diff changeset
311 clrf divisor_tank
heinrichsweikamp
parents:
diff changeset
312
heinrichsweikamp
parents:
diff changeset
313 store_dive_data5:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
314 bcf event_occured ; clear the global event flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
315 clrf event_byte1 ; reset event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
316 clrf event_byte2 ; reset event byte 2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
317 return ; done (sample with all informations written to external flash)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
318
0
heinrichsweikamp
parents:
diff changeset
319 store_dive_cns:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
320 movff int_O_CNS_current+0,WREG ; get current CNS, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
321 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
322 movff int_O_CNS_current+1,WREG ; get current CNS, high byte
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
323 bcf WREG,int_warning_flag ; clear warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
324 bcf WREG,int_attention_flag ; clear attention flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
325 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
326 movlw div_cns
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
327 movwf divisor_cns ; reload divisor from CF
0
heinrichsweikamp
parents:
diff changeset
328 return
heinrichsweikamp
parents:
diff changeset
329
heinrichsweikamp
parents:
diff changeset
330 store_dive_tank:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
331 ; OSTC TR tank pressure logging
0
heinrichsweikamp
parents:
diff changeset
332 movlw div_tank
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
333 movwf divisor_tank ; reload divisor from CF
0
heinrichsweikamp
parents:
diff changeset
334 return
heinrichsweikamp
parents:
diff changeset
335
heinrichsweikamp
parents:
diff changeset
336 store_dive_decoplan:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
337 ; Store the deco plan
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
338 lfsr FSR1,char_O_deco_time_for_log ; load base address of deco stop times table
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
339 movlw NUM_STOPS_LOG ; load size of deco stop times table
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
340 movwf lo ; copy size to loop counter
0
heinrichsweikamp
parents:
diff changeset
341 store_dive_decoplan_loop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
342 movf POSTINC1,W ; get a stop time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
343 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
344 decfsz lo,F ; decrement loop counter, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
345 bra store_dive_decoplan_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
346 movlw div_decoplan ; YES - get divisor for deco plan recording
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
347 movwf divisor_decoplan ; - reload timer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
348 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
349
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
350 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
351
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
352 IFDEF _external_sensor
0
heinrichsweikamp
parents:
diff changeset
353
heinrichsweikamp
parents:
diff changeset
354 store_dive_ppO2_sensors:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
355 movff sensor1_ppO2,WREG ; get sensor 1 ppO2 (in 0.01 bar steps)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
356 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
357 SMOVII sensor1_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor to hi:lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
358 movf lo,W ; in 0.1 mV steps, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
359 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
360 movf hi,W ; in 0.1 mV steps, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
361 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
362
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
363 movff sensor2_ppO2,WREG ; get sensor 2 ppO2 (in 0.01 bar steps)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
364 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
365 SMOVII sensor2_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor to hi:lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
366 movf lo,W ; in 0.1 mV steps, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
367 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
368 movf hi,W ; in 0.1 mV steps, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
369 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
370
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
371 movff sensor3_ppO2,WREG ; get sensor 3 ppO2 (in 0.01 bar steps)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
372 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
373 SMOVII sensor3_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor to hi:lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
374 movf lo,W ; in 0.1 mV steps, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
375 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
376 movf hi,W ; in 0.1 mV steps, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
377 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
378
heinrichsweikamp
parents:
diff changeset
379 movlw div_ppo2_sensors
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
380 movwf divisor_ppo2_sensors ; reload timer
0
heinrichsweikamp
parents:
diff changeset
381 return
heinrichsweikamp
parents:
diff changeset
382
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
383 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
384
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
385 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
386
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
387 store_dive_supersat:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
388 movff int_O_lead_supersat+0,WREG ; get leading tissue's supersaturation (value is limited to 255, only lower byte is used for the value)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
389 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
390 movlw div_gf
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
391 movwf divisor_supersat ; reload timer
0
heinrichsweikamp
parents:
diff changeset
392 return
heinrichsweikamp
parents:
diff changeset
393
heinrichsweikamp
parents:
diff changeset
394 store_dive_decodata:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
395 ; Check if deco stops are necessary
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
396 movff char_O_deco_depth,WREG ; get depth of the first stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
397 tstfsz WREG ; depth of first stop > 0 m (aka in deco) ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
398 bra store_dive_decodata_deco ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
399 ; NO - within NDL
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
400 clrf WREG ; =0: no stop dive
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
401 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
402 movff char_O_NDL_norm,WREG ; get NDL time in normal plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
403 rcall ghostwrite_byte_profile ; store it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
404 bra store_dive_decodata_common
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
405 store_dive_decodata_deco:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
406 ; YES - in deco
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
407 movff char_O_deco_depth,WREG ; get depth of the first stop in meters
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
408 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
409 movff char_O_deco_time,WREG ; get time of the first stop in minutes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
410 rcall ghostwrite_byte_profile ; store it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
411 store_dive_decodata_common:
0
heinrichsweikamp
parents:
diff changeset
412 movlw div_deco
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
413 movwf divisor_deco ; reload timer
0
heinrichsweikamp
parents:
diff changeset
414 return
heinrichsweikamp
parents:
diff changeset
415
heinrichsweikamp
parents:
diff changeset
416 store_dive_temperature:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
417 SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature to hi:lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
418 movf lo,W ; get low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
419 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
420 movf hi,W ; get high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
421 rcall ghostwrite_byte_profile ; store it
0
heinrichsweikamp
parents:
diff changeset
422 movlw div_temperature
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
423 movwf divisor_temperature ; reload timer
0
heinrichsweikamp
parents:
diff changeset
424 return
heinrichsweikamp
parents:
diff changeset
425
heinrichsweikamp
parents:
diff changeset
426 ghostwrite_byte_header:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
427 goto write_byte_ext_flash_plus_header ; (this call will also delete the 4kB TOC entry first)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
428 ; returns...
0
heinrichsweikamp
parents:
diff changeset
429
heinrichsweikamp
parents:
diff changeset
430 ghostwrite_byte_profile:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
431 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
432 ; returns...
0
heinrichsweikamp
parents:
diff changeset
433
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
434
0
heinrichsweikamp
parents:
diff changeset
435 global ghostwriter_end_dive
heinrichsweikamp
parents:
diff changeset
436 ghostwriter_end_dive:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
437 ; save end-of-profile pointer to store in header
0
heinrichsweikamp
parents:
diff changeset
438 movff ext_flash_address+0,ext_flash_log_pointer+0
heinrichsweikamp
parents:
diff changeset
439 movff ext_flash_address+1,ext_flash_log_pointer+1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
440 movff ext_flash_address+2,ext_flash_log_pointer+2
0
heinrichsweikamp
parents:
diff changeset
441
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
442 ; remember last custom view shown in dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
443 movff active_customview,customview_divemode
39
e4e91fe8b09d remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents: 35
diff changeset
444
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
445 btfss divetime_longer_1min ; dive longer then one minute
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
446 goto ghostwriter_end_dive_common ; NO - discard everything
0
heinrichsweikamp
parents:
diff changeset
447
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
448 ; In DEBUG compile, write simulated dives to logbook
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
449 ifndef _DEBUG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
450 btfsc sensor_override_active ; are we in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
451 goto ghostwriter_end_dive_common ; YES - discard everything
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
452 endif
0
heinrichsweikamp
parents:
diff changeset
453
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
454 btfss FLAG_apnoe_mode ; are we in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
455 bra ghostwriter_end_dive_1 ; NO - proceed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
456 TSTOSS opt_store_apnoe_dive ; YES - logging in apnoe mode enabled?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
457 goto ghostwriter_end_dive_common ; NO - discard everything
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
458
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
459 ghostwriter_end_dive_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
460 ; Dive finished (and longer than one minute)
0
heinrichsweikamp
parents:
diff changeset
461
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
462 btfsc FLAG_apnoe_mode ; are we in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
463 call apnoe_calc_maxdepth ; YES - calculate max. depth (again) for very short apnoe dives
0
heinrichsweikamp
parents:
diff changeset
464
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
465 movlw 0xFD ; coding for End-of-Profile, byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
466 rcall ghostwrite_byte_profile ; store it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
467 movlw 0xFD ; coding for End-of-Profile, byte 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
468 rcall ghostwrite_byte_profile ; store it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
469
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
470 ; Save end-of-profile pointer to store in header
0
heinrichsweikamp
parents:
diff changeset
471 movff ext_flash_address+0,ext_flash_log_pointer+0
heinrichsweikamp
parents:
diff changeset
472 movff ext_flash_address+1,ext_flash_log_pointer+1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
473 movff ext_flash_address+2,ext_flash_log_pointer+2
0
heinrichsweikamp
parents:
diff changeset
474
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
475 ; Set to first address again to store dive length ext_flash_dive_counter:3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
476 rcall ghostwriter_load_pointer ; load ext_flash_address:3 from EEPROM .4-.6
0
heinrichsweikamp
parents:
diff changeset
477
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
478 incf_ext_flash_address_0x20 d'6' ; skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
479 ; Store dive length
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
480 movf ext_flash_dive_counter+0,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
481 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
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
482 movf ext_flash_dive_counter+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
483 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
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
484 movf ext_flash_dive_counter+2,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
485 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
486
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
487 ; profile recording done
0
heinrichsweikamp
parents:
diff changeset
488
heinrichsweikamp
parents:
diff changeset
489 ; Load total number of dives
heinrichsweikamp
parents:
diff changeset
490 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
491 movff EEDATA,lo
heinrichsweikamp
parents:
diff changeset
492 read_int_eeprom .3
heinrichsweikamp
parents:
diff changeset
493 movff EEDATA,hi
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
494
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
495 INCI mpr ; increase total dive counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
496
0
heinrichsweikamp
parents:
diff changeset
497 ; Store new number in EEPROM
heinrichsweikamp
parents:
diff changeset
498 movff lo,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
499 write_int_eeprom .2
0
heinrichsweikamp
parents:
diff changeset
500 movff hi,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
501 write_int_eeprom .3
0
heinrichsweikamp
parents:
diff changeset
502
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
503 decf lo,F ; -1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
504
0
heinrichsweikamp
parents:
diff changeset
505 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
506 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
507 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
508 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
509 ; 255: 2FF000h-2FFFFFh -> lo=255
heinrichsweikamp
parents:
diff changeset
510
heinrichsweikamp
parents:
diff changeset
511 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
512 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
513 movlw 0x20
heinrichsweikamp
parents:
diff changeset
514 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
515 movlw .16
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
516 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
0
heinrichsweikamp
parents:
diff changeset
517 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
518 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
519 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
520 addwfc ext_flash_address+2,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
521
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
522 ; write header start code
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
523 movlw 0xFA ; header start
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
524 rcall ghostwrite_byte_header ; (this call will also delete the 4kB TOC entry first)
0
heinrichsweikamp
parents:
diff changeset
525 movlw 0xFA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
526 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
527
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
528 ; store pointer to begin of dive profile
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
529 read_int_eeprom .4
0
heinrichsweikamp
parents:
diff changeset
530 movf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
531 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
532 read_int_eeprom .5
0
heinrichsweikamp
parents:
diff changeset
533 movf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
534 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
535 read_int_eeprom .6
0
heinrichsweikamp
parents:
diff changeset
536 movf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
537 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
538
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
539 ; store pointer to end of dive profile
0
heinrichsweikamp
parents:
diff changeset
540 movf ext_flash_log_pointer+0,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
541 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
542 movf ext_flash_log_pointer+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
543 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
544 movf ext_flash_log_pointer+2,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
545 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
546
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
547 ; write the remainder of the header
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
548 movlw logbook_profile_version ; defined in hwos.inc
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
549 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
550
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
551 ; store dive length
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
552 movf ext_flash_dive_counter+0,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
553 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
554 movf ext_flash_dive_counter+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
555 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
556 movf ext_flash_dive_counter+2,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
557 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
558
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
559 ; store start of time time & date
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
560 lfsr FSR0,start_year ; load base address of start-of-dive data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
561 movf POSTINC0,W ; year
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
562 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
563 movf POSTINC0,W ; month
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
564 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
565 movf POSTINC0,W ; day
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
566 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
567 movf POSTINC0,W ; hour
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
568 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
569 movf POSTINC0,W ; minute
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
570 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
571
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
572 btfss FLAG_apnoe_mode ; store apnoe max or normal max (which is only max from the last descent)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
573 bra end_dive1 ; store normal depth
0
heinrichsweikamp
parents:
diff changeset
574
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
575 ; apnoe max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
576 MOVII apnoe_max_pressure,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
577 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
578 MOVII mpr,apnoe_max_pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
579 bra end_dive2 ; store max depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
580
0
heinrichsweikamp
parents:
diff changeset
581 end_dive1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
582 ; normal max depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
583 MOVII pressure_rel_max_cached,mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
584 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
585 MOVII mpr,pressure_rel_max_cached
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
586
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
587 end_dive2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
588 ; store max depth (common part)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
589 movf lo,W ; max. depth, low byte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
590 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
591 movf hi,W ; max. depth, high byte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
592 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
593
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
594 ; store dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
595 SMOVTT counted_divetime_mins,mpr ; ISR-safe 3 byte copy of minutes:2 and seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
596 movf mpr+0,W ; dive time minutes, low byte
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
597 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
598 movf mpr+1,W ; dive time minutes, high byte
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
599 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
600 movf mpr+2,W ; dive time seconds
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
601 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
0
heinrichsweikamp
parents:
diff changeset
602
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
603 ; store minimum temperature
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
604 movff temperature_min+0,WREG ; minimum temperature, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
605 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
606 movff temperature_min+1,WREG ; minimum temperature, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
607 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
608
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
609 ; store surface pressure (as used by deco engine)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
610 movff int_I_pres_surface+0,WREG ; surface pressure, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
611 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
612 movff int_I_pres_surface+1,WREG ; surface pressure, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
613 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
614
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
615 ; store desaturation time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
616 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
617 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
618 movff int_O_desaturation_time+1,WREG ; desaturation time in minutes, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
619 rcall ghostwrite_byte_header ; WREG -> header in ext. flash
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
620
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
621 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
622 btfsc FLAG_ccr_mode ; in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
623 bra end_dive_dil_gaslist ; YES - write diluent gas list
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
624 btfsc FLAG_pscr_mode ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
625 bra end_dive_dil_gaslist ; YES - write diluent gas list
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
626 ENDIF
0
heinrichsweikamp
parents:
diff changeset
627
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
628 end_dive_oc_gaslist: ; write OC gases
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
629 lfsr FSR0,opt_gas_O2_ratio-.1 ; set base address to (opt_gas_O2_ratio - 1) because of pre-increment statement
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
630 bra end_dive_gaslist ; write all 5 OC gases
0
heinrichsweikamp
parents:
diff changeset
631
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
632 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
633 end_dive_dil_gaslist: ; write diluents
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
634 lfsr FSR0,opt_dil_O2_ratio-.1 ; set base address to (opt_dil_O2_ratio - 1) because of pre-increment statement
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
635 ;bra end_dive_gaslist ; write all 5 diluents
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
636 ENDIF
0
heinrichsweikamp
parents:
diff changeset
637
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
638 end_dive_gaslist: ; helper function for writing gas list entries
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
639 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
640 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
641 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
642 ; opt_gas_O2_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
643 ; opt_dil_O2_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
644 ; opt_gas_He_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
645 ; opt_dil_He_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
646 ; opt_gas_type res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
647 ; opt_dil_type res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
648 ; opt_gas_change res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
649 ; opt_dil_change res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
650 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
651 movlw .5 ; 5 gases to store
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
652 movwf lo ; use lo as counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
653 end_dive_gaslist_loop:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
654 movf PREINC0,W ; increment base address and get O2 ratio into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
655 rcall ghostwrite_byte_header ; store data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
656 movlw .10 ; offset for H2 ratios
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
657 movf PLUSW0,W ; get H2 ratio into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
658 rcall ghostwrite_byte_header ; store data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
659 movlw .30 ; offset for change depths
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
660 movf PLUSW0,W ; get change depth into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
661 rcall ghostwrite_byte_header ; store data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
662 movlw .20 ; offset for types
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
663 movf PLUSW0,W ; get type into WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
664 rcall ghostwrite_byte_header ; store data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
665 decfsz lo ; decrement counter, did it became 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
666 bra end_dive_gaslist_loop ; NO - loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
667 ;bra end_dive_oc_cc_common ; YES - done
0
heinrichsweikamp
parents:
diff changeset
668
heinrichsweikamp
parents:
diff changeset
669 end_dive_oc_cc_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
670 movlw softwareversion_x ; get firmware version X (major)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
671 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
672 movlw softwareversion_y ; get firmware version Y (minor)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
673 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
674
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
675 ; store battery voltage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
676 movf batt_voltage+0,W ; get battery voltage, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
677 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
678 movf batt_voltage+1,W ; get battery voltage, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
679 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
680
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
681 ; store sampling rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
682 movf sampling_rate,W ; get sampling rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
683 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
684
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
685 ; store CNS at beginning of dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
686 movf CNS_start+0,W ; get CNS at start of dive, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
687 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
688 movf CNS_start+1,W ; get CNS at start of dive, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
689 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
690
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
691 ; store gradient factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
692 movff supersat_start,WREG ; get supersaturation at start of dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
693 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
694 movff int_O_lead_supersat+0,WREG ; get supersaturation at end of dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
695 rcall ghostwrite_byte_header ; store data
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
696
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
697 ; store logbook offset
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
698 call do_logoffset_common_read ; read into mpr:2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
699 movf mpr+0,W
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
700 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
701 movf mpr+1,W
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
702 rcall ghostwrite_byte_header ; store data
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
703
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
704 ; store battery info at Byte 59
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
705 movf batt_percent,W ; 0-100%
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
706 rcall ghostwrite_byte_header ; store data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
707
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
708 ; store setpoints
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
709 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
710 lfsr FSR0,opt_setpoint_cbar ; base address of ppO2 values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
711 lfsr FSR1,opt_setpoint_change ; base address of change depths
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
712 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
713 movlw .5 ; 5 setpoints to be stored
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
714 movwf lo ; use lo as counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
715 end_dive_sp_loop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
716 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
717 movf POSTINC0,W ; get ppO2 value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
718 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
719 clrf WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
720 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
721 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
722 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
723 movf POSTINC1,W ; get change depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
724 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
725 clrf WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
726 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
727 rcall ghostwrite_byte_header ; store data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
728 decfsz lo ; decrement counter, did it became 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
729 bra end_dive_sp_loop ; NO - loop
0
heinrichsweikamp
parents:
diff changeset
730
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
731 ; store salinity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
732 movff opt_salinity,WREG ; get salinity (0-4%)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
733 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
734
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
735 ; store CNS at end of dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
736 movff int_O_CNS_current+0,WREG ; get current CNS, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
737 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
738 movff int_O_CNS_current+1,WREG ; get current CNS, high byte
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
739 bcf WREG,int_warning_flag ; clear warning flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
740 bcf WREG,int_attention_flag ; clear attention flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
741 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
742
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
743 ; store average depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
744 movff pressure_rel_avg_total+0,WREG ; get total dive average depth, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
745 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
746 movff pressure_rel_avg_total+1,WREG ; get total dive average depth, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
747 rcall ghostwrite_byte_header ; store data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
748
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
749 ; store total dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
750 SMOVII total_divetime_secs,mpr ; ISR-safe 2 byte copy of the total dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
751 movff mpr+0,WREG ; total dive time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
752 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
753 movff mpr+1,WREG ; total dive time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
754 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
755
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
756 ; store GF low or saturation multiplier
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
757 movff char_I_GF_Low_percentage,WREG ; get GF_lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
758 movff char_I_deco_model,lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
759 decfsz lo,F ; skip next line if char_I_deco_model == 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
760 movff char_I_saturation_multiplier,WREG ; get saturation multiplier
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
761 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
762
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
763 ; store GF high or desaturation multiplier
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
764 movff char_I_GF_High_percentage,WREG ; get GF_hi
0
heinrichsweikamp
parents:
diff changeset
765 movff char_I_deco_model,lo
heinrichsweikamp
parents:
diff changeset
766 decfsz lo,F ; jump over next line if char_I_deco_model == 1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
767 movff char_I_desaturation_multiplier,WREG ; get desaturation multiplier
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
768 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
769
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
770 ; store deco model
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
771 movff char_I_deco_model,WREG ; get deco model (0 = ZH-L16, 1 = ZH-L16-GF)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
772 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
773
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
774 ; store total dive number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
775 read_int_eeprom .2 ; get total dive counter, low
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
776 movf EEDATA,W ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
777 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
778 read_int_eeprom .3 ; get total dive counter, high
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
779 movf EEDATA,W ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
780 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
781
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
782 ; store deco mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
783 movff opt_dive_mode,WREG ; get deco mode (0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
784 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
785
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
786 ; store tissue data - N2 chars
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
787 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
788 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
789 lfsr FSR1,char_O_tissue_pres_N2
0
heinrichsweikamp
parents:
diff changeset
790 end_dive_store_tissues_N2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
791 movf POSTINC1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
792 bcf WREG,7 ; clear flag bit for on-gassing/off-gassing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
793 rcall ghostwrite_byte_header ; store data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
794 decfsz lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
795 bra end_dive_store_tissues_N2 ; NO
0
heinrichsweikamp
parents:
diff changeset
796
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
797 ; store tissue data - N2 floats
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
798 movlw .64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
799 movwf lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
800 lfsr FSR1,0x700 ; pres_tissue_N2+0 ; 16*4 Byte Float = 64 Bytes
0
heinrichsweikamp
parents:
diff changeset
801 end_dive_store_tissues_N2_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
802 movf POSTINC1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
803 rcall ghostwrite_byte_header ; store data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
804 decfsz lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
805 bra end_dive_store_tissues_N2_2 ; NO
0
heinrichsweikamp
parents:
diff changeset
806
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
807 ; store tissue data - He chars
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
808 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
809 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
810 lfsr FSR1,char_O_tissue_pres_He
0
heinrichsweikamp
parents:
diff changeset
811 end_dive_store_tissues_He:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
812 movf POSTINC1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
813 bcf WREG,7 ; clear flag bit for on-gassing/off-gassing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
814 rcall ghostwrite_byte_header ; store data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
815 decfsz lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
816 bra end_dive_store_tissues_He ; NO
0
heinrichsweikamp
parents:
diff changeset
817
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
818 ; store tissue data - He floats
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
819 movlw .64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
820 movwf lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
821 lfsr FSR1,0x740 ; pres_tissue_He+0 ; 16*4 Byte Float = 64 Bytes
0
heinrichsweikamp
parents:
diff changeset
822 end_dive_store_tissues_He_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
823 movf POSTINC1,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
824 rcall ghostwrite_byte_header ; store data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
825 decfsz lo,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
826 bra end_dive_store_tissues_He_2 ; NO
0
heinrichsweikamp
parents:
diff changeset
827
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
828 ; store last stop depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
829 movff char_I_depth_last_deco,WREG ; get last stop depth [m]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
830 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
831
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
832 ; store deco distance
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
833 movff char_I_deco_distance,WREG ; get assumed distance to shown stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
834 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
835
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
836 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
837 ; store last HUD data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
838 SMOVTT hud_status_byte,mpr ; ISR-safe 3 byte copy of last HUD status (1 byte) and battery voltage (2 byte)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
839 movff mpr+1,WREG ; HUD battery value, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
840 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
841 movff mpr+2,WREG ; HUD battery value, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
842 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
843 movff mpr+0,WREG ; HUD status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
844 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
845 ELSE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
846 ; store dummy data to keep format
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
847 clrf WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
848 rcall ghostwrite_byte_header ; store null byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
849 clrf WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
850 rcall ghostwrite_byte_header ; store null byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
851 clrf WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
852 rcall ghostwrite_byte_header ; store null byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
853 ENDIF
0
heinrichsweikamp
parents:
diff changeset
854
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
855 ; store battery gauge registers [nAs]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
856 SMOVSS battery_gauge,mpr ; ISR-safe 6 byte copy of battery gauge value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
857 movf mpr+0,W ; get byte 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
858 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
859 movf mpr+1,W ; get byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
860 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
861 movf mpr+2,W ; get byte 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
862 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
863 movf mpr+3,W ; get byte 3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
864 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
865 movf mpr+4,W ; get byte 4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
866 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
867 movf mpr+5,W ; get byte 5
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
868 rcall ghostwrite_byte_header ; store data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
869
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
870 ; write header stop code
0
heinrichsweikamp
parents:
diff changeset
871 movlw 0xFB
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
872 rcall ghostwrite_byte_header ; store data
0
heinrichsweikamp
parents:
diff changeset
873 movlw 0xFB
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
874 rcall ghostwrite_byte_header ; store data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
875
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
876 call divemode_store_statistics ; store/update statistics for this unit
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
877 bsf reset_surface_interval ; request ISR to reset the surface interval timer
0
heinrichsweikamp
parents:
diff changeset
878
heinrichsweikamp
parents:
diff changeset
879 ghostwriter_end_dive_common:
heinrichsweikamp
parents:
diff changeset
880 ; Update ext_flash_log_pointer into EEPROM
heinrichsweikamp
parents:
diff changeset
881 clrf EEADRH
heinrichsweikamp
parents:
diff changeset
882 movff ext_flash_log_pointer+0,EEDATA
heinrichsweikamp
parents:
diff changeset
883 write_int_eeprom .4
heinrichsweikamp
parents:
diff changeset
884 movff ext_flash_log_pointer+1,EEDATA
heinrichsweikamp
parents:
diff changeset
885 write_int_eeprom .5
heinrichsweikamp
parents:
diff changeset
886 movff ext_flash_log_pointer+2,EEDATA
heinrichsweikamp
parents:
diff changeset
887 write_int_eeprom .6
heinrichsweikamp
parents:
diff changeset
888
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
889 ; In DEBUG compile, write simulated dives to logbook and keep tissue pressures from simulation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
890 btfss simulatormode ; in simulator mode, i.e. need to restore tissue pressures?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
891 bra ghostwriter_end_dive_common_1 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
892 bcf simulatormode ; YES - clear mode flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
893 ifndef _DEBUG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
894 call deco_pull_tissues_from_vault ; - restore tissue pressures (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
895 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
896 endif
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
897
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
898 ghostwriter_end_dive_common_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
899 bsf reset_timebase ; request ISR to reset the timebase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
900 ; btfsc reset_timebase ; has the ISR confirmed reset of timebase?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
901 ; bra $-2 ; NO - not yet, loop waiting for the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
902 bcf sensor_override_request ; request ISR to terminate the simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
903 btfsc sensor_override_active ; has the ISR confirmed termination of simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
904 bra $-2 ; NO - not yet, loop waiting for the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
905 call update_battery_registers ; update battery registers into EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
906 movff simulator_time,char_I_dive_interval ; get the simulator runtime, reads 0 if exiting from a real dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
907 call deco_calc_dive_interval ; catch up with tissue desaturation when exiting from simulator,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
908 ; else calculates for 2 seconds only when exiting from a real dive,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
909 ; needed to update CNS, GF and tissue graphics for surface display (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
910 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time after catch-up (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
911 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
912
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
913 ; the last surface pressure sample may have been taken while being submerged a bit already,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
914 ; therefore it will be replaced by the sample taken one more before, which is the one that
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
915 ; became the surface pressure reference used while this dive.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
916 MOVII pressure_abs_ref,pressure_abs_sampled
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
917
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
918 goto surfloop ; done with post-dive operations, return to surface loop
166
30ebaf72170d BUGFIX: Flip compass with flipped screen, too
heinrichsweikamp
parents: 147
diff changeset
919
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
920
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
921 ghostwriter_load_pointer: ; load ext_flash_address:3 from EEPROM .4-.6
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
922 clrf EEADRH ; make sure to select EEPROM bank 0
0
heinrichsweikamp
parents:
diff changeset
923 read_int_eeprom .4
heinrichsweikamp
parents:
diff changeset
924 movff EEDATA,ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
925 read_int_eeprom .5
heinrichsweikamp
parents:
diff changeset
926 movff EEDATA,ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
927 read_int_eeprom .6
heinrichsweikamp
parents:
diff changeset
928 movff EEDATA,ext_flash_address+2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
929 return
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
930
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
931 ghostwriter_short_header_init: ; proceed one page forward
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
932 clrf EEDATA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
933 write_int_eeprom .4 ; ext_flash_address+0 = 0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
934 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
935 addwf ext_flash_address+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
936 movlw .0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
937 addwfc ext_flash_address+2,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
938 movlw 0x20
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
939 cpfseq ext_flash_address+2 ; at address 0x200000?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
940 bra ghostwriter_short_header_init2 ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
941 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
942 ghostwriter_short_header_init2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
943 movlw 0xF0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
944 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
945
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
946 movff ext_flash_address+1,EEDATA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
947 write_int_eeprom .5 ; write new pointer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
948 movff ext_flash_address+2,EEDATA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
949 write_int_eeprom .6 ; write new pointer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
950 bra ghostwriter_short_header2 ; Done
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
951
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
952
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
953 global ghostwriter_short_header
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
954 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
955 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
956 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
957
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
958 ; 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
959 ; stored correctly. e.g. after a battery fail during the dive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
960 call ext_flash_byte_read_plus_0x20 ; into ext_flash_rw
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
961 incfsz ext_flash_rw,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
962 bra ghostwriter_short_header_init ; not 0xFF -> init page
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
963 call ext_flash_byte_read_plus_0x20 ; into ext_flash_rw
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
964 incfsz ext_flash_rw,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
965 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
966
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
967 ghostwriter_short_header2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
968 ; All ok, reload the pointer and start
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
969 rcall ghostwriter_load_pointer ; load ext_flash_address:3 from EEPROM .4-.6
0
heinrichsweikamp
parents:
diff changeset
970
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
971 ; Clear dive length counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
972 clrf ext_flash_dive_counter+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
973 clrf ext_flash_dive_counter+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
974 clrf ext_flash_dive_counter+2
0
heinrichsweikamp
parents:
diff changeset
975
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
976 ; Write short header with dive number into profile memory
0
heinrichsweikamp
parents:
diff changeset
977 movlw 0xFA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
978 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
979 movlw 0xFA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
980 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
981 ; Load total number of dives (low byte only)
heinrichsweikamp
parents:
diff changeset
982 read_int_eeprom .2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
983 incf EEDATA,W ; +1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
984 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
985 read_int_eeprom .3
heinrichsweikamp
parents:
diff changeset
986 movf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
987 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
988 movlw 0xFA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
989 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
990 movlw 0xFA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
991 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
992
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
993 ; 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
994 ; Writing 0xFF three times here is mandatory
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
995 ; - 0xFF can be overwritten after the dive
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
996 ; - ghostwrite_byte_profile takes care of 4kB Page switching
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
997 ; - 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
998
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
999 movlw 0xFF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1000 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1001 movlw 0xFF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1002 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1003 movlw 0xFF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1004 call write_byte_ext_flash_plus_nocnt ; WREG -> profile in ext. flash (No ext_flash_dive_counter:3 increase)
0
heinrichsweikamp
parents:
diff changeset
1005
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1006 movf sampling_rate,W ; get sampling rate
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1007 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1008
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1009 movlw .7 ; number of divisors
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1010 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1011
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1012 movlw .0 ; type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1013 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1014 movlw infolength_temperature
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1015 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1016 movlw div_temperature ; divisor temperature
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1017 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1018
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1019 movlw .1 ; Type
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1020 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1021 movlw infolength_deco
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1022 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1023 movlw div_deco ; divisor deco data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1024 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1025
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1026 movlw .2 ; type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1027 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1028 movlw infolength_gf
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1029 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1030 movlw div_gf ; divisor gf
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1031 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1032
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1033 movlw .3 ; type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1034 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1035 movlw infolength_ppo2_sensors
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1036 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1037 movlw div_ppo2_sensors ; divisor ppO2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1038 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1039 movlw .0 ; no ppO2 data in OC mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1040 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1041
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1042 movlw .4 ; type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1043 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1044 movlw infolength_decoplan
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1045 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1046 movlw div_decoplan ; divisor debug
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1047 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1048
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1049 movlw .5 ; Type
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1050 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1051 movlw infolength_cns
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1052 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1053 movlw div_cns ; divisor CNS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1054 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1055
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1056 movlw .6 ; Type
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1057 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1058 movlw infolength_tank
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1059 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1060 movlw div_tank ; divisor tank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1061 rcall ghostwrite_byte_profile ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
1062
heinrichsweikamp
parents:
diff changeset
1063 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1064
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1065 divemode_store_statistics: ; store/update statistics for this unit
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1066 call vault_decodata_into_eeprom ; update deco data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1067 call do_logoffset_common_read ; read current logbook offset into mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1068
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1069 tstfsz lo ; offset, low byte = 0 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1070 bra change_logbook_offset1 ; NO - adjust offset
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1071 tstfsz hi ; offset, high byte = 0 ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
1072 bra change_logbook_offset1 ; NO - adjust offset
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1073 bra change_logbook_offset2 ; YES to both - skip offset routine
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1074
0
heinrichsweikamp
parents:
diff changeset
1075 change_logbook_offset1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1076 INCI mpr ; increment offset
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1077 call do_logoffset_common_write ; write incremented offset as the new offset
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1078
0
heinrichsweikamp
parents:
diff changeset
1079 change_logbook_offset2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1080 clrf mpr+0 ; prepare a 4 byte null value to clear the last dive time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1081 clrf mpr+1 ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1082 clrf mpr+2 ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1083 clrf mpr+3 ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1084 SMOVFF mpr,lastdive_time ; ISR-safe 4 byte copy of null value to last dive time counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1085
453
b4f28ab23b87 NEW: Show Uptime (Time since last firmware boot) in information menu
heinrichsweikamp
parents: 437
diff changeset
1086
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1087 ; ISR-safe 3 byte copy of minutes:2 and seconds to last dive duration
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1088 SMOVTT counted_divetime_mins,lastdive_duration
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1089
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1090 ; 2 byte copies of max and avg relative pressures to last dive data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1091 MOVII pressure_rel_max_cached,lastdive_maxdepth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1092 MOVII pressure_rel_avg_total, lastdive_avgdepth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
1093
0
heinrichsweikamp
parents:
diff changeset
1094 return
heinrichsweikamp
parents:
diff changeset
1095
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
1096 END