externvoid(*triggerHandler)();//Pointer for the trigger function (Gets pointed to the relevant decoder)
externvoid(*triggerSecondaryHandler)();//Pointer for the secondary trigger function (Gets pointed to the relevant decoder)
externuint16_t(*getRPM)();//Pointer to the getRPM function (Gets pointed to the relevant decoder)
externint(*getCrankAngle)();//Pointer to the getCrank Angle function (Gets pointed to the relevant decoder)
externvoid(*triggerSetEndTeeth)();//Pointer to the triggerSetEndTeeth function of each decoder
externvolatileunsignedlongcurTime;
externvolatileunsignedlongcurGap;
externvolatileunsignedlongcurTime2;
externvolatileunsignedlongcurGap2;
externvolatileunsignedlonglastGap;
externvolatileunsignedlongtargetGap;
externvolatileunsignedlongcompositeLastToothTime;
externunsignedlongMAX_STALL_TIME;//The maximum time (in uS) that the system will continue to function before the engine is considered stalled/stopped. This is unique to each decoder, depending on the number of teeth etc. 500000 (half a second) is used as the default value, most decoders will be much less.
externvolatileuint16_ttoothCurrentCount;//The current number of teeth (Onec sync has been achieved, this can never actually be 0
externvolatilebytetoothSystemCount;//Used for decoders such as Audi 135 where not every tooth is used for calculating crank angle. This variable stores the actual number of teeth, not the number being used to calculate crank angle
externvolatileunsignedlongtoothSystemLastToothTime;//As below, but used for decoders where not every tooth count is used for calculation
externvolatileunsignedlongtoothLastToothTime;//The time (micros()) that the last tooth was registered
externvolatileunsignedlongtoothLastSecToothTime;//The time (micros()) that the last tooth was registered on the secondary input
externvolatileunsignedlongtoothLastMinusOneToothTime;//The time (micros()) that the tooth before the last tooth was registered
externvolatileunsignedlongtoothOneTime;//The time (micros()) that tooth 1 last triggered
externvolatileunsignedlongtoothOneMinusOneTime;//The 2nd to last time (micros()) that tooth 1 last triggered
externvolatileboolrevolutionOne;// For sequential operation, this tracks whether the current revolution is 1 or 2 (not 1)
externvolatileunsignedintsecondaryToothCount;//Used for identifying the current secondary (Usually cam) tooth for patterns with multiple secondary teeth
externvolatileunsignedlongsecondaryLastToothTime;//The time (micros()) that the last tooth was registered (Cam input)
externvolatileunsignedlongsecondaryLastToothTime1;//The time (micros()) that the last tooth was registered (Cam input)
externvolatileuint16_ttriggerActualTeeth;
externvolatileunsignedlongtriggerFilterTime;// The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
externvolatileunsignedlongtriggerSecFilterTime;// The shortest time (in uS) that pulses will be accepted (Used for debounce filtering) for the secondary input
externvolatileboolvalidTrigger;//Is set true when the last trigger (Primary or secondary) was valid (ie passed filters)
externunsignedinttriggerSecFilterTime_duration;// The shortest valid time (in uS) pulse DURATION
externvolatileuint16_ttriggerToothAngle;//The number of crank degrees that elapse per tooth
externvolatilebooltriggerToothAngleIsCorrect;//Whether or not the triggerToothAngle variable is currently accurate. Some patterns have times when the triggerToothAngle variable cannot be accurately set.
externboolsecondDerivEnabled;//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
externbooldecoderIsSequential;//Whether or not the decoder supports sequential operation
externbooldecoderIsLowRes;//Is set true, certain extra calculations are performed for better timing accuracy
externbooldecoderHasSecondary;//Whether or not the pattern uses a secondary input
externbooldecoderHasFixedCrankingTiming;//Whether or not the decoder supports fixed cranking timing
externbytecheckSyncToothCount;//How many teeth must've been seen on this revolution before we try to confirm sync (Useful for missing tooth type decoders)
externunsignedlongelapsedTime;
externunsignedlonglastCrankAngleCalc;
externint16_tlastToothCalcAdvance;//Invalid value here forces calculation of this on first main loop
externunsignedlonglastVVTtime;//The time between the vvt reference pulse and the last crank pulse
externint16_ttoothAngles[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