auto-sync

This commit is contained in:
rusEfi 2014-09-15 21:03:09 -05:00
parent 5b8461eac8
commit 4319ef796b
2 changed files with 11 additions and 2 deletions

View File

@ -413,7 +413,7 @@ typedef struct {
bool isWaveAnalyzerEnabled : 1; // bit 9 bool isWaveAnalyzerEnabled : 1; // bit 9
bool isIdleThreadEnabled : 1; // bit 10 bool isIdleThreadEnabled : 1; // bit 10
int digitalChartSize; uint32_t digitalChartSize;
/** /**
* cc/min, cubic centimeter per minute * cc/min, cubic centimeter per minute
* *

View File

@ -72,6 +72,7 @@ void WaveChart::resetWaveChart() {
#endif /* DEBUG_WAVE */ #endif /* DEBUG_WAVE */
resetLogging(&logging); resetLogging(&logging);
counter = 0; counter = 0;
startTimeUs = 0;
appendPrintf(&logging, "wave_chart%s", DELIMETER); appendPrintf(&logging, "wave_chart%s", DELIMETER);
} }
@ -79,7 +80,15 @@ static char WAVE_LOGGING_BUFFER[WAVE_LOGGING_SIZE] CCM_OPTIONAL
; ;
int WaveChart::isWaveChartFull() { int WaveChart::isWaveChartFull() {
return counter >= engineConfiguration->digitalChartSize; /**
* Say at 300rpm we should get at least four events per revolution.
* That's 300/60*4=20 events per second
* digitalChartSize/20 is the longest meaningful chart.
*
*/
uint64_t chartDurationInSeconds = (getTimeNowUs() - startTimeUs) / 1000000;
bool startedTooLongAgo = startTimeUs!= 0 && chartDurationInSeconds > engineConfiguration->digitalChartSize / 20;
return startedTooLongAgo || counter >= engineConfiguration->digitalChartSize;
} }
static void printStatus(void) { static void printStatus(void) {