Better tooth log handling

This commit is contained in:
Josh Stewart 2016-10-19 13:12:08 +11:00
parent d140cd74ff
commit a4593ae339
3 changed files with 16 additions and 6 deletions

View File

@ -661,7 +661,7 @@ void sendPage(bool useChar)
}
case seqFuelPage:
{
byte response[200]; //Bit hacky, but the size is: (8x8 + 8 + 8) + (8x8 + 8 + 8) = 160
byte response[200]; //The size is: (6x6 + 6 + 6) * 4 + 8 (Leftover values)
for (int x = 0; x < 200; x++) { 0; }
@ -748,7 +748,7 @@ void sendPage(bool useChar)
//MS format has origin (0,0) in the bottom left corner, we use the top left for efficiency reasons
byte response[map_page_size];
for (int x = 0; x < 256; x++) { response[x] = currentTable.values[15 - x / 16][x % 16]; if ( (x & 31) == 1) { loop(); } } //This is slightly non-intuitive, but essentially just flips the table vertically (IE top line becomes the bottom line etc). Columns are unchanged
for (int x = 0; x < 256; x++) { response[x] = currentTable.values[15 - x / 16][x % 16]; if ( (x & 15) == 1) { loop(); } } //This is slightly non-intuitive, but essentially just flips the table vertically (IE top line becomes the bottom line etc). Columns are unchanged. Every 16 loops, manually call loop() to avoid potential misses
loop();
for (int x = 256; x < 272; x++) { response[x] = byte(currentTable.axisX[(x - 256)] / 100); } //RPM Bins for VE table (Need to be dvidied by 100)
loop();
@ -776,7 +776,7 @@ void sendPage(bool useChar)
for (byte x = 0; x < page_size; x++)
{
response[x] = *((byte *)pnt_configPage + x); //Each byte is simply the location in memory of the configPage + the offset + the variable number (x)
if ( (x & 31) == 1) { loop(); }
if ( (x & 31) == 1) { loop(); } //Every 32 loops, do a manual call to loop() to ensure that there is no misses
}
Serial.write((byte *)&response, sizeof(response));
// }
@ -915,6 +915,7 @@ void sendToothLog(bool useChar)
}
BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY);
}
toothLogRead = true;
}
void testComm()

View File

@ -18,6 +18,7 @@ volatile unsigned long toothOneMinusOneTime = 0; //The 2nd to last time (micros(
volatile bool revolutionOne = 0; // For sequential operation, this tracks whether the current revolution is 1 or 2 (not 1)
volatile unsigned int toothHistory[TOOTH_LOG_BUFFER];
volatile unsigned int toothHistoryIndex = 0;
volatile bool toothLogRead = false; //Flag to indicate whether the current tooth log values have been read out yet
volatile byte secondaryToothCount; //Used for identifying the current secondary (Usually cam) tooth for patterns with multiple secondary teeth
volatile unsigned long secondaryLastToothTime = 0; //The time (micros()) that the last tooth was registered (Cam input)

View File

@ -21,12 +21,19 @@ toothLastToothTime - The time (In uS) that the last primary tooth was 'seen'
*/
static inline void addToothLogEntry(unsigned long time)
static inline void addToothLogEntry(unsigned long toothTime)
{
//High speed tooth logging history
toothHistory[toothHistoryIndex] = time;
toothHistory[toothHistoryIndex] = toothTime;
if(toothHistoryIndex == (TOOTH_LOG_BUFFER-1))
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a set of concurrent values.
{
if (toothLogRead)
{
toothHistoryIndex = 0;
BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY);
toothLogRead = false; //The tooth log ready bit is cleared to ensure that we only get a set of concurrent values.
}
}
else
{ toothHistoryIndex++; }
}
@ -106,6 +113,7 @@ void triggerPri_missingTooth()
if ( curGap > targetGap || toothCurrentCount > triggerActualTeeth)
{
if(toothCurrentCount < (triggerActualTeeth) && currentStatus.hasSync) { currentStatus.hasSync = false; return; } //This occurs when we're at tooth #1, but haven't seen all the other teeth. This indicates a signal issue so we flag lost sync so this will attempt to resync on the next revolution.
toothCurrentCount = 1;
revolutionOne = !revolutionOne; //Flip sequential revolution tracker
toothOneMinusOneTime = toothOneTime;