diff --git a/Board320_240.cpp b/Board320_240.cpp index bc6c895..940c2b2 100644 --- a/Board320_240.cpp +++ b/Board320_240.cpp @@ -55,13 +55,13 @@ void Board320_240::afterSetup() { if (liveData->settings.wifiEnabled == 1) { /*Serial.print("memReport(): MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM bytes free. "); - Serial.println(heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM)); + Serial.println(heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM)); - Serial.println("WiFi init..."); + Serial.println("WiFi init..."); WiFi.enableSTA(true); WiFi.mode(WIFI_STA); WiFi.begin(liveData->settings.wifiSsid, liveData->settings.wifiPassword); - Serial.println("WiFi init completed...");*/ + Serial.println("WiFi init completed...");*/ } // Init GPS @@ -814,41 +814,6 @@ void Board320_240::drawSceneSoc10Table() { spr.drawString(tmpStr1, 310, zeroY + (14 * 15), 2); } -/** - DEBUG screen -*/ -void Board320_240::drawSceneDebug() { - - int32_t posx, posy; - String chHex, chHex2; - uint8_t chByte; - - spr.setTextSize(1); // Size for small 5x7 font - spr.setTextColor(TFT_SILVER, TFT_TEMP); - spr.setTextDatum(TL_DATUM); - spr.drawString(debugAtshRequest, 0, 0, 2); - spr.drawString(debugCommandRequest, 128, 0, 2); - spr.drawString(liveData->commandRequest, 256, 0, 2); - spr.setTextDatum(TR_DATUM); - - for (int i = 0; i < debugLastString.length() / 2; i++) { - chHex = debugLastString.substring(i * 2, (i * 2) + 2); - chHex2 = debugPreviousString.substring(i * 2, (i * 2) + 2); - spr.setTextColor(((chHex.equals(chHex2)) ? TFT_SILVER : TFT_GREEN), TFT_TEMP); - chByte = liveData->hexToDec(chHex.c_str(), 1, false); - posx = (((i) % 10) * 32) + 24; - posy = ((floor((i) / 10)) * 32) + 24; - sprintf(tmpStr1, "%03d", chByte); - spr.drawString(tmpStr1, posx + 4, posy, 2); - - spr.setTextColor(TFT_YELLOW, TFT_TEMP); - sprintf(tmpStr1, "%c", (char)chByte); - spr.drawString(tmpStr1, posx + 4, posy + 13, 2); - } - - debugPreviousString = debugLastString; -} - /** Modify caption */ @@ -1146,7 +1111,7 @@ void Board320_240::redrawScreen() { drawSceneMain(); } } else { - displayScreenAutoMode = SCREEN_DASH; + displayScreenAutoMode = SCREEN_DASH; } // 2. Main screen if (displayScreen == SCREEN_DASH) { @@ -1168,10 +1133,6 @@ void Board320_240::redrawScreen() { if (displayScreen == SCREEN_SOC10) { drawSceneSoc10Table(); } - // 7. DEBUG SCREEN - if (displayScreen == SCREEN_DEBUG) { - drawSceneDebug(); - } if (!displayScreenSpeedHud) { @@ -1196,7 +1157,7 @@ void Board320_240::redrawScreen() { spr.setTextDatum(TL_DATUM); sprintf(tmpStr1, "%d", liveData->params.gpsSat); spr.drawString(tmpStr1, 194, 2, 2); - + } // BLE not connected @@ -1209,7 +1170,7 @@ void Board320_240::redrawScreen() { spr.drawString("Press middle button to menu.", 0, 200, 2); spr.drawString(APP_VERSION, 0, 220, 2); } - + spr.pushSprite(0, 0); } } @@ -1281,11 +1242,6 @@ void Board320_240::mainLoop() { displayScreenSpeedHud = !displayScreenSpeedHud; redrawScreen(); } - if (liveData->settings.debugScreen == 1 && displayScreen == SCREEN_DEBUG) { - debugCommandIndex = (debugCommandIndex >= liveData->commandQueueCount) ? liveData->commandQueueLoopFrom : debugCommandIndex + 1; - redrawScreen(); - } - } } } @@ -1312,10 +1268,10 @@ void Board320_240::mainLoop() { // SD card recording if (liveData->params.sdcardInit && liveData->params.sdcardRecording && liveData->params.sdcardCanNotify && - (liveData->params.odoKm != -1 && liveData->params.socPerc != -1)) { + (liveData->params.odoKm != -1 && liveData->params.socPerc != -1)) { //Serial.println(&now, "%y%m%d%H%M"); - + // create filename if (liveData->params.operationTimeSec > 0 && strlen(liveData->params.sdcardFilename) == 0) { sprintf(liveData->params.sdcardFilename, "/%llu.json", uint64_t(liveData->params.operationTimeSec / 60)); @@ -1350,7 +1306,7 @@ void Board320_240::mainLoop() { // Shutdown when car is off if (liveData->params.automaticShutdownTimer != 0 && liveData->params.currentTime - liveData->params.automaticShutdownTimer > 5) - shutdownDevice(); + shutdownDevice(); } /** @@ -1371,10 +1327,20 @@ bool Board320_240::sdcardMount() { } int8_t countdown = 3; + bool SdState; + while (1) { Serial.print("Initializing SD card..."); +#ifdef BOARD_TTGO_T4 + SPIClass * hspi = new SPIClass(HSPI); + spiSD.begin(pinSdcardSclk, pinSdcardMiso, pinSdcardMosi, pinSdcardCs); //SCK,MISO,MOSI,ss + SdState = SD.begin(pinSdcardCs, *hspi, SPI_FREQUENCY); +#endif // BOARD_TTGO_T4 +#ifdef BOARD_M5STACK_COREM5STACK + SdState = SD.begin(pinSdcardCs); +#endif // BOARD_M5STACK_CORE - if (SD.begin(pinSdcardCs)) { + if (SdState) { uint8_t cardType = SD.cardType(); if (cardType == CARD_NONE) { diff --git a/Board320_240.h b/Board320_240.h index 0dc4f27..f807797 100644 --- a/Board320_240.h +++ b/Board320_240.h @@ -16,6 +16,8 @@ #include #include #include "BoardInterface.h" +#include +#include class Board320_240 : public BoardInterface { @@ -23,7 +25,6 @@ class Board320_240 : public BoardInterface { // TFT, SD SPI TFT_eSPI tft = TFT_eSPI(); TFT_eSprite spr = TFT_eSprite(&tft); - //SPIClass spiSD(HSPI); HardwareSerial* gpsHwUart = NULL; TinyGPSPlus gps; char tmpStr1[20]; diff --git a/BoardInterface.h b/BoardInterface.h index 3a2db28..164af0e 100644 --- a/BoardInterface.h +++ b/BoardInterface.h @@ -24,12 +24,6 @@ class BoardInterface { bool testDataMode = false; bool scanDevices = false; String sdcardRecordBuffer = ""; - // Debug screen - next command with right button - uint16_t debugCommandIndex = 0; - String debugAtshRequest = "ATSH7E4"; - String debugCommandRequest = "220101"; - String debugLastString = "620101FFF7E7FF99000000000300B10EFE120F11100F12000018C438C30B00008400003864000035850000153A00001374000647010D017F0BDA0BDA03E8"; - String debugPreviousString = "620101FFF7E7FFB3000000000300120F9B111011101011000014CC38CB3B00009100003A510000367C000015FB000013D3000690250D018E0000000003E8"; // void setLiveData(LiveData* pLiveData); void attachCar(CarInterface* pCarInterface); diff --git a/CarRenaultZoe.cpp b/CarRenaultZoe.cpp index a2e7b7a..fd09657 100644 --- a/CarRenaultZoe.cpp +++ b/CarRenaultZoe.cpp @@ -9,8 +9,8 @@ #include "LiveData.h" #include "CarRenaultZoe.h" -#define commandQueueCountRenaultZoe 18 -#define commandQueueLoopFromRenaultZoe 11 +#define commandQueueCountRenaultZoe 28 +#define commandQueueLoopFromRenaultZoe 9 /** activateCommandQueue @@ -32,6 +32,7 @@ void CarRenaultZoe::activateCommandQueue() { ////"AT AT0", // disabled adaptive timing "AT DP", "AT ST16", // reduced timeout to 1, orig.16 + // Loop from (RENAULT ZOE) // LBC Lithium battery controller @@ -45,6 +46,18 @@ void CarRenaultZoe::activateCommandQueue() { "2141", "2142", "2161", + + // CLUSTER Instrument panel + "ATSH743", + "ATFCSH743", + "atfcsd300010", + "atfcsm1", + "220201", + "220202", + "220203", + "220204", + "220205", + "220206", }; // diff --git a/LiveData.h b/LiveData.h index 125a4e6..e013e0e 100644 --- a/LiveData.h +++ b/LiveData.h @@ -32,7 +32,6 @@ #define SCREEN_CELLS 4 #define SCREEN_CHARGING 5 #define SCREEN_SOC10 6 -#define SCREEN_DEBUG 7 // Structure with realtime values typedef struct { diff --git a/README.md b/README.md index 5fb13ce..c832d6f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # evDash (old enirodashboard) Supported devices -1. LILYGO TTGO T4 v1.3 -2. M5STACK CORE1 IOT Development Kit +1. M5STACK CORE1 IOT Development Kit (best option) +2. LILYGO TTGO T4 v1.3 (!!! limited support, no SDcard/GSM/GPS/CAN module) Working only with electric vehicles Kia e-NIRO (EV), Hyundai Kona EV, Hyundai Ioniq EV, Kia Niro Phev 8.9kWh diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a286d0d..2af74e6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,6 +1,8 @@ # RELEASE NOTES ### Next version +- removed debug screen +- sdcard working only with m5stack ### v2.1.1 2020-12-14 - tech refactoring: `hexToDecFromResponse`, `decFromResponse` diff --git a/dist/ttgo_t4_v13/evDash.ino.bin b/dist/ttgo_t4_v13/evDash.ino.bin index 34accf9..0f5c42a 100644 Binary files a/dist/ttgo_t4_v13/evDash.ino.bin and b/dist/ttgo_t4_v13/evDash.ino.bin differ diff --git a/evDash.ino b/evDash.ino index d0f02b6..fe151db 100644 --- a/evDash.ino +++ b/evDash.ino @@ -99,6 +99,7 @@ bool doNextAtCommand() { Serial.print(">>> "); Serial.println(liveData->commandRequest); String tmpStr = liveData->commandRequest + "\r"; + liveData->responseRowMerged = ""; liveData->pRemoteCharacteristicWrite->writeValue(tmpStr.c_str(), tmpStr.length()); liveData->commandQueueIndex++; @@ -116,9 +117,6 @@ bool parseRow() { // Merge 0:xxxx 1:yyyy 2:zzzz to single xxxxyyyyzzzz string if (liveData->responseRow.length() >= 2 && liveData->responseRow.charAt(1) == ':') { - if (liveData->responseRow.charAt(0) == '0') { - liveData->responseRowMerged = ""; - } liveData->responseRowMerged += liveData->responseRow.substring(2); } @@ -133,15 +131,6 @@ bool parseRowMerged() { Serial.print("merged:"); Serial.println(liveData->responseRowMerged); - // Catch output for debug screen - if (board->displayScreen == SCREEN_DEBUG) { - if (board->debugCommandIndex == liveData->commandQueueIndex) { - board->debugAtshRequest = liveData->currentAtshRequest; - board->debugCommandRequest = liveData->commandRequest; - board->debugLastString = liveData->responseRowMerged; - } - } - // Parse by selected car interface car->parseRowMerged(); @@ -202,8 +191,8 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { } /* if (advertisedDevice.getServiceDataUUID().toString() != "") { - Serial.print("ServiceDataUUID: "); - Serial.println(advertisedDevice.getServiceDataUUID().toString().c_str()); + Serial.print("ServiceDataUUID: "); + Serial.println(advertisedDevice.getServiceDataUUID().toString().c_str()); if (advertisedDevice.getServiceUUID().toString() != "") { Serial.print("ServiceUUID: "); Serial.println(advertisedDevice.getServiceUUID().toString().c_str()); @@ -412,9 +401,9 @@ void startBleScan() { #ifdef SIM800L_ENABLED bool sim800lSetup() { Serial.println("Setting SIM800L module"); - + SerialGPRS.begin(9600); - + sim800l = new SIM800L((Stream *)&SerialGPRS, SIM800L_RST, 512 , 512); // SIM800L DebugMode: //sim800l = new SIM800L((Stream *)&SerialGPRS, SIM800L_RST, 512 , 512, (Stream *)&Serial); @@ -436,7 +425,7 @@ bool sim800lSetup() { bool sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn); for (uint8_t i = 0; i < 5 && !sim800l_gprs; i++) { - Serial.println("Problem to set GPRS APN, retry in 1 sec"); + Serial.println("Problem to set GPRS APN, retry in 1 sec"); delay(1000); sim800l_gprs = sim800l->setupGPRS(liveData->settings.gprsApn); } @@ -466,7 +455,7 @@ bool sendDataViaGPRS() { return false; } - if(!sim800l->isConnectedGPRS()) { + if (!sim800l->isConnectedGPRS()) { Serial.println("GPRS not connected... Connecting"); bool connected = sim800l->connectGPRS(); for (uint8_t i = 0; i < 5 && !connected; i++) { @@ -474,7 +463,7 @@ bool sendDataViaGPRS() { delay(1000); connected = sim800l->connectGPRS(); } - if(connected) { + if (connected) { Serial.println("GPRS connected!"); } else { Serial.println("GPRS not connected! Reseting SIM800L module!"); @@ -571,7 +560,6 @@ void setup(void) { car->setLiveData(liveData); car->activateCommandQueue(); board->attachCar(car); - board->debugCommandIndex = liveData->commandQueueLoopFrom; // Redraw screen board->redrawScreen(); diff --git a/menu.h b/menu.h index fbe5b61..26eeb59 100644 --- a/menu.h +++ b/menu.h @@ -36,7 +36,7 @@ MENU_ITEM menuItemsSource[100] = { {MENU_SCREEN_BRIGHTNESS, 3, -1, "LCD brightness"}, {MENU_PREDRAWN_GRAPHS, 3, -1, "Pre-drawn ch.graphs"}, {MENU_HEADLIGHTS_REMINDER, 3, -1, "Headlight reminder"}, - {MENU_DEBUG_SCREEN, 3, -1, "Debug screen"}, +// {MENU_DEBUG_SCREEN, 3, -1, "Debug screen"}, /* // NTP