Speeduino
Loading...
Searching...
No Matches
Macros | Functions
fuel_calcs.cpp File Reference
#include "fuel_calcs.h"
#include "maths.h"
#include "unit_testing.h"
#include "globals.h"

Macros

#define ASSIGN_PULSEWIDTH_OR_ZERO(index, pw)    current.PW ## index = ((current.maxInjOutputs) >= (uint8_t)(index)) ? (pw) : 0U
 

Functions

TESTABLE_INLINE_STATIC uint16_t calculateRequiredFuel (const config2 &page2, const statuses &current)
 
static uint8_t calcNitrousStagePercent (uint8_t minRPMDiv100, uint8_t maxRPMDiv100, const statuses &current)
 
static uint16_t calcNitrousStagePulseWidth (uint8_t minRPMDiv100, uint8_t maxRPMDiv100, uint8_t adderMinDiv100, uint8_t adderMaxDiv100, const statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t pwApplyNitrous (uint16_t pw, const config10 &page10, const statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t calculatePWLimit (const config2 &page2, const statuses &current)
 
static uint32_t applyMapMode (uint32_t intermediate, const config2 &page2, const statuses &current)
 
static uint32_t applyAFRMultiplier (uint32_t intermediate, const config2 &page2, const config6 &page6, const statuses &current)
 
static uint32_t applyCorrections (uint32_t intermediate, uint16_t corrections)
 
static uint16_t computeInitialPw (uint16_t REQ_FUEL, uint8_t VE)
 
static uint32_t includeOpenTime (uint32_t intermediate, uint16_t injOpen)
 
static uint32_t includeAe (uint32_t intermediate, uint16_t REQ_FUEL, const config2 &page2, const statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t calcPrimaryPulseWidth (uint16_t injOpenTime, const config2 &page2, const config6 &page6, const config10 &page10, const statuses &current)
 
TESTABLE_INLINE_STATIC uint16_t applyPwLimits (uint16_t pw, uint16_t pwLimit, const config10 &page10, const statuses &current)
 
static bool canApplyStaging (const config2 &page2, const config10 &page10)
 
static uint32_t calcTotalStagePw (uint16_t primaryPW, uint16_t injOpenTime, const config10 &page10)
 
static uint32_t calcStagePrimaryPw (uint32_t totalPw, const config10 &page10)
 
static uint32_t calcStageSecondaryPw (uint32_t totalPw, const config10 &page10)
 
static pulseWidths applyStagingModeTable (uint16_t primaryPW, uint16_t injOpenTime, const config10 &page10, const statuses &current)
 
static pulseWidths applyStagingModeAuto (uint16_t primaryPW, uint16_t pwLimit, uint16_t injOpenTime, const config10 &page10)
 
TESTABLE_INLINE_STATIC pulseWidths calculateSecondaryPw (uint16_t primaryPw, uint16_t pwLimit, uint16_t injOpenTime, const config2 &page2, const config10 &page10, const statuses &current)
 
void applyPwToInjectorChannels (const pulseWidths &pulse_widths, const config2 &page2, statuses &current)
 Apply the calculated pulse widths to the current system state.
 
TESTABLE_INLINE_STATIC uint16_t calculateOpenTime (const config2 &page2, const statuses &current)
 
pulseWidths computePulseWidths (const config2 &page2, const config6 &page6, const config10 &page10, const statuses &current)
 This function calculates the required pulsewidth time (in µS) given the current tune & system state.
 

Macro Definition Documentation

◆ ASSIGN_PULSEWIDTH_OR_ZERO

#define ASSIGN_PULSEWIDTH_OR_ZERO (   index,
  pw 
)     current.PW ## index = ((current.maxInjOutputs) >= (uint8_t)(index)) ? (pw) : 0U

Function Documentation

◆ applyAFRMultiplier()

static uint32_t applyAFRMultiplier ( uint32_t  intermediate,
const config2 page2,
const config6 page6,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyCorrections()

static uint32_t applyCorrections ( uint32_t  intermediate,
uint16_t  corrections 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyMapMode()

static uint32_t applyMapMode ( uint32_t  intermediate,
const config2 page2,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyPwLimits()

TESTABLE_INLINE_STATIC uint16_t applyPwLimits ( uint16_t  pw,
uint16_t  pwLimit,
const config10 page10,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyPwToInjectorChannels()

void applyPwToInjectorChannels ( const pulseWidths pulse_widths,
const config2 page2,
statuses current 
)

Apply the calculated pulse widths to the current system state.

Parameters
pulseWidthsResult of computePulseWidths()
page2Tune settings
currentCurrent system state
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyStagingModeAuto()

static pulseWidths applyStagingModeAuto ( uint16_t  primaryPW,
uint16_t  pwLimit,
uint16_t  injOpenTime,
const config10 page10 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyStagingModeTable()

static pulseWidths applyStagingModeTable ( uint16_t  primaryPW,
uint16_t  injOpenTime,
const config10 page10,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcNitrousStagePercent()

static uint8_t calcNitrousStagePercent ( uint8_t  minRPMDiv100,
uint8_t  maxRPMDiv100,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcNitrousStagePulseWidth()

static uint16_t calcNitrousStagePulseWidth ( uint8_t  minRPMDiv100,
uint8_t  maxRPMDiv100,
uint8_t  adderMinDiv100,
uint8_t  adderMaxDiv100,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcPrimaryPulseWidth()

TESTABLE_INLINE_STATIC uint16_t calcPrimaryPulseWidth ( uint16_t  injOpenTime,
const config2 page2,
const config6 page6,
const config10 page10,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcStagePrimaryPw()

static uint32_t calcStagePrimaryPw ( uint32_t  totalPw,
const config10 page10 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcStageSecondaryPw()

static uint32_t calcStageSecondaryPw ( uint32_t  totalPw,
const config10 page10 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calcTotalStagePw()

static uint32_t calcTotalStagePw ( uint16_t  primaryPW,
uint16_t  injOpenTime,
const config10 page10 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateOpenTime()

TESTABLE_INLINE_STATIC uint16_t calculateOpenTime ( const config2 page2,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculatePWLimit()

TESTABLE_INLINE_STATIC uint16_t calculatePWLimit ( const config2 page2,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateRequiredFuel()

TESTABLE_INLINE_STATIC uint16_t calculateRequiredFuel ( const config2 page2,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateSecondaryPw()

TESTABLE_INLINE_STATIC pulseWidths calculateSecondaryPw ( uint16_t  primaryPw,
uint16_t  pwLimit,
uint16_t  injOpenTime,
const config2 page2,
const config10 page10,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canApplyStaging()

static bool canApplyStaging ( const config2 page2,
const config10 page10 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeInitialPw()

static uint16_t computeInitialPw ( uint16_t  REQ_FUEL,
uint8_t  VE 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ computePulseWidths()

pulseWidths computePulseWidths ( const config2 page2,
const config6 page6,
const config10 page10,
const statuses current 
)

This function calculates the required pulsewidth time (in µS) given the current tune & system state.

Parameters
page2Tune settings
page6Tune settings
page10Tune settings
currentCurrent system state
Returns
pulseWidths The primary and secondary injector pulse width in uS
Here is the call graph for this function:
Here is the caller graph for this function:

◆ includeAe()

static uint32_t includeAe ( uint32_t  intermediate,
uint16_t  REQ_FUEL,
const config2 page2,
const statuses current 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ includeOpenTime()

static uint32_t includeOpenTime ( uint32_t  intermediate,
uint16_t  injOpen 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pwApplyNitrous()

TESTABLE_INLINE_STATIC uint16_t pwApplyNitrous ( uint16_t  pw,
const config10 page10,
const statuses current 
)
Here is the call graph for this function:
Here is the caller graph for this function: