mirror of https://github.com/rusefi/speeduino.git
Formatting cleanup
This commit is contained in:
parent
425ec75828
commit
23c3c8b6bf
|
@ -165,7 +165,8 @@ int getCrankAngle_missingTooth(int timePerDegree)
|
||||||
|
|
||||||
int crankAngle = (tempToothCurrentCount - 1) * triggerToothAngle + configPage2.triggerAngle; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
|
int crankAngle = (tempToothCurrentCount - 1) * triggerToothAngle + configPage2.triggerAngle; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
|
||||||
//Estimate the number of degrees travelled since the last tooth}
|
//Estimate the number of degrees travelled since the last tooth}
|
||||||
long elapsedTime = micros() - tempToothLastToothTime;
|
long elapsedTime = (micros() - tempToothLastToothTime);
|
||||||
|
//crankAngle += DIV_ROUND_CLOSEST(elapsedTime, timePerDegree);
|
||||||
if(elapsedTime < SHRT_MAX ) { crankAngle += div((int)elapsedTime, timePerDegree).quot; } //This option is much faster, but only available for smaller values of elapsedTime
|
if(elapsedTime < SHRT_MAX ) { crankAngle += div((int)elapsedTime, timePerDegree).quot; } //This option is much faster, but only available for smaller values of elapsedTime
|
||||||
else { crankAngle += ldiv(elapsedTime, timePerDegree).quot; }
|
else { crankAngle += ldiv(elapsedTime, timePerDegree).quot; }
|
||||||
|
|
||||||
|
@ -1331,6 +1332,3 @@ int getCrankAngle_non360(int timePerDegree)
|
||||||
|
|
||||||
return crankAngle;
|
return crankAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3
maths.h
3
maths.h
|
@ -1,6 +1,7 @@
|
||||||
#ifndef MATH_H
|
#ifndef MATH_H
|
||||||
#define MATH_H
|
#define MATH_H
|
||||||
|
|
||||||
int fastMap1023toX(unsigned long x, int out_max);
|
int fastMap1023toX(unsigned long, int);
|
||||||
|
unsigned long percentage(byte, unsigned long);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "cancomms.h"
|
#include "cancomms.h"
|
||||||
#include "math.h"
|
#include "maths.h"
|
||||||
#include "corrections.h"
|
#include "corrections.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
//#include "display.h"
|
//#include "display.h"
|
||||||
|
@ -1015,6 +1015,8 @@ void loop()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long rpm_adjust = ((long)(micros() - toothOneTime) * (long)currentStatus.rpmDOT) / 1000000; //Take into account any likely accleration that has occurred since the last full revolution completed
|
long rpm_adjust = ((long)(micros() - toothOneTime) * (long)currentStatus.rpmDOT) / 1000000; //Take into account any likely accleration that has occurred since the last full revolution completed
|
||||||
|
|
||||||
|
//timePerDegree = DIV_ROUND_CLOSEST(166666L, (currentStatus.RPM + rpm_adjust));
|
||||||
timePerDegree = ldiv( 166666L, currentStatus.RPM + rpm_adjust).quot; //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
|
timePerDegree = ldiv( 166666L, currentStatus.RPM + rpm_adjust).quot; //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1322,8 +1324,6 @@ void loop()
|
||||||
//***********************************************************************************************
|
//***********************************************************************************************
|
||||||
//| BEGIN IGNITION SCHEDULES
|
//| BEGIN IGNITION SCHEDULES
|
||||||
//Likewise for the ignition
|
//Likewise for the ignition
|
||||||
crankAngle = getCrankAngle(timePerDegree); //Refresh with the latest crank angle
|
|
||||||
if (crankAngle > CRANK_ANGLE_MAX_IGN ) { crankAngle -= 360; }
|
|
||||||
|
|
||||||
//fixedCrankingOverride is used to extend the dwell during cranking so that the decoder can trigger the spark upon seeing a certain tooth. Currently only available on the basic distributor and 4g63 decoders.
|
//fixedCrankingOverride is used to extend the dwell during cranking so that the decoder can trigger the spark upon seeing a certain tooth. Currently only available on the basic distributor and 4g63 decoders.
|
||||||
if ( configPage2.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) { fixedCrankingOverride = currentStatus.dwell * 2; }
|
if ( configPage2.ignCranklock && BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) { fixedCrankingOverride = currentStatus.dwell * 2; }
|
||||||
|
@ -1334,6 +1334,11 @@ void loop()
|
||||||
if(ignitionOn && !currentStatus.launchingHard && !BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) && !BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM) && !currentStatus.flatShiftingHard)
|
if(ignitionOn && !currentStatus.launchingHard && !BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) && !BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM) && !currentStatus.flatShiftingHard)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Refresh the current crank angle info
|
||||||
|
//ignition1StartAngle = 335;
|
||||||
|
crankAngle = getCrankAngle(timePerDegree); //Refresh with the latest crank angle
|
||||||
|
if (crankAngle > CRANK_ANGLE_MAX_IGN ) { crankAngle -= 360; }
|
||||||
|
|
||||||
//if (ignition1StartAngle <= crankAngle && ignition1.schedulesSet == 0) { ignition1StartAngle += CRANK_ANGLE_MAX_IGN; }
|
//if (ignition1StartAngle <= crankAngle && ignition1.schedulesSet == 0) { ignition1StartAngle += CRANK_ANGLE_MAX_IGN; }
|
||||||
if (ignition1StartAngle > crankAngle)
|
if (ignition1StartAngle > crankAngle)
|
||||||
{
|
{
|
||||||
|
@ -1341,13 +1346,12 @@ void loop()
|
||||||
long some_time = ((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree);
|
long some_time = ((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree);
|
||||||
long newRPM = (long)(some_time * currentStatus.rpmDOT) / 1000000L;
|
long newRPM = (long)(some_time * currentStatus.rpmDOT) / 1000000L;
|
||||||
newRPM = currentStatus.RPM + (newRPM/2);
|
newRPM = currentStatus.RPM + (newRPM/2);
|
||||||
unsigned long timePerDegree_1 = ldiv( 166666L, newRPM).quot;*/
|
unsigned long timePerDegree_1 = ldiv( 166666L, newRPM).quot;
|
||||||
|
unsigned long timeout = (unsigned long)(ignition1StartAngle - crankAngle) * 282UL;
|
||||||
|
*/
|
||||||
setIgnitionSchedule1(ign1StartFunction,
|
setIgnitionSchedule1(ign1StartFunction,
|
||||||
((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree),
|
((unsigned long)(ignition1StartAngle - crankAngle) * (unsigned long)timePerDegree), //(timeout/10),
|
||||||
//some_time -some_accel,
|
currentStatus.dwell + fixedCrankingOverride, //((unsigned long)((unsigned long)currentStatus.dwell* currentStatus.RPM) / newRPM) + fixedCrankingOverride,
|
||||||
//((unsigned long)((unsigned long)currentStatus.dwell* currentStatus.RPM) / newRPM) + fixedCrankingOverride,
|
|
||||||
currentStatus.dwell + fixedCrankingOverride,
|
|
||||||
ign1EndFunction
|
ign1EndFunction
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue