comparison Discovery/Src/logbook_miniLive.c @ 603:c56ed16dbd39

T3 profile view: Added visualization of deco data
author Ideenmodellierer
date Wed, 06 Jan 2021 19:41:43 +0100
parents 2cb0a97a07ad
children ae7f8333c900
comparison
equal deleted inserted replaced
602:2cb0a97a07ad 603:c56ed16dbd39
22 22
23 #include <string.h> 23 #include <string.h>
24 #include "logbook_miniLive.h" 24 #include "logbook_miniLive.h"
25 #include "data_exchange.h" 25 #include "data_exchange.h"
26 #include "logbook.h" 26 #include "logbook.h"
27 #include "tHome.h"
27 28
28 /* 29 /*
29 ****************************************************************************** 30 ******************************************************************************
30 * @brief t7_updateMiniLiveLogbook. / Create depth samples for view during dive 31 * @brief t7_updateMiniLiveLogbook. / Create depth samples for view during dive
31 * @author heinrichs weikamp gmbh 32 * @author heinrichs weikamp gmbh
42 43
43 /* Replay Block data storage */ 44 /* Replay Block data storage */
44 #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 */
45 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH]; 46 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH];
46 uint16_t liveDepthData[DEPTH_DATA_LENGTH]; 47 uint16_t liveDepthData[DEPTH_DATA_LENGTH];
48 uint16_t liveDecoData[DEPTH_DATA_LENGTH];
47 static uint16_t lifeDataIndex = 0; 49 static uint16_t lifeDataIndex = 0;
48 50
49 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */ 51 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */
50 static uint16_t ReplayDataLength = 0; /* Number of data entries */ 52 static uint16_t ReplayDataLength = 0; /* Number of data entries */
51 static uint16_t ReplayDataMaxDepth = 0; 53 static uint16_t ReplayDataMaxDepth = 0;
83 { 85 {
84 static uint8_t bDiveMode = 0; 86 static uint8_t bDiveMode = 0;
85 static uint32_t last_second = 0; 87 static uint32_t last_second = 0;
86 static uint8_t secondsCount = 0; 88 static uint8_t secondsCount = 0;
87 static uint8_t lifesecondsCount = 0; 89 static uint8_t lifesecondsCount = 0;
90
91 const SDecoinfo* pDecoinfo;
92 uint8_t stopDepth = 0;
93 uint16_t stopTime = 0;
88 94
89 if(checkOncePerSecond) 95 if(checkOncePerSecond)
90 { 96 {
91 uint32_t now = current_second(); 97 uint32_t now = current_second();
92 if( last_second == now) 98 if( last_second == now)
108 MLLdataDepth[i] = 0; 114 MLLdataDepth[i] = 0;
109 115
110 for(lifeDataIndex = 0; lifeDataIndex < DEPTH_DATA_LENGTH; lifeDataIndex++) 116 for(lifeDataIndex = 0; lifeDataIndex < DEPTH_DATA_LENGTH; lifeDataIndex++)
111 { 117 {
112 liveDepthData[lifeDataIndex] = 0xFFFF; 118 liveDepthData[lifeDataIndex] = 0xFFFF;
119 liveDecoData[lifeDataIndex] = 0xFFFF;
113 } 120 }
114 lifesecondsCount = 0; 121 lifesecondsCount = 0;
115 lifeDataIndex = 0; 122 lifeDataIndex = 0;
116 liveDepthData[lifeDataIndex++] = 0; /* start at 0 */ 123 liveDepthData[lifeDataIndex++] = 0; /* start at 0 */
117 } 124 }
144 ReplayDataResolution *= 2; 151 ReplayDataResolution *= 2;
145 compressBuffer_uint16(liveDepthData,DEPTH_DATA_LENGTH); 152 compressBuffer_uint16(liveDepthData,DEPTH_DATA_LENGTH);
146 compressBuffer_uint16(ReplayDepthData,DEPTH_DATA_LENGTH); /* also compress Replay data to siplify mapping between live and replay data */ 153 compressBuffer_uint16(ReplayDepthData,DEPTH_DATA_LENGTH); /* also compress Replay data to siplify mapping between live and replay data */
147 lifeDataIndex = DEPTH_DATA_LENGTH / 2; 154 lifeDataIndex = DEPTH_DATA_LENGTH / 2;
148 } 155 }
149 liveDepthData[lifeDataIndex++] = (int)(stateUsed->lifeData.depth_meter * 100); 156 liveDepthData[lifeDataIndex] = (int)(stateUsed->lifeData.depth_meter * 100);
157 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE)
158 {
159 pDecoinfo = &stateUsed->decolistVPM;
160 }
161 else
162 {
163 pDecoinfo = &stateUsed->decolistBuehlmann;
164 }
165 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &stopDepth, &stopTime);
166 if(stopDepth)
167 {
168 liveDecoData[lifeDataIndex] = stopDepth * 100;
169 }
170 else
171 {
172 liveDecoData[lifeDataIndex] = 0xFFFF;
173 }
174 lifeDataIndex++;
150 } 175 }
151 } 176 }
152 else if(bDiveMode == 3) 177 else if(bDiveMode == 3)
153 { 178 {
154 //End of Dive 179 //End of Dive
219 244
220 uint16_t *getMiniLiveReplayPointerToData(void) 245 uint16_t *getMiniLiveReplayPointerToData(void)
221 { 246 {
222 return liveDepthData; 247 return liveDepthData;
223 } 248 }
249 uint16_t *getMiniLiveDecoPointerToData(void)
250 {
251 return liveDecoData;
252 }
224 uint16_t getMiniLiveReplayLength(void) 253 uint16_t getMiniLiveReplayLength(void)
225 { 254 {
226 return lifeDataIndex; 255 return lifeDataIndex;
227 } 256 }
228 257