comparison Discovery/Src/logbook_miniLive.c @ 610:ae7f8333c900

Added access to logbook marker data: In previous version event data could only be stored in memory but read back and usage in the OSTC itself was not supported. After the events like a marker set by the diver may be retrieved from the log. Added visualization of markers to T3_Profile view
author Ideenmodellierer
date Thu, 14 Jan 2021 20:38:28 +0100
parents c56ed16dbd39
children bf574fb3efa0
comparison
equal deleted inserted replaced
609:1b243c6c7067 610:ae7f8333c900
42 static uint8_t MLLtickIntervallSeconds = 2; 42 static uint8_t MLLtickIntervallSeconds = 2;
43 43
44 /* Replay Block data storage */ 44 /* Replay Block data storage */
45 #define DEPTH_DATA_LENGTH (1800u) /* Resolution: 1 hours dive, sampling every 2 seconds */ 45 #define DEPTH_DATA_LENGTH (1800u) /* Resolution: 1 hours dive, sampling every 2 seconds */
46 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH]; 46 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH];
47 uint8_t ReplayMarkerData[DEPTH_DATA_LENGTH];
47 uint16_t liveDepthData[DEPTH_DATA_LENGTH]; 48 uint16_t liveDepthData[DEPTH_DATA_LENGTH];
48 uint16_t liveDecoData[DEPTH_DATA_LENGTH]; 49 uint16_t liveDecoData[DEPTH_DATA_LENGTH];
49 static uint16_t lifeDataIndex = 0; 50 static uint16_t lifeDataIndex = 0;
50 51
51 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */ 52 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */
67 68
68 void compressBuffer_uint16(uint16_t* pdata, uint16_t size) 69 void compressBuffer_uint16(uint16_t* pdata, uint16_t size)
69 { 70 {
70 uint16_t* pTarget = pdata; 71 uint16_t* pTarget = pdata;
71 uint16_t* pSource = pdata; 72 uint16_t* pSource = pdata;
73 uint16_t result = 0;
72 74
73 uint16_t index = 0; 75 uint16_t index = 0;
74 76
75 for(index = 0; index < size/2; index++) 77 for(index = 0; index < size/2; index++)
76 { 78 {
77 *pTarget = *pSource++; 79 *pTarget = *pSource++;
78 *pTarget += *pSource++; 80 *pTarget += *pSource++;
79 *pTarget++ /= 2; 81 result = *pTarget /= 2;
82 if((*pTarget != 0) && (result == 0)) /* avoid termination of information by round up to 1 */
83 {
84 *pTarget++ = 1;
85 }
86 else
87 {
88 *pTarget++ = result;
89 }
80 } 90 }
81 memset(pTarget,0,size/2); 91 memset(pTarget,0,size/2);
82 } 92 }
83 93
84 void updateMiniLiveLogbook( _Bool checkOncePerSecond) 94 void updateMiniLiveLogbook( _Bool checkOncePerSecond)
184 } 194 }
185 195
186 uint8_t prepareReplayLog(uint8_t StepBackwards) 196 uint8_t prepareReplayLog(uint8_t StepBackwards)
187 { 197 {
188 uint8_t retVal = 0; 198 uint8_t retVal = 0;
199 uint16_t index = 0;
189 uint16_t dataLength = 0; 200 uint16_t dataLength = 0;
201 uint8_t markerDetected = 0;
190 202
191 SLogbookHeader logbookHeader; 203 SLogbookHeader logbookHeader;
192 204
193 if(ReplayDataOffset == StepBackwards) /* Entry already selected => reset selection */ 205 if(ReplayDataOffset == StepBackwards) /* Entry already selected => reset selection */
194 { 206 {
203 else 215 else
204 { 216 {
205 ReplayDataOffset = StepBackwards; 217 ReplayDataOffset = StepBackwards;
206 logbook_getHeader(StepBackwards ,&logbookHeader); 218 logbook_getHeader(StepBackwards ,&logbookHeader);
207 219
208 dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 220 dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData);
221
222 /* check if a marker is provided. If not disable marker functionality for the replay block */
223 for(index = 0; index < dataLength; index++)
224 {
225 if(ReplayMarkerData[index] != 0)
226 {
227 markerDetected = 1;
228 break;
229 }
230 }
231 if(markerDetected == 0)
232 {
233 ReplayMarkerData[0] = 0xFF;
234 }
209 235
210 if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */ 236 if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */
211 { 237 {
212 ReplayDataResolution = (logbookHeader.diveTimeMinutes * 60 + logbookHeader.diveTimeSeconds) / dataLength; 238 ReplayDataResolution = (logbookHeader.diveTimeMinutes * 60 + logbookHeader.diveTimeSeconds) / dataLength;
213 } 239 }
224 } 250 }
225 } 251 }
226 return retVal; 252 return retVal;
227 } 253 }
228 254
229 uint8_t getReplayInfo(uint16_t** pReplayData, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes) 255 uint8_t getReplayInfo(uint16_t** pReplayData, uint8_t** pReplayMarker, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes)
230 { 256 {
231 uint8_t retVal = 0; 257 uint8_t retVal = 0;
232 258
233 if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL)) 259 if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL) && (pReplayMarker != 0))
234 { 260 {
235 *pReplayData = ReplayDepthData; 261 *pReplayData = ReplayDepthData;
262 *pReplayMarker = ReplayMarkerData;
236 *DataLength = ReplayDataLength; 263 *DataLength = ReplayDataLength;
237 *MaxDepth = ReplayDataMaxDepth; 264 *MaxDepth = ReplayDataMaxDepth;
238 *diveMinutes = ReplayDataMinutes; 265 *diveMinutes = ReplayDataMinutes;
239 retVal = 1; 266 retVal = 1;
240 } 267 }