annotate Discovery/Src/logbook.c @ 1058:3c73180fde1d Icon_Integration tip

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