refactoring: reduce magic constant
This commit is contained in:
parent
f9dfcc8b9a
commit
4c7e8560e0
|
@ -69,7 +69,7 @@ void DynoView::update(vssSrc src) {
|
|||
*/
|
||||
void DynoView::updateAcceleration(efitimeus_t deltaTime, float deltaSpeed) {
|
||||
if (deltaSpeed != 0.0) {
|
||||
acceleration = ((deltaSpeed / 3.6) / (deltaTime / 1000000.0));
|
||||
acceleration = ((deltaSpeed / 3.6) / (deltaTime / US_PER_SECOND_F));
|
||||
if (direction) {
|
||||
//decceleration
|
||||
acceleration *= -1;
|
||||
|
|
|
@ -623,7 +623,7 @@ float Engine::getTimeIgnitionSeconds(void) const {
|
|||
// return negative if the ignition is turned off
|
||||
if (ignitionOnTimeNt == 0)
|
||||
return -1;
|
||||
float numSeconds = (float)NT2US(getTimeNowNt() - ignitionOnTimeNt) / 1000000.0f;
|
||||
float numSeconds = (float)NT2US(getTimeNowNt() - ignitionOnTimeNt) / US_PER_SECOND_F;
|
||||
return numSeconds;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
// for compatibility reasons, apply only if the factor is greater than unity (only allow adding fuel)
|
||||
if (engineConfiguration->postCrankingFactor > 1.0f) {
|
||||
// convert to microsecs and then to seconds
|
||||
running.timeSinceCrankingInSecs = NT2US(timeSinceCranking) / 1000000.0f;
|
||||
running.timeSinceCrankingInSecs = NT2US(timeSinceCranking) / US_PER_SECOND_F;
|
||||
// use interpolation for correction taper
|
||||
running.postCrankingFuelCorrection = interpolateClamped(0.0f, engineConfiguration->postCrankingFactor,
|
||||
engineConfiguration->postCrankingDurationSec, 1.0f, running.timeSinceCrankingInSecs);
|
||||
|
@ -184,7 +184,7 @@ void EngineState::updateTChargeK(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUF
|
|||
float newTCharge = getTCharge(rpm, tps PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
// convert to microsecs and then to seconds
|
||||
efitick_t curTime = getTimeNowNt();
|
||||
float secsPassed = (float)NT2US(curTime - timeSinceLastTChargeK) / 1000000.0f;
|
||||
float secsPassed = (float)NT2US(curTime - timeSinceLastTChargeK) / US_PER_SECOND_F;
|
||||
if (!cisnan(newTCharge)) {
|
||||
// control the rate of change or just fill with the initial value
|
||||
sd.tCharge = (sd.tChargeK == 0) ? newTCharge : limitRateOfChange(newTCharge, sd.tCharge, CONFIG(tChargeAirIncrLimit), CONFIG(tChargeAirDecrLimit), secsPassed);
|
||||
|
|
|
@ -219,7 +219,7 @@ static void applyConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
static void digitalMapWidthCallback(void) {
|
||||
efitick_t nowNt = getTimeNowNt();
|
||||
|
||||
mapFreq = 1000000.0 / NT2US(nowNt - prevWidthTimeNt);
|
||||
mapFreq = US_PER_SECOND_F / NT2US(nowNt - prevWidthTimeNt);
|
||||
|
||||
prevWidthTimeNt = nowNt;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue