diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 1f97a0cc..50b5f6e3 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -353,8 +353,8 @@ page = 1 #endif ;VSS settings - vssEnable = bits, U08, 102, [0:0], "Off", "On" - vssPullup = bits, U08, 102, [1:1], "Off", "On" + vssMode = bits, U08, 102, [0:1], "Off", "INVALID", "Pulses per KM", "Pulses per mile" ;INVALID value will be CAN + ;vssPullup = bits, U08, 102, [1:1], "Off", "On" vssPin = bits, U08, 102, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" vssPulsesPerKm= scalar, U16, 103, "pulses" 1.0, 0.0, 0.0, 25500, 0 vssSmoothing = scalar, U08, 105, "%", 1.0, 0, 0, 255, 0 @@ -365,6 +365,7 @@ page = 1 vssRatio5 = scalar, U16, 114, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 vssRatio6 = scalar, U16, 116, "km/h per 1000rpm", 0.1, 0, 0, 99.9, 1 + unused2-95 = array, U08, 118, [10], "%", 1.0, 0.0, 0.0, 255, 0 ;Page 2 is the fuel map and axis bins only @@ -1057,6 +1058,7 @@ page = 11 requiresPowerCycle = launchEnable requiresPowerCycle = launchHiLo requiresPowerCycle = flexEnabled + requiresPowerCycle = vssMode requiresPowerCycle = oddfire2 requiresPowerCycle = oddfire3 requiresPowerCycle = oddfire4 @@ -1212,6 +1214,14 @@ page = 11 ;Again, force the setting from the controller for the trigger edges. This is particularly useful for the Oct 2018 update where the names of the dges changed controllerPriority = TrigEdge controllerPriority = TrigEdgeSec + ;VSS Ratios and calibration need controller priority so they can be set with the command buttons + controllerPriority = vssPulsesPerKm + controllerPriority = vssRatio1 + controllerPriority = vssRatio2 + controllerPriority = vssRatio3 + controllerPriority = vssRatio4 + controllerPriority = vssRatio5 + controllerPriority = vssRatio6 ;These are the limits for each of the load algorithms (Refer to the PC Variables section) ;Order is: MAP TPS IMAP/EMAP ITB UNUSED UNUSED UNUSED UNUSED @@ -1782,22 +1792,22 @@ menuDialog = main dialog = vss_gear_1, "", xAxis field = "Speed ratio 1", vssRatio1 - commandButton = "Set Gear 1", cmdVSSratio1, {vssEnable} + commandButton = "Set Gear 1", cmdVSSratio1, { vssMode > 1 } dialog = vss_gear_2, "", xAxis field = "Speed ratio 2", vssRatio2 - commandButton = "Set Gear 2", cmdVSSratio2, {vssEnable} + commandButton = "Set Gear 2", cmdVSSratio2, { vssMode > 1 } dialog = vss_gear_3, "", xAxis field = "Speed ratio 3", vssRatio3 - commandButton = "Set Gear 3", cmdVSSratio3, {vssEnable} + commandButton = "Set Gear 3", cmdVSSratio3, { vssMode > 1 } dialog = vss_gear_4, "", xAxis field = "Speed ratio 4", vssRatio4 - commandButton = "Set Gear 4", cmdVSSratio4, {vssEnable} + commandButton = "Set Gear 4", cmdVSSratio4, { vssMode > 1 } dialog = vss_gear_5, "", xAxis field = "Speed ratio 5", vssRatio5 - commandButton = "Set Gear 5", cmdVSSratio5, {vssEnable} + commandButton = "Set Gear 5", cmdVSSratio5, { vssMode > 1 } dialog = vss_gear_6, "", xAxis field = "Speed ratio 6", vssRatio6 - commandButton = "Set Gear 6", cmdVSSratio6, {vssEnable} + commandButton = "Set Gear 6", cmdVSSratio6, { vssMode > 1 } dialog = vss_gear_detection, "Gear Detection", yAxis field = "After setting 'Pulses per km/mile' above" @@ -1810,14 +1820,14 @@ menuDialog = main panel = vss_gear_6 dialog = vss_calibration, "VSS Calibration" - field = "Pulses Per KM", vssPulsesPerKm, {vssEnable} - commandButton = "50km/h auto-calibrate", cmdVSS50kmh, {vssEnable} - field = "Smoothing Factor", vssSmoothing, {vssEnable} + field = "Pulses Per KM", vssPulsesPerKm, { vssMode > 1 } + commandButton = "60km/h auto-calibrate", cmdVSS60kmh, { vssMode > 1 } + field = "Smoothing Factor", vssSmoothing, { vssMode > 1 } dialog = vssSettings, "", yAxis - field = "VSS Enabled", vssEnable - field = "VSS Pin", vssPin, {vssEnable} - field = "Use Pullup", vssPullup, {vssEnable} + field = "VSS Input Mode", vssMode + field = "VSS Pin", vssPin, { vssMode > 1 } + ;field = "Use Pullup", vssPullup, { vssMode > 1 } panel = vss_calibration panel = vss_gear_detection @@ -3070,7 +3080,7 @@ cmdtestspk8on = "E\x03\x16" cmdtestspk8off = "E\x03\x17" cmdtestspk850dc = "E\x03\x18" -cmdVSS50kmh = "E\x99\x00" +cmdVSS60kmh = "E\x99\x00" cmdVSSratio1 = "E\x99\x01" cmdVSSratio2 = "E\x99\x02" cmdVSSratio3 = "E\x99\x03" @@ -3476,7 +3486,7 @@ cmdVSSratio6 = "E\x99\x06" stgDutyCycleGauge = stgDutyCycle, "Staging Duty Cycle", "%", 0, 100, -1, -1, 70, 80, 1, 1 egoCorrGauge = egoCorrection, "EGO Correction", "%", 50, 150, 90, 99, 101, 110, 0, 0 - gammaEnrichGauge = gammaEnrich, "Gamma Enrichment", "%", 50, 150, -1, -1, 151, 151, 0, 0 + gammaEnrichGauge = gammaEnrich, "Gamma Enrichment", "%", 50, 250, -1, -1, 151, 151, 0, 0 pulseWidthGauge = pulseWidth, "Pulse Width", "mSec", 0, 35.0, 1.0, 1.2, 20, 25, 3, 3 tachometer = rpm, "Engine Speed", "RPM", 0, {rpmhigh}, 300, 600, {rpmwarn}, {rpmdang}, 0, 0 veGauge = veCurr, "Current VE", "%", 0, 120, -1, -1, 999, 999, 0, 0 @@ -3621,30 +3631,30 @@ cmdVSSratio6 = "E\x99\x06" tpsaccden = bits, U08, 2, [5:5] mapaccaen = bits, U08, 2, [6:6] mapaccden = bits, U08, 2, [7:7] - syncLossCounter = scalar, U08, 3, "", 1.000, 0.000 - map = scalar, U16, 4, "kpa", 1.000, 0.000 - iatRaw = scalar, U08, 6, "°C", 1.000, 0.000 - coolantRaw = scalar, U08, 7, "°C", 1.000, 0.000 - batCorrection = scalar, U08, 8, "%", 1.000, 0.000 - batteryVoltage = scalar, U08, 9, "V", 0.100, 0.000 - afr = scalar, U08, 10, "O2", 0.100, 0.000 - egoCorrection = scalar, U08, 11, "%", 1.000, 0.000 - airCorrection = scalar, U08, 12, "%", 1.000, 0.000 - warmupEnrich = scalar, U08, 13, "%", 1.000, 0.000 - rpm = scalar, U16, 14, "rpm", 1.000, 0.000 - accelEnrich = scalar, U08, 16, "%", 2.000, 0.000 - gammaEnrich = scalar, U16, 17, "%", 1.000, 0.000 - VE1 = scalar, U08, 19, "%", 1.000, 0.000 - VE2 = scalar, U08, 20, "%", 1.000, 0.000 - afrTarget = scalar, U08, 21, "O2", 0.100, 0.000 - TPSdot = scalar, U08, 22, "%/s", 10.00, 0.000 - advance = scalar, S08, 23, "deg", 1.000, 0.000 - tps = scalar, U08, 24, "%", 1.000, 0.000 - loopsPerSecond = scalar, U16, 25, "loops", 1.000, 0.000 - freeRAM = scalar, U16, 27, "bytes", 1.000, 0.000 - boostTarget = scalar, U08, 29, "kPa", 2.000, 0.000 - boostDuty = scalar, U08, 30, "%", 1.000, 0.000 - status2 = scalar, U08, 31, "bits", 1.000, 0.000 + syncLossCounter = scalar, U08, 3, "", 1.000, 0.000 + map = scalar, U16, 4, "kpa", 1.000, 0.000 + iatRaw = scalar, U08, 6, "°C", 1.000, 0.000 + coolantRaw = scalar, U08, 7, "°C", 1.000, 0.000 + batCorrection = scalar, U08, 8, "%", 1.000, 0.000 + batteryVoltage = scalar, U08, 9, "V", 0.100, 0.000 + afr = scalar, U08, 10, "O2", 0.100, 0.000 + egoCorrection = scalar, U08, 11, "%", 1.000, 0.000 + airCorrection = scalar, U08, 12, "%", 1.000, 0.000 + warmupEnrich = scalar, U08, 13, "%", 1.000, 0.000 + rpm = scalar, U16, 14, "rpm", 1.000, 0.000 + accelEnrich = scalar, U08, 16, "%", 2.000, 0.000 + gammaEnrich = scalar, U16, 17, "%", 1.000, 0.000 + VE1 = scalar, U08, 19, "%", 1.000, 0.000 + VE2 = scalar, U08, 20, "%", 1.000, 0.000 + afrTarget = scalar, U08, 21, "O2", 0.100, 0.000 + TPSdot = scalar, U08, 22, "%/s", 10.00, 0.000 + advance = scalar, S08, 23, "deg", 1.000, 0.000 + tps = scalar, U08, 24, "%", 1.000, 0.000 + loopsPerSecond = scalar, U16, 25, "loops", 1.000, 0.000 + freeRAM = scalar, U16, 27, "bytes", 1.000, 0.000 + boostTarget = scalar, U08, 29, "kPa", 2.000, 0.000 + boostDuty = scalar, U08, 30, "%", 1.000, 0.000 + status2 = scalar, U08, 31, "bits", 1.000, 0.000 launchHard = bits, U08, 31, [0:0] launchSoft = bits, U08, 31, [1:1] hardLimitOn = bits, U08, 31, [2:2] @@ -3657,53 +3667,52 @@ cmdVSSratio6 = "E\x99\x06" flex = scalar, U08, 34, "%", 1.000, 0.000 flexFuelCor = scalar, U08, 35, "%", 1.000, 0.000 flexIgnCor = scalar, S08, 36, "deg", 1.000, 0.000 - idleLoad = scalar, U08, 37, { bitStringValue( idleUnits , iacAlgorithm ) }, { (iacAlgorithm == 2 || iacAlgorithm == 3) ? 1.000 : 2.000 }, 0.000 ; This is a combined variable covering both PWM and stepper IACs. The units and precision used depend on which idle algorithm is chosen testoutputs = scalar, U08, 38, "bits", 1.000, 0.000 - testenabled = bits, U08, 38, [0:0] - testactive = bits, U08, 38, [1:1] + testenabled = bits, U08, 38, [0:0] + testactive = bits, U08, 38, [1:1] afr2 = scalar, U08, 39, "O2", 0.100, 0.000 - baro = scalar, U08, 40, "kpa", 1.000, 0.000 - auxin_gauge0 = scalar, U16, 41, "", 1.000, 0.000 - auxin_gauge1 = scalar, U16, 43, "", 1.000, 0.000 - auxin_gauge2 = scalar, U16, 45, "", 1.000, 0.000 - auxin_gauge3 = scalar, U16, 47, "", 1.000, 0.000 - auxin_gauge4 = scalar, U16, 49, "", 1.000, 0.000 - auxin_gauge5 = scalar, U16, 51, "", 1.000, 0.000 - auxin_gauge6 = scalar, U16, 53, "", 1.000, 0.000 - auxin_gauge7 = scalar, U16, 55, "", 1.000, 0.000 - auxin_gauge8 = scalar, U16, 57, "", 1.000, 0.000 - auxin_gauge9 = scalar, U16, 59, "", 1.000, 0.000 - auxin_gauge10 = scalar, U16, 61, "", 1.000, 0.000 - auxin_gauge11 = scalar, U16, 63, "", 1.000, 0.000 - auxin_gauge12 = scalar, U16, 65, "", 1.000, 0.000 - auxin_gauge13 = scalar, U16, 67, "", 1.000, 0.000 - auxin_gauge14 = scalar, U16, 69, "", 1.000, 0.000 - auxin_gauge15 = scalar, U16, 71, "", 1.000, 0.000 - tpsADC = scalar, U08, 73, "ADC",1.000, 0.000 - errors = scalar, U08, 74, "bits", 1.000, 0.000 - errorNum = bits, U08, 74, [0:1] - currentError = bits, U08, 74, [2:7] - pulseWidth = scalar, U16, 75, "ms", 0.001, 0.000 - pulseWidth2 = scalar, U16, 77, "ms", 0.001, 0.000 - pulseWidth3 = scalar, U16, 79, "ms", 0.001, 0.000 - pulseWidth4 = scalar, U16, 81, "ms", 0.001, 0.000 - status3 = scalar, U08, 83, "bits", 1.000, 0.000 - resetLockOn = bits, U08, 83, [0:0] - nitrousOn = bits, U08, 83, [1:1] - fuel2Active = bits, U08, 83, [2:2] - unused81_3-4 = bits, U08, 83, [3:4] - nSquirts = bits, U08, 83, [5:7] - unused1 = scalar, U08, 84, "ADC",1.000, 0.000 - fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, 1.000, 0.000 - ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000 - dwell = scalar, U16, 89, "ms", 0.001, 0.000 + baro = scalar, U08, 40, "kpa", 1.000, 0.000 + auxin_gauge0 = scalar, U16, 41, "", 1.000, 0.000 + auxin_gauge1 = scalar, U16, 43, "", 1.000, 0.000 + auxin_gauge2 = scalar, U16, 45, "", 1.000, 0.000 + auxin_gauge3 = scalar, U16, 47, "", 1.000, 0.000 + auxin_gauge4 = scalar, U16, 49, "", 1.000, 0.000 + auxin_gauge5 = scalar, U16, 51, "", 1.000, 0.000 + auxin_gauge6 = scalar, U16, 53, "", 1.000, 0.000 + auxin_gauge7 = scalar, U16, 55, "", 1.000, 0.000 + auxin_gauge8 = scalar, U16, 57, "", 1.000, 0.000 + auxin_gauge9 = scalar, U16, 59, "", 1.000, 0.000 + auxin_gauge10 = scalar, U16, 61, "", 1.000, 0.000 + auxin_gauge11 = scalar, U16, 63, "", 1.000, 0.000 + auxin_gauge12 = scalar, U16, 65, "", 1.000, 0.000 + auxin_gauge13 = scalar, U16, 67, "", 1.000, 0.000 + auxin_gauge14 = scalar, U16, 69, "", 1.000, 0.000 + auxin_gauge15 = scalar, U16, 71, "", 1.000, 0.000 + tpsADC = scalar, U08, 73, "ADC", 1.000, 0.000 + errors = scalar, U08, 74, "bits", 1.000, 0.000 + errorNum = bits, U08, 74, [0:1] + currentError = bits, U08, 74, [2:7] + pulseWidth = scalar, U16, 75, "ms", 0.001, 0.000 + pulseWidth2 = scalar, U16, 77, "ms", 0.001, 0.000 + pulseWidth3 = scalar, U16, 79, "ms", 0.001, 0.000 + pulseWidth4 = scalar, U16, 81, "ms", 0.001, 0.000 + status3 = scalar, U08, 83, "bits", 1.000, 0.000 + resetLockOn = bits, U08, 83, [0:0] + nitrousOn = bits, U08, 83, [1:1] + fuel2Active = bits, U08, 83, [2:2] + unused81_3-4 = bits, U08, 83, [3:4] + nSquirts = bits, U08, 83, [5:7] + unused1 = scalar, U08, 84, "ADC",1.000, 0.000 + fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, 1.000, 0.000 + ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000 + dwell = scalar, U16, 89, "ms", 0.001, 0.000 CLIdleTarget = scalar, U08, 91, "RPM", 10.00, 0.000 - MAPdot = scalar, U08, 92, "kPa/s", 10.00, 0.000 + MAPdot = scalar, U08, 92, "kPa/s", 10.00, 0.000 vvtAngle = scalar, S08, 93, "deg", 1.00, 0.000 vvtTarget = scalar, U08, 94, "deg", 1.00, 0.000 vvtDuty = scalar, U08, 95, "%", 1.00, 0.000 - flexBoostCor = scalar, S16, 96, "kPa", 1.000, 0.000 + flexBoostCor = scalar, S16, 96, "kPa", 1.000, 0.000 baroCorrection = scalar, U08, 98, "%", 1.000, 0.000 veCurr = scalar, U08, 99, "%", 1.000, 0.000 ASECurr = scalar, U08, 100, "%", 1.000, 0.000 diff --git a/speeduino/TS_CommandButtonHandler.h b/speeduino/TS_CommandButtonHandler.h index c61df0dd..602746bd 100644 --- a/speeduino/TS_CommandButtonHandler.h +++ b/speeduino/TS_CommandButtonHandler.h @@ -54,5 +54,12 @@ #define TS_CMD_IGN8_OFF 791 #define TS_CMD_IGN8_50PC 792 +#define TS_CMD_VSS_60KMH 39168 //0x99x00 +#define TS_CMD_VSS_RATIO1 39169 +#define TS_CMD_VSS_RATIO2 39170 +#define TS_CMD_VSS_RATIO3 39171 +#define TS_CMD_VSS_RATIO4 39172 +#define TS_CMD_VSS_RATIO5 39173 +#define TS_CMD_VSS_RATIO6 39174 -void TS_CommandButtonsHandler(int); \ No newline at end of file +uint16_t TS_CommandButtonsHandler(int); \ No newline at end of file diff --git a/speeduino/TS_CommandButtonHandler.ino b/speeduino/TS_CommandButtonHandler.ino index cf85bbc0..8376ba75 100644 --- a/speeduino/TS_CommandButtonHandler.ino +++ b/speeduino/TS_CommandButtonHandler.ino @@ -8,9 +8,17 @@ #include "globals.h" #include "utils.h" #include "scheduledIO.h" +#include "sensors.h" -void TS_CommandButtonsHandler(int buttonCommand) +/** + * @brief + * + * @param buttonCommand The command number of the button that was clicked. See TS_CommendButtonHandler.h for a list of button IDs + * @return uint16_t If the button command remains incomplete (IE When it must wait for a certain action to complete) the return value is eqaul to the button ID. Otherwise this function returns 0 + */ +uint16_t TS_CommandButtonsHandler(int buttonCommand) { + uint16_t returnValue = 0; switch (buttonCommand) { case 256: // cmd is stop @@ -280,7 +288,64 @@ void TS_CommandButtonsHandler(int buttonCommand) #endif break; + //VSS Calibration routines + case TS_CMD_VSS_60KMH: + //Calibrate the actual pulses per distance + if( (vssLastPulseTime > 0) && (vssLastMinusOnePulseTime > 0) ) + { + if(vssLastPulseTime > vssLastMinusOnePulseTime) + { + configPage2.vssPulsesPerKm = 60000000UL / (vssLastPulseTime - vssLastMinusOnePulseTime); + } + } + break; + + //Calculate the RPM to speed ratio for each gear + case TS_CMD_VSS_RATIO1: + if(currentStatus.vss > 0) + { + configPage2.vssRatio1 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + + case TS_CMD_VSS_RATIO2: + if(currentStatus.vss > 0) + { + configPage2.vssRatio2 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + + case TS_CMD_VSS_RATIO3: + if(currentStatus.vss > 0) + { + configPage2.vssRatio3 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + + case TS_CMD_VSS_RATIO4: + if(currentStatus.vss > 0) + { + configPage2.vssRatio4 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + + case TS_CMD_VSS_RATIO5: + if(currentStatus.vss > 0) + { + configPage2.vssRatio5 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + + case TS_CMD_VSS_RATIO6: + if(currentStatus.vss > 0) + { + configPage2.vssRatio6 = (currentStatus.vss * 10000) / currentStatus.RPM; + } + break; + default: break; } + + return returnValue; } \ No newline at end of file diff --git a/speeduino/auxiliaries.ino b/speeduino/auxiliaries.ino index e07b1ec6..cb6eae03 100644 --- a/speeduino/auxiliaries.ino +++ b/speeduino/auxiliaries.ino @@ -311,7 +311,7 @@ void nitrousControl() // STAGE1 = 1 // STAGE2 = 2 // BOTH = 3 (ie STAGE1 + STAGE2 = BOTH) - currentStatus.nitrous_status = NITROUS_OFF; + currentStatus.nitrous_status = NITROUS_OFF; //Reset the current state if( (currentStatus.RPM > realStage1MinRPM) && (currentStatus.RPM < realStage1MaxRPM) ) { currentStatus.nitrous_status += NITROUS_STAGE1; diff --git a/speeduino/comms.ino b/speeduino/comms.ino index 1c87f1f9..0e0a3c04 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -86,20 +86,38 @@ void command() } break; - //The following can be used to show the amount of free memory - case 'E': // receive command button commands - cmdPending = true; - if(Serial.available() >= 2) + if(cmdPending == true) { - byte cmdGroup = Serial.read(); - byte cmdValue = Serial.read(); - int cmdCombined = word(cmdGroup, cmdValue); - if (currentStatus.RPM == 0) { TS_CommandButtonsHandler(cmdCombined); } + // - cmdPending = false; } + else + { + cmdPending = true; + + if(Serial.available() >= 2) + { + byte cmdGroup = Serial.read(); + byte cmdValue = Serial.read(); + uint16_t cmdCombined = word(cmdGroup, cmdValue); + + if ( (cmdCombined >= TS_CMD_INJ1_ON) && (cmdCombined <=TS_CMD_IGN8_50PC) ) + { + //Hardware test buttons + if (currentStatus.RPM == 0) { TS_CommandButtonsHandler(cmdCombined); } + cmdPending = false; + } + else if( (cmdCombined >= TS_CMD_VSS_60KMH) && (cmdCombined <= TS_CMD_VSS_RATIO6) ) + { + //VSS Calibration commands + TS_CommandButtonsHandler(cmdCombined); + cmdPending = false; + } + } + } + break; case 'F': // send serial protocol version diff --git a/speeduino/errors.ino b/speeduino/errors.ino index 6e5938b3..524a2c2a 100644 --- a/speeduino/errors.ino +++ b/speeduino/errors.ino @@ -49,12 +49,16 @@ void clearError(byte errorID) byte getNextError() { packedError currentError; + byte currentErrorNum = 0; - //We alternate through the errors once per second - byte currentErrorNum = currentStatus.secl % MAX_ERRORS; //Which error number will be returned. This changes once per second. Note that as long as MAX_ERRORS is a power of 2, this % operation is performed very quickly. + if(errorCount > 0) + { + //We alternate through the errors once per second + currentErrorNum = currentStatus.secl % errorCount; //Which error number will be returned. This changes once per second. - currentError.errorNum = currentErrorNum; - currentError.errorID = errorCodes[currentErrorNum]; + currentError.errorNum = currentErrorNum; + currentError.errorID = errorCodes[currentErrorNum]; + } return *(byte*)¤tError; //Ugly, but this forces the cast of the currentError struct to a byte. } diff --git a/speeduino/globals.h b/speeduino/globals.h index 4551483c..62a00e3c 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -647,8 +647,8 @@ struct config2 { byte dfcoMinCLT; //VSS Stuff - byte vssEnable : 1; - byte vssPullup : 1; + byte vssMode : 2; + byte vssPin : 6; uint16_t vssPulsesPerKm; byte vssSmoothing; @@ -1107,6 +1107,7 @@ extern byte pinStepperEnable; //Turning the DRV8825 driver on/off extern byte pinLaunch; extern byte pinIgnBypass; //The pin used for an ignition bypass (Optional) extern byte pinFlex; //Pin with the flex sensor attached +extern byte pinVSS; extern byte pinBaro; //Pin that an external barometric pressure sensor is attached to (If used) extern byte pinResetControl; // Output pin used control resetting the Arduino #ifdef USE_MC33810 diff --git a/speeduino/globals.ino b/speeduino/globals.ino index f29253a8..1257f8c8 100644 --- a/speeduino/globals.ino +++ b/speeduino/globals.ino @@ -197,6 +197,7 @@ byte pinStepperEnable; //Turning the DRV8825 driver on/off byte pinLaunch; byte pinIgnBypass; //The pin used for an ignition bypass (Optional) byte pinFlex; //Pin with the flex sensor attached +byte pinVSS; byte pinBaro; //Pin that an al barometric pressure sensor is attached to (If used) byte pinResetControl; // Output pin used control resetting the Arduino #ifdef USE_MC33810 diff --git a/speeduino/init.ino b/speeduino/init.ino index af51b0ae..f5912d43 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -271,8 +271,13 @@ void initialiseAll() //Check whether the flex sensor is enabled and if so, attach an interupt for it if(configPage2.flexEnabled > 0) { - attachInterrupt(digitalPinToInterrupt(pinFlex), flexPulse, RISING); - currentStatus.ethanolPct = 0; + attachInterrupt(digitalPinToInterrupt(pinFlex), flexPulse, RISING); + currentStatus.ethanolPct = 0; + } + //Same as above, but for the VSS input + if(configPage2.vssMode > 1) // VSS modes 2 and 3 are interrupt drive (Mode 1 is CAN) + { + attachInterrupt(digitalPinToInterrupt(pinVSS), vssPulse, RISING); } //Once the configs have been loaded, a number of one time calculations can be completed @@ -2452,6 +2457,10 @@ void setPinMapping(byte boardID) { pinMode(pinFlex, INPUT); //Standard GM / Continental flex sensor requires pullup, but this should be onboard. The internal pullup will not work (Requires ~3.3k)! } + if(configPage2.vssMode > 1) + { + pinMode(pinVSS, INPUT); //Standard GM / Continental flex sensor requires pullup, but this should be onboard. The internal pullup will not work (Requires ~3.3k)! + } if(configPage6.launchEnabled > 0) { if (configPage6.lnchPullRes == true) { pinMode(pinLaunch, INPUT_PULLUP); } diff --git a/speeduino/sensors.h b/speeduino/sensors.h index 04425966..72790c05 100644 --- a/speeduino/sensors.h +++ b/speeduino/sensors.h @@ -65,6 +65,7 @@ void initialiseADC(); void readTPS(bool=true); //Allows the option to override the use of the filter void readO2_2(); void flexPulse(); +void vssPulse(); uint16_t readAuxanalog(uint8_t analogPin); uint16_t readAuxdigital(uint8_t digitalPin); void readCLT(bool=true); //Allows the option to override the use of the filter diff --git a/speeduino/sensors.ino b/speeduino/sensors.ino index da32d55c..0ebeacd5 100644 --- a/speeduino/sensors.ino +++ b/speeduino/sensors.ino @@ -491,7 +491,11 @@ uint16_t getSpeed() { uint16_t tempSpeed = 0; uint32_t pulseTime = 0; - if(configPage2.vssEnable == true) + if(configPage2.vssMode == 1) + { + //VSS mode 1 is (Will be) CAN + } + else if(configPage2.vssMode > 1) { if( (vssLastPulseTime > 0) && (vssLastMinusOnePulseTime > 0) ) //Check we've had at least 2 pulses {