From b0c6b40ff6f3723f651de562b1ae4969238ff473 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Mon, 10 Jul 2017 11:56:49 +1000 Subject: [PATCH] Error checks on the missing tooth end tooth calculation --- speeduino/decoders.ino | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/speeduino/decoders.ino b/speeduino/decoders.ino index 37366d8f..c0366568 100644 --- a/speeduino/decoders.ino +++ b/speeduino/decoders.ino @@ -239,8 +239,19 @@ void triggerSetEndTeeth_missingTooth() if(ignition1EndTooth > triggerActualTeeth) { ignition1EndTooth = triggerActualTeeth; } ignition2EndTooth = ( (ignition2EndAngle - configPage2.triggerAngle) / triggerToothAngle ) - 1; + if(ignition2EndTooth > configPage2.triggerTeeth) { ignition2EndTooth -= configPage2.triggerTeeth; } + if(ignition2EndTooth <= 0) { ignition2EndTooth -= configPage2.triggerTeeth; } + if(ignition2EndTooth > triggerActualTeeth) { ignition2EndTooth = triggerActualTeeth; } + ignition3EndTooth = ( (ignition3EndAngle - configPage2.triggerAngle) / triggerToothAngle ) - 1; + if(ignition3EndTooth > configPage2.triggerTeeth) { ignition3EndTooth -= configPage2.triggerTeeth; } + if(ignition3EndTooth <= 0) { ignition3EndTooth -= configPage2.triggerTeeth; } + if(ignition3EndTooth > triggerActualTeeth) { ignition3EndTooth = triggerActualTeeth; } + ignition4EndTooth = ( (ignition4EndAngle - configPage2.triggerAngle) / triggerToothAngle ) - 1; + if(ignition4EndTooth > configPage2.triggerTeeth) { ignition4EndTooth -= configPage2.triggerTeeth; } + if(ignition4EndTooth <= 0) { ignition4EndTooth -= configPage2.triggerTeeth; } + if(ignition4EndTooth > triggerActualTeeth) { ignition4EndTooth = triggerActualTeeth; } }