Mercurial > public > ostc4
annotate Discovery/Src/logbook.c @ 471:73da921869d9 fix-bat-2
bugfix: implement battery charge percentage in dive header
This commit is (much) less trivial than the related 919e5cb51c92.
First, rename the CCRmode attribute (corresponding to byte Ox59) of
the SLogbookHeaderOSTC3. This byte (according to the hwOS interface
document) does not contain any CCR related value, but it contains
"battery information". Already since 2017, this byte is used from
libdivecomputer to interface the charge percentage. So, its
renamed from CCRmode to batteryCharge, to reflect its true purpose.
Now, simply add a batteryCharge attribute to the SLogbookHeader
(and see below why that is possible, without breaking things).
The remaining changes are trivial to implement battery charge
percentage in dive header.
Caveat: do not get confused by the exact role of the individual
logbook header types. SLogbookHeaderOSTC3 is the formal type of
the logbook format that the OSTC4 produces. This format is
supposed to identical to the format, as is used in hwOS for the
series of small OSTCs. Only some values of attributes are different.
For example, the OSTC4 supports VPM, so byte 0x79 (deco model used
for this dive) also has a value for VPM. But the SLogbookHeader
type, despite its name and structure, is *not* a true logbook
header, as it includes attributes that are not available in the
SLogbookHeaderOSTC3 formal header type.
Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Wed, 22 Apr 2020 13:08:57 +0200 |
parents | 2c2df051e554 |
children | 90d1f793dcf2 |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @copyright heinrichs weikamp | |
4 * @file logbook.c | |
5 * @author heinrichs weikamp gmbh and heinrichs weikamp gmbh | |
6 * @date 22-Apr-2014 | |
7 * @version V0.0.3 | |
8 * @since 03-Feb-2016 | |
9 * @brief Everything about creating and evaluating the logbook | |
10 * without the flash part which is included in externLogbookFlash.c | |
11 * and the USB/Bluetooth part in tComm.c | |
12 * CHANGE V0.0.3 hw: ppO2 sensor values | |
13 * CHANGE V0.0.4 hw: fix event bytes according to hwos_interface.odt dated 160610 in bitbucket hwOS | |
14 * @bug | |
15 * @warning | |
16 @verbatim | |
17 ============================================================================== | |
18 ##### Header ##### | |
19 ============================================================================== | |
20 [..] SLogbookHeader | |
21 The order has changed in comparsion to OSTC3 for perfect alignment | |
22 with 16bit and 32bit. The header is 256kB as well. | |
23 DO NOT rearrange anything but add new data to a second page | |
24 beyond diveHeaderEnd. Use extraPagesWithData to indicate that there is | |
25 data available that was not available in the OSTC3 256KB | |
26 This data will be behind the diveHeaderEnd. DO NOT delete diveHeaderEnd. | |
27 | |
28 [..] SLogbookHeaderOSTC3 | |
29 is the format used by the OSTC3. | |
30 logbook_getHeaderOSTC3() does the job using the global headers in logbook.c | |
31 | |
32 [..] SSmallHeader | |
33 - is the format used by the OSTC3 | |
34 | |
35 [..] Summary | |
36 The header format is not perfect and might be optimized prior to | |
37 releasing the diving computer. For now it is good to be compatible | |
38 with PC software available for checking the content of the logbook | |
39 | |
40 | |
41 @endverbatim | |
42 ****************************************************************************** | |
43 * @attention | |
44 * | |
45 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
46 * | |
47 ****************************************************************************** | |
48 */ | |
49 | |
50 /* Includes ------------------------------------------------------------------*/ | |
51 #include <stdint.h> | |
52 #include <string.h> | |
53 #include "logbook.h" | |
54 //#include "test_vpm.h" | |
55 #include "externLogbookFlash.h" | |
56 #include "data_exchange.h" | |
57 #include "decom.h" | |
58 #include "tHome.h" // for tHome_findNextStop() | |
445 | 59 #include "settings.h" |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
60 #include "configuration.h" |
38 | 61 |
62 /* Private types -------------------------------------------------------------*/ | |
63 | |
64 #define LOGBOOK_VERSION (0x30) | |
65 #define LOGBOOK_VERSION_OSTC3 (0x24) | |
66 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
67 #define DEFAULT_SAMPLES (100) /* Number of sample data bytes in case of an broken header information */ |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
68 #define DUMMY_SAMPLES (1000) /* Maximum number of samples profided by a dummy dive profile */ |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
69 |
38 | 70 typedef struct /* don't forget to adjust void clear_divisor(void) */ |
71 { | |
72 uint8_t temperature; | |
73 uint8_t deco_ndl; | |
74 uint8_t gradientFactor; | |
75 uint8_t ppo2; | |
76 uint8_t decoplan; | |
77 uint8_t cns; | |
78 uint8_t tank; | |
79 } SDivisor; | |
80 | |
81 /* Exported variables --------------------------------------------------------*/ | |
82 | |
83 /* Private variables ---------------------------------------------------------*/ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
84 static SLogbookHeader gheader; |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
85 static SLogbookHeaderOSTC3 headerOSTC3; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
86 static SLogbookHeaderOSTC3compact headerOSTC3compact; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
87 static SSmallHeader smallHeader; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
88 static SDivisor divisor; |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
89 static SDivisor divisorBackup; |
38 | 90 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
91 static SSmallHeader smallDummyHeader; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
92 static uint16_t dummyWriteIdx; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
93 static uint16_t dummyReadIdx; |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
94 static uint8_t dummyMemoryBuffer[5000]; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
95 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
96 |
38 | 97 /* Private function prototypes -----------------------------------------------*/ |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
98 static void clear_divisor(void); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
99 static void logbook_SetAverageDepth(float average_depth_meter); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
100 static void logbook_SetMinTemperature(float min_temperature_celsius); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
101 static void logbook_SetMaxCNS(float max_cns_percentage); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
102 static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal); |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
103 static void logbook_SetLastStop(float last_stop_depth_bar); |
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
104 static void logbook_writedata(void * data, int length_byte); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
105 static void logbook_UpdateHeader(const SDiveState * pStateReal); |
458 | 106 static void logbook_createDummyProfile(SLogbookHeader* pHeader, uint16_t length, uint16_t* depth, int16_t* temperature, uint16_t* ppo2); |
38 | 107 |
108 /* Exported functions --------------------------------------------------------*/ | |
109 | |
110 void logbook_EndDive(void) | |
111 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
112 ext_flash_close_new_dive_log((uint8_t*) &gheader); |
38 | 113 } |
114 | |
115 | |
116 // =============================================================================== | |
117 // logbook_last_totalDiveCount | |
118 /// @brief Fix setting issues | |
119 /// @date 04-April-2016 | |
120 /// | |
121 /// @return diveNumber (totalDiveCounter) of latest log entry, 0 if not a valid header | |
122 // =============================================================================== | |
123 uint16_t logbook_lastDive_diveNumber(void) | |
124 { | |
125 SLogbookHeader tempLogbookHeader; | |
126 if(logbook_getHeader(0, &tempLogbookHeader)) | |
127 { | |
128 return tempLogbookHeader.diveNumber; | |
129 } | |
130 else | |
131 { | |
132 return 0; | |
133 } | |
134 } | |
135 | |
136 | |
137 /** | |
138 ****************************************************************************** | |
139 * @brief logbook_getCurrentHeader. / | |
281 | 140 * @author heinrichs weikamp |
38 | 141 * @version V0.0.1 |
142 * @date 22-April-2014 | |
143 ****************************************************************************** | |
144 * | |
145 * @return SLogbookHeader*: | |
146 */ | |
147 SLogbookHeader* logbook_getCurrentHeader(void) | |
148 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
149 return &gheader; |
38 | 150 } |
151 | |
152 /** | |
153 ****************************************************************************** | |
154 * @brief logbook_getNumberOfHeaders. / | |
155 * @author heinrichs weikamp gmbh | |
156 * @version V0.0.1 | |
157 * @date 18-May-2016 | |
158 ****************************************************************************** | |
159 * | |
160 * @return uint8_t : number of valid headers (0xFAFA) found. | |
161 */ | |
162 uint8_t logbook_getNumberOfHeaders(void) | |
163 { | |
164 return ext_flash_count_dive_headers(); | |
165 } | |
166 | |
167 | |
168 /** | |
169 ****************************************************************************** | |
170 * @brief logbook_getHeader. / | |
281 | 171 * @author heinrichs weikamp |
38 | 172 * @version V0.0.1 |
173 * @date 22-April-2014 | |
174 ****************************************************************************** | |
175 * | |
176 * @param StepBackwards : 0 Last lokbook entry, 1 second to last entry, etc. | |
177 * @param SSLogbookHeader* pLogbookHeader: Output found LogbookHeader | |
178 * @return uint8_t : 1 = success | |
179 */ | |
180 uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader) | |
181 { | |
182 ext_flash_read_dive_header((uint8_t *)pLogbookHeader, StepBackwards); | |
183 if(pLogbookHeader->diveHeaderStart != 0xFAFA) | |
184 return 0; | |
185 else | |
186 return 1; | |
187 } | |
188 | |
189 /** | |
190 ****************************************************************************** | |
191 * @brief logbook_initNewdiveProfile. / | |
192 * creates header and smallHeader from diveState and global Settings | |
193 * and writes new lookboock entry on flash device | |
194 * diveState | |
281 | 195 * @author heinrichs weikamp |
38 | 196 * @version V0.0.1 |
197 * @date 22-April-2014 | |
198 ****************************************************************************** | |
199 * | |
200 * @param SDiveState* pInfo: Input | |
201 * @param SSettings* pSettings: Input | |
202 */ | |
203 | |
204 void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings) | |
205 { | |
206 RTC_DateTypeDef Sdate; | |
207 RTC_TimeTypeDef Stime; | |
208 | |
209 for(int i = 0; i < sizeof(SLogbookHeader); i++) | |
210 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
211 ((uint8_t*)(&gheader))[i] = 0; |
38 | 212 } |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
213 gheader.diveHeaderStart = 0xFAFA; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
214 gheader.diveHeaderEnd = 0xFBFB; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
215 gheader.samplingRate = 2; |
38 | 216 if(pInfo->diveSettings.diveMode == DIVEMODE_OC) |
217 { | |
218 for(int i = 0; i < 5; i++) | |
219 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
220 gheader.gasordil[i].oxygen_percentage = pSettings->gas[i+1].oxygen_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
221 gheader.gasordil[i].helium_percentage = pSettings->gas[i+1].helium_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
222 gheader.gasordil[i].note.uw = pSettings->gas[i+1].note.uw; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
223 gheader.gasordil[i].depth_meter = pSettings->gas[i+1].depth_meter; |
38 | 224 } |
225 } | |
226 else | |
227 { | |
228 for(int i = 0; i < 5; i++) | |
229 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
230 gheader.gasordil[i].oxygen_percentage = pSettings->gas[i+6].oxygen_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
231 gheader.gasordil[i].helium_percentage = pSettings->gas[i+6].helium_percentage; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
232 gheader.gasordil[i].note.uw = pSettings->gas[i+6].note.uw; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
233 gheader.gasordil[i].depth_meter = pSettings->gas[i+6].depth_meter; |
38 | 234 } |
235 | |
236 for(int i = 0; i < 5; i++) | |
237 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
238 gheader.setpoint[i].setpoint_cbar = pSettings->setpoint[i+1].setpoint_cbar; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
239 gheader.setpoint[i].depth_meter = pSettings->setpoint[i+1].depth_meter; |
38 | 240 } |
241 } | |
242 // header.gasordil[pInfo->lifeData.actualGas.GasIdInSettings].depth_meter = 0; | |
243 | |
244 translateDate(pInfo->lifeData.dateBinaryFormat, &Sdate); | |
245 translateTime(pInfo->lifeData.timeBinaryFormat, &Stime); | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
246 gheader.dateYear = Sdate.Year; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
247 gheader.dateMonth = Sdate.Month; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
248 gheader.dateDay = Sdate.Date; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
249 gheader.timeHour = Stime.Hours; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
250 gheader.timeMinute = Stime.Minutes; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
251 gheader.cnsAtBeginning = (uint16_t)pInfo->lifeData.cns; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
252 gheader.surfacePressure_mbar = (uint16_t)(pInfo->lifeData.pressure_surface_bar * 1000); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
253 gheader.firmwareVersionHigh = firmwareVersion_16bit_high(); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
254 gheader.firmwareVersionLow = firmwareVersion_16bit_low(); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
255 gheader.logbookProfileVersion = LOGBOOK_VERSION; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
256 gheader.salinity = pSettings->salinity; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
257 gheader.diveNumber = pSettings->totalDiveCounter; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
258 gheader.personalDiveCount = pSettings->personalDiveCount; |
38 | 259 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
260 gheader.diveMode = pInfo->diveSettings.diveMode; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
261 gheader.CCRmode = pInfo->diveSettings.CCR_Mode; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
262 gheader.lastDecostop_m = pSettings->last_stop_depth_meter; |
38 | 263 |
264 if(pInfo->diveSettings.deco_type.ub.standard == GF_MODE) | |
265 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
266 gheader.decoModel = 1; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
267 gheader.gfLow_or_Vpm_conservatism = pInfo->diveSettings.gf_low; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
268 gheader.gfHigh = pInfo->diveSettings.gf_high; |
38 | 269 } |
270 else | |
271 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
272 gheader.decoModel = 2; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
273 gheader.gfLow_or_Vpm_conservatism = pInfo->diveSettings.vpm_conservatism; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
274 gheader.gfHigh = 0; |
38 | 275 } |
276 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
277 memcpy(gheader.n2Compartments, pInfo->lifeData.tissue_nitrogen_bar, 64); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
278 memcpy(gheader.heCompartments, pInfo->lifeData.tissue_helium_bar, 64); |
38 | 279 |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
280 logbook_SetCompartmentDesaturation(pInfo); |
38 | 281 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
282 ext_flash_start_new_dive_log_and_set_actualPointerSample((uint8_t*)&gheader); |
38 | 283 |
284 smallHeader.profileLength[0] = 0xFF; | |
285 smallHeader.profileLength[1] = 0xFF; | |
286 smallHeader.profileLength[2] = 0xFF; | |
287 smallHeader.samplingRate_seconds = 2; | |
288 smallHeader.numDivisors = 7; | |
289 | |
290 smallHeader.tempType = 0; | |
291 smallHeader.tempLength = 2; | |
292 smallHeader.tempDivisor = 6; | |
293 | |
294 smallHeader.deco_ndlType = 1; | |
295 smallHeader.deco_ndlLength = 2; | |
296 smallHeader.deco_ndlDivisor = 6; //= 6; | |
297 | |
298 /* GF in % at actual position */ | |
299 smallHeader.gfType = 2; | |
300 smallHeader.gfLength = 1; | |
301 smallHeader.gfDivisor = 0; //12; | |
302 | |
303 /* 3 Sensors: 8bit ppO2 in 0.01bar, 16bit voltage in 0,1mV */ | |
304 smallHeader.ppo2Type = 3; | |
305 smallHeader.ppo2Length = 9; | |
306 smallHeader.ppo2Divisor = 2; //2 | |
307 | |
308 /* last 15 stops in minutes (last, second_to_last, ... */ | |
309 /* last stop depth is defined in header */ | |
310 smallHeader.decoplanType = 4; | |
311 smallHeader.decoplanLength = 15; | |
312 smallHeader.decoplanDivisor = 12;//12; | |
313 | |
314 smallHeader.cnsType = 5; | |
315 smallHeader.cnsLength = 2; | |
316 smallHeader.cnsDivisor = 12; | |
317 | |
318 smallHeader.tankType = 6; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
319 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
320 smallHeader.tankLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
321 smallHeader.tankDivisor = 30; /* log tank data once a minute */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
322 #else |
38 | 323 smallHeader.tankLength = 0; |
324 smallHeader.tankDivisor = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
325 #endif |
38 | 326 logbook_writedata((void *) &smallHeader,sizeof(smallHeader)); |
327 | |
328 clear_divisor(); | |
329 } | |
330 | |
331 /** | |
332 ****************************************************************************** | |
333 * @brief clear_divisor / clears divisor struct | |
281 | 334 * @author heinrichs weikamp |
38 | 335 * @version V0.0.1 |
336 * @date 22-April-2014 | |
337 ****************************************************************************** | |
338 * | |
339 */ | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
340 static void clear_divisor(void) |
38 | 341 { |
342 divisor.cns = smallHeader.cnsDivisor - 1; | |
343 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
344 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
345 divisor.gradientFactor = smallHeader.gfDivisor -1 ; | |
346 divisor.ppo2 = smallHeader.ppo2Divisor - 1; | |
347 divisor.tank = smallHeader.tankDivisor - 1; | |
348 divisor.temperature = smallHeader.tempDivisor - 1; | |
349 } | |
350 | |
351 | |
352 /** | |
353 ****************************************************************************** | |
354 * @brief add16. / adds 16 bit variable to 8 bit array | |
281 | 355 * @author heinrichs weikamp |
38 | 356 * @version V0.0.1 |
357 * @date 22-April-2014 | |
358 ****************************************************************************** | |
359 * | |
360 * @param uint8_t *pos: Output 8 bit array | |
361 * @param uint16_t var: 16 bit variable | |
362 */ | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
363 static void addU16(uint8_t *pos, uint16_t var) |
38 | 364 { |
365 *((uint16_t*)pos) = var; | |
366 } | |
367 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
368 static void addS16(uint8_t *pos, int16_t var) |
38 | 369 { |
370 *((int16_t*)pos) = var; | |
371 } | |
372 | |
373 /** | |
374 ****************************************************************************** | |
375 * @brief logbook_writeSample. / Writes one logbook sampl | |
281 | 376 * @author heinrichs weikamp |
38 | 377 * @date 22-April-2014 |
378 * @version V0.0.2 | |
379 * @since 20-June-2016 | |
380 * @bug Deco/NDL Status fixed in V0.0.2 | |
381 | |
382 | |
383 ****************************************************************************** | |
384 * | |
385 * @param SDiveState state: | |
386 */ | |
387 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
388 void logbook_writeSample(const SDiveState *state) |
38 | 389 { |
390 uint8_t sample[256]; | |
391 // int position = 0; | |
392 int length = 0; | |
393 // _Bool bEvent = 0; | |
394 uint8_t nextstopDepthMeter = 0; | |
395 uint16_t nextstopLengthSeconds = 0; | |
396 uint8_t nextstopLengthMinutes = 0; | |
397 bit8_Type eventByte1, eventByte2; | |
398 bit8_Type profileByteFlag; | |
399 int i = 0; | |
400 for(i = 0; i <256 ;i++) | |
401 sample[i] = 0; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
402 addU16(sample, (uint16_t)(state->lifeData.depth_meter * 100)); |
38 | 403 length += 2; |
404 sample[2] = 0; | |
405 length++; | |
406 eventByte1.uw = 0; | |
407 eventByte2.uw = 0; | |
408 //uint16_t tmpU16 = 0; | |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
409 const SDecoinfo * pDecoinfo; // new hw 160620 |
38 | 410 |
411 //BuildEevntyte 1 | |
412 // sub old 0-3 only one at a time | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
413 if(state->events.manualMarker) |
38 | 414 { |
415 eventByte1.uw = 6; | |
416 } | |
417 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
418 if(state->warnings.decoMissed) |
38 | 419 { |
420 eventByte1.uw = 2; | |
421 } | |
422 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
423 if(state->warnings.ppO2Low) |
38 | 424 { |
425 eventByte1.uw = 4; | |
426 } | |
427 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
428 if(state->warnings.ppO2High) |
38 | 429 { |
430 eventByte1.uw = 5; | |
431 } | |
432 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
433 if(state->warnings.lowBattery) |
38 | 434 { |
435 eventByte1.uw = 7; | |
436 } | |
437 else | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
438 if(state->warnings.slowWarning) |
38 | 439 { |
440 eventByte1.uw = 1; | |
441 } | |
442 // sub bit 4 to 7 | |
281 | 443 if(state->events.manualGasSet) |
38 | 444 { |
445 eventByte1.ub.bit4 = 1; | |
446 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
447 if(state->events.gasChange) |
38 | 448 { |
449 eventByte1.ub.bit5 = 1; | |
450 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
451 if(state->events.setpointChange) |
38 | 452 { |
453 eventByte1.ub.bit6 = 1; | |
454 } | |
455 // sub bit 7 + eventbyte2 | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
456 if(state->events.bailout) |
38 | 457 { |
458 eventByte1.ub.bit7 = 1; | |
459 eventByte2.ub.bit0 = 1; | |
460 } | |
461 //Add EventByte 1 | |
462 if(eventByte1.uw > 0) | |
463 { | |
464 sample[length] = eventByte1.uw; | |
465 length++; | |
466 } | |
467 if(eventByte2.uw > 0) | |
468 { | |
469 sample[length] = eventByte2.uw; | |
470 length++; | |
471 } | |
472 //Add EventInfos | |
281 | 473 if(state->events.manualGasSet) |
38 | 474 { |
475 //manual gas in %O2 & %He | |
281 | 476 sample[length] = state->events.info_manualGasSetO2; |
38 | 477 length += 1; |
281 | 478 sample[length] = state->events.info_manualGasSetHe; |
38 | 479 length += 1; |
480 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
481 if(state->events.gasChange) |
38 | 482 { |
483 //Current gas (gasid) | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
484 sample[length] = state->events.info_GasChange; |
38 | 485 length += 1; |
486 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
487 if(state->events.setpointChange) |
38 | 488 { |
489 //New setpoint in cbar | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
490 sample[length] = state->events.info_SetpointChange; |
38 | 491 length += 1; |
492 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
493 if(state->events.bailout) |
38 | 494 { |
495 //bailout gas in % O2 & %He | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
496 sample[length] = state->events.info_bailoutO2; |
38 | 497 length += 1; |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
498 sample[length] = state->events.info_bailoutHe; |
38 | 499 length += 1; |
500 } | |
501 | |
502 | |
503 if(divisor.temperature == 0) | |
504 { | |
505 divisor.temperature = smallHeader.tempDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
506 addS16(&sample[length], (int16_t)((state->lifeData.temperature_celsius * 10.0f) + 0.5f)); |
38 | 507 length += 2; |
508 } | |
509 else | |
510 { | |
511 divisor.temperature--; | |
512 } | |
513 | |
514 | |
515 if(smallHeader.deco_ndlDivisor > 0) | |
516 { | |
517 if(divisor.deco_ndl == 0) | |
518 { | |
519 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
520 | |
521 if(stateUsed->diveSettings.deco_type.ub.standard == GF_MODE) | |
522 pDecoinfo = &stateUsed->decolistBuehlmann; | |
523 else if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) | |
524 pDecoinfo = &stateUsed->decolistVPM; | |
525 else // should not happen as only GF and VPM at the moment | |
526 { | |
527 sample[length] = 0; | |
528 length += 1; | |
529 sample[length] = 0; | |
530 length += 1; | |
458 | 531 pDecoinfo = &stateUsed->decolistBuehlmann; /* use GF per default if something went wrong */ |
38 | 532 } |
533 | |
534 if(pDecoinfo->output_ndl_seconds > 0) | |
535 { | |
536 sample[length] = 0; | |
537 length += 1; | |
283
04cdeff80254
Bugfix: write NDL in logbook correctly
Jan Mulder <jlmulder@xs4all.nl>
parents:
281
diff
changeset
|
538 sample[length] = (uint8_t)(pDecoinfo->output_ndl_seconds / 60); |
281 | 539 |
540 // Limit stored sample within 0 to 240 mins (Since it's 8bit UINT only) | |
541 if ((pDecoinfo->output_ndl_seconds / 60) > 240) sample[length] = 240; | |
542 if ((pDecoinfo->output_ndl_seconds / 60) < 0) sample[length] = 0; | |
543 | |
38 | 544 length += 1; |
545 } | |
546 else if(pDecoinfo->output_time_to_surface_seconds) | |
547 { | |
548 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); | |
549 nextstopLengthMinutes = (nextstopLengthSeconds +59 ) / 60; | |
550 | |
551 sample[length] = nextstopDepthMeter; | |
552 length += 1; | |
553 sample[length] = nextstopLengthMinutes; | |
554 length += 1; | |
555 } | |
556 else | |
557 { | |
558 sample[length] = 0; | |
559 length += 1; | |
560 sample[length] = 0; | |
561 length += 1; | |
562 } | |
563 } | |
564 else | |
565 { | |
566 divisor.deco_ndl --; | |
567 } | |
568 } | |
569 | |
570 | |
571 if(smallHeader.ppo2Divisor) | |
572 { | |
573 if(divisor.ppo2 == 0) | |
574 { | |
575 divisor.ppo2 = smallHeader.ppo2Divisor - 1; | |
576 | |
577 for(int i = 0; i <3; i++) | |
578 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
579 sample[length] = (uint8_t)(state->lifeData.ppO2Sensor_bar[i] * 100.0f + 0.5f); |
38 | 580 length += 1; |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
581 addU16(&sample[length], (uint16_t)(state->lifeData.sensorVoltage_mV[i] * 10.0f + 0.5f)); |
38 | 582 length += 2; |
583 } | |
584 } | |
585 else | |
586 { | |
587 divisor.ppo2--; | |
588 } | |
589 } | |
590 | |
591 | |
592 if(smallHeader.decoplanDivisor) | |
593 { | |
594 if(divisor.decoplan == 0) | |
595 { | |
596 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
597 if(state->diveSettings.deco_type.ub.standard == VPM_MODE) |
38 | 598 { |
599 for(int i = 0; i <15; i++) | |
600 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
601 sample[length] = state->decolistVPM.output_stop_length_seconds[i] / 60; |
38 | 602 length += 1; |
603 } | |
604 } | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
605 else if(state->diveSettings.deco_type.ub.standard == GF_MODE) |
38 | 606 { |
607 for(int i = 0; i <15; i++) | |
608 { | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
609 sample[length] = state->decolistBuehlmann.output_stop_length_seconds[i] / 60; |
38 | 610 length += 1; |
611 } | |
612 } | |
613 else | |
614 { | |
615 for(int i = 0; i <15; i++) | |
616 { | |
617 sample[length] = 0; | |
618 length += 1; | |
619 } | |
620 } | |
621 // add16(&sample[length], state.temperature); | |
622 //length += 2; | |
623 } | |
624 else | |
625 { | |
626 divisor.decoplan --; | |
627 } | |
628 } | |
629 if(divisor.cns == 0) | |
630 { | |
631 divisor.cns = smallHeader.cnsDivisor - 1; | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
632 addU16(&sample[length], (uint16_t)state->lifeData.cns); |
38 | 633 length += 2; |
634 } | |
635 else | |
636 { | |
637 divisor.cns--; | |
638 } | |
639 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
640 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
641 if(smallHeader.tankDivisor) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
642 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
643 if(divisor.tank == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
644 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
645 divisor.tank = smallHeader.tankDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
646 addS16(&sample[length], ((state->lifeData.bottle_bar[state->lifeData.actualGas.GasIdInSettings]))); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
647 length += smallHeader.tankLength; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
648 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
649 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
650 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
651 divisor.tank--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
652 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
653 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
654 #endif |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
655 |
38 | 656 profileByteFlag.uw = length - 3; |
657 if(eventByte1.uw) | |
658 { | |
659 profileByteFlag.ub.bit7 = 1; | |
660 } | |
661 sample[2] = profileByteFlag.uw; | |
662 logbook_writedata((void *) sample,length); | |
663 | |
664 } | |
665 | |
666 /** | |
667 ****************************************************************************** | |
668 * @brief readSample. / Reads data of one logbook sample | |
281 | 669 * @author heinrichs weikamp |
38 | 670 * @version V0.0.1 |
671 * @date 22-April-2014 | |
672 ****************************************************************************** | |
673 * | |
674 * @param int32_t* depth: output Value | |
675 * @param int16_t * gasid: output Value | |
676 * @param int32_t* temperature: output Value | |
677 * @param int32_t* sensor1, sensor2, sensor3: output Value | |
678 * @param int32_t* cns: output Value | |
679 * @return bytes read / 0 = reading Error | |
680 */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
681 static uint16_t readSample(int32_t* depth, int16_t * gasid, int16_t* setpoint_cbar, int32_t* temperature, int32_t* sensor1, int32_t* sensor2, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
682 int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank) |
38 | 683 { |
684 int length = 0; | |
685 _Bool bEvent = 0; | |
686 bit8_Type eventByte1, eventByte2; | |
687 bit8_Type profileByteFlag; | |
688 | |
689 eventByte1.uw = 0; | |
690 eventByte2.uw = 0; | |
691 uint8_t tempU8 = 0; | |
692 uint16_t temp = 0; | |
693 uint16_t bytesRead = 0; | |
694 | |
695 if(gasid) | |
696 *gasid = -1; | |
697 if(temperature) | |
698 *temperature = -1000; | |
699 if(sensor1) | |
700 *sensor1 = -1; | |
701 if(sensor2) | |
702 *sensor2 = -1; | |
703 if(sensor3) | |
704 *sensor3 = -1; | |
705 if(cns) | |
706 *cns = -1; | |
707 if(setpoint_cbar) | |
708 *setpoint_cbar = -1; | |
709 if(bailout) | |
710 *bailout = -1; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
711 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
712 *tank = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
713 |
38 | 714 if(manualGas) |
715 { | |
716 manualGas->percentageO2 =-1; | |
717 manualGas->percentageHe =-1; | |
718 } | |
719 if(decostopDepth) | |
720 *decostopDepth = -1; | |
721 | |
722 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
723 if(depth) | |
724 *depth = (int32_t)temp; | |
725 bytesRead += 2; | |
726 | |
727 ext_flash_read_next_sample_part( &profileByteFlag.uw, 1); | |
728 bytesRead ++; | |
729 | |
730 bEvent = profileByteFlag.ub.bit7; | |
731 profileByteFlag.ub.bit7 = 0; | |
732 length = profileByteFlag.uw; | |
733 | |
734 if(bEvent) | |
735 { | |
736 ext_flash_read_next_sample_part( &eventByte1.uw, 1); | |
737 bytesRead ++; | |
738 | |
739 length--; | |
740 | |
741 //second event byte | |
742 if(eventByte1.ub.bit7) | |
743 { | |
744 ext_flash_read_next_sample_part( &eventByte2.uw, 1); | |
745 bytesRead ++; | |
746 length--; | |
747 } | |
748 else | |
749 { | |
750 eventByte2.uw = 0; | |
751 } | |
752 | |
753 //manual Gas Set | |
754 if( eventByte1.ub.bit4) | |
755 { | |
756 //Evaluate manual Gas | |
757 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
758 bytesRead +=1; | |
759 length -= 1; | |
760 manualGas->percentageO2 = tempU8; | |
761 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
762 bytesRead +=1; | |
763 length -= 1; | |
764 manualGas->percentageHe = tempU8; | |
765 if(gasid) | |
766 *gasid = 0; | |
767 } | |
768 //gas change | |
769 if( eventByte1.ub.bit5) | |
770 { | |
771 ext_flash_read_next_sample_part( &tempU8, 1); | |
772 bytesRead +=1; | |
773 length -= 1; | |
774 if(gasid) | |
775 *gasid = (uint16_t)tempU8; | |
776 } | |
777 //SetpointChange | |
778 if( eventByte1.ub.bit6) | |
779 { | |
780 ext_flash_read_next_sample_part( &tempU8, 1); | |
781 *setpoint_cbar = tempU8; | |
782 bytesRead +=1; | |
783 length -= 1; | |
784 } | |
785 | |
786 // second event Byte | |
787 //bailout | |
298
50c26a4442af
Bugfix: fix drawing of CCR bailout profile
Jan Mulder <jlmulder@xs4all.nl>
parents:
283
diff
changeset
|
788 if(eventByte2.ub.bit0) |
38 | 789 { |
790 //evaluate bailout gas Gas | |
791 *bailout = 1; | |
792 | |
793 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
794 bytesRead +=1; | |
795 length -= 1; | |
796 manualGas->percentageO2 = tempU8; | |
797 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); | |
798 bytesRead +=1; | |
799 length -= 1; | |
800 manualGas->percentageHe = tempU8; | |
801 | |
802 if(gasid) | |
803 *gasid = 0; | |
804 } | |
805 } | |
806 | |
807 if(divisor.temperature == 0) | |
808 { | |
809 divisor.temperature = smallHeader.tempDivisor - 1; | |
810 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
811 bytesRead +=2; | |
812 length -= 2; | |
813 if(temperature) | |
814 { | |
815 *temperature = (int32_t)temp; | |
816 } | |
817 } | |
818 else | |
819 { | |
820 divisor.temperature--; | |
821 } | |
822 | |
823 if(smallHeader.deco_ndlDivisor > 0) | |
824 { | |
825 if(divisor.deco_ndl == 0) | |
826 { | |
827 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | |
828 ext_flash_read_next_sample_part( &tempU8, 1); | |
829 if(decostopDepth) | |
830 { | |
831 *decostopDepth = tempU8 * 100; | |
832 } | |
833 ext_flash_read_next_sample_part( &tempU8, 1); | |
834 bytesRead += 2; | |
835 length -= 2; | |
836 } | |
837 else | |
838 { | |
839 divisor.deco_ndl--; | |
840 } | |
841 } | |
842 | |
843 if(divisor.ppo2 == 0) | |
844 { | |
845 int32_t ppO2Tmp = 0; | |
846 divisor.ppo2 = smallHeader.ppo2Divisor -1; | |
847 for(int i = 0; i <3 ; i++) | |
848 { | |
849 ext_flash_read_next_sample_part( &tempU8, 1); | |
850 ppO2Tmp += tempU8; | |
851 bytesRead +=1; | |
852 length -= 1; | |
853 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
854 bytesRead +=2; | |
855 length -= 2; | |
856 if(sensor1 && (i==0)) | |
857 *sensor1 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
858 if(sensor2 && (i==1)) | |
859 *sensor2 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
860 if(sensor3 && (i==2)) | |
861 *sensor3 = (((int32_t)tempU8) * 0xFFFF) + temp; | |
862 } | |
863 } | |
864 else | |
865 { | |
866 divisor.ppo2--; | |
867 } | |
868 | |
869 if(smallHeader.decoplanDivisor > 0) | |
870 { | |
871 if(divisor.decoplan == 0) | |
872 { | |
873 divisor.decoplan = smallHeader.decoplanDivisor - 1; | |
874 for(int i = 0; i <15; i++) | |
875 ext_flash_read_next_sample_part( &tempU8, 1); | |
876 bytesRead += 15; | |
877 length -= 15; | |
878 } | |
879 else | |
880 { | |
881 divisor.decoplan--; | |
882 } | |
883 } | |
884 | |
885 | |
886 | |
887 if(divisor.cns == 0) | |
888 { | |
889 divisor.cns = smallHeader.cnsDivisor - 1; | |
890 | |
891 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); | |
892 bytesRead +=2; | |
893 length -= 2; | |
894 if(cns) | |
895 { | |
896 *cns = (int32_t)temp; | |
897 } | |
898 } | |
899 else | |
900 { | |
901 divisor.cns--; | |
902 } | |
903 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
904 #ifdef ENABLE_BOTTLE_SENSOR |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
905 if(smallHeader.tankDivisor) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
906 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
907 if(divisor.tank == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
908 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
909 divisor.tank = smallHeader.tankDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
910 ext_flash_read_next_sample_part( (uint8_t*)&temp, 2); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
911 bytesRead +=2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
912 length -= 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
913 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
914 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
915 *tank = (uint16_t)temp; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
916 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
917 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
918 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
919 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
920 divisor.tank--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
921 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
922 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
923 #endif |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
924 |
38 | 925 if (length != 0) |
926 return 0; | |
927 | |
928 return bytesRead; | |
929 } | |
930 /** | |
931 ****************************************************************************** | |
932 * @brief logbook_readSampleData. / Reads sample data of whole logbook entry | |
281 | 933 * @author heinrichs weikamp |
38 | 934 * @version V0.0.1 |
935 * @date 22-April-2014 | |
936 ****************************************************************************** | |
937 * | |
938 * @param uint8_t StepBackwards: witch lookbook entry? | |
939 * @param uint16_t length : maxlength of output arrays | |
940 * @param int32_t* depth : output array | |
941 * @param int16_t * gasid : output array | |
942 * @param int32_t* temperature : output array | |
943 * @param int32_t* ppo2 : output array | |
944 * @param int32_t* cns : output array | |
945 * @return length of output | |
946 */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
947 uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
948 uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
949 uint16_t* decostopDepth, uint16_t* tank) |
38 | 950 { |
951 //Test read | |
952 //SLogbookHeader header; | |
953 | |
954 //logbook_getHeader(&header); | |
955 SLogbookHeader header; | |
458 | 956 int16_t iNum; |
957 int16_t firstgasid = 0; | |
958 uint16_t retVal = 0; | |
959 int16_t compression = 0; | |
960 int16_t i; | |
38 | 961 // uint32_t diveTime_seconds; |
962 int32_t depthVal = 0; | |
963 int16_t gasidVal = 0; | |
964 int16_t setPointVal = 0; | |
965 int16_t bailoutVal = 0; | |
966 int16_t bailoutLast = 0; | |
967 uint16_t setPointLast = 0; | |
968 int32_t temperatureVal = 0; | |
969 int32_t sensor1Val = 0; | |
970 int32_t sensor2Val = 0; | |
971 int32_t sensor3Val = 0; | |
972 int32_t sensor1Last = 0; | |
973 int32_t sensor2Last = 0; | |
974 int32_t sensor3Last = 0; | |
975 int32_t cnsVal = 0; | |
976 int32_t depthLast = 0; | |
977 int16_t gasidLast = 0; | |
978 int32_t temperatureLast = 0; | |
979 int32_t temperatureFirst = 0; | |
980 int32_t cnsLast = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
981 int16_t decostepDepthVal = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
982 int16_t decostepDepthLast = 0; |
457 | 983 uint16_t tankVal = 0; |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
984 uint32_t small_profileLength = 0; |
38 | 985 |
986 SManualGas manualGasVal; | |
987 SManualGas manualGasLast; | |
988 manualGasLast.percentageO2 = 0; | |
989 manualGasLast.percentageHe = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
990 uint16_t numSamples = 0; |
38 | 991 |
992 float ambiant_pressure_bar = 0; | |
993 float ppO2 = 0; | |
994 ext_flash_read_dive_header((uint8_t*)&header, StepBackwards); | |
995 for(i = 0;i< 5;i++) | |
996 { | |
997 if(header.gasordil[i].note.ub.first) | |
998 break; | |
999 } | |
1000 firstgasid = i + 1; | |
1001 if(header.diveMode == DIVEMODE_CCR) | |
1002 setPointLast = header.setpoint[0].setpoint_cbar; | |
1003 else | |
1004 setPointLast = 0; | |
1005 //diveTime_seconds = header.diveTime_seconds ; | |
1006 for(compression = 1; compression < 100; compression ++) | |
1007 { | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1008 numSamples = (header.total_diveTime_seconds / header.samplingRate)/compression; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1009 if(numSamples <= length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1010 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1011 break; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1012 } |
38 | 1013 } |
1014 | |
1015 | |
1016 for(i = 0;i< length;i++) | |
1017 { | |
1018 if(depth) | |
1019 depth[i] = 0; | |
1020 if(temperature) | |
1021 temperature[i] = 0; | |
1022 if(gasid) | |
1023 gasid[i] = 0; | |
1024 if(ppo2) | |
1025 ppo2[i] = 0; | |
1026 if(setpoint) | |
1027 setpoint[i] = 0; | |
1028 if(sensor1) | |
1029 sensor1[i] = 0; | |
1030 if(sensor2) | |
1031 sensor2[i] = 0; | |
1032 if(sensor3) | |
1033 sensor3[i] = 0; | |
1034 if(cns) | |
1035 cns[i] = 0; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1036 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1037 tank[i] = 0; |
38 | 1038 } |
1039 //We start with fist gasid | |
1040 gasidLast = firstgasid; | |
1041 | |
1042 | |
1043 //uint16_t* ppo2, uint16_t* cns# | |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1044 uint32_t totalNumberOfBytes = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1045 uint32_t bytesRead = 0; |
38 | 1046 ext_flash_open_read_sample( StepBackwards,&totalNumberOfBytes); |
1047 ext_flash_read_next_sample_part((uint8_t*)&smallHeader, sizeof(SSmallHeader)); | |
1048 bytesRead += sizeof(SSmallHeader); | |
1049 | |
1050 clear_divisor(); | |
1051 | |
1052 iNum = 0; | |
1053 int counter = 0; | |
1054 temperatureLast = -1000; | |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1055 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1056 small_profileLength = (smallHeader.profileLength[2] << 16) + (smallHeader.profileLength[1] << 8) + smallHeader.profileLength[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1057 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1058 if(totalNumberOfBytes == small_profileLength) /* sizes provided by header and small header are the same => real data */ |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1059 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1060 while ((bytesRead < totalNumberOfBytes) && (iNum < length)) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1061 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1062 ext_flash_set_entry_point(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1063 divisorBackup = divisor; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1064 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1065 &bailoutVal, &decostepDepthVal, &tankVal); |
38 | 1066 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1067 if(retVal == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1068 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1069 //Error try to read again!!! |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1070 ext_flash_reopen_read_sample_at_entry_point(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1071 divisor = divisorBackup; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1072 retVal = readSample(&depthVal,&gasidVal,&setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1073 &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal); |
38 | 1074 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1075 if(retVal == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1076 break; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1077 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1078 bytesRead +=retVal; |
38 | 1079 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1080 //if for some variable no new value is in the sample for (z.B. gasidVal = -1), we take the last value |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1081 if(depthVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1082 depthVal = depthLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1083 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1084 depthLast = depthVal; |
38 | 1085 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1086 if(gasidVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1087 gasidVal = gasidLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1088 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1089 gasidLast = gasidVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1090 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1091 if(temperatureVal == -1000) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1092 temperatureVal = temperatureLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1093 else |
38 | 1094 { |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1095 if(temperatureLast == -1000) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1096 temperatureFirst = temperatureVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1097 temperatureLast = temperatureVal; |
38 | 1098 } |
1099 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1100 if(setPointVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1101 setPointVal = setPointLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1102 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1103 setPointLast = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1104 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1105 if(sensor1Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1106 sensor1Val = sensor1Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1107 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1108 sensor1Last = sensor1Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1109 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1110 if(sensor2Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1111 sensor2Val = sensor2Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1112 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1113 sensor2Last = sensor2Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1114 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1115 if(sensor3Val == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1116 sensor3Val = sensor3Last; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1117 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1118 sensor3Last = sensor3Val; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1119 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1120 if(cnsVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1121 cnsVal = cnsLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1122 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1123 cnsLast = cnsVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1124 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1125 if(manualGasVal.percentageO2 == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1126 manualGasVal = manualGasLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1127 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1128 manualGasLast = manualGasVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1129 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1130 if(bailoutVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1131 bailoutVal = bailoutLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1132 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1133 bailoutLast = bailoutVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1134 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1135 if(decostepDepthVal == -1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1136 decostepDepthVal = decostepDepthLast; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1137 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1138 decostepDepthLast = decostepDepthVal; |
38 | 1139 |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1140 counter++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1141 // Heed compression |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1142 // Write here to arrays |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1143 if(counter == compression) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1144 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1145 if(depth) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1146 depth[iNum] = depthVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1147 if(gasid) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1148 gasid[iNum] = gasidVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1149 if(temperature) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1150 temperature[iNum] = temperatureVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1151 if(cns) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1152 cns[iNum] = cnsVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1153 if(bailout) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1154 bailout[iNum] = bailoutVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1155 if(decostopDepth) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1156 decostopDepth[iNum] = decostepDepthVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1157 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1158 if(ppo2) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1159 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1160 //Calc ppo2 - Values |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1161 SGas gas; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1162 gas.setPoint_cbar = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1163 if(gasidVal > 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1164 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1165 gas.helium_percentage = header.gasordil[gasidVal - 1].helium_percentage; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1166 gas.nitrogen_percentage = 100 - gas.helium_percentage - header.gasordil[gasidVal - 1].oxygen_percentage; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1167 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1168 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1169 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1170 gas.helium_percentage = manualGasVal.percentageHe; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1171 gas.nitrogen_percentage = 100 - gas.helium_percentage - manualGasVal.percentageO2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1172 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1173 ambiant_pressure_bar =((float)(depthVal + header.surfacePressure_mbar))/1000; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1174 ppO2 = decom_calc_ppO2(ambiant_pressure_bar, &gas ); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1175 ppo2[iNum] = (uint16_t) ( ppO2 * 100); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1176 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1177 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1178 if(tank) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1179 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1180 tank[iNum] = tankVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1181 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1182 if(setpoint) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1183 setpoint[iNum] = setPointVal; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1184 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1185 if(sensor1) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1186 sensor1[iNum] = (sensor1Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1187 if(sensor2) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1188 sensor2[iNum] = (sensor2Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1189 if(sensor3) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1190 sensor3[iNum] = (sensor3Val / 0xFFFF) & 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1191 iNum++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1192 counter = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1193 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1194 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1195 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1196 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1197 { |
458 | 1198 logbook_createDummyProfile(&header, numSamples, depth, temperature, ppo2); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1199 iNum = numSamples; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1200 } |
38 | 1201 |
1202 // Fix first Temperature Entries 150930 hw | |
1203 if(temperature) | |
1204 { | |
1205 int i = 0; | |
1206 while((temperature[i] == -1000) && (i < iNum)) | |
1207 temperature[i++] = temperatureFirst; | |
1208 } | |
1209 | |
1210 ext_flash_close_read_sample(); | |
1211 return iNum; | |
1212 } | |
1213 | |
1214 | |
1215 /******************************************************************************** | |
1216 * @brief logbook_InitAndWrite. / Controls writing of logbook | |
1217 * Should be called ten times per second | |
1218 * Automatically Initializes logbook at beginning of dive, | |
1219 * write samples every 2 seconds | |
1220 * and finishes logbook after end of dive | |
1221 *********************************************************************************/ | |
1222 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1223 void logbook_InitAndWrite(const SDiveState *pStateReal) |
38 | 1224 { |
1225 SSettings *pSettings = settingsGetPointer(); | |
1226 static uint8_t bDiveMode = 0; | |
1227 static uint32_t tickstart = 0; | |
1228 uint32_t ticksdiff = 0; | |
1229 uint32_t lasttick = 0; | |
1230 static float min_temperature_float_celsius = 0; | |
1231 | |
1232 if(!bDiveMode) | |
1233 { | |
1234 if((pStateReal->mode == MODE_DIVE) && (pStateReal->diveSettings.diveMode != DIVEMODE_Apnea) && (pStateReal->lifeData.dive_time_seconds >= 5)) | |
1235 { | |
1236 //InitdiveProfile | |
1237 pSettings->totalDiveCounter++; | |
1238 logbook_initNewdiveProfile(pStateReal,settingsGetPointer()); | |
1239 min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; | |
1240 //Write logbook sample | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
1241 logbook_writeSample(pStateReal); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1242 resetEvents(pStateReal); |
38 | 1243 tickstart = HAL_GetTick(); |
1244 bDiveMode = 1; | |
1245 } | |
1246 } | |
1247 else if((pStateReal->mode == MODE_DIVE) && (pStateReal->diveSettings.diveMode != DIVEMODE_Apnea)) | |
1248 { | |
1249 lasttick = HAL_GetTick(); | |
1250 ticksdiff = time_elapsed_ms(tickstart,lasttick); | |
1251 // | |
1252 if(ticksdiff >= 2000) | |
1253 { | |
1254 //Write logbook sample | |
269
6e78137952af
cleanup: do not pass large struct by value
Jan Mulder <jlmulder@xs4all.nl>
parents:
225
diff
changeset
|
1255 logbook_writeSample(pStateReal); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1256 resetEvents(pStateReal); |
38 | 1257 if(min_temperature_float_celsius > pStateReal->lifeData.temperature_celsius) |
1258 min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; | |
1259 tickstart = lasttick; | |
1260 if((bDiveMode == 1) && (pStateReal->lifeData.dive_time_seconds >= pSettings->divetimeToCreateLogbook)) | |
1261 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1262 ext_flash_create_new_dive_log((uint8_t*)&gheader); |
38 | 1263 /** save settings |
1264 * with new lastDiveLogId and time and day | |
1265 */ | |
1266 pSettings->personalDiveCount++; | |
1267 if(pSettings->logbookOffset) | |
1268 { | |
1269 pSettings->logbookOffset++; | |
1270 } | |
427 | 1271 ext_flash_write_settings(0); |
38 | 1272 ext_flash_disable_protection_for_logbook(); |
426
514e6269256f
Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents:
411
diff
changeset
|
1273 |
514e6269256f
Added function to analyse the sampel ringbuffer:
ideenmodellierer
parents:
411
diff
changeset
|
1274 ext_flash_CloseSector(); /* this is just a repair function which invalidates a not used sector in case a log maintenance was called before dive */ |
38 | 1275 bDiveMode = 3; |
1276 } | |
1277 if(bDiveMode == 3) | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1278 logbook_UpdateHeader(pStateReal); |
38 | 1279 } |
1280 } | |
1281 else if(bDiveMode == 3) | |
1282 { | |
1283 //End of Dive | |
1284 logbook_SetAverageDepth(pStateReal->lifeData.average_depth_meter); | |
1285 logbook_SetMinTemperature(min_temperature_float_celsius); | |
1286 logbook_SetMaxCNS(pStateReal->lifeData.cns); | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1287 logbook_SetCompartmentDesaturation(pStateReal); |
38 | 1288 logbook_SetLastStop(pStateReal->diveSettings.last_stop_depth_bar); |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1289 gheader.batteryVoltage = pStateReal->lifeData.battery_voltage * 1000; |
471
73da921869d9
bugfix: implement battery charge percentage in dive header
Jan Mulder <jlmulder@xs4all.nl>
parents:
465
diff
changeset
|
1290 gheader.batteryCharge = pStateReal->lifeData.battery_charge; |
38 | 1291 logbook_EndDive(); |
1292 bDiveMode = 0; | |
1293 } else | |
1294 { | |
1295 ext_flash_enable_protection(); | |
1296 } | |
1297 } | |
1298 | |
1299 | |
1300 /* Private functions ---------------------------------------------------------*/ | |
1301 | |
1302 /******************************************************************************** | |
1303 * @brief logbook_UpdateHeader. / | |
1304 * set date, time, max depth. etc. pp. | |
1305 * the internal pointer to the end of profile and length will be set by | |
1306 ext_flash_close_new_dive_log() in externLogbookFlash.c | |
1307 * @author heinrichs weikamp gmbh | |
1308 * @version V0.0.1 | |
1309 * @date 27-Nov-2014 | |
1310 *********************************************************************************/ | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1311 static void logbook_UpdateHeader(const SDiveState *pStateReal) |
38 | 1312 { |
1313 // uint16_t secondsAtShallow = 0; | |
1314 RTC_DateTypeDef Sdate; | |
1315 RTC_TimeTypeDef Stime; | |
1316 uint32_t time1_u32, time2_u32; | |
1317 uint32_t divetimeHelper; | |
1318 | |
1319 /* time and day */ | |
1320 /* don't update CHANGE 160224 hw, maybe save actual time and date at other place | |
1321 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
1322 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
1323 | |
1324 header.dateYear = Sdate.Year; | |
1325 header.dateMonth = Sdate.Month; | |
1326 header.dateDay = Sdate.Date; | |
1327 header.timeHour = Stime.Hours; | |
1328 header.timeMinute = Stime.Minutes; | |
1329 */ | |
1330 /// 160315 Quick fix for empty date problem | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1331 if((!(gheader.dateYear)) || (!(gheader.dateMonth)) || (!(gheader.dateDay))) |
38 | 1332 { |
1333 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
1334 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
1335 | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1336 gheader.dateYear = Sdate.Year; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1337 gheader.dateMonth = Sdate.Month; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1338 gheader.dateDay = Sdate.Date; |
38 | 1339 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1340 time1_u32 = (uint32_t)gheader.timeMinute + (uint32_t)(gheader.timeHour * 60); |
38 | 1341 time2_u32 = (uint32_t)Stime.Minutes + (uint32_t)(Stime.Hours * 60); |
1342 if(time2_u32 < time1_u32) | |
1343 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1344 if(gheader.dateDay > 1) |
38 | 1345 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1346 gheader.dateDay -= 1; |
38 | 1347 } |
1348 else | |
1349 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1350 gheader.dateMonth --; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1351 if(!gheader.dateMonth) |
38 | 1352 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1353 gheader.dateYear--; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1354 gheader.dateMonth = 12; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1355 gheader.dateDay = 31; |
38 | 1356 } |
1357 else | |
1358 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1359 if(gheader.dateMonth == 2) |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1360 gheader.dateDay = 28; |
38 | 1361 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1362 if((gheader.dateMonth == 4) || (gheader.dateMonth == 6) || (gheader.dateMonth == 9) || (gheader.dateMonth == 11)) |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1363 gheader.dateDay = 30; |
38 | 1364 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1365 gheader.dateDay = 31; |
38 | 1366 } |
1367 } | |
1368 } | |
1369 } | |
1370 | |
1371 /* duration */ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1372 gheader.total_diveTime_seconds = pStateReal->lifeData.dive_time_seconds; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1373 gheader.maxDepth = pStateReal->lifeData.max_depth_meter * 100; |
38 | 1374 |
1375 /* old: | |
1376 | |
1377 secondsAtShallow = pSettings->timeoutDiveReachedZeroDepth; | |
1378 if(pStateReal->lifeData.dive_time_seconds <= secondsAtShallow) | |
1379 secondsAtShallow = 0; | |
1380 header.diveTimeMinutes = (header.total_diveTime_seconds - secondsAtShallow )/ 60; | |
1381 header.diveTimeSeconds = header.total_diveTime_seconds - secondsAtShallow - (header.diveTimeMinutes * 60); | |
1382 */ | |
1383 divetimeHelper = pStateReal->lifeData.dive_time_seconds_without_surface_time; | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1384 gheader.diveTimeMinutes = (uint16_t)(divetimeHelper/60); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1385 divetimeHelper -= 60 * (uint32_t)gheader.diveTimeMinutes; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1386 gheader.diveTimeSeconds = (uint16_t)divetimeHelper; |
38 | 1387 |
1388 /* deco algorithm (final) */ | |
1389 if(pStateReal->diveSettings.deco_type.ub.standard == GF_MODE) | |
1390 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1391 gheader.decoModel = 1; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1392 gheader.gfLow_or_Vpm_conservatism = pStateReal->diveSettings.gf_low; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1393 gheader.gfHigh = pStateReal->diveSettings.gf_high; |
38 | 1394 } |
1395 else | |
1396 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1397 gheader.decoModel = 2; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1398 gheader.gfLow_or_Vpm_conservatism = pStateReal->diveSettings.vpm_conservatism; |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1399 gheader.gfHigh = 0; |
38 | 1400 } |
1401 | |
1402 /* tissue load */ | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1403 memcpy(gheader.n2Compartments, pStateReal->lifeData.tissue_nitrogen_bar, 64); |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1404 memcpy(gheader.heCompartments, pStateReal->lifeData.tissue_helium_bar, 64); |
38 | 1405 |
1406 } | |
1407 | |
1408 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1409 static void logbook_SetAverageDepth(float average_depth_meter) |
38 | 1410 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1411 gheader.averageDepth_mbar = (uint16_t)(average_depth_meter * 100); |
38 | 1412 } |
1413 | |
1414 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1415 static void logbook_SetMinTemperature(float min_temperature_celsius) |
38 | 1416 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1417 gheader.minTemp = (int16_t)((min_temperature_celsius * 10.0f) + 0.5f); |
38 | 1418 } |
1419 | |
1420 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1421 static void logbook_SetMaxCNS(float max_cns_percentage) |
38 | 1422 { |
1423 if(max_cns_percentage < 9999) | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1424 gheader.maxCNS = (uint16_t)(max_cns_percentage); |
38 | 1425 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1426 gheader.maxCNS = 9999; |
38 | 1427 } |
1428 | |
1429 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
1430 static void logbook_SetCompartmentDesaturation(const SDiveState * pStateReal) |
38 | 1431 { |
225
2bb1db22b5f5
cleanup: random set of cleanups
Jan Mulder <jlmulder@xs4all.nl>
parents:
199
diff
changeset
|
1432 SLifeData2 secondaryInformation = { 0 }; |
38 | 1433 |
1434 decom_tissues_desaturation_time(&pStateReal->lifeData, &secondaryInformation); | |
1435 for(int i=0;i<16;i++) | |
1436 { | |
1437 if(secondaryInformation.tissue_nitrogen_desaturation_time_minutes[i] <= (15 * 255)) | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1438 gheader.n2CompartDesatTime_min[i] = (uint8_t)((secondaryInformation.tissue_nitrogen_desaturation_time_minutes[i] + 14) / 15); |
38 | 1439 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1440 gheader.n2CompartDesatTime_min[i] = 255; |
38 | 1441 if(secondaryInformation.tissue_helium_desaturation_time_minutes[i] <= (15 * 255)) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1442 gheader.heCompartDesatTime_min[i] = (uint8_t)((secondaryInformation.tissue_helium_desaturation_time_minutes[i] + 14 )/ 15); |
38 | 1443 else |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1444 gheader.heCompartDesatTime_min[i] = 255; |
38 | 1445 } |
1446 } | |
1447 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1448 static void logbook_SetLastStop(float last_stop_depth_bar) |
38 | 1449 { |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1450 gheader.lastDecostop_m = (uint8_t)(last_stop_depth_bar / 10.0f); |
38 | 1451 } |
1452 | |
194
f23b9055436f
cleanup: more trivial cleanup (logbook.c/h)
Jan Mulder <jlmulder@xs4all.nl>
parents:
149
diff
changeset
|
1453 static void logbook_writedata(void * data, int length_byte) |
38 | 1454 { |
1455 ext_flash_write_sample(data, length_byte); | |
1456 } | |
1457 | |
1458 /******************************************************************************** | |
1459 * @brief logbook_build_ostc3header. / | |
1460 * @author heinrichs weikamp gmbh | |
1461 * @version V0.0.2 | |
1462 * @date 27-Nov-2014 | |
1463 *********************************************************************************/ | |
1464 SLogbookHeaderOSTC3 * logbook_build_ostc3header(SLogbookHeader* pHead) | |
1465 { | |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1466 convert_Type data,data2; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1467 uint16_t dummyLength = 0; |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1468 uint8_t returnEmptyHeader = 0; |
38 | 1469 |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1470 uint32_t headerProfileLength, sampleProfileLength, sampleProfileStart; |
38 | 1471 |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1472 |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1473 if(pHead->diveHeaderStart != 0xFAFA) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1474 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1475 returnEmptyHeader = 1; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1476 } |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1477 else |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1478 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1479 memcpy(headerOSTC3.diveHeaderStart, &pHead->diveHeaderStart, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1480 memcpy(headerOSTC3.pBeginProfileData, &pHead->pBeginProfileData, 3); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1481 memcpy(headerOSTC3.pEndProfileData, &pHead->pEndProfileData, 3); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1482 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1483 data.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1484 data.u8bit.byteLow = pHead->pBeginProfileData[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1485 data.u8bit.byteMidLow = pHead->pBeginProfileData[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1486 data.u8bit.byteMidHigh = pHead->pBeginProfileData[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1487 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1488 sampleProfileStart = data.u32bit; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1489 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1490 data2.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1491 data2.u8bit.byteLow = pHead->pEndProfileData[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1492 data2.u8bit.byteMidLow = pHead->pEndProfileData[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1493 data2.u8bit.byteMidHigh = pHead->pEndProfileData[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1494 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1495 data.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1496 data.u8bit.byteLow = pHead->profileLength[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1497 data.u8bit.byteMidLow = pHead->profileLength[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1498 data.u8bit.byteMidHigh = pHead->profileLength[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1499 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1500 if(data.u32bit != 0xFFFFFF) /* if the profile in use ? */ |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1501 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1502 if(data2.u32bit < sampleProfileStart) /* Wrap around of sample ring detected */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1503 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1504 if(ext_flash_SampleOverrunValid() == 0) /* Wrap around does not seem to be valid => fallback */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1505 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1506 sampleProfileStart = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1507 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1508 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1509 if( sampleProfileStart == 0) /* should never happen unless OSTC with older debug version is in use (or invalid overrun) */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1510 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1511 sampleProfileLength = 1; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1512 headerProfileLength = 2; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1513 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1514 else |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1515 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1516 headerProfileLength = (pHead->profileLength[2] << 16) + (pHead->profileLength[1] << 8) + pHead->profileLength[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1517 sampleProfileLength = ext_flash_read_profilelength_small_header(sampleProfileStart); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1518 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1519 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1520 if(sampleProfileLength != headerProfileLength) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1521 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1522 dummyLength = logbook_fillDummySampleBuffer(pHead); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1523 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1524 data2.u32bit = sampleProfileStart + dummyLength; /* calc new end address (which is equal to dummyLength) */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1525 data.u32bit = dummyLength; /* data is used below to represent the length */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1526 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1527 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1528 data.u32bit += 3; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1529 headerOSTC3.profileLength[0] = data.u8bit.byteLow; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1530 headerOSTC3.profileLength[1] = data.u8bit.byteMidLow; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1531 headerOSTC3.profileLength[2] = data.u8bit.byteMidHigh; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1532 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1533 memcpy(headerOSTC3.gasordil, pHead->gasordil, 20); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1534 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1535 if(pHead->logbookProfileVersion == LOGBOOK_VERSION) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1536 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1537 headerOSTC3.logbookProfileVersion = LOGBOOK_VERSION_OSTC3; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1538 memcpy(headerOSTC3.personalDiveCount, &pHead->personalDiveCount, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1539 headerOSTC3.safetyDistance_10cm = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1540 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1541 for(int i=0;i<5;i++) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1542 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1543 if(!pHead->gasordil[i].note.ub.active) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1544 headerOSTC3.gasordil[3 + (i*4)] = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1545 else if(pHead->gasordil[i].note.ub.first) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1546 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1547 /* depth = 0, note = 1 */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1548 headerOSTC3.gasordil[2 + (i*4)] = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1549 headerOSTC3.gasordil[3 + (i*4)] = 1; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1550 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1551 else if( pHead->gasordil[i].depth_meter) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1552 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1553 /* note = 3 */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1554 headerOSTC3.gasordil[3 + (i*4)] = 3; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1555 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1556 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1557 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1558 else |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1559 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1560 headerOSTC3.logbookProfileVersion = 0xFF; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1561 headerOSTC3.personalDiveCount[0] = 0xFF; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1562 headerOSTC3.personalDiveCount[1] = 0xFF; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1563 headerOSTC3.safetyDistance_10cm = 0xFF; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1564 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1565 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1566 headerOSTC3.dateYear = pHead->dateYear; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1567 headerOSTC3.dateMonth = pHead->dateMonth; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1568 headerOSTC3.dateDay = pHead->dateDay; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1569 headerOSTC3.timeHour = pHead->timeHour; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1570 headerOSTC3.timeMinute = pHead->timeMinute; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1571 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1572 memcpy(headerOSTC3.maxDepth, &pHead->maxDepth, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1573 memcpy(headerOSTC3.diveTimeMinutes, &pHead->diveTimeMinutes, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1574 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1575 headerOSTC3.diveTimeSeconds = pHead->diveTimeSeconds; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1576 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1577 memcpy(headerOSTC3.minTemp, &pHead->minTemp, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1578 memcpy(headerOSTC3.surfacePressure_mbar,&pHead->surfacePressure_mbar, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1579 memcpy(headerOSTC3.desaturationTime, &pHead->desaturationTime, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1580 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1581 headerOSTC3.firmwareVersionHigh = pHead->firmwareVersionHigh; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1582 headerOSTC3.firmwareVersionLow = pHead->firmwareVersionLow; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1583 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1584 memcpy(headerOSTC3.batteryVoltage, &pHead->batteryVoltage, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1585 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1586 headerOSTC3.samplingRate = pHead->samplingRate; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1587 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1588 memcpy(headerOSTC3.cnsAtBeginning, &pHead->cnsAtBeginning, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1589 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1590 headerOSTC3.gfAtBeginning = pHead->gfAtBeginning; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1591 headerOSTC3.gfAtEnd = pHead->gfAtEnd; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1592 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1593 memcpy(headerOSTC3.setpoint, pHead->setpoint, 10); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1594 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1595 headerOSTC3.salinity = pHead->salinity; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1596 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1597 memcpy(headerOSTC3.maxCNS, &pHead->maxCNS, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1598 memcpy(headerOSTC3.averageDepth_mbar, &pHead->averageDepth_mbar, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1599 memcpy(headerOSTC3.total_diveTime_seconds, &pHead->total_diveTime_seconds, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1600 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1601 headerOSTC3.gfLow_or_Vpm_conservatism = pHead->gfLow_or_Vpm_conservatism; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1602 headerOSTC3.gfHigh = pHead->gfHigh; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1603 headerOSTC3.decoModel = pHead->decoModel; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1604 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1605 memcpy(headerOSTC3.diveNumber, &pHead->diveNumber, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1606 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1607 headerOSTC3.diveMode = pHead->diveMode; |
471
73da921869d9
bugfix: implement battery charge percentage in dive header
Jan Mulder <jlmulder@xs4all.nl>
parents:
465
diff
changeset
|
1608 headerOSTC3.batteryCharge = pHead->batteryCharge; |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1609 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1610 memcpy(headerOSTC3.n2CompartDesatTime_min,pHead->n2CompartDesatTime_min, 16); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1611 memcpy(headerOSTC3.n2Compartments, pHead->n2Compartments, 64); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1612 memcpy(headerOSTC3.heCompartDesatTime_min,pHead->heCompartDesatTime_min, 16); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1613 memcpy(headerOSTC3.heCompartments, pHead->heCompartments, 64); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1614 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1615 headerOSTC3.lastDecostop_m = pHead->lastDecostop_m; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1616 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1617 memcpy(headerOSTC3.hwHudBattery_mV, &pHead->hwHudBattery_mV, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1618 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1619 headerOSTC3.hwHudLastStatus = pHead->hwHudLastStatus; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1620 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1621 memcpy(headerOSTC3.batteryGaugeRegisters,&pHead->batteryGaugeRegisters, 6); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1622 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1623 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1624 memcpy(headerOSTC3.diveHeaderEnd, &pHead->diveHeaderEnd, 2); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1625 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1626 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1627 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1628 returnEmptyHeader = 1; |
38 | 1629 } |
1630 } | |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1631 if(returnEmptyHeader) /* profile not in use => return array full of 0xFF */ |
38 | 1632 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1633 memset(&headerOSTC3, 0xFF, sizeof(headerOSTC3)); |
38 | 1634 } |
1635 | |
1636 return &headerOSTC3; | |
1637 } | |
1638 | |
1639 | |
1640 /******************************************************************************** | |
1641 * @brief logbook_build_ostc3header_compact. / | |
1642 * @author heinrichs weikamp gmbh | |
1643 * @version V0.0.1 | |
1644 * @date 31-Juli-2015 | |
1645 *********************************************************************************/ | |
1646 SLogbookHeaderOSTC3compact * logbook_build_ostc3header_compact(SLogbookHeader* pHead) | |
1647 { | |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1648 uint8_t returnEmptyHeader = 0; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1649 convert_Type data, data2; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1650 uint32_t dummyLength = 0; |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1651 uint32_t headerProfileLength, sampleProfileLength, sampleProfileStart; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1652 |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1653 if(pHead->diveHeaderStart != 0xFAFA) |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1654 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1655 returnEmptyHeader = 1; |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1656 } |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1657 else |
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1658 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1659 data.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1660 data.u8bit.byteLow = pHead->pBeginProfileData[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1661 data.u8bit.byteMidLow = pHead->pBeginProfileData[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1662 data.u8bit.byteMidHigh = pHead->pBeginProfileData[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1663 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1664 sampleProfileStart = data.u32bit; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1665 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1666 data2.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1667 data2.u8bit.byteLow = pHead->pEndProfileData[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1668 data2.u8bit.byteMidLow = pHead->pEndProfileData[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1669 data2.u8bit.byteMidHigh = pHead->pEndProfileData[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1670 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1671 data.u8bit.byteHigh = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1672 data.u8bit.byteLow = pHead->profileLength[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1673 data.u8bit.byteMidLow = pHead->profileLength[1]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1674 data.u8bit.byteMidHigh = pHead->profileLength[2]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1675 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1676 if(data.u32bit != 0xFFFFFF) |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1677 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1678 if(data2.u32bit < sampleProfileStart) /* Wrap around of sample ring detected */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1679 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1680 if(ext_flash_SampleOverrunValid() == 0) /* Wrap around does not seem to be valid => fallback */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1681 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1682 sampleProfileStart = 0; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1683 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1684 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1685 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1686 if( sampleProfileStart == 0) /* no sample data available => use dummy */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1687 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1688 sampleProfileLength = 1; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1689 headerProfileLength = 2; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1690 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1691 else |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1692 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1693 headerProfileLength = (pHead->profileLength[2] << 16) + (pHead->profileLength[1] << 8) + pHead->profileLength[0]; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1694 sampleProfileLength = ext_flash_read_profilelength_small_header(sampleProfileStart); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1695 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1696 if(sampleProfileLength != headerProfileLength) |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1697 { |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1698 dummyLength = logbook_fillDummySampleBuffer(pHead); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1699 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1700 data2.u32bit = sampleProfileStart + dummyLength; /* calc new end address (which is equal to dummyLength) */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1701 data.u32bit = dummyLength; /* data is used below to represent the length */ |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1702 } |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1703 data.u32bit += 3; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1704 headerOSTC3compact.profileLength[0] = data.u8bit.byteLow; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1705 headerOSTC3compact.profileLength[1] = data.u8bit.byteMidLow; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1706 headerOSTC3compact.profileLength[2] = data.u8bit.byteMidHigh; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1707 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1708 headerOSTC3compact.dateYear = pHead->dateYear; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1709 headerOSTC3compact.dateMonth = pHead->dateMonth; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1710 headerOSTC3compact.dateDay = pHead->dateDay; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1711 headerOSTC3compact.timeHour = pHead->timeHour; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1712 headerOSTC3compact.timeMinute = pHead->timeMinute; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1713 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1714 memcpy(headerOSTC3compact.maxDepth, &pHead->maxDepth, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1715 memcpy(headerOSTC3compact.diveTimeMinutes, &pHead->diveTimeMinutes, 2); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1716 |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1717 headerOSTC3compact.diveTimeSeconds = pHead->diveTimeSeconds; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1718 headerOSTC3compact.totalDiveNumberLow = pHead->diveNumber & 0xFF; |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1719 headerOSTC3compact.totalDiveNumberHigh = (uint8_t)(pHead->diveNumber/256); |
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1720 headerOSTC3compact.profileVersion = 0x24; // Logbook-Profile version, 0x24 = date and time is start not end |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1721 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1722 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1723 { |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1724 returnEmptyHeader = 1; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1725 } |
411
e908b894f107
Bugfix: Limit log length in case of corrupted sample storage:
ideenmodellierer
parents:
325
diff
changeset
|
1726 } |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1727 if(returnEmptyHeader) |
38 | 1728 { |
1729 memset(&headerOSTC3compact, 0xFF, sizeof(SLogbookHeaderOSTC3compact)); | |
1730 } | |
1731 return &headerOSTC3compact; | |
1732 } | |
1733 | |
1734 | |
1735 /** | |
1736 ****************************************************************************** | |
1737 * @brief logbook_readSampleData. / Reads sample data of whole logbook entry | |
281 | 1738 * @author heinrichs weikamp |
38 | 1739 * @version V0.0.1 |
1740 * @date 22-April-2014 | |
1741 ****************************************************************************** | |
1742 * | |
1743 * @param uint8_t StepBackwards: witch lookbook entry? | |
1744 * @param uint16_t length : maxlength of output arrays | |
1745 * @param int32_t* depth : output array | |
1746 * @param int16_t * gasid : output array | |
1747 * @param int32_t* temperature : output array | |
1748 * @param int32_t* ppo2 : output array | |
1749 * @param int32_t* cns : output array | |
1750 * @return length of output | |
1751 */ | |
1752 void logbook_recover_brokenlog(uint8_t headerId) | |
1753 { | |
1754 int16_t retVal; | |
1755 int32_t depthVal = 0; | |
1756 int16_t gasidVal = 0; | |
1757 int16_t setPointVal = 0; | |
1758 int16_t bailoutVal = 0; | |
1759 int32_t temperatureVal = 0; | |
1760 int32_t sensor1Val = 0; | |
1761 int32_t sensor2Val = 0; | |
1762 int32_t sensor3Val = 0; | |
1763 int32_t cnsVal = 0; | |
1764 SManualGas manualGasVal; | |
1765 | |
1766 //uint16_t* ppo2, uint16_t* cns# | |
1767 uint32_t bytesRead = 0; | |
1768 | |
1769 ext_flash_read_block_start(); | |
1770 ext_flash_read_next_sample_part((uint8_t*)&smallHeader, sizeof(SSmallHeader)); | |
1771 bytesRead += sizeof(SSmallHeader); | |
1772 | |
1773 clear_divisor(); | |
1774 | |
1775 | |
1776 int sampleCounter = 0; | |
1777 int maxdepth = 0; | |
1778 uint32_t avrdepth = 0; | |
1779 while (true) | |
1780 { | |
1781 | |
1782 ext_flash_set_entry_point(); | |
1783 divisorBackup = divisor; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1784 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1785 if(retVal == 0) |
1786 { | |
1787 //Error try to read again!!! | |
1788 ext_flash_reopen_read_sample_at_entry_point(); | |
1789 divisor = divisorBackup; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1790 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1791 |
1792 if(retVal == 0) | |
1793 { | |
1794 //Error try to read again!!! | |
1795 ext_flash_reopen_read_sample_at_entry_point(); | |
1796 divisor = divisorBackup; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1797 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); |
38 | 1798 |
1799 if(retVal == 0) | |
1800 { | |
1801 ext_flash_reopen_read_sample_at_entry_point(); | |
1802 break; | |
1803 } | |
1804 | |
1805 } | |
1806 } | |
1807 if(depthVal > maxdepth) | |
1808 maxdepth = depthVal; | |
1809 avrdepth += depthVal; | |
1810 sampleCounter++; | |
1811 bytesRead +=retVal; | |
1812 } | |
1813 avrdepth/= sampleCounter; | |
1814 ext_flash_close_read_sample(); | |
1815 SLogbookHeader header; | |
1816 | |
1817 ext_flash_read_dive_header2((uint8_t*) &header, headerId, false); | |
1818 header.total_diveTime_seconds = sampleCounter * header.samplingRate; | |
1819 header.diveTimeMinutes = header.total_diveTime_seconds /60; | |
1820 header.diveTimeSeconds = header.total_diveTime_seconds - header.diveTimeMinutes * 60; | |
1821 header.maxDepth = maxdepth; | |
1822 header.averageDepth_mbar = avrdepth; | |
1823 SSettings * settings = settingsGetPointer(); | |
1824 settings->lastDiveLogId = headerId; | |
1825 ext_flash_close_new_dive_log((uint8_t *)&header); | |
1826 } | |
1827 | |
458 | 1828 void logbook_createDummyProfile(SLogbookHeader* pHeader, uint16_t length, uint16_t* depth, int16_t* temperature, uint16_t* ppo2) |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1829 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1830 uint8_t drawDeco = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1831 uint16_t index = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1832 uint16_t indexDescenStop = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1833 uint16_t indexAscendStart = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1834 uint16_t simDecentDepth = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1835 uint16_t simDecentStep = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1836 uint16_t simAcentDepth = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1837 uint16_t simAcentStep = 0; |
458 | 1838 float ambiant_pressure_bar = 0; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1839 |
458 | 1840 simDecentStep = pHeader->maxDepth / (length / 6); /* first 1/6 for descend */ |
1841 simAcentStep = pHeader->maxDepth / (length / 3); /* first 1/3 for ascend */ | |
1842 | |
1843 SGas gas; | |
1844 | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1845 |
458 | 1846 if(ppo2) |
1847 { | |
1848 /* find first gas ID */ | |
1849 for(index = 0; index < NUM_GAS; index++) | |
1850 { | |
1851 if(pHeader->gasordil[index].note.ub.first) | |
1852 break; | |
1853 } | |
1854 if(index != NUM_GAS) | |
1855 { | |
1856 gas.helium_percentage = pHeader->gasordil[index].helium_percentage; | |
1857 gas.nitrogen_percentage = 100 - gas.helium_percentage - pHeader->gasordil[index].oxygen_percentage; | |
1858 } | |
1859 } | |
1860 | |
1861 while((index < length) && (simDecentDepth < pHeader->maxDepth)) /* draw decent */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1862 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1863 depth[index] = simDecentDepth; |
458 | 1864 temperature[index] = pHeader->minTemp; |
1865 if(ppo2) | |
1866 { | |
1867 ambiant_pressure_bar =((float)(depth[index] + pHeader->surfacePressure_mbar))/1000; | |
1868 ppo2[index] = (uint16_t) ((decom_calc_ppO2(ambiant_pressure_bar, &gas )) * 100); | |
1869 } | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1870 index++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1871 simDecentDepth += simDecentStep; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1872 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1873 indexDescenStop = index; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1874 index = length -1; |
458 | 1875 while((index > indexDescenStop) && (simAcentDepth < pHeader->maxDepth)) /* draw ascend including max deco stop */ |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1876 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1877 depth[index] = simAcentDepth; |
458 | 1878 temperature[index] = pHeader->minTemp; |
1879 if(ppo2) | |
1880 { | |
1881 ambiant_pressure_bar =((float)(depth[index] + pHeader->surfacePressure_mbar))/1000; | |
1882 ppo2[index] = (uint16_t) ((decom_calc_ppO2(ambiant_pressure_bar, &gas )) * 100); | |
1883 } | |
1884 if((drawDeco) && (simAcentDepth < pHeader->lastDecostop_m)) /* draw deco step */ | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1885 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1886 drawDeco = length / 10; |
458 | 1887 while(drawDeco) |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1888 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1889 index--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1890 depth[index] = simAcentDepth; |
458 | 1891 temperature[index] = pHeader->minTemp; |
1892 if(ppo2) | |
1893 { | |
1894 ambiant_pressure_bar =((float)(depth[index] + pHeader->surfacePressure_mbar))/1000; | |
1895 ppo2[index] = (uint16_t) ((decom_calc_ppO2(ambiant_pressure_bar, &gas )) * 100); | |
1896 } | |
1897 drawDeco--; | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1898 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1899 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1900 index--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1901 simAcentDepth += simAcentStep; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1902 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1903 indexAscendStart = index; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1904 index = indexDescenStop; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1905 while(index <= indexAscendStart) /* draw isobar dive phase */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1906 { |
458 | 1907 depth[index] = pHeader->maxDepth; |
1908 temperature[index] = pHeader->minTemp; | |
1909 if(ppo2) | |
1910 { | |
1911 ambiant_pressure_bar =((float)(depth[index] + pHeader->surfacePressure_mbar))/1000; | |
1912 ppo2[index] = (uint16_t) ((decom_calc_ppO2(ambiant_pressure_bar, &gas )) * 100); | |
1913 } | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1914 index++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1915 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1916 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1917 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1918 void logbook_resetDummy() |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1919 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1920 dummyWriteIdx = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1921 dummyReadIdx = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1922 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1923 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1924 void logbook_writeDummy(void* data, uint16_t length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1925 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1926 memcpy(&dummyMemoryBuffer[dummyWriteIdx],(uint8_t *)data, length); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1927 dummyWriteIdx += length; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1928 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1929 void logbook_writeDummySample(uint16_t depth, int16_t temperature) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1930 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1931 uint8_t sample[10]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1932 int length = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1933 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1934 int i = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1935 for(i = 0; i <10 ;i++) sample[i] = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1936 addU16(sample, depth); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1937 length += 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1938 sample[2] = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1939 length++; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1940 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1941 if(divisor.temperature == 0) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1942 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1943 divisor.temperature = smallHeader.tempDivisor - 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1944 addS16(&sample[length], temperature); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1945 length += 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1946 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1947 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1948 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1949 divisor.temperature--; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1950 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1951 |
465
2c2df051e554
Compare profile length from header and sample data to identify valid profiles
ideenmodellierer
parents:
458
diff
changeset
|
1952 logbook_writeDummy((void *) sample,length); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1953 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1954 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1955 |
458 | 1956 uint16_t logbook_fillDummySampleBuffer(SLogbookHeader* pHeader) |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1957 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1958 uint16_t depthArray[DUMMY_SAMPLES]; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1959 int16_t temperatureArray[DUMMY_SAMPLES]; |
458 | 1960 uint16_t ppo2Array[DUMMY_SAMPLES]; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1961 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1962 uint16_t index = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1963 uint16_t dummyBufferSize = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1964 uint16_t dummyProfileLength = 0; |
458 | 1965 uint32_t overallSecond = pHeader->diveTimeMinutes * 60 + pHeader->diveTimeSeconds; |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1966 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1967 logbook_resetDummy(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1968 clear_divisor(); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1969 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1970 smallDummyHeader.profileLength[0] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1971 smallDummyHeader.profileLength[1] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1972 smallDummyHeader.profileLength[2] = 0xFF; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1973 smallDummyHeader.samplingRate_seconds = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1974 smallDummyHeader.numDivisors = 7; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1975 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1976 smallDummyHeader.tempType = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1977 smallDummyHeader.tempLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1978 smallDummyHeader.tempDivisor = 6; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1979 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1980 smallDummyHeader.deco_ndlType = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1981 smallDummyHeader.deco_ndlLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1982 smallDummyHeader.deco_ndlDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1983 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1984 /* GF in % at actual position */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1985 smallDummyHeader.gfType = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1986 smallDummyHeader.gfLength = 1; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1987 smallDummyHeader.gfDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1988 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1989 /* 3 Sensors: 8bit ppO2 in 0.01bar, 16bit voltage in 0,1mV */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1990 smallDummyHeader.ppo2Type = 3; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1991 smallDummyHeader.ppo2Length = 9; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1992 smallDummyHeader.ppo2Divisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1993 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1994 /* last 15 stops in minutes (last, second_to_last, ... */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1995 /* last stop depth is defined in header */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1996 smallDummyHeader.decoplanType = 4; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1997 smallDummyHeader.decoplanLength = 15; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1998 smallDummyHeader.decoplanDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
1999 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2000 smallDummyHeader.cnsType = 5; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2001 smallDummyHeader.cnsLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2002 smallDummyHeader.cnsDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2003 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2004 smallDummyHeader.tankType = 6; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2005 smallDummyHeader.tankLength = 2; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2006 smallDummyHeader.tankDivisor = 0; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2007 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2008 if((overallSecond / smallDummyHeader.samplingRate_seconds) > DUMMY_SAMPLES) /* reduce sample interval to keep buffer size */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2009 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2010 smallDummyHeader.samplingRate_seconds = overallSecond / DUMMY_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2011 dummyProfileLength = DUMMY_SAMPLES; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2012 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2013 else |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2014 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2015 dummyProfileLength = overallSecond / smallDummyHeader.samplingRate_seconds; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2016 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2017 logbook_writeDummy((void *) &smallDummyHeader,sizeof(smallDummyHeader)); |
458 | 2018 logbook_createDummyProfile(pHeader,dummyProfileLength, depthArray, temperatureArray, ppo2Array ); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2019 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2020 for (index = 0; index < dummyProfileLength; index++) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2021 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2022 logbook_writeDummySample(depthArray[index], temperatureArray[index]); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2023 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2024 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2025 dummyBufferSize = dummyWriteIdx; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2026 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2027 return dummyBufferSize; /* return size of dummy buffer */ |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2028 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2029 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2030 void logbook_readDummySamples(uint8_t* pTarget, uint16_t length) |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2031 { |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2032 memcpy(pTarget,&dummyMemoryBuffer[dummyReadIdx],length); |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2033 dummyReadIdx += length; |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2034 } |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2035 |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
445
diff
changeset
|
2036 |
38 | 2037 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |