2015-11-24 21:55:36 -08:00
# include <limits.h>
2015-05-16 04:06:54 -07:00
volatile unsigned long curTime ;
2015-12-08 18:33:35 -08:00
volatile unsigned long curGap ;
2015-09-07 23:46:42 -07:00
volatile unsigned long curTime2 ;
2015-12-08 18:33:35 -08:00
volatile unsigned long curGap2 ;
volatile unsigned long lastGap ;
volatile unsigned long targetGap ;
2015-05-16 04:06:54 -07:00
volatile int toothCurrentCount = 0 ; //The current number of teeth (Onec sync has been achieved, this can never actually be 0
volatile unsigned long toothLastToothTime = 0 ; //The time (micros()) that the last tooth was registered
2015-09-07 23:46:42 -07:00
volatile unsigned long toothLastSecToothTime = 0 ; //The time (micros()) that the last tooth was registered on the secondary input
2015-05-16 04:06:54 -07:00
volatile unsigned long toothLastMinusOneToothTime = 0 ; //The time (micros()) that the tooth before the last tooth was registered
volatile unsigned long toothOneTime = 0 ; //The time (micros()) that tooth 1 last triggered
volatile unsigned long toothOneMinusOneTime = 0 ; //The 2nd to last time (micros()) that tooth 1 last triggered
2015-10-30 02:35:45 -07:00
volatile unsigned int toothHistory [ TOOTH_LOG_BUFFER ] ;
2015-09-07 16:49:34 -07:00
volatile unsigned int toothHistoryIndex = 0 ;
2015-05-16 04:06:54 -07:00
2015-07-12 03:34:59 -07:00
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)
2015-05-16 04:06:54 -07:00
volatile int triggerActualTeeth ;
2015-09-13 04:16:30 -07:00
volatile unsigned long triggerFilterTime ; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
2015-09-07 23:46:42 -07:00
unsigned int triggerSecFilterTime ; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) for the secondary input
2015-10-31 13:18:09 -07:00
int triggerToothAngle ; //The number of crank degrees that elapse per tooth
2015-06-11 20:18:36 -07:00
unsigned long revolutionTime ; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that)
2015-11-29 00:53:41 -08:00
bool secondDerivEnabled ; //The use of the 2nd derivative calculation is limited to certain decoders. This is set to either true or false in each decoders setup routine
2015-07-12 03:34:59 -07:00
2015-10-31 13:18:09 -07:00
int toothAngles [ 24 ] ; //An array for storing fixed tooth angles. Currently sized at 24 for the GM 24X decoder, but may grow later if there are other decoders that use this style
2015-07-12 21:22:05 -07:00
2015-07-12 03:34:59 -07:00
//Used for identifying long and short pulses on the 4G63 (And possibly other) trigger patterns
# define LONG 0;
# define SHORT 1;
2015-11-24 21:55:36 -08:00