Mercurial > public > ostc4
annotate Discovery/Src/logbook_miniLive.c @ 713:1fbcca5bdf5d
Increased version number and set beta label
author | Ideenmodellierer |
---|---|
date | Sun, 20 Nov 2022 20:37:44 +0100 |
parents | bf574fb3efa0 |
children | 7bd347bdaa81 |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @copyright heinrichs weikamp | |
4 * @file logbook_miniLive.c | |
5 * @author heinrichs weikamp gmbh | |
6 * @date 13-March-2015 | |
7 * @version V0.0.1 | |
8 * @since 13-March-2015 | |
9 * @brief little logbook for during the dive | |
10 * @bug | |
11 * @warning | |
12 ****************************************************************************** | |
13 * @attention | |
14 * | |
15 * <h2><center>© COPYRIGHT(c) 2015 heinrichs weikamp</center></h2> | |
16 * | |
17 ****************************************************************************** | |
18 */ | |
19 | |
20 /* Includes ------------------------------------------------------------------*/ | |
598 | 21 |
22 | |
23 #include <string.h> | |
38 | 24 #include "logbook_miniLive.h" |
25 #include "data_exchange.h" | |
598 | 26 #include "logbook.h" |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
27 #include "tHome.h" |
38 | 28 |
29 /* | |
30 ****************************************************************************** | |
31 * @brief t7_updateMiniLiveLogbook. / Create depth samples for view during dive | |
32 * @author heinrichs weikamp gmbh | |
33 * @version V0.0.1 | |
34 * @date 13-March-2015 | |
35 ****************************************************************************** | |
36 * | |
37 */ | |
38 | |
39 #define MLLsize (296) | |
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
40 static uint16_t MLLdataDepth[MLLsize]; |
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
41 static uint16_t MLLpointer = 0; |
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
42 static uint8_t MLLtickIntervallSeconds = 2; |
598 | 43 |
44 /* Replay Block data storage */ | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
45 #define DEPTH_DATA_LENGTH (1800u) /* Resolution: 1 hours dive, sampling every 2 seconds */ |
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
46 uint16_t ReplayDepthData[DEPTH_DATA_LENGTH]; |
610 | 47 uint8_t ReplayMarkerData[DEPTH_DATA_LENGTH]; |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
48 uint16_t liveDepthData[DEPTH_DATA_LENGTH]; |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
49 uint16_t liveDepthDataMod[DEPTH_DATA_LENGTH]; /* live data modified to fit to marker checks */ |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
50 uint16_t liveDecoData[DEPTH_DATA_LENGTH]; |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
51 uint16_t liveDecoDataMod[DEPTH_DATA_LENGTH]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
52 static uint16_t liveDataIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
53 static uint16_t liveDataIndexMod = 0; |
598 | 54 |
55 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */ | |
56 static uint16_t ReplayDataLength = 0; /* Number of data entries */ | |
57 static uint16_t ReplayDataMaxDepth = 0; | |
58 static uint16_t ReplayDataMinutes = 0; | |
59 static uint16_t ReplayDataOffset = 0xFFFF; /* Stepbackwards format used by log functions */ | |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
60 static uint16_t ReplayMarkerIndex = 0; |
38 | 61 |
62 uint16_t *getMiniLiveLogbookPointerToData(void) | |
63 { | |
64 return MLLdataDepth; | |
65 } | |
66 | |
67 | |
68 uint16_t getMiniLiveLogbookActualDataLength(void) | |
69 { | |
70 return MLLpointer; | |
71 } | |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
72 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
73 uint16_t MiniLiveLogbook_getNextMarkerIndex(uint16_t curIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
74 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
75 uint16_t index = 0; |
38 | 76 |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
77 if((ReplayMarkerData[0] != 0xFF) && (curIndex < ReplayDataLength)) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
78 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
79 index = curIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
80 do |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
81 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
82 index++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
83 if (index == ReplayDataLength) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
84 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
85 index = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
86 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
87 if(ReplayMarkerData[index] != 0) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
88 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
89 break; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
90 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
91 }while (index != curIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
92 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
93 return index; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
94 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
95 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
96 static uint16_t workdata[DEPTH_DATA_LENGTH]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
97 static void compressMarkerData(uint16_t* pSource, uint16_t* pTarget, float step, uint16_t startIndex, uint16_t stopIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
98 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
99 uint16_t workIndex = startIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
100 float nextStep = (float)workIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
101 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
102 while (workIndex <= ReplayMarkerIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
103 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
104 workdata[workIndex] = *pSource++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
105 nextStep += step; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
106 while(nextStep < workIndex + 1) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
107 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
108 if(*pSource != 0xFFFF) /* do not average "ignore" value */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
109 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
110 if(workdata[workIndex] == 0xFFFF) /* first value to be shown */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
111 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
112 workdata[workIndex] = *pSource; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
113 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
114 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
115 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
116 workdata[workIndex] += *pSource; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
117 workdata[workIndex] /= 2; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
118 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
119 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
120 pSource++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
121 nextStep += step; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
122 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
123 workIndex++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
124 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
125 memcpy(&pTarget[startIndex],&workdata[startIndex],(workIndex - startIndex -1) * 2); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
126 while(workIndex < DEPTH_DATA_LENGTH) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
127 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
128 pTarget[workIndex] = 0xFFFF; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
129 workIndex++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
130 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
131 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
132 static void stretchMarkerData(uint16_t* pSource, uint16_t* pTarget, float step, uint16_t startIndex, uint16_t stopIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
133 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
134 uint16_t workIndex = startIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
135 float nextStep = (float)workIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
136 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
137 while (workIndex <= stopIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
138 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
139 nextStep += step; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
140 if(nextStep > stopIndex) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
141 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
142 nextStep = stopIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
143 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
144 while(workIndex <= (uint16_t)nextStep) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
145 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
146 workdata[workIndex++] = *pSource; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
147 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
148 pSource++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
149 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
150 memcpy(&pTarget[startIndex],&workdata[startIndex],(workIndex - startIndex) * 2); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
151 while(workIndex < DEPTH_DATA_LENGTH) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
152 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
153 pTarget[workIndex] = 0xFFFF; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
154 workIndex++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
155 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
156 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
157 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
158 void MiniLiveLogbook_checkMarker(void) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
159 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
160 static uint16_t lastLifeIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
161 uint16_t* pDepthData; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
162 uint16_t* pDecoData; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
163 float step; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
164 uint16_t lastMarkerIndex = ReplayMarkerIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
165 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
166 ReplayMarkerIndex = MiniLiveLogbook_getNextMarkerIndex(ReplayMarkerIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
167 if(ReplayMarkerIndex <= lastMarkerIndex) /* no other marker found or last marker checked => reset marker to 0 to deactivate check function */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
168 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
169 ReplayMarkerIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
170 lastLifeIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
171 liveDataIndexMod = liveDataIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
172 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
173 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
174 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
175 if(lastMarkerIndex == 0) /* use real live data */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
176 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
177 pDepthData = &liveDepthData[0]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
178 pDecoData = &liveDecoData[0]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
179 lastLifeIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
180 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
181 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
182 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
183 pDepthData = &liveDepthDataMod[lastMarkerIndex]; /* work with already modified data */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
184 pDecoData = &liveDecoDataMod[lastMarkerIndex]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
185 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
186 if(lastLifeIndex == liveDataIndex) /* repeated button press before new data was generated => draw straight line */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
187 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
188 step = ReplayMarkerIndex-lastMarkerIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
189 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
190 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
191 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
192 step = (ReplayMarkerIndex-lastMarkerIndex) / (float)(liveDataIndex - lastLifeIndex); /* the live data shall be modified to match the history data */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
193 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
194 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
195 lastLifeIndex = liveDataIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
196 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
197 if(step < 1) /* compression needed */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
198 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
199 compressMarkerData(pDepthData, liveDepthDataMod, step, lastMarkerIndex, ReplayMarkerIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
200 compressMarkerData(pDecoData, liveDecoDataMod, step, lastMarkerIndex, ReplayMarkerIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
201 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
202 else /* stretch data */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
203 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
204 stretchMarkerData(pDepthData, liveDepthDataMod, step, lastMarkerIndex, ReplayMarkerIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
205 stretchMarkerData(pDecoData, liveDecoDataMod, step, lastMarkerIndex, ReplayMarkerIndex); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
206 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
207 liveDataIndexMod = ReplayMarkerIndex; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
208 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
209 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
210 |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
211 |
598 | 212 void compressBuffer_uint16(uint16_t* pdata, uint16_t size) |
213 { | |
214 uint16_t* pTarget = pdata; | |
215 uint16_t* pSource = pdata; | |
610 | 216 uint16_t result = 0; |
598 | 217 uint16_t index = 0; |
38 | 218 |
598 | 219 for(index = 0; index < size/2; index++) |
220 { | |
221 *pTarget = *pSource++; | |
222 *pTarget += *pSource++; | |
610 | 223 result = *pTarget /= 2; |
224 if((*pTarget != 0) && (result == 0)) /* avoid termination of information by round up to 1 */ | |
225 { | |
226 *pTarget++ = 1; | |
227 } | |
228 else | |
229 { | |
230 *pTarget++ = result; | |
231 } | |
598 | 232 } |
233 memset(pTarget,0,size/2); | |
234 } | |
235 | |
38 | 236 void updateMiniLiveLogbook( _Bool checkOncePerSecond) |
237 { | |
238 static uint8_t bDiveMode = 0; | |
239 static uint32_t last_second = 0; | |
240 static uint8_t secondsCount = 0; | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
241 static uint8_t lifesecondsCount = 0; |
38 | 242 |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
243 const SDecoinfo* pDecoinfo; |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
244 uint8_t stopDepth = 0; |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
245 uint16_t stopTime = 0; |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
246 |
38 | 247 if(checkOncePerSecond) |
248 { | |
249 uint32_t now = current_second(); | |
250 if( last_second == now) | |
251 return; | |
252 last_second = now; | |
253 } | |
254 secondsCount++; | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
255 lifesecondsCount++; |
38 | 256 |
257 if(!bDiveMode) | |
258 { | |
259 if((stateUsed->mode == MODE_DIVE) && (stateUsed->lifeData.dive_time_seconds >= 5)) | |
260 { | |
261 secondsCount = 0; | |
262 MLLtickIntervallSeconds = 2; | |
263 bDiveMode = 1; | |
264 MLLpointer = 1; | |
265 for(int i=0;i<MLLsize;i++) | |
266 MLLdataDepth[i] = 0; | |
598 | 267 |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
268 for(liveDataIndex = 0; liveDataIndex < DEPTH_DATA_LENGTH; liveDataIndex++) |
598 | 269 { |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
270 liveDepthData[liveDataIndex] = 0xFFFF; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
271 liveDecoData[liveDataIndex] = 0xFFFF; |
598 | 272 } |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
273 lifesecondsCount = 0; |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
274 liveDataIndex = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
275 liveDataIndexMod = 0; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
276 liveDepthData[liveDataIndex++] = 0; /* start at 0 */ |
38 | 277 } |
278 } | |
279 else if(stateUsed->mode == MODE_DIVE) | |
280 { | |
281 bDiveMode = 3; | |
282 // | |
283 if(secondsCount >= MLLtickIntervallSeconds) | |
284 { | |
285 secondsCount = 0; | |
598 | 286 /* in case of a buffer overrun the buffer is divided and the first half is filled with a compressed image of the complete buffer */ |
38 | 287 if((MLLpointer >= MLLsize) && (MLLtickIntervallSeconds < 127)) |
288 { | |
289 MLLpointer = 0; | |
290 MLLtickIntervallSeconds *= 2; | |
598 | 291 |
292 compressBuffer_uint16(MLLdataDepth,MLLsize); | |
38 | 293 MLLpointer = MLLsize/2; |
294 } | |
295 if(MLLpointer < MLLsize) | |
296 MLLdataDepth[MLLpointer++] = (int)(stateUsed->lifeData.depth_meter * 10); | |
297 } | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
298 if(lifesecondsCount >= ReplayDataResolution) |
598 | 299 { |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
300 lifesecondsCount = 0; |
598 | 301 |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
302 if(liveDataIndex >= DEPTH_DATA_LENGTH) /* compress data */ |
598 | 303 { |
304 ReplayDataResolution *= 2; | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
305 compressBuffer_uint16(liveDepthData,DEPTH_DATA_LENGTH); |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
306 compressBuffer_uint16(liveDepthDataMod, DEPTH_DATA_LENGTH); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
307 compressBuffer_uint16(ReplayDepthData,DEPTH_DATA_LENGTH); /* also compress Replay data to simplify mapping between live and replay data */ |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
308 liveDataIndex = DEPTH_DATA_LENGTH / 2; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
309 liveDataIndexMod /= 2; |
598 | 310 } |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
311 liveDepthData[liveDataIndex] = (int)(stateUsed->lifeData.depth_meter * 100); |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
312 liveDepthDataMod[liveDataIndexMod] = liveDepthData[liveDataIndex]; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
313 |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
314 if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
315 { |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
316 pDecoinfo = &stateUsed->decolistVPM; |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
317 } |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
318 else |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
319 { |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
320 pDecoinfo = &stateUsed->decolistBuehlmann; |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
321 } |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
322 tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &stopDepth, &stopTime); |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
323 if(stopDepth) |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
324 { |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
325 liveDecoData[liveDataIndex] = stopDepth * 100; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
326 liveDecoDataMod[liveDataIndexMod] = stopDepth * 100; |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
327 } |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
328 else |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
329 { |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
330 liveDecoData[liveDataIndex] = 0xFFFF; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
331 liveDecoDataMod[liveDataIndexMod] = 0xFFFF; |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
332 } |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
333 liveDataIndex++; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
334 liveDataIndexMod++; |
598 | 335 } |
38 | 336 } |
337 else if(bDiveMode == 3) | |
338 { | |
339 //End of Dive | |
340 for(int i=0;i<MLLsize;i++) | |
341 MLLdataDepth[i] = 0; | |
342 bDiveMode = 0; | |
343 } | |
344 } | |
345 | |
598 | 346 uint8_t prepareReplayLog(uint8_t StepBackwards) |
347 { | |
348 uint8_t retVal = 0; | |
610 | 349 uint16_t index = 0; |
598 | 350 uint16_t dataLength = 0; |
610 | 351 uint8_t markerDetected = 0; |
38 | 352 |
598 | 353 SLogbookHeader logbookHeader; |
354 | |
355 if(ReplayDataOffset == StepBackwards) /* Entry already selected => reset selection */ | |
356 { | |
357 ReplayDataOffset = 0xFFFF; | |
358 ReplayDataResolution = 2; | |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
359 ReplayDataLength = 0; |
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
360 ReplayDataMaxDepth = 0; |
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
361 ReplayDataMinutes = 0; |
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
362 |
598 | 363 retVal = 1; |
364 } | |
365 else | |
366 { | |
367 ReplayDataOffset = StepBackwards; | |
368 logbook_getHeader(StepBackwards ,&logbookHeader); | |
369 | |
610 | 370 dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData); |
371 | |
372 /* check if a marker is provided. If not disable marker functionality for the replay block */ | |
373 for(index = 0; index < dataLength; index++) | |
374 { | |
375 if(ReplayMarkerData[index] != 0) | |
376 { | |
377 markerDetected = 1; | |
378 break; | |
379 } | |
380 } | |
381 if(markerDetected == 0) | |
382 { | |
383 ReplayMarkerData[0] = 0xFF; | |
384 } | |
598 | 385 |
386 if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */ | |
387 { | |
388 ReplayDataResolution = (logbookHeader.diveTimeMinutes * 60 + logbookHeader.diveTimeSeconds) / dataLength; | |
389 } | |
390 else | |
391 { | |
392 ReplayDataResolution = logbookHeader.samplingRate; | |
393 } | |
394 ReplayDataLength = dataLength; | |
395 ReplayDataMaxDepth = logbookHeader.maxDepth; | |
396 ReplayDataMinutes = logbookHeader.diveTimeMinutes; | |
397 if(dataLength != 0) | |
398 { | |
399 retVal = 1; | |
400 } | |
401 } | |
402 return retVal; | |
403 } | |
404 | |
610 | 405 uint8_t getReplayInfo(uint16_t** pReplayData, uint8_t** pReplayMarker, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes) |
598 | 406 { |
407 uint8_t retVal = 0; | |
408 | |
610 | 409 if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL) && (pReplayMarker != 0)) |
598 | 410 { |
602
2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Ideenmodellierer
parents:
598
diff
changeset
|
411 *pReplayData = ReplayDepthData; |
610 | 412 *pReplayMarker = ReplayMarkerData; |
598 | 413 *DataLength = ReplayDataLength; |
414 *MaxDepth = ReplayDataMaxDepth; | |
415 *diveMinutes = ReplayDataMinutes; | |
416 retVal = 1; | |
417 } | |
418 | |
419 return retVal; | |
420 } | |
421 | |
422 uint16_t *getMiniLiveReplayPointerToData(void) | |
423 { | |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
424 if(ReplayMarkerIndex == 0) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
425 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
426 return liveDepthData; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
427 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
428 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
429 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
430 return liveDepthDataMod; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
431 } |
598 | 432 } |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
433 uint16_t *getMiniLiveDecoPointerToData(void) |
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
434 { |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
435 if(ReplayMarkerIndex == 0) |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
436 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
437 return liveDecoData; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
438 } |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
439 else |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
440 { |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
441 return liveDecoDataMod; |
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
442 } |
603
c56ed16dbd39
T3 profile view: Added visualization of deco data
Ideenmodellierer
parents:
602
diff
changeset
|
443 } |
598 | 444 uint16_t getMiniLiveReplayLength(void) |
445 { | |
620
bf574fb3efa0
Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents:
610
diff
changeset
|
446 return liveDataIndex; |
598 | 447 } |
448 | |
449 uint16_t getReplayOffset(void) | |
450 { | |
451 return ReplayDataOffset; | |
452 } | |
453 | |
454 uint16_t getReplayDataResolution(void) | |
455 { | |
456 return ReplayDataResolution; | |
457 } | |
38 | 458 |
459 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |