annotate Discovery/Src/logbook_miniLive.c @ 869:4e10a3e087a1 Evo_2_23

Reactivate Bootloader: The bootloader has not been compiled for a long time. Changes were necessary to catch up with the actual code
author Ideenmodellierer
date Mon, 12 Aug 2024 22:23:03 +0200
parents bf574fb3efa0
children 7bd347bdaa81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @copyright heinrichs weikamp
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @file logbook_miniLive.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 13-March-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @since 13-March-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief little logbook for during the dive
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * @bug
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * @warning
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /* Includes ------------------------------------------------------------------*/
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
21
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
22
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
23 #include <string.h>
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 #include "logbook_miniLive.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 #include "data_exchange.h"
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
26 #include "logbook.h"
603
c56ed16dbd39 T3 profile view: Added visualization of deco data
Ideenmodellierer
parents: 602
diff changeset
27 #include "tHome.h"
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 * @brief t7_updateMiniLiveLogbook. / Create depth samples for view during dive
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 * @date 13-March-2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
43
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
54
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
55 static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
56 static uint16_t ReplayDataLength = 0; /* Number of data entries */
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
57 static uint16_t ReplayDataMaxDepth = 0;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
58 static uint16_t ReplayDataMinutes = 0;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 uint16_t *getMiniLiveLogbookPointerToData(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 return MLLdataDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 uint16_t getMiniLiveLogbookActualDataLength(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 return MLLpointer;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
212 void compressBuffer_uint16(uint16_t* pdata, uint16_t size)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
213 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
214 uint16_t* pTarget = pdata;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
215 uint16_t* pSource = pdata;
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
216 uint16_t result = 0;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
217 uint16_t index = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
219 for(index = 0; index < size/2; index++)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
220 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
221 *pTarget = *pSource++;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
222 *pTarget += *pSource++;
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
223 result = *pTarget /= 2;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
224 if((*pTarget != 0) && (result == 0)) /* avoid termination of information by round up to 1 */
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
225 {
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
226 *pTarget++ = 1;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
227 }
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
228 else
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
229 {
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
230 *pTarget++ = result;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
231 }
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
232 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
233 memset(pTarget,0,size/2);
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
234 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
235
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 void updateMiniLiveLogbook( _Bool checkOncePerSecond)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 static uint8_t bDiveMode = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 static uint32_t last_second = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 if(checkOncePerSecond)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 uint32_t now = current_second();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 if( last_second == now)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 last_second = now;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 if(!bDiveMode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 if((stateUsed->mode == MODE_DIVE) && (stateUsed->lifeData.dive_time_seconds >= 5))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 secondsCount = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 MLLtickIntervallSeconds = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 bDiveMode = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 MLLpointer = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 for(int i=0;i<MLLsize;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 MLLdataDepth[i] = 0;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 else if(stateUsed->mode == MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 bDiveMode = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 //
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 if(secondsCount >= MLLtickIntervallSeconds)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 secondsCount = 0;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 if((MLLpointer >= MLLsize) && (MLLtickIntervallSeconds < 127))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 MLLpointer = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 MLLtickIntervallSeconds *= 2;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
291
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
292 compressBuffer_uint16(MLLdataDepth,MLLsize);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 MLLpointer = MLLsize/2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 if(MLLpointer < MLLsize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 MLLdataDepth[MLLpointer++] = (int)(stateUsed->lifeData.depth_meter * 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
301
620
bf574fb3efa0 Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents: 610
diff changeset
302 if(liveDataIndex >= DEPTH_DATA_LENGTH) /* compress data */
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
303 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
335 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 else if(bDiveMode == 3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 //End of Dive
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 for(int i=0;i<MLLsize;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 MLLdataDepth[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 bDiveMode = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
346 uint8_t prepareReplayLog(uint8_t StepBackwards)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
347 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
348 uint8_t retVal = 0;
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
349 uint16_t index = 0;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
350 uint16_t dataLength = 0;
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
351 uint8_t markerDetected = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
353 SLogbookHeader logbookHeader;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
354
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
355 if(ReplayDataOffset == StepBackwards) /* Entry already selected => reset selection */
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
356 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
357 ReplayDataOffset = 0xFFFF;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
363 retVal = 1;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
364 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
365 else
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
366 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
367 ReplayDataOffset = StepBackwards;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
368 logbook_getHeader(StepBackwards ,&logbookHeader);
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
369
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
370 dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData);
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
371
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
372 /* check if a marker is provided. If not disable marker functionality for the replay block */
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
373 for(index = 0; index < dataLength; index++)
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
374 {
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
375 if(ReplayMarkerData[index] != 0)
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
376 {
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
377 markerDetected = 1;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
378 break;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
379 }
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
380 }
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
381 if(markerDetected == 0)
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
382 {
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
383 ReplayMarkerData[0] = 0xFF;
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
384 }
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
385
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
386 if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
387 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
388 ReplayDataResolution = (logbookHeader.diveTimeMinutes * 60 + logbookHeader.diveTimeSeconds) / dataLength;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
389 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
390 else
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
391 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
392 ReplayDataResolution = logbookHeader.samplingRate;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
393 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
394 ReplayDataLength = dataLength;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
395 ReplayDataMaxDepth = logbookHeader.maxDepth;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
396 ReplayDataMinutes = logbookHeader.diveTimeMinutes;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
397 if(dataLength != 0)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
398 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
399 retVal = 1;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
400 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
401 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
402 return retVal;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
403 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
404
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
405 uint8_t getReplayInfo(uint16_t** pReplayData, uint8_t** pReplayMarker, uint16_t* DataLength, uint16_t* MaxDepth, uint16_t* diveMinutes)
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
406 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
407 uint8_t retVal = 0;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
408
610
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
409 if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL) && (pReplayMarker != 0))
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
ae7f8333c900 Added access to logbook marker data:
Ideenmodellierer
parents: 603
diff changeset
412 *pReplayMarker = ReplayMarkerData;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
413 *DataLength = ReplayDataLength;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
414 *MaxDepth = ReplayDataMaxDepth;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
415 *diveMinutes = ReplayDataMinutes;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
416 retVal = 1;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
417 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
418
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
419 return retVal;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
420 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
421
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
422 uint16_t *getMiniLiveReplayPointerToData(void)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
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
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
444 uint16_t getMiniLiveReplayLength(void)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
445 {
620
bf574fb3efa0 Added minilog functions to allow marker synchronisation:
Ideenmodellierer
parents: 610
diff changeset
446 return liveDataIndex;
598
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
447 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
448
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
449 uint16_t getReplayOffset(void)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
450 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
451 return ReplayDataOffset;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
452 }
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
453
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
454 uint16_t getReplayDataResolution(void)
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
455 {
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
456 return ReplayDataResolution;
0a3836643173 New replay block for T3 profile:
Ideenmodellierer
parents: 300
diff changeset
457 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/