annotate src/ghostwriter.asm @ 604:ca4556fb60b9

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