annotate src/ghostwriter.asm @ 629:237931377539

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