Minor cleanups before release

This commit is contained in:
Josh Stewart 2017-11-07 22:05:23 +11:00
parent 8f0d654ffa
commit 0de3a231c9
4 changed files with 23 additions and 14 deletions

View File

@ -4,8 +4,13 @@
int fastMap1023toX(int, int);
unsigned long percentage(byte, unsigned long);
#define degreesToUS(degrees) (decoderIsLowRes == true ) ? ((degrees * 166666UL) / currentStatus.RPM) : degrees * (unsigned long)timePerDegree
//#define degreesToUS(degrees) (decoderIsLowRes == true ) ? ((degrees * 166666UL) / currentStatus.RPM) : (degrees * (unsigned long)timePerDegree)
#define degreesToUS(degrees) ((degrees * revolutionTime) / 360)
//#define degreesToUS(degrees) ((degrees * revolutionTime * 3054198967ULL) >> 40) //Fast version of divide by 360
//#define degreesToUS(degrees) (degrees * (unsigned long)timePerDegree)
#define uSToDegrees(time) (((unsigned long)time * currentStatus.RPM) / 166666)
//#define uSToDegrees(time) ( (((uint64_t)time * currentStatus.RPM * 211107077ULL) >> 45) ) //Crazy magic numbers method from Hackers delight (www.hackersdelight.org/magic.htm)
#define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) ^ ((d) < 0)) ? (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d)))
//This is a dedicated function that specifically handles the case of mapping 0-1023 values into a 0 to X range

View File

@ -37,10 +37,12 @@ uint16_t MAPcurRev; //Tracks which revolution we're sampling on
*/
#define ADC_FILTER(input, alpha, prior) (((long)input * (256 - alpha) + ((long)prior * alpha))) >> 8
void instanteneousMAPReading();
void readMAP();
static inline void instanteneousMAPReading() __attribute__((always_inline));
static inline void readMAP() __attribute__((always_inline));
void readTPS();
void flexPulse();
#if defined(ANALOG_ISR)
//Analog ISR interrupt routine
/*

View File

@ -48,7 +48,7 @@ void initialiseADC()
MAPrunningValue = 0;
}
void instanteneousMAPReading()
static inline void instanteneousMAPReading()
{
unsigned int tempReading;
//Instantaneous MAP readings
@ -71,7 +71,7 @@ void instanteneousMAPReading()
}
void readMAP()
static inline void readMAP()
{
unsigned int tempReading;
//MAP Sampling system
@ -119,7 +119,7 @@ void readMAP()
if(currentStatus.MAP < 0) { currentStatus.MAP = 0; } //Sanity check
}
else { instanteneousMAPReading(); }
MAPcurRev = currentStatus.startRevolutions; //Reset the current rev count
MAPrunningValue = 0;
MAPcount = 0;

View File

@ -811,12 +811,12 @@ void loop()
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //ATmega2561 does not have Serial3
//if Can interface is enabled then check for external data requests.
if (configPage10.enable_candata_in) //if external data input is enabled
{
{
if (configPage10.enable_canbus == 1) // megas only support can via secondary serial
{
for (byte caninChan = 0; caninChan <16 ; caninChan++)
{
currentStatus.current_caninchannel = caninChan;
currentStatus.current_caninchannel = caninChan;
//currentStatus.canin[14] = currentStatus.current_caninchannel;
currentStatus.canin[13] = ((configPage10.caninput_source_can_address[currentStatus.current_caninchannel]&2047)+0x100);
if (BIT_CHECK(configPage10.caninput_sel,currentStatus.current_caninchannel)) //if current input channel bit is enabled
@ -827,7 +827,7 @@ void loop()
}
}
}
#elif defined(CORE_STM32) || defined(CORE_TEENSY)
//if serial3io is enabled then check for serial3 requests.
if (configPage10.enable_candata_in)
@ -839,11 +839,11 @@ void loop()
{
if (configPage10.enable_canbus == 1) //can via secondary serial
{
sendCancommand(2,0,currentStatus.current_caninchannel,0,((configPage10.caninput_source_can_address[currentStatus.current_caninchannel]&2047)+256)); //send an R command for data from paramgroup[currentStatus.current_caninchannel]
}
sendCancommand(2,0,currentStatus.current_caninchannel,0,((configPage10.caninput_source_can_address[currentStatus.current_caninchannel]&2047)+256)); //send an R command for data from paramgroup[currentStatus.current_caninchannel]
}
else if (configPage10.enable_canbus == 2) // can via internal can module
{
sendCancommand(3,configPage10.speeduino_tsCanId,currentStatus.current_caninchannel,0,configPage10.caninput_source_can_address[currentStatus.current_caninchannel]); //send via localcanbus the command for data from paramgroup[currentStatus.current_caninchannel]
{
sendCancommand(3,configPage10.speeduino_tsCanId,currentStatus.current_caninchannel,0,configPage10.caninput_source_can_address[currentStatus.current_caninchannel]); //send via localcanbus the command for data from paramgroup[currentStatus.current_caninchannel]
}
}
}
@ -1339,11 +1339,13 @@ void loop()
ign1EndFunction
);
}
/*
if(ignition1EndAngle > crankAngle && configPage2.StgCycles == 0)
{
unsigned long uSToEnd = degreesToUS( (ignition1EndAngle - crankAngle) );
//refreshIgnitionSchedule1( uSToEnd + fixedCrankingOverride );
refreshIgnitionSchedule1( uSToEnd + fixedCrankingOverride );
}
*/
tempCrankAngle = crankAngle - channel2IgnDegrees;
if( tempCrankAngle < 0) { tempCrankAngle += CRANK_ANGLE_MAX_IGN; }