Mercurial > public > ostc4
changeset 602:2cb0a97a07ad
Added replay data scaling in case life data is longer than replay block
Minor: variable name changes
author | Ideenmodellierer |
---|---|
date | Tue, 05 Jan 2021 20:35:01 +0100 |
parents | 7ef2d310287d |
children | c56ed16dbd39 |
files | Discovery/Src/logbook_miniLive.c Discovery/Src/t3.c |
diffstat | 2 files changed, 51 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/logbook_miniLive.c Mon Jan 04 22:49:07 2021 +0100 +++ b/Discovery/Src/logbook_miniLive.c Tue Jan 05 20:35:01 2021 +0100 @@ -41,10 +41,10 @@ static uint8_t MLLtickIntervallSeconds = 2; /* Replay Block data storage */ -#define DEPTH_DATA_LENGTH (1800u) /* Resolution: 5 hours dive, sampling every 10 seconds */ -uint16_t depthdata[DEPTH_DATA_LENGTH]; -uint16_t livedepthdata[DEPTH_DATA_LENGTH * 2]; -static uint16_t historyIndex = 0; +#define DEPTH_DATA_LENGTH (1800u) /* Resolution: 1 hours dive, sampling every 2 seconds */ +uint16_t ReplayDepthData[DEPTH_DATA_LENGTH]; +uint16_t liveDepthData[DEPTH_DATA_LENGTH]; +static uint16_t lifeDataIndex = 0; static uint8_t ReplayDataResolution = 2; /* Time represented by one sample (second) */ static uint16_t ReplayDataLength = 0; /* Number of data entries */ @@ -84,7 +84,7 @@ static uint8_t bDiveMode = 0; static uint32_t last_second = 0; static uint8_t secondsCount = 0; - static uint8_t historysecondsCount = 0; + static uint8_t lifesecondsCount = 0; if(checkOncePerSecond) { @@ -94,7 +94,7 @@ last_second = now; } secondsCount++; - historysecondsCount++; + lifesecondsCount++; if(!bDiveMode) { @@ -107,13 +107,13 @@ for(int i=0;i<MLLsize;i++) MLLdataDepth[i] = 0; - for(historyIndex = 0; historyIndex < DEPTH_DATA_LENGTH; historyIndex++) + for(lifeDataIndex = 0; lifeDataIndex < DEPTH_DATA_LENGTH; lifeDataIndex++) { - livedepthdata[historyIndex] = 0xFFFF; + liveDepthData[lifeDataIndex] = 0xFFFF; } - historysecondsCount = 0; - historyIndex = 0; - livedepthdata[historyIndex++] = 0; /* start at 0 */ + lifesecondsCount = 0; + lifeDataIndex = 0; + liveDepthData[lifeDataIndex++] = 0; /* start at 0 */ } } else if(stateUsed->mode == MODE_DIVE) @@ -135,17 +135,18 @@ if(MLLpointer < MLLsize) MLLdataDepth[MLLpointer++] = (int)(stateUsed->lifeData.depth_meter * 10); } - if(historysecondsCount > ReplayDataResolution) + if(lifesecondsCount >= ReplayDataResolution) { - historysecondsCount = 0; + lifesecondsCount = 0; - if(historyIndex >= 2*DEPTH_DATA_LENGTH) /* compress data */ + if(lifeDataIndex >= DEPTH_DATA_LENGTH) /* compress data */ { ReplayDataResolution *= 2; - compressBuffer_uint16(livedepthdata,2*DEPTH_DATA_LENGTH); - historyIndex = DEPTH_DATA_LENGTH; + compressBuffer_uint16(liveDepthData,DEPTH_DATA_LENGTH); + compressBuffer_uint16(ReplayDepthData,DEPTH_DATA_LENGTH); /* also compress Replay data to siplify mapping between live and replay data */ + lifeDataIndex = DEPTH_DATA_LENGTH / 2; } - livedepthdata[historyIndex++] = (int)(stateUsed->lifeData.depth_meter * 100); + liveDepthData[lifeDataIndex++] = (int)(stateUsed->lifeData.depth_meter * 100); } } else if(bDiveMode == 3) @@ -168,6 +169,10 @@ { ReplayDataOffset = 0xFFFF; ReplayDataResolution = 2; + ReplayDataLength = 0; + ReplayDataMaxDepth = 0; + ReplayDataMinutes = 0; + retVal = 1; } else @@ -175,7 +180,7 @@ ReplayDataOffset = StepBackwards; logbook_getHeader(StepBackwards ,&logbookHeader); - dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, depthdata,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */ { @@ -202,7 +207,7 @@ if((ReplayDataOffset != 0xFFFF) && (pReplayData != NULL) && (DataLength != NULL) && (MaxDepth != NULL)) { - *pReplayData = depthdata; + *pReplayData = ReplayDepthData; *DataLength = ReplayDataLength; *MaxDepth = ReplayDataMaxDepth; *diveMinutes = ReplayDataMinutes; @@ -214,11 +219,11 @@ uint16_t *getMiniLiveReplayPointerToData(void) { - return livedepthdata; + return liveDepthData; } uint16_t getMiniLiveReplayLength(void) { - return historyIndex; + return lifeDataIndex; } uint16_t getReplayOffset(void)
--- a/Discovery/Src/t3.c Mon Jan 04 22:49:07 2021 +0100 +++ b/Discovery/Src/t3.c Tue Jan 05 20:35:01 2021 +0100 @@ -183,13 +183,13 @@ void t3_miniLiveLogProfile(void) { SWindowGimpStyle wintemp; - uint16_t datalength = 0; + uint16_t replayDataLength = 0; + uint16_t liveDataLength = 0; + uint16_t drawDataLength = 0; uint16_t* pReplayData; uint16_t max_depth = 10; char text[TEXTSIZE]; point_t start, stop; - uint8_t doNotDrawLifeData = 0; - uint16_t diveMinutes = 0; wintemp.left = t3c1.WindowX0; @@ -206,32 +206,30 @@ if(getReplayOffset() != 0xFFFF) { - getReplayInfo(&pReplayData, &datalength, &max_depth, &diveMinutes); + getReplayInfo(&pReplayData, &replayDataLength, &max_depth, &diveMinutes); } if(max_depth < (uint16_t)(stateUsed->lifeData.max_depth_meter * 100)) { max_depth = (uint16_t)(stateUsed->lifeData.max_depth_meter * 100); } - if(datalength != 0) - { - GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, datalength, CLUT_Font031, NULL); - } - else + + liveDataLength = getMiniLiveReplayLength(); + + if(replayDataLength > liveDataLength) + { + drawDataLength = replayDataLength; + } + else + { + drawDataLength = liveDataLength; + } + + if(drawDataLength < CV_PROFILE_WIDTH) { - datalength = getMiniLiveReplayLength(); - if(datalength < CV_PROFILE_WIDTH) - { - if(datalength < 3) /* wait for some data entries to start graph */ - { - doNotDrawLifeData = 1; - } - datalength = CV_PROFILE_WIDTH; - } - diveMinutes = 0; /* do not show divetime because it is already shown in the upper field */ + drawDataLength = CV_PROFILE_WIDTH; } - if(diveMinutes != 0) { snprintf(text,TEXTSIZE,"\002%dmin",diveMinutes); @@ -241,9 +239,14 @@ snprintf(text,TEXTSIZE,"\002%01.1fm", max_depth / 100.0); GFX_write_string(&FontT42,&t3c1,text,0); - if(!doNotDrawLifeData) + if(replayDataLength != 0) + { + GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, pReplayData, drawDataLength, CLUT_Font031, NULL); + } + + if(liveDataLength > 3) { - GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), datalength, CLUT_Font030, NULL); + GFX_graph_print(&t3screen, &wintemp, 0,1,0, max_depth, getMiniLiveReplayPointerToData(), drawDataLength, CLUT_Font030, NULL); } }