From 811c4614f1212a55c0660d2506f2a909a48c31bc Mon Sep 17 00:00:00 2001 From: BM Devs Date: Fri, 7 Apr 2017 02:58:35 -0400 Subject: [PATCH] Add files via upload --- BMDatalogger/BMDatalogger.ino | 83 +++++ BMDatalogger/ButtonsManager.ino | 77 ++++ BMDatalogger/DatalogProtocol.ino | 594 +++++++++++++++++++++++++++++++ BMDatalogger/ScreenDisplay.ino | 129 +++++++ BMDatalogger/ScreenJ12.ino | 16 + BMDatalogger/ScreenOptions.ino | 131 +++++++ BMDatalogger/ScreenStart.ino | 19 + 7 files changed, 1049 insertions(+) create mode 100644 BMDatalogger/BMDatalogger.ino create mode 100644 BMDatalogger/ButtonsManager.ino create mode 100644 BMDatalogger/DatalogProtocol.ino create mode 100644 BMDatalogger/ScreenDisplay.ino create mode 100644 BMDatalogger/ScreenJ12.ino create mode 100644 BMDatalogger/ScreenOptions.ino create mode 100644 BMDatalogger/ScreenStart.ino diff --git a/BMDatalogger/BMDatalogger.ino b/BMDatalogger/BMDatalogger.ino new file mode 100644 index 0000000..f3b4cbf --- /dev/null +++ b/BMDatalogger/BMDatalogger.ino @@ -0,0 +1,83 @@ +//##################################################### +//##################################################### +//##################################################### +/* + * THIS IS THE BM DEVS DATALOGGER + * + * THIS WORKS BY DATALOGGING ECTUNE ISR V3 PROTOCOL ON + * THE ARDUINO SERIAL PORT. THIS WORKS WITH 2X BUTTONS + * NAVIGATION ONLY. IT ONLY WORKS FOR THE 20X04 LCD + * + * #################################################### + * ALL CREDITS GOES TO : + * -Bouletmarc (BM Devs) + * -Majidi + * -Thatguy +*/ +//##################################################### +//##################################################### +//##################################################### + +//Load Modules +#include "Wire.h" +#include +#include +#include +#include + +//Set Inputs +LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); +const int TopButton = 9; +const int BottomButton = 8; + +//Screen Settings +const int ScreenMaxIndex = 35; //Maximum datalogs values +int ScreenCurrentIndex = 0; +int ScreenIndex[8]; //Display Index for 8x values +bool ScreenOption = false; + +//Options Vars +const String VersionStr = "V2.0.0"; +int Timeout = 200; +int Injectors_Size = 240; +int mBarSeaLevel = 1013; +byte TrannyType = 5; +byte O2Input = 0; +byte MapValue = 0; +byte UseCelcius = 1; +byte UseKMH = 1; +bool EcuConnected = false; + +//##################################################### + +void setup() { + //Initialize Screen Indexes + for (int i=0; i<8; i++) ScreenIndex[i] = i; + + //Initialize Buttons Pinout + pinMode(TopButton,INPUT_PULLUP); + pinMode(BottomButton,INPUT_PULLUP); + + //Start LCD Display + lcd.begin(20, 4); + StartScreen(); + lcd.clear(); + + //Initialize Connection/Optinos + Connect(); + LoadOptions(); +} + +//##################################################### + +void loop() { + delay(Timeout); + + //Screens Loop + if (!ScreenOption) { + if (!EcuConnected) SetJ12Screen(); + if (EcuConnected) Display(); + } + else DisplayOptions(); +} + diff --git a/BMDatalogger/ButtonsManager.ino b/BMDatalogger/ButtonsManager.ino new file mode 100644 index 0000000..ed0be59 --- /dev/null +++ b/BMDatalogger/ButtonsManager.ino @@ -0,0 +1,77 @@ +//Buttons Vars +#define ON 1 +#define OFF 0 +volatile int buttonTop = 0; +volatile int buttonBottom = 0; +volatile int buttonDual = 0; +unsigned long last_interrupt_time=0; +int debouncing = 50; + +//Apply Buttons +void GetButtonStates() { + if (buttonTop == ON) ApplyTop(); + if (buttonBottom == ON) ApplyBottom(); + if (buttonDual == ON) ApplyDual(); +} + +void ApplyTop() { + //Increase Index + ScreenIndex[ScreenCurrentIndex]++; + + //Check If the Index is not already been in use + for (int i=0; i<8; i++) + if (i != ScreenCurrentIndex) + if(ScreenIndex[ScreenCurrentIndex] == ScreenIndex[i]) + ScreenIndex[ScreenCurrentIndex]++; + + if(ScreenIndex[ScreenCurrentIndex] > ScreenMaxIndex) ScreenIndex[ScreenCurrentIndex] = 1; + buttonTop=OFF; +} + +void ApplyBottom() { + //Switch to the next lines + ScreenCurrentIndex++; + if(ScreenIndex[ScreenCurrentIndex] > (8 - 1)) ScreenCurrentIndex = 0; + buttonBottom=OFF; +} + +void ApplyDual() { + if (ScreenOption) ScreenOption = false; + else ScreenOption = true; +} + +//########################################################################################################### +//########################################################################################################### +//########################################################################################################### +//Get States +void GetButtonTopState() { + if (digitalRead(TopButton) == LOW) { + if (!EcuConnected) + EcuConnected = true; + else { + unsigned long interrupt_time = millis(); + if (buttonTop == OFF && (interrupt_time - last_interrupt_time > debouncing)) { + delay(30); + if (digitalRead(BottomButton) == LOW) buttonDual = ON; + else buttonTop=ON; + last_interrupt_time = interrupt_time; + } + } + } +} + +void GetButtonBottomState() { + if (digitalRead(BottomButton) == LOW) { + if (!EcuConnected) + EcuConnected = true; + else { + unsigned long interrupt_time = millis(); + if (buttonBottom == OFF && (interrupt_time - last_interrupt_time > debouncing)) { + delay(30); + if (digitalRead(TopButton) == LOW) buttonDual = ON; + else buttonBottom=ON; + last_interrupt_time = interrupt_time; + } + } + } +} diff --git a/BMDatalogger/DatalogProtocol.ino b/BMDatalogger/DatalogProtocol.ino new file mode 100644 index 0000000..313fa78 --- /dev/null +++ b/BMDatalogger/DatalogProtocol.ino @@ -0,0 +1,594 @@ +bool J12_Cut = true; +const int Array_Size = 52; +byte Datalog_Bytes[Array_Size]; +byte GB[10] = {0x46, 0x00, 0x67, 0x00, 0x8E, 0x00, 0xB8, 0x00, 0x52, 0xDE}; + +void Connect() { + Serial.begin(38400); +} + +/*void Disconnect() { + Serial.end(); +}*/ + +bool GetJ12Cut() { + J12_Cut = true; + Serial.write((byte) 171); + if ((int) Serial.read() != 205) J12_Cut = false; + return J12_Cut; +} + +void GetData(){ + while(Serial.available()) + for (int i = 0; i < Array_Size; i++) + Datalog_Bytes[i] = Serial.read(); + + Serial.flush(); + Serial.write(" "); +} + +void SetTranny(int ThisTranny) { + TrannyType = ThisTranny; + if (ThisTranny == 0) { + GB[0] = 0x46; + GB[1] = 0x00; + GB[2] = 0x67; + GB[3] = 0x00; + GB[4] = 0x8E; + GB[5] = 0x00; + GB[6] = 0xB8; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB[10] = {0x46, 0x00, 0x67, 0x00, 0x8E, 0x00, 0xB8, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 1) { + GB[0] = 0x42; + GB[1] = 0x00; + GB[2] = 0x5D; + GB[3] = 0x00; + GB[4] = 0x87; + GB[5] = 0x00; + GB[6] = 0xB6; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x42, 0x00, 0x5D, 0x00, 0x87, 0x00, 0xB6, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 2) { + GB[0] = 0x46; + GB[1] = 0x00; + GB[2] = 0x64; + GB[3] = 0x00; + GB[4] = 0x91; + GB[5] = 0x00; + GB[6] = 0xB8; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x46, 0x00, 0x64, 0x00, 0x91, 0x00, 0xB8, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 3) { + GB[0] = 0x48; + GB[1] = 0x00; + GB[2] = 0x71; + GB[3] = 0x00; + GB[4] = 0xAA; + GB[5] = 0x00; + GB[6] = 0xE3; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x48, 0x00, 0x71, 0x00, 0xAA, 0x00, 0xE3, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 4) { + GB[0] = 0x46; + GB[1] = 0x00; + GB[2] = 0x6E; + GB[3] = 0x00; + GB[4] = 0x9A; + GB[5] = 0x00; + GB[6] = 0xC4; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x46, 0x00, 0x6E, 0x00, 0x9A, 0x00, 0xC4, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 5) { + GB[0] = 0x48; + GB[1] = 0x00; + GB[2] = 0x71; + GB[3] = 0x00; + GB[4] = 0xB2; + GB[5] = 0x00; + GB[6] = 0xD6; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x48, 0x00, 0x71, 0x00, 0xB2, 0x00, 0xD6, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 6) { + GB[0] = 0x47; + GB[1] = 0x00; + GB[2] = 0x6E; + GB[3] = 0x00; + GB[4] = 0x9E; + GB[5] = 0x00; + GB[6] = 0xC3; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x47, 0x00, 0x6E, 0x00, 0x9E, 0x00, 0xC3, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 7) { + GB[0] = 0x47; + GB[1] = 0x00; + GB[2] = 0x6E; + GB[3] = 0x00; + GB[4] = 0x9E; + GB[5] = 0x00; + GB[6] = 0xC9; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x47, 0x00, 0x6E, 0x00, 0x9E, 0x00, 0xC9, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 8) { + GB[0] = 0x4A; + GB[1] = 0x00; + GB[2] = 0x7B; + GB[3] = 0x00; + GB[4] = 0xAF; + GB[5] = 0x00; + GB[6] = 0xE0; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x4A, 0x00, 0x7B, 0x00, 0xAF, 0x00, 0xE0, 0x00, 0x52, 0xDE}; + } else if (ThisTranny == 9) { + GB[0] = 0x4B; + GB[1] = 0x00; + GB[2] = 0x7D; + GB[3] = 0x00; + GB[4] = 0xBC; + GB[5] = 0x00; + GB[6] = 0xED; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x4B, 0x00, 0x7D, 0x00, 0xBC, 0x00, 0xED, 0x00, 0x52, 0xDE}; + } else if (ThisTranny > 9) { + GB[0] = 0x46; + GB[1] = 0x00; + GB[2] = 0x67; + GB[3] = 0x00; + GB[4] = 0x8E; + GB[5] = 0x00; + GB[6] = 0xB8; + GB[7] = 0x00; + GB[8] = 0x52; + GB[9] = 0xDE; + //GB = {0x46, 0x00, 0x67, 0x00, 0x8E, 0x00, 0xB8, 0x00, 0x52, 0xDE}; + TrannyType = 0; + } +} + +long Long2Bytes(byte ThisByte1, byte ThisByte2) { + return (long) ((long) ThisByte2 * 256 + (long) ThisByte1); +} + +float GetTemperature(byte ThisByte) { + float ThisTemp = (float) ThisByte / 51; + ThisTemp = (0.1423*pow(ThisTemp,6)) - (2.4938*pow(ThisTemp,5)) + (17.837*pow(ThisTemp,4)) - (68.698*pow(ThisTemp,3)) + (154.69*pow(ThisTemp,2)) - (232.75*ThisTemp) + 284.24; + ThisTemp = ((ThisTemp - 32)*5)/9; + + if (UseCelcius == 0) + ThisTemp = ThisTemp * 1.8 + 32.0; + + return ThisTemp; + /*if (UseCelcius) + return round(double_Temperature[(int) ThisByte]); + return round(GetTemperatureF(double_Temperature[(int) ThisByte]));*/ +} + +double GetVolt(byte ThisByte) { + return round(((double) ThisByte * 0.0196078438311815) * 100) / 100; +} + +float GetDuration(int ThisInt) { + return (float) ThisInt * 3.20000004768372 / 1000.0; +} + +byte GetActivated(byte ThisByte, int ThisPos, bool Reversed) { + int bitArray[8]; + for (int i=0; i < 8; ++i ) { + bitArray[i] = ThisByte & 1; + ThisByte = ThisByte >> 1; + } + + if (Reversed) + return bitArray[ThisPos] ? (byte) 0 : (byte) 1; + return bitArray[ThisPos] ? (byte) 1 : (byte) 0; +} + +float GetInstantConsumption(){ + float hundredkm = ((60 / GetVss()) * 100) / 60; //minutes needed to travel 100km + float fuelc = (hundredkm * ((Injectors_Size / 100) * GetDuty())) / 1000; + return constrain(fuelc, 0.0001, 50.0); +} + +float GetDuty(){ + return ((float) GetRpm() * (float) GetInj()) / 1200; +} + +float GetValueHG(int ThisInt) { + return (float) round(((double) ThisInt * 0.02952999) * 10) / 10; +} + +unsigned int GetEct(){ + return GetTemperature(Datalog_Bytes[0]); +} + +unsigned int GetIat(){ + return GetTemperature(Datalog_Bytes[1]); +} + +float GetO2(){ + if (O2Input == 0) return round((float) GetVolt(Datalog_Bytes[2]) * 100) / 100;//O2Byte = Datalog_Bytes[2]; + if (O2Input == 1) return round((float) GetVolt(Datalog_Bytes[24]) * 100) / 100;//O2Byte = Datalog_Bytes[24]; + if (O2Input == 2) return round((float) GetVolt(Datalog_Bytes[44]) * 100) / 100;//O2Byte = Datalog_Bytes[44]; //byte_25 + if (O2Input == 3) return round((float) GetVolt(Datalog_Bytes[45]) * 100) / 100;//O2Byte = Datalog_Bytes[45]; + //return round((float) GetVolt(O2Byte) * 100) / 100; + //return ((2 * (float) O2Byte[2]) + 10) / 10f; +} + +unsigned int GetBaro(){ + return (int) round((double) ((int) Datalog_Bytes[3] / 2 + 24) * 7.221 - 59.0); +} + +float GetMap(){ + int ThisInt = (int) Datalog_Bytes[4]; + //if (MapValue == 0) return ((float) ThisInt * 2041) / 255; //(1764/255) * (float) ThisInt; + if (MapValue == 0) return 6.9176 * (float) ThisInt; + else if (MapValue == 1) return (float) (ThisInt / 1000); + else if (MapValue == 2) return (float) round(-((double) GetValueHG(mBarSeaLevel) + (double) GetValueHG(ThisInt)) * 10) / 10; + else if (MapValue == 3) return GetValueHG(ThisInt); + else if (MapValue == 4) return (float) round(((double) (ThisInt - mBarSeaLevel) * 0.0145037695765495) * 100) / 100; //GetValuePSI(ThisInt); + else if (MapValue == 5) return (float) round((double) ThisInt * 0.1); //GetValueKPa(ThisInt); + else return 0; + + //float mapRaw = Datalog_Bytes[4]; + //return (1764/255)*mapRaw; +} + +unsigned int GetTps(){ + return (int) round(((double) Datalog_Bytes[5] - 25.0) / 2.04); + //return constrain((0.4716 * Datalog_Bytes[5]) - 11.3184, 0, 100); +} + +unsigned int GetRpm(){ + //return (int) (1875000/Long2Bytes(Datalog_Bytes[6], Datalog_Bytes[7])); + return (int) (1851562/Long2Bytes(Datalog_Bytes[6], Datalog_Bytes[7])); +} + +bool GetIgnCut(){ + return (bool) GetActivated(Datalog_Bytes[8], 2, false); +} + +bool GetVTSM(){ + return (bool) GetActivated(Datalog_Bytes[8], 3, false); +} + +bool GetFuelCut1(){ + return (bool) GetActivated(Datalog_Bytes[8], 4, false); +} + +bool GetFuelCut2(){ + return (bool) GetActivated(Datalog_Bytes[8], 5, false); +} + +unsigned int GetVss(){ + if (UseKMH == 1) + return (int) Datalog_Bytes[16]; + return (int) round((float) Datalog_Bytes[16] / 1.6f); +} + +double GetInjFV() { + return round(((double) Long2Bytes(Datalog_Bytes[17], Datalog_Bytes[18]) / 4.0) * 100) / 100; +} + +float GetInjectorDuty() { + return (float) ((double) GetRpm() * (double) GetDuration(Long2Bytes(Datalog_Bytes[17], Datalog_Bytes[18])) / 1200.0); +} + +float GetInj(){ + return (float) (Long2Bytes(Datalog_Bytes[17], Datalog_Bytes[18]) / 352); +} + +unsigned int GetIgn(){ + return (0.25 * Datalog_Bytes[19]) - 6; +} + +bool GetVTP(){ + return (bool) GetActivated(Datalog_Bytes[21], 3, false); +} + +bool GetFanCtrl(){ + return (bool) GetActivated(Datalog_Bytes[22], 4, false); +} + +bool GetAtlCtrl(){ + return (bool) GetActivated(Datalog_Bytes[22], 5, false); +} + +bool GetMIL(){ + return (bool) GetActivated(Datalog_Bytes[23], 5, false); +} + +float GetBattery(){ + return (26.0 * Datalog_Bytes[25]) / 270.0; +} + +bool GetInputFTL(){ + return (bool) GetActivated(Datalog_Bytes[38], 0, false); +} + +bool GetInputFTS(){ + return (bool) GetActivated(Datalog_Bytes[38], 1, false); +} + +bool GetInputEBC(){ + return (bool) GetActivated(Datalog_Bytes[38], 2, false); +} + +bool GetInputBST(){ + return (bool) GetActivated(Datalog_Bytes[38], 7, false); +} + +bool GetOutputFTL(){ + return (bool) GetActivated(Datalog_Bytes[39], 0, false); +} + +bool GetOutputAntilag(){ + return (bool) GetActivated(Datalog_Bytes[39], 1, false); +} + +bool GetOutputFTS(){ + return (bool) GetActivated(Datalog_Bytes[39], 2, false); +} + +bool GetOutputBoostCut(){ + return (bool) GetActivated(Datalog_Bytes[39], 3, false); +} + +bool GetOutputEBC(){ + return (bool) GetActivated(Datalog_Bytes[39], 4, false); +} + +bool GetOutput2ndMap(){ + return (bool) GetActivated(Datalog_Bytes[39], 5, false); +} + +bool GetOutputFanCtrl(){ + return (bool) GetActivated(Datalog_Bytes[39], 6, false); +} + +bool GetOutputBST(){ + return (bool) GetActivated(Datalog_Bytes[39], 7, false); +} + +bool GetLeanProtect(){ + return (bool) GetActivated(Datalog_Bytes[43], 7, false); +} + +double GetIACVDuty(){ + return ((double) ((float) Long2Bytes(Datalog_Bytes[49], Datalog_Bytes[50]) / 32768) * 100.0 - 100.0); +} + +double GetMapVolt(){ + return GetVolt(Datalog_Bytes[4]); +} + +double GetTPSVolt(){ + return GetVolt(Datalog_Bytes[5]); +} + +double GetInjDuration(){ + return round(((double) GetDuration((int) Long2Bytes(Datalog_Bytes[17], Datalog_Bytes[18]))) * 100) / 100; +} + +unsigned int GetGear(){ + if (GetVss() == 0) + return 0; + + long ThisRatio = (long) (GetVss() * 256) * (long) GetRpm() / (long) 256; + byte Gear = 0; + + for (int i = 0; i < 4; i++) { + int ThisIndex = i * 2; + if (ThisRatio >= GB[ThisIndex]) Gear = i + 1; + else break; + } + + return Gear; +} + + + + + + +//################################################################################################################################ +//################################################################################################################################ +//################################################################################################################################ +//REMOVED UNUSED DISPLAY + +/*int GetIgnTable(){ + return (0.25 * Datalog_Bytes[20]) - 6; +} + +bool GetParkN(){ + return (bool) GetActivated(Datalog_Bytes[21], 0, false); +} + +bool GetBKSW(){ + return (bool) GetActivated(Datalog_Bytes[21], 1, false); +} + +bool GetACC(){ + return (bool) GetActivated(Datalog_Bytes[21], 2, false); +} + +bool GetStart(){ + return (bool) GetActivated(Datalog_Bytes[21], 4, false); +} + +bool GetSCC(){ + return (bool) GetActivated(Datalog_Bytes[21], 5, false); +} + +bool GetVTSFeedBack(){ + return (bool) GetActivated(Datalog_Bytes[21], 6, false); +} + +bool GetPSP(){ + return (bool) GetActivated(Datalog_Bytes[21], 7, false); +} + +bool GetFuelPump(){ + return (bool) GetActivated(Datalog_Bytes[22], 0, false); +} + +bool GetIAB(){ + return (bool) GetActivated(Datalog_Bytes[22], 2, false); +} + +bool GetPurge(){ + return (bool) GetActivated(Datalog_Bytes[22], 6, false); +} + +bool GetAC(){ + return (bool) GetActivated(Datalog_Bytes[22], 7, false); +} + +bool GetO2Heater(){ + return (bool) GetActivated(Datalog_Bytes[23], 6, false); +} + +bool GetVTS(){ + return (bool) GetActivated(Datalog_Bytes[23], 7, false); +} + +double GetELDVolt(){ + return GetVolt(Datalog_Bytes[24]); +} + +bool GetATShift1(){ + return (bool) GetActivated(Datalog_Bytes[8], 6, false); +} + +bool GetATShift2(){ + return (bool) GetActivated(Datalog_Bytes[8], 7, false); +} + +double GetECTFC(){ + return GetFC(Datalog_Bytes[26], 128); +} + +long GetO2Short(){ + return (long) GetFC(Long2Bytes(Datalog_Bytes[27], Datalog_Bytes[28]), 32768); +} + +long GetO2Long(){ + return (long) GetFC(Long2Bytes(Datalog_Bytes[29], Datalog_Bytes[30]), 32768); +} + +long GetIATFC(){ + return (long) GetFC(Long2Bytes(Datalog_Bytes[31], Datalog_Bytes[32]), 32768); +} + +double GetVEFC(){ + return GetFC(Datalog_Bytes[33], 128); +} + +float GetIATIC(){ + return GetIC(Datalog_Bytes[34]); +} + +float GetECTIC(){ + return GetIC(Datalog_Bytes[35]); +} + +float GetGEARIC(){ + return GetIC(Datalog_Bytes[36]); +} + +bool GetInputEBCHi(){ + return (bool) GetActivated(Datalog_Bytes[38], 3, false); +} + +bool GetInputGPO1(){ + return (bool) GetActivated(Datalog_Bytes[38], 4, false); +} + +bool GetInputGPO2(){ + return (bool) GetActivated(Datalog_Bytes[38], 5, false); +} + +bool GetInputGPO3(){ + return (bool) GetActivated(Datalog_Bytes[38], 6, false); +} + +double GetEBCBaseDuty(){ + return GetEBC(Datalog_Bytes[40]); +} + +double GetEBCDuty(){ + return GetEBC(Datalog_Bytes[41]); +} + +bool GetOutputGPO1(){ + return (bool) GetActivated(Datalog_Bytes[43], 0, false); +} + +bool GetOutputGPO2(){ + return (bool) GetActivated(Datalog_Bytes[43], 1, false); +} + +bool GetOutputGPO3(){ + return (bool) GetActivated(Datalog_Bytes[43], 2, false); +} + +bool GetOutputBSTStage2(){ + return (bool) GetActivated(Datalog_Bytes[43], 3, false); +} + +bool GetOutputBSTStage3(){ + return (bool) GetActivated(Datalog_Bytes[43], 4, false); +} + +bool GetOutputBSTStage4(){ + return (bool) GetActivated(Datalog_Bytes[43], 5, false); +} + +bool GetPostFuel(){ + return (bool) GetActivated(Datalog_Bytes[8], 0, false); +} + +bool GetSCCChecker(){ + return (bool) GetActivated(Datalog_Bytes[8], 1, false); +} + +float GetIC(byte ThisByte) { + if ((int) ThisByte == 128) + return 0.0f; + if ((int) ThisByte < 128) + return (float) (128 - (int) ThisByte) * -0.25f; + return (float) ((int) ThisByte - 128) * 0.25f; +} + +double GetFC(long ThisByte, long ThisLong) { + double num = (double) ThisByte / (double) ThisLong; + //if (CorrectionUnits == "multi") + return round((num) * 100) / 100; + //return round(num * 100.0 - 100.0); +} + +double GetEBC(byte ThisByte) { + double num = (double) ThisByte / 2.0; + if (num > 100.0) + num = 100.0; + return round((num * 10)) / 10; +}*/ diff --git a/BMDatalogger/ScreenDisplay.ino b/BMDatalogger/ScreenDisplay.ino new file mode 100644 index 0000000..7136503 --- /dev/null +++ b/BMDatalogger/ScreenDisplay.ino @@ -0,0 +1,129 @@ +void Display() { + GetData(); + GetButtonTopState(); + GetButtonBottomState(); + GetButtonStates(); + execScreen(); +} + +void execScreen(){ + //Running 8x Loop for 20x04 Display + for (int i=0; i<8; i++) { + //Get Text Index + int ThisScreenIndex = ScreenIndex[i]; + + //Set Text + String Text = ""; + if (ThisScreenIndex == 0) Text += "RPM:" + String(GetRpm()); + if (ThisScreenIndex == 1) Text += "ECT:" + String(GetEct()) + "C"; + if (ThisScreenIndex == 2) Text += "IAT:" + String(GetIat()) + "C"; + if (ThisScreenIndex == 3) Text += "TPS:" + String(GetTps()) + "%"; + if (ThisScreenIndex == 4) Text += "O2:" + String(GetO2()); + if (ThisScreenIndex == 5) Text += "IGN:" + String(GetIgn()); + if (ThisScreenIndex == 6) Text += "INJ:" + String(GetInj()) + "ms"; + if (ThisScreenIndex == 7) Text += "FUEL:" + String(GetInstantConsumption()) + "L"; + if (ThisScreenIndex == 8) Text += "DTY:" + String(GetInjectorDuty()); + if (ThisScreenIndex == 9) Text += "MAP:" + String(GetMap()); + if (ThisScreenIndex == 10) Text += "VSS:" + String(GetVss()) + "kmh"; + if (ThisScreenIndex == 11) Text += "Gear:" + String(GetGear()); + if (ThisScreenIndex == 12) Text += "BATT:" + String(GetBattery()); + if (ThisScreenIndex == 13) Text += "VTSM:" + String(GetVTSM()); + if (ThisScreenIndex == 14) Text += "ICUT:" + String(GetIgnCut()); + if (ThisScreenIndex == 15) Text += "FCUT:" + String(GetFuelCut1()); + if (ThisScreenIndex == 16) Text += "FCUT2:" + String(GetFuelCut2()); + if (ThisScreenIndex == 17) Text += "INJFV:" + String(GetInjFV()); + if (ThisScreenIndex == 18) Text += "INJD:" + String(GetInjDuration()); + if (ThisScreenIndex == 19) Text += "VTP:" + String(GetVTP()); + if (ThisScreenIndex == 20) Text += "FCTRL:" + String(GetFanCtrl()); + if (ThisScreenIndex == 21) Text += "ACTRL:" + String(GetAtlCtrl()); + if (ThisScreenIndex == 22) Text += "MIL:" + String(GetMIL()); + if (ThisScreenIndex == 23) Text += "FTLI:" + String(GetInputFTL()); + if (ThisScreenIndex == 24) Text += "FTSI:" + String(GetInputFTS()); + if (ThisScreenIndex == 25) Text += "EBCI:" + String(GetInputEBC()); + if (ThisScreenIndex == 26) Text += "BSTI:" + String(GetInputBST()); + if (ThisScreenIndex == 27) Text += "FTLO:" + String(GetOutputFTL()); + if (ThisScreenIndex == 28) Text += "ATLG:" + String(GetOutputAntilag()); + if (ThisScreenIndex == 29) Text += "FTSO:" + String(GetOutputFTS()); + if (ThisScreenIndex == 30) Text += "BSTCT:" + String(GetOutputBoostCut()); + if (ThisScreenIndex == 31) Text += "EBCO:" + String(GetOutputEBC()); + if (ThisScreenIndex == 32) Text += "2MAP:" + String(GetOutput2ndMap()); + if (ThisScreenIndex == 33) Text += "FCTRLO:" + String(GetOutputFanCtrl()); + if (ThisScreenIndex == 34) Text += "BSTO:" + String(GetOutputBST()); + if (ThisScreenIndex == 35) Text += "IACV:" + String(GetIACVDuty()); + + //POSSIBLE USELESS DATALOGS + //if (ThisScreenIndex == 00) Text += " BARO:" + String(GetBaro()); + //if (ThisScreenIndex == 00) Text += " PSTF:" + String(GetPostFuel()); + //if (ThisScreenIndex == 00) Text += " SCC.C:" + String(GetSCCChecker()); + //if (ThisScreenIndex == 00) Text += " ATSF1:" + String(GetATShift1()); + //if (ThisScreenIndex == 00) Text += " ATSF2:" + String(GetATShift2()); + //if (ThisScreenIndex == 00) Text += " IGNT:" + String(GetIgnTable()); + //if (ThisScreenIndex == 00) Text += " PARK:" + String(GetParkN()); + //if (ThisScreenIndex == 00) Text += " BKSW:" + String(GetBKSW()); + //if (ThisScreenIndex == 00) Text += " ACC:" + String(GetACC()); + //if (ThisScreenIndex == 00) Text += " STRT:" + String(GetStart()); + //if (ThisScreenIndex == 00) Text += " SCC:" + String(GetSCC()); + //if (ThisScreenIndex == 00) Text += " VTSFB:" + String(GetVTSFeedBack()); + //if (ThisScreenIndex == 00) Text += " PSP:" + String(GetPSP()); + //if (ThisScreenIndex == 00) Text += " FPMP:" + String(GetFuelPump()); + //if (ThisScreenIndex == 00) Text += " IAB:" + String(GetIAB()); + //if (ThisScreenIndex == 00) Text += " PURGE:" + String(GetPurge()); + //if (ThisScreenIndex == 00) Text += " AC:" + String(GetAC()); + //if (ThisScreenIndex == 00) Text += " O2H:" + String(GetO2Heater()); + //if (ThisScreenIndex == 00) Text += " VTS:" + String(GetVTS()); + //if (ThisScreenIndex == 00) Text += " ELDV:" + String(GetELDVolt()) + "v"; + //if (ThisScreenIndex == 00) Text += " ECTFC:" + String(GetECTFC()); + //if (ThisScreenIndex == 00) Text += " O2S:" + String(GetO2Short()); + //if (ThisScreenIndex == 00) Text += " O2L:" + String(GetO2Long()); + //if (ThisScreenIndex == 00) Text += " IATFC:" + String(GetIATFC()); + //if (ThisScreenIndex == 00) Text += " VEFC:" + String(GetVEFC()); + //if (ThisScreenIndex == 00) Text += " IATIC:" + String(GetIATIC()); + //if (ThisScreenIndex == 00) Text += " ECTIC:" + String(GetECTIC()); + //if (ThisScreenIndex == 00) Text += " GEARIC:" + String(GetGEARIC()); + //if (ThisScreenIndex == 00) Text += " EBCHi:" + String(GetInputEBCHi()); + //if (ThisScreenIndex == 00) Text += " GPO1I:" + String(GetInputGPO1()); + //if (ThisScreenIndex == 00) Text += " GPO2I:" + String(GetInputGPO2()); + //if (ThisScreenIndex == 00) Text += " GPO3I:" + String(GetInputGPO3()); + //if (ThisScreenIndex == 00) Text += " EBCBDTY:" + String(GetEBCBaseDuty()); + //if (ThisScreenIndex == 00) Text += " EBCDTY:" + String(GetEBCDuty()); + //if (ThisScreenIndex == 00) Text += " GPO1O:" + String(GetOutputGPO1()); + //if (ThisScreenIndex == 00) Text += " GPO2O:" + String(GetOutputGPO2()); + //if (ThisScreenIndex == 00) Text += " GPO3O:" + String(GetOutputGPO3()); + //if (ThisScreenIndex == 00) Text += " BSTS2:" + String(GetOutputBSTStage2()); + //if (ThisScreenIndex == 00) Text += " BSTS3:" + String(GetOutputBSTStage3()); + //if (ThisScreenIndex == 00) Text += " BSTS4:" + String(GetOutputBSTStage4()); + //if (ThisScreenIndex == 00) Text += " LEAN:" + String(GetLeanProtect()); + + //Reset Invalid Char Over Text Lenght + int ResetLenght = 10 - Text.length(); + for (int i2=0; i2