Mercurial > public > ostc4
annotate Discovery/Inc/logbook.h @ 475:4b000e2386c2 Improve_Button_Sleep
Changed default values:
Invalid pressure was signalled using the float 100.0 causing the OSTC to enter dive mode if for some I2C communication was disturbed during startup.
The default value for button responsitivness was set to 85% without considering the needed HWOS transformation calculation. Applying that the value for 85% is 51
PowerOnReset is state is now identified using the same functionality as already introduced for the battery charge handling.
Initialization of pressure sensor in case of I2C problems only if the initialization was not successfull before:
The pressure sensor is reset via a I2C commend in case of a I2C error. A reset might be helpfull in case of a "hanging" ADC operation but that would not be indicated by a I2C problem => resetting the sensor in case of a I2C problem might cause (small) change of pressure value
author | ideenmodellierer |
---|---|
date | Tue, 12 May 2020 22:52:05 +0200 |
parents | 5dd996ed8611 |
children | 73da921869d9 |
rev | line source |
---|---|
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 | |
458 | 33 #define NUM_GAS (5) /* number of selectable gases */ |
34 | |
38 | 35 typedef struct |
36 { | |
37 uint8_t setpoint_cbar; | |
38 uint8_t depth_meter; | |
39 } SSetpointLog; | |
40 | |
41 typedef struct | |
42 { | |
43 uint8_t oxygen_percentage; | |
44 uint8_t helium_percentage; | |
45 uint8_t depth_meter; | |
46 gasbit8_Type note; | |
47 } SGasListLog; | |
48 | |
49 //Logbook | |
50 typedef struct | |
51 { | |
52 uint16_t diveHeaderStart; | |
53 uint8_t pBeginProfileData[3]; | |
54 uint8_t pEndProfileData[3]; | |
55 uint8_t profileLength[3]; | |
56 uint8_t logbookProfileVersion; | |
57 uint8_t dateYear; | |
58 uint8_t dateMonth; | |
59 uint8_t dateDay; | |
60 uint8_t timeHour; | |
61 uint8_t timeMinute; | |
62 uint8_t extraPagesWithData; /* from here on: changes in order with respect to OSTC3 */ | |
63 uint16_t maxDepth; | |
64 uint16_t diveTimeMinutes; | |
65 uint8_t diveTimeSeconds; | |
66 uint8_t samplingRate; | |
67 int16_t minTemp; | |
68 uint16_t surfacePressure_mbar; | |
69 uint16_t desaturationTime; | |
458 | 70 SGasListLog gasordil[NUM_GAS]; |
38 | 71 uint8_t firmwareVersionLow; |
72 uint8_t firmwareVersionHigh; | |
73 uint16_t batteryVoltage; | |
74 uint16_t cnsAtBeginning; | |
75 uint8_t gfAtBeginning; | |
76 uint8_t gfAtEnd; | |
77 uint16_t personalDiveCount; | |
458 | 78 SSetpointLog setpoint[NUM_GAS]; |
38 | 79 uint16_t maxCNS; |
80 uint16_t averageDepth_mbar; | |
81 uint16_t total_diveTime_seconds; | |
82 uint8_t salinity; | |
83 uint8_t gfLow_or_Vpm_conservatism; | |
84 uint8_t gfHigh; | |
85 uint8_t decoModel; | |
86 float n2Compartments[16]; | |
87 float heCompartments[16]; | |
88 uint8_t n2CompartDesatTime_min[16]; | |
89 uint8_t heCompartDesatTime_min[16]; | |
90 uint16_t diveNumber; | |
91 uint8_t lastDecostop_m; | |
92 uint8_t CCRmode; | |
93 uint8_t diveMode; | |
94 uint8_t hwHudLastStatus; /* from here on identical to OSTC3 again */ | |
95 uint16_t hwHudBattery_mV; | |
96 uint8_t batteryGaugeRegisters[6]; | |
97 uint16_t diveHeaderEnd; | |
98 } SLogbookHeader; | |
99 | |
100 //Logbook OSTC3 | |
101 typedef struct | |
102 { | |
103 uint8_t diveHeaderStart[2]; | |
104 uint8_t pBeginProfileData[3]; | |
105 uint8_t pEndProfileData[3]; | |
106 uint8_t logbookProfileVersion; | |
107 uint8_t profileLength[3]; | |
108 uint8_t dateYear; | |
109 uint8_t dateMonth; | |
110 uint8_t dateDay; | |
111 uint8_t timeHour; | |
112 uint8_t timeMinute; | |
113 uint8_t maxDepth[2]; | |
114 uint8_t diveTimeMinutes[2]; | |
115 uint8_t diveTimeSeconds; | |
116 uint8_t minTemp[2]; | |
117 uint8_t surfacePressure_mbar[2]; | |
118 uint8_t desaturationTime[2]; | |
458 | 119 uint8_t gasordil[NUM_GAS*4]; |
38 | 120 uint8_t firmwareVersionLow; |
121 uint8_t firmwareVersionHigh; | |
122 uint8_t batteryVoltage[2]; | |
123 uint8_t samplingRate; | |
124 uint8_t cnsAtBeginning[2]; | |
125 uint8_t gfAtBeginning; | |
126 uint8_t gfAtEnd; | |
127 uint8_t personalDiveCount[2]; | |
128 uint8_t CCRmode; | |
129 uint8_t setpoint[5*2]; | |
130 uint8_t salinity; | |
131 uint8_t maxCNS[2]; | |
132 uint8_t averageDepth_mbar[2]; | |
133 uint8_t total_diveTime_seconds[2]; | |
134 uint8_t gfLow_or_Vpm_conservatism; | |
135 uint8_t gfHigh; | |
136 uint8_t decoModel; | |
137 uint8_t diveNumber[2]; | |
138 uint8_t diveMode; | |
139 uint8_t n2CompartDesatTime_min[16]; | |
140 uint8_t n2Compartments[16*4]; | |
141 uint8_t heCompartDesatTime_min[16]; | |
142 uint8_t heCompartments[16*4]; | |
143 uint8_t lastDecostop_m; | |
144 uint8_t safetyDistance_10cm; | |
145 uint8_t hwHudBattery_mV[2]; | |
146 uint8_t hwHudLastStatus; | |
147 uint8_t batteryGaugeRegisters[6]; | |
148 uint8_t diveHeaderEnd[2]; | |
149 } SLogbookHeaderOSTC3; | |
150 | |
151 | |
152 //Logbook OSTC3 | |
153 typedef struct | |
154 { | |
155 uint8_t profileLength[3]; | |
156 uint8_t dateYear; | |
157 uint8_t dateMonth; | |
158 uint8_t dateDay; | |
159 uint8_t timeHour; | |
160 uint8_t timeMinute; | |
161 uint8_t maxDepth[2]; | |
162 uint8_t diveTimeMinutes[2]; | |
163 uint8_t diveTimeSeconds; | |
164 uint8_t totalDiveNumberLow; | |
165 uint8_t totalDiveNumberHigh; | |
166 uint8_t profileVersion; | |
167 } SLogbookHeaderOSTC3compact; | |
168 | |
169 | |
170 typedef struct | |
171 { | |
172 uint8_t profileLength[3]; | |
173 uint8_t samplingRate_seconds; | |
174 uint8_t numDivisors; | |
175 uint8_t tempType; | |
176 uint8_t tempLength; | |
177 uint8_t tempDivisor; | |
178 uint8_t deco_ndlType; | |
179 uint8_t deco_ndlLength; | |
180 uint8_t deco_ndlDivisor; | |
181 uint8_t gfType; | |
182 uint8_t gfLength; | |
183 uint8_t gfDivisor; | |
184 uint8_t ppo2Type; | |
185 uint8_t ppo2Length; | |
186 uint8_t ppo2Divisor; | |
187 uint8_t decoplanType; | |
188 uint8_t decoplanLength; | |
189 uint8_t decoplanDivisor; | |
190 uint8_t cnsType; | |
191 uint8_t cnsLength; | |
192 uint8_t cnsDivisor; | |
193 uint8_t tankType; | |
194 uint8_t tankLength; | |
195 uint8_t tankDivisor; | |
196 } SSmallHeader; | |
197 | |
198 typedef struct | |
199 { | |
200 int8_t percentageO2; | |
201 int8_t percentageHe; | |
202 } SManualGas; | |
203 | |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
204 void logbook_writeSample(const SDiveState *state); |
38 | 205 void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings); |
206 void logbook_EndDive(void); | |
207 | |
208 SLogbookHeader* logbook_getCurrentHeader(void); | |
209 SLogbookHeaderOSTC3 * logbook_build_ostc3header(SLogbookHeader* pLogbookHeader); | |
210 SLogbookHeaderOSTC3compact * logbook_build_ostc3header_compact(SLogbookHeader* pHead); | |
211 | |
212 uint8_t logbook_getNumberOfHeaders(void); | |
213 uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader); | |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
270
diff
changeset
|
214 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:
270
diff
changeset
|
215 uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, |
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
270
diff
changeset
|
216 uint16_t* decostopDepth, uint16_t* tank); |
38 | 217 void logbook_test(void); |
270
2e58a4094770
feature, debug: make simulator write a logbook entry
Jan Mulder <jlmulder@xs4all.nl>
parents:
269
diff
changeset
|
218 void logbook_InitAndWrite(const SDiveState* pStateReal); |
38 | 219 void logbook_recover_brokenlog(uint8_t headerId); |
220 | |
221 uint16_t logbook_lastDive_diveNumber(void); | |
458 | 222 uint16_t logbook_fillDummySampleBuffer(SLogbookHeader* pHeader); |
455
928a14568689
Reactivated samples for bottle pressure information:
ideenmodellierer
parents:
270
diff
changeset
|
223 void logbook_readDummySamples(uint8_t* pTarget, uint16_t length); |
38 | 224 |
225 #endif /* LOGBOOK_H */ |