38
|
1 ///////////////////////////////////////////////////////////////////////////////
|
|
2 /// -*- coding: UTF-8 -*-
|
|
3 ///
|
|
4 /// \file Discovery/Inc/logbook.h
|
|
5 /// \brief
|
|
6 /// \author Heinrichs Weikamp
|
|
7 /// \date 2018
|
|
8 ///
|
|
9 /// $Id$
|
|
10 ///////////////////////////////////////////////////////////////////////////////
|
|
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
|
|
12 ///
|
|
13 /// This program is free software: you can redistribute it and/or modify
|
|
14 /// it under the terms of the GNU General Public License as published by
|
|
15 /// the Free Software Foundation, either version 3 of the License, or
|
|
16 /// (at your option) any later version.
|
|
17 ///
|
|
18 /// This program is distributed in the hope that it will be useful,
|
|
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 /// GNU General Public License for more details.
|
|
22 ///
|
|
23 /// You should have received a copy of the GNU General Public License
|
|
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25 //////////////////////////////////////////////////////////////////////////////
|
|
26
|
|
27 #ifndef LOGBOOK_H
|
|
28 #define LOGBOOK_H
|
|
29
|
|
30 #include "data_central.h"
|
|
31 #include "settings.h"
|
|
32
|
|
33 typedef struct
|
|
34 {
|
|
35 uint8_t setpoint_cbar;
|
|
36 uint8_t depth_meter;
|
|
37 } SSetpointLog;
|
|
38
|
|
39 typedef struct
|
|
40 {
|
|
41 uint8_t oxygen_percentage;
|
|
42 uint8_t helium_percentage;
|
|
43 uint8_t depth_meter;
|
|
44 gasbit8_Type note;
|
|
45 } SGasListLog;
|
|
46
|
|
47 //Logbook
|
|
48 typedef struct
|
|
49 {
|
|
50 uint16_t diveHeaderStart;
|
|
51 uint8_t pBeginProfileData[3];
|
|
52 uint8_t pEndProfileData[3];
|
|
53 uint8_t profileLength[3];
|
|
54 uint8_t logbookProfileVersion;
|
|
55 uint8_t dateYear;
|
|
56 uint8_t dateMonth;
|
|
57 uint8_t dateDay;
|
|
58 uint8_t timeHour;
|
|
59 uint8_t timeMinute;
|
|
60 uint8_t extraPagesWithData; /* from here on: changes in order with respect to OSTC3 */
|
|
61 uint16_t maxDepth;
|
|
62 uint16_t diveTimeMinutes;
|
|
63 uint8_t diveTimeSeconds;
|
|
64 uint8_t samplingRate;
|
|
65 int16_t minTemp;
|
|
66 uint16_t surfacePressure_mbar;
|
|
67 uint16_t desaturationTime;
|
|
68 SGasListLog gasordil[5];
|
|
69 uint8_t firmwareVersionLow;
|
|
70 uint8_t firmwareVersionHigh;
|
|
71 uint16_t batteryVoltage;
|
|
72 uint16_t cnsAtBeginning;
|
|
73 uint8_t gfAtBeginning;
|
|
74 uint8_t gfAtEnd;
|
|
75 uint16_t personalDiveCount;
|
|
76 SSetpointLog setpoint[5];
|
|
77 uint16_t maxCNS;
|
|
78 uint16_t averageDepth_mbar;
|
|
79 uint16_t total_diveTime_seconds;
|
|
80 uint8_t salinity;
|
|
81 uint8_t gfLow_or_Vpm_conservatism;
|
|
82 uint8_t gfHigh;
|
|
83 uint8_t decoModel;
|
|
84 float n2Compartments[16];
|
|
85 float heCompartments[16];
|
|
86 uint8_t n2CompartDesatTime_min[16];
|
|
87 uint8_t heCompartDesatTime_min[16];
|
|
88 uint16_t diveNumber;
|
|
89 uint8_t lastDecostop_m;
|
|
90 uint8_t CCRmode;
|
|
91 uint8_t diveMode;
|
|
92 uint8_t hwHudLastStatus; /* from here on identical to OSTC3 again */
|
|
93 uint16_t hwHudBattery_mV;
|
|
94 uint8_t batteryGaugeRegisters[6];
|
|
95 uint16_t diveHeaderEnd;
|
|
96 } SLogbookHeader;
|
|
97
|
|
98 //Logbook OSTC3
|
|
99 typedef struct
|
|
100 {
|
|
101 uint8_t diveHeaderStart[2];
|
|
102 uint8_t pBeginProfileData[3];
|
|
103 uint8_t pEndProfileData[3];
|
|
104 uint8_t logbookProfileVersion;
|
|
105 uint8_t profileLength[3];
|
|
106 uint8_t dateYear;
|
|
107 uint8_t dateMonth;
|
|
108 uint8_t dateDay;
|
|
109 uint8_t timeHour;
|
|
110 uint8_t timeMinute;
|
|
111 uint8_t maxDepth[2];
|
|
112 uint8_t diveTimeMinutes[2];
|
|
113 uint8_t diveTimeSeconds;
|
|
114 uint8_t minTemp[2];
|
|
115 uint8_t surfacePressure_mbar[2];
|
|
116 uint8_t desaturationTime[2];
|
|
117 uint8_t gasordil[5*4];
|
|
118 uint8_t firmwareVersionLow;
|
|
119 uint8_t firmwareVersionHigh;
|
|
120 uint8_t batteryVoltage[2];
|
|
121 uint8_t samplingRate;
|
|
122 uint8_t cnsAtBeginning[2];
|
|
123 uint8_t gfAtBeginning;
|
|
124 uint8_t gfAtEnd;
|
|
125 uint8_t personalDiveCount[2];
|
|
126 uint8_t CCRmode;
|
|
127 uint8_t setpoint[5*2];
|
|
128 uint8_t salinity;
|
|
129 uint8_t maxCNS[2];
|
|
130 uint8_t averageDepth_mbar[2];
|
|
131 uint8_t total_diveTime_seconds[2];
|
|
132 uint8_t gfLow_or_Vpm_conservatism;
|
|
133 uint8_t gfHigh;
|
|
134 uint8_t decoModel;
|
|
135 uint8_t diveNumber[2];
|
|
136 uint8_t diveMode;
|
|
137 uint8_t n2CompartDesatTime_min[16];
|
|
138 uint8_t n2Compartments[16*4];
|
|
139 uint8_t heCompartDesatTime_min[16];
|
|
140 uint8_t heCompartments[16*4];
|
|
141 uint8_t lastDecostop_m;
|
|
142 uint8_t safetyDistance_10cm;
|
|
143 uint8_t hwHudBattery_mV[2];
|
|
144 uint8_t hwHudLastStatus;
|
|
145 uint8_t batteryGaugeRegisters[6];
|
|
146 uint8_t diveHeaderEnd[2];
|
|
147 } SLogbookHeaderOSTC3;
|
|
148
|
|
149
|
|
150 //Logbook OSTC3
|
|
151 typedef struct
|
|
152 {
|
|
153 uint8_t profileLength[3];
|
|
154 uint8_t dateYear;
|
|
155 uint8_t dateMonth;
|
|
156 uint8_t dateDay;
|
|
157 uint8_t timeHour;
|
|
158 uint8_t timeMinute;
|
|
159 uint8_t maxDepth[2];
|
|
160 uint8_t diveTimeMinutes[2];
|
|
161 uint8_t diveTimeSeconds;
|
|
162 uint8_t totalDiveNumberLow;
|
|
163 uint8_t totalDiveNumberHigh;
|
|
164 uint8_t profileVersion;
|
|
165 } SLogbookHeaderOSTC3compact;
|
|
166
|
|
167
|
|
168 typedef struct
|
|
169 {
|
|
170 uint8_t profileLength[3];
|
|
171 uint8_t samplingRate_seconds;
|
|
172 uint8_t numDivisors;
|
|
173 uint8_t tempType;
|
|
174 uint8_t tempLength;
|
|
175 uint8_t tempDivisor;
|
|
176 uint8_t deco_ndlType;
|
|
177 uint8_t deco_ndlLength;
|
|
178 uint8_t deco_ndlDivisor;
|
|
179 uint8_t gfType;
|
|
180 uint8_t gfLength;
|
|
181 uint8_t gfDivisor;
|
|
182 uint8_t ppo2Type;
|
|
183 uint8_t ppo2Length;
|
|
184 uint8_t ppo2Divisor;
|
|
185 uint8_t decoplanType;
|
|
186 uint8_t decoplanLength;
|
|
187 uint8_t decoplanDivisor;
|
|
188 uint8_t cnsType;
|
|
189 uint8_t cnsLength;
|
|
190 uint8_t cnsDivisor;
|
|
191 uint8_t tankType;
|
|
192 uint8_t tankLength;
|
|
193 uint8_t tankDivisor;
|
|
194 } SSmallHeader;
|
|
195
|
|
196 typedef struct
|
|
197 {
|
|
198 int8_t percentageO2;
|
|
199 int8_t percentageHe;
|
|
200 } SManualGas;
|
|
201
|
|
202 void logbook_writeSample(SDiveState state);
|
|
203 void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings);
|
|
204 void logbook_EndDive(void);
|
|
205
|
|
206 SLogbookHeader* logbook_getCurrentHeader(void);
|
|
207 SLogbookHeaderOSTC3 * logbook_build_ostc3header(SLogbookHeader* pLogbookHeader);
|
|
208 SLogbookHeaderOSTC3compact * logbook_build_ostc3header_compact(SLogbookHeader* pHead);
|
|
209
|
|
210 uint8_t logbook_getNumberOfHeaders(void);
|
|
211 uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader);
|
|
212 uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, uint16_t* decostopDepth);
|
|
213 void logbook_test(void);
|
|
214 void logbook_InitAndWrite(void);
|
|
215 void logbook_recover_brokenlog(uint8_t headerId);
|
|
216
|
|
217 uint16_t logbook_lastDive_diveNumber(void);
|
|
218
|
|
219 #endif /* LOGBOOK_H */
|