From e16108d806d603dfe7cb8894f00f501890bc6845 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Wed, 25 May 2022 11:03:33 +1000 Subject: [PATCH] Prevent overflow of the AE RPM taper. Fixes #843 --- speeduino/corrections.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/speeduino/corrections.ino b/speeduino/corrections.ino index 0c5fa65e..2eaaf924 100644 --- a/speeduino/corrections.ino +++ b/speeduino/corrections.ino @@ -431,7 +431,7 @@ uint16_t correctionAccel() else { int16_t taperRange = trueTaperMax - trueTaperMin; - int16_t taperPercent = ((currentStatus.RPM - trueTaperMin) * 100) / taperRange; //The percentage of the way through the RPM taper range + int16_t taperPercent = ((currentStatus.RPM - trueTaperMin) * 100UL) / taperRange; //The percentage of the way through the RPM taper range accelValue = percentage((100-taperPercent), accelValue); //Calculate the above percentage of the calculated accel amount. } } @@ -490,7 +490,7 @@ uint16_t correctionAccel() else { int16_t taperRange = trueTaperMax - trueTaperMin; - int16_t taperPercent = ((currentStatus.RPM - trueTaperMin) * 100) / taperRange; //The percentage of the way through the RPM taper range + int16_t taperPercent = ((currentStatus.RPM - trueTaperMin) * 100UL) / taperRange; //The percentage of the way through the RPM taper range accelValue = percentage( (100 - taperPercent), accelValue); //Calculate the above percentage of the calculated accel amount. } }