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

Added access to logbook marker data: In previous version event data could only be stored in memory but read back and usage in the OSTC itself was not supported. After the events like a marker set by the diver may be retrieved from the log. Added visualization of markers to T3_Profile view
author Ideenmodellierer
date Thu, 14 Jan 2021 20:38:28 +0100
parents c56ed16dbd39
children beeb23d18443
comparison
equal deleted inserted replaced
609:1b243c6c7067 610:ae7f8333c900
178 { 178 {
179 t3_selection_customview = selectedCustomview; 179 t3_selection_customview = selectedCustomview;
180 } 180 }
181 } 181 }
182 182
183 void t3_drawMarker(GFX_DrawCfgScreen *hgfx, const SWindowGimpStyle *window, uint8_t *data, uint16_t datalength, uint8_t color)
184 {
185 uint16_t line = 0;
186 uint16_t dataIndex = 0;
187 uint16_t lastDataIndex = 0;
188 uint16_t windowWidth = 0;
189 int16_t factor = 0;
190 uint8_t setMarker = 0;
191
192 point_t start;
193 point_t stop;
194
195
196 if( (window->bottom <= 479)
197 && (window->top <= 479)
198 && (window->right <= 799)
199 && (window->left <= 799)
200 && (window->right >= 0)
201 && (window->left >= 0)
202 && (window->bottom > window->top)
203 && (window->right > window->left))
204 {
205 windowWidth = window->right - window->left;
206 if(settingsGetPointer()->FlipDisplay)
207 {
208 start.y = window->bottom;
209 stop.y = window->top;
210 }
211 else
212 {
213 start.y = 479 - window->bottom;
214 stop.y = 479 - window->top;
215 }
216
217 while((line <= windowWidth) && (dataIndex < datalength))
218 {
219 factor = (10 * line * (long)datalength)/windowWidth;
220 dataIndex = factor/10;
221 /* check if a marker is set in the intervall which is bypassed because of data reduction */
222 setMarker = 0;
223 while(lastDataIndex <= dataIndex)
224 {
225 lastDataIndex++;
226 if(data[lastDataIndex] != 0)
227 {
228 setMarker = 1;
229 break;
230 }
231 }
232 lastDataIndex = dataIndex;
233 int rest = factor - dataIndex*10;
234 if(rest >= 5)
235 dataIndex++;
236
237 if((datalength - 1) < dataIndex)
238 dataIndex = datalength-1;
239
240 if((line > 0) && (setMarker)) /* draw marker line */
241 {
242 start.x = line;
243 stop.x = line;
244 GFX_draw_line(hgfx, start, stop, color);
245 }
246 line++;
247 dataIndex++;
248 }
249 }
250 }
251
183 void t3_miniLiveLogProfile(void) 252 void t3_miniLiveLogProfile(void)
184 { 253 {
185 SWindowGimpStyle wintemp; 254 SWindowGimpStyle wintemp;
186 uint16_t replayDataLength = 0; 255 uint16_t replayDataLength = 0;
187 uint16_t liveDataLength = 0; 256 uint16_t liveDataLength = 0;
188 uint16_t drawDataLength = 0; 257 uint16_t drawDataLength = 0;
189 uint16_t* pReplayData; 258 uint16_t* pReplayData;
259 uint8_t* pReplayMarker;
190 uint16_t max_depth = 10; 260 uint16_t max_depth = 10;
191 char text[TEXTSIZE]; 261 char text[TEXTSIZE];
192 point_t start, stop; 262 point_t start, stop;
193 uint16_t diveMinutes = 0; 263 uint16_t diveMinutes = 0;
194 264
204 274
205 GFX_draw_line(&t3screen, start, stop, CLUT_Font020); 275 GFX_draw_line(&t3screen, start, stop, CLUT_Font020);
206 276
207 if(getReplayOffset() != 0xFFFF) 277 if(getReplayOffset() != 0xFFFF)
208 { 278 {
209 getReplayInfo(&pReplayData, &replayDataLength, &max_depth, &diveMinutes); 279 getReplayInfo(&pReplayData, &pReplayMarker, &replayDataLength, &max_depth, &diveMinutes);
210 } 280 }
211 281
212 if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100)) 282 if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100))
213 { 283 {
214 max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100); 284 max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100);
240 GFX_write_string(&FontT42,&t3c1,text,0); 310 GFX_write_string(&FontT42,&t3c1,text,0);
241 311
242 if(replayDataLength != 0) 312 if(replayDataLength != 0)
243 { 313 {
244 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, drawDataLength, CLUT_Font031, NULL); 314 GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, drawDataLength, CLUT_Font031, NULL);
315 if(pReplayMarker[0] != 0xFF)
316 {
317 t3_drawMarker(&t3screen, &wintemp, pReplayMarker, drawDataLength, CLUT_CompassUserHeadingTick);
318 }
245 } 319 }
246 320
247 if(liveDataLength > 3) 321 if(liveDataLength > 3)
248 { 322 {
249 GFX_graph_print(&t3screen,&wintemp,wintemp.top * -1,1,0,max_depth, getMiniLiveDecoPointerToData(),drawDataLength, CLUT_NiceGreen, NULL); 323 GFX_graph_print(&t3screen,&wintemp,wintemp.top * -1,1,0,max_depth, getMiniLiveDecoPointerToData(),drawDataLength, CLUT_NiceGreen, NULL);