From b7c93fe47218a78a7d1eb704ff344007a3d7d517 Mon Sep 17 00:00:00 2001 From: Jan Matik Date: Sun, 20 Dec 2020 12:44:20 +0100 Subject: [PATCH] Added new classes and menu item for BMW i3 --- CarBmwI3.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ CarBmwI3.h | 13 +++++++ LiveData.h | 1 + evDash.ino | 7 +++- menu.h | 1 + 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 CarBmwI3.cpp create mode 100644 CarBmwI3.h diff --git a/CarBmwI3.cpp b/CarBmwI3.cpp new file mode 100644 index 0000000..ff5b8bd --- /dev/null +++ b/CarBmwI3.cpp @@ -0,0 +1,104 @@ +#include "CarBmwI3.h" +#include + +/** + activateliveData->commandQueue +*/ +void CarBmwI3::activateCommandQueue() { + const uint16_t commandQueueLoopFrom = 8; + + const std::vector commandQueue = { + "AT Z", // Reset all + "AT D", // All to defaults + "AT I", // Print the version ID + "AT E0", // Echo off + "AT PP2COFF", // Disable prog parameter 2C + //"AT SH6F1", // Set header to 6F1 + "AT CF600", // Set the ID filter to 600 + "AT CM700", // Set the ID mask to 700 + "AT PBC001", // Protocol B options and baudrate (div 1 = 500k) + "AT SPB", // Set protocol to B and save it (USER1 11bit, 125kbaud) + "AT AT0", // Adaptive timing off + "AT STFF", // Set timeout to ff x 4ms + "AT AL", // Allow long messages ( > 7 Bytes) + "AT H1", // Additional headers on + "AT S0", // Printing of spaces off + "AT L0", // Linefeeds off + "AT CSM0", // Silent monitoring off + "AT CTM5", // Set timer multiplier to 5 + "AT JE", // Use J1939 SAE data format + + // Loop from (BMW i3) + // BMS + "ATSH6F1", + "22DDBC" /*, // SOC + + + // VMCU + "ATSH7E2", + "2101", + // speed, ... + "2102", + // aux, ... + + //"ATSH7Df", + //"2106", + //"220106", + + // Aircondition + // IONIQ OK + "ATSH7B3", + "220100", + // in/out temp + "220102", + // coolant temp1, 2 + + // BCM / TPMS + // IONIQ OK + "ATSH7A0", + "22c00b", + // tire pressure/temp + + // CLUSTER MODULE + // IONIQ OK + "ATSH7C6", + "22B002", + // odo + */ + }; + + // 28kWh version + liveData->params.batteryTotalAvailableKWh = 18.8; + liveData->params.batModuleTempCount = 5; //? + + // Empty and fill command queue + for(auto item : liveData->commandQueue) { + item = ""; + } + + for (int i = 0; i < commandQueue.size(); i++) { + liveData->commandQueue[i] = commandQueue[i]; + } + + liveData->commandQueueLoopFrom = commandQueueLoopFrom; + liveData->commandQueueCount = commandQueue.size(); +} + +/** + parseRowMerged +*/ +void CarBmwI3::parseRowMerged() +{ + + +} + +/** + loadTestData +*/ +void CarBmwI3::loadTestData() +{ + + +} + diff --git a/CarBmwI3.h b/CarBmwI3.h new file mode 100644 index 0000000..2476554 --- /dev/null +++ b/CarBmwI3.h @@ -0,0 +1,13 @@ +#pragma once + +#include "CarInterface.h" + +class CarBmwI3 : public CarInterface { + +protected: + +public: + void activateCommandQueue() override; + void parseRowMerged() override; + void loadTestData() override; +}; \ No newline at end of file diff --git a/LiveData.h b/LiveData.h index e013e0e..4867459 100644 --- a/LiveData.h +++ b/LiveData.h @@ -18,6 +18,7 @@ #define CAR_HYUNDAI_KONA_2020_39 4 #define CAR_RENAULT_ZOE 5 #define CAR_KIA_NIRO_PHEV 6 +#define CAR_BMW_I3_2014 7 #define CAR_DEBUG_OBD2_KIA 999 // diff --git a/evDash.ino b/evDash.ino index fe151db..06a7c86 100644 --- a/evDash.ino +++ b/evDash.ino @@ -59,6 +59,7 @@ #include "CarRenaultZoe.h" #include "CarKiaNiroPhev.h" #include "CarKiaDebugObd2.h" +#include "CarBmwI3.h" #ifdef SIM800L_ENABLED #include @@ -551,8 +552,10 @@ void setup(void) { car = new CarHyundaiIoniq(); } else if (liveData->settings.carType == CAR_KIA_NIRO_PHEV) { car = new CarKiaNiroPhev(); - } else if (liveData->settings.carType == CAR_RENAULT_ZOE) { - car = new CarRenaultZoe(); + } else if(liveData->settings.carType == CAR_RENAULT_ZOE) { + car = new CarRenaultZoe(); + } else if(liveData->settings.carType == CAR_BMW_I3_2014) { + car = new CarBmwI3(); } else { // if (liveData->settings.carType == CAR_DEBUG_OBD2_KIA) car = new CarKiaDebugObd2(); diff --git a/menu.h b/menu.h index 26eeb59..f14f52d 100644 --- a/menu.h +++ b/menu.h @@ -22,6 +22,7 @@ MENU_ITEM menuItemsSource[100] = { {105, 1, -1, "Hyundai Kona 2020 39kWh"}, {106, 1, -1, "Renault Zoe 22kWh (DEV)"}, {107, 1, -1, "Kia Niro PHEV 8.9kWh"}, + {108, 1, -1, "BMW i3 2014 22kWh (DEV)"}, {120, 1, -1, "Debug OBD2 Kia"}, {300, 3, 0, "<- parent menu"},