diff --git a/Board320_240.cpp b/Board320_240.cpp index d06aa83..2db7970 100644 --- a/Board320_240.cpp +++ b/Board320_240.cpp @@ -1128,21 +1128,23 @@ void Board320_240::redrawScreen() { // 1. Auto mode = >5kpm Screen 3 - speed, other wise basic Screen2 - Main screen, if charging then Screen 5 Graph if (displayScreen == SCREEN_AUTO) { if (liveData->params.speedKmh > 5) { - if (displayScreenAutoMode != 3) { - displayScreenAutoMode = 3; + if (displayScreenAutoMode != SCREEN_SPEED) { + displayScreenAutoMode = SCREEN_SPEED; } drawSceneSpeed(); } else if (liveData->params.batPowerKw > 1) { - if (displayScreenAutoMode != 5) { - displayScreenAutoMode = 5; + if (displayScreenAutoMode != SCREEN_CHARGING) { + displayScreenAutoMode = SCREEN_CHARGING; } drawSceneChargingGraph(); } else { - if (displayScreenAutoMode != 2) { - displayScreenAutoMode = 2; + if (displayScreenAutoMode != SCREEN_DASH) { + displayScreenAutoMode = SCREEN_DASH; } drawSceneMain(); } + } else { + displayScreenAutoMode = SCREEN_DASH; } // 2. Main screen if (displayScreen == SCREEN_DASH) { @@ -1174,9 +1176,8 @@ void Board320_240::redrawScreen() { // SDCARD recording /*liveData->params.sdcardRecording*/ if (liveData->settings.sdcardEnabled == 1) { - spr.fillCircle(310, 10, 4, TFT_BLACK); - - spr.fillCircle(310, 10, 3, + spr.fillCircle((displayScreen == SCREEN_SPEED || displayScreenAutoMode == SCREEN_SPEED) ? 160 : 310, 10, 4, TFT_BLACK); + spr.fillCircle((displayScreen == SCREEN_SPEED || displayScreenAutoMode == SCREEN_SPEED) ? 160 : 310, 10, 3, (liveData->params.sdcardInit == 1) ? (liveData->params.sdcardRecording) ? (strlen(liveData->params.sdcardFilename) != 0) ? @@ -1186,6 +1187,15 @@ void Board320_240::redrawScreen() { TFT_YELLOW /* failed to initialize sdcard */ ); } + if (gpsHwUart != NULL && (displayScreen == SCREEN_SPEED || displayScreenAutoMode == SCREEN_SPEED)) { + spr.drawCircle(180, 10, 5, (gps.location.isValid()) ? TFT_GREEN : TFT_RED); + spr.setTextSize(1); + spr.setTextColor((gps.location.isValid()) ? TFT_GREEN : TFT_WHITE, TFT_BLACK); + spr.setTextDatum(TL_DATUM); + sprintf(tmpStr1, "%d", liveData->params.gpsSat); + spr.drawString(tmpStr1, 194, 2, 2); + + } // BLE not connected if (!liveData->bleConnected && liveData->bleConnect) { @@ -1197,7 +1207,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); } } @@ -1272,8 +1282,6 @@ void Board320_240::mainLoop() { if (liveData->settings.debugScreen == 1 && displayScreen == SCREEN_DEBUG) { debugCommandIndex = (debugCommandIndex >= liveData->commandQueueCount) ? liveData->commandQueueLoopFrom : debugCommandIndex + 1; redrawScreen(); - // log every queue loop (temp) - liveData->params.sdcardCanNotify = true; } } diff --git a/BoardInterface.cpp b/BoardInterface.cpp index 54d9ded..afc4e38 100644 --- a/BoardInterface.cpp +++ b/BoardInterface.cpp @@ -193,22 +193,21 @@ void BoardInterface::loadSettings() { } /** - * After setup - */ + After setup +*/ void BoardInterface::afterSetup() { // Init Comm iterface - if (liveData->settings.commType == COMM_TYPE_OBD2BLE4) { + if (liveData->settings.commType == COMM_TYPE_OBD2BLE4) { commInterface = new CommObd2Ble4(); - } else - if (liveData->settings.commType == COMM_TYPE_OBD2CAN) { + } else if (liveData->settings.commType == COMM_TYPE_OBD2CAN) { commInterface = new CommObd2Ble4(); //commInterface = new CommObd2Can(); } //commInterface->initComm(liveData, NULL); commInterface->connectDevice(); } - + /** Custom commands */ @@ -232,15 +231,15 @@ void BoardInterface::customConsoleCommand(String cmd) { } /** - * Serialize parameters - */ + Serialize parameters +*/ bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) { - - StaticJsonDocument<1500> jsonData; - if (inclApiKey) + StaticJsonDocument<2048> jsonData; + + if (inclApiKey) jsonData["apiKey"] = liveData->settings.remoteApiKey; - + jsonData["carType"] = liveData->settings.carType; jsonData["batTotalKwh"] = liveData->params.batteryTotalAvailableKWh; jsonData["currTime"] = liveData->params.currentTime; @@ -250,14 +249,14 @@ bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) { jsonData["lat"] = liveData->params.gpsLat; jsonData["lon"] = liveData->params.gpsLon; jsonData["alt"] = liveData->params.gpsAlt; - + jsonData["socPerc"] = liveData->params.socPerc; jsonData["sohPerc"] = liveData->params.sohPerc; jsonData["powKwh100"] = liveData->params.batPowerKwh100; jsonData["speedKmh"] = liveData->params.speedKmh; jsonData["motorRpm"] = liveData->params.motorRpm; jsonData["odoKm"] = liveData->params.odoKm; - + jsonData["batPowKw"] = liveData->params.batPowerKw; jsonData["batPowA"] = liveData->params.batPowerAmp; jsonData["batV"] = liveData->params.batVoltage; @@ -265,7 +264,7 @@ bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) { jsonData["cedKwh"] = liveData->params.cumulativeEnergyDischargedKWh; jsonData["maxChKw"] = liveData->params.availableChargePower; jsonData["maxDisKw"] = liveData->params.availableDischargePower; - + jsonData["cellMinV"] = liveData->params.batCellMinV; jsonData["cellMaxV"] = liveData->params.batCellMaxV; jsonData["bMinC"] = round(liveData->params.batMinC); @@ -282,7 +281,7 @@ bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) { jsonData["auxPerc"] = liveData->params.auxPerc; jsonData["auxV"] = liveData->params.auxVoltage; jsonData["auxA"] = liveData->params.auxCurrentAmp; - + jsonData["inC"] = liveData->params.indoorTemperature; jsonData["outC"] = liveData->params.outdoorTemperature; jsonData["c1C"] = liveData->params.coolantTemp1C; @@ -297,6 +296,8 @@ bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) { jsonData["tRrC"] = liveData->params.tireRearRightTempC; jsonData["tRrBar"] = round(liveData->params.tireRearRightPressureBar * 10) / 10; + jsonData["debugData"] = liveData->params.debugData; + serializeJson(jsonData, Serial); serializeJson(jsonData, file); } diff --git a/CarKiaEniro.cpp b/CarKiaEniro.cpp index 94ccb9d..0d03cb9 100644 --- a/CarKiaEniro.cpp +++ b/CarKiaEniro.cpp @@ -110,9 +110,14 @@ void CarKiaEniro::parseRowMerged() { bool tempByte; float tempFloat; + String tmpStr; // ABS / ESP + AHB 7D1 if (liveData->currentAtshRequest.equals("ATSH7D1")) { + // Init debug data + tmpStr = ""; + tmpStr.toCharArray(liveData->params.debugData, tmpStr.length() + 1); + // if (liveData->commandRequest.equals("22C101")) { uint8_t driveMode = liveData->hexToDecFromResponse(22, 24, 1, false); liveData->params.forwardDriveMode = (driveMode == 4); @@ -158,8 +163,7 @@ void CarKiaEniro::parseRowMerged() { if (liveData->commandRequest.equals("22B002")) { tempFloat = liveData->params.odoKm; liveData->params.odoKm = liveData->decFromResponse(18, 24); - if (tempFloat != liveData->params.odoKm) - liveData->params.sdcardCanNotify = true; + //if (tempFloat != liveData->params.odoKm) liveData->params.sdcardCanNotify = true; } } @@ -253,8 +257,7 @@ void CarKiaEniro::parseRowMerged() { liveData->params.socPercPrevious = liveData->params.socPerc; liveData->params.sohPerc = liveData->hexToDecFromResponse(56, 60, 2, false) / 10.0; liveData->params.socPerc = liveData->hexToDecFromResponse(68, 70, 1, false) / 2.0; - if (liveData->params.socPercPrevious != liveData->params.socPerc) - liveData->params.sdcardCanNotify = true; + // if (liveData->params.socPercPrevious != liveData->params.socPerc) liveData->params.sdcardCanNotify = true; // Soc10ced table, record x0% CEC/CED table (ex. 90%->89%, 80%->79%) if (liveData->params.socPercPrevious - liveData->params.socPerc > 0) { @@ -273,12 +276,18 @@ void CarKiaEniro::parseRowMerged() { for (int i = 30; i < 32; i++) { // ai/aj position liveData->params.cellVoltage[96 - 30 + i] = liveData->hexToDecFromResponse(14 + (i * 2), 14 + (i * 2) + 2, 1, false) / 50; } + // log 220105 to sdcard + tmpStr = String(liveData->params.debugData) + liveData->currentAtshRequest + '/' + liveData->commandRequest + '/' + liveData->responseRowMerged + '\n'; + tmpStr.toCharArray(liveData->params.debugData, tmpStr.length() + 1); } // BMS 7e4 if (liveData->commandRequest.equals("220106")) { liveData->params.coolingWaterTempC = liveData->hexToDecFromResponse(14, 16, 1, false); liveData->params.bmsUnknownTempC = liveData->hexToDecFromResponse(18, 20, 1, true); liveData->params.bmsUnknownTempD = liveData->hexToDecFromResponse(46, 48, 1, true); + // log 220106 to sdcard + tmpStr = String(liveData->params.debugData) + liveData->currentAtshRequest + '/' + liveData->commandRequest + '/' + liveData->responseRowMerged + '\n'; + tmpStr.toCharArray(liveData->params.debugData, tmpStr.length() + 1); } } diff --git a/LiveData.cpp b/LiveData.cpp index 45d41bd..036404d 100644 --- a/LiveData.cpp +++ b/LiveData.cpp @@ -109,6 +109,9 @@ void LiveData::initParams() { params.chargingGraphHeaterTempC[i] = -100; params.chargingGraphWaterCoolantTempC[i] = -100; } + // + tmpStr = ""; + tmpStr.toCharArray(params.debugData, tmpStr.length() + 1); // Menu menuItemsCount = sizeof(menuItemsSource) / sizeof(menuItemsSource[0]); diff --git a/LiveData.h b/LiveData.h index fc89913..93520f4 100644 --- a/LiveData.h +++ b/LiveData.h @@ -130,6 +130,7 @@ typedef struct { float soc10odo[11]; // odo history time_t soc10time[11]; // time for avg speed // additional + char debugData[256]; /* uint8_t bmsMainRelay; uint8_t highVoltageCharging; diff --git a/evDash.ino b/evDash.ino index 6ae1d38..c46301c 100644 --- a/evDash.ino +++ b/evDash.ino @@ -85,6 +85,8 @@ bool doNextAtCommand() { if (liveData->commandQueueIndex >= liveData->commandQueueCount) { liveData->commandQueueIndex = liveData->commandQueueLoopFrom; board->redrawScreen(); + // log every queue loop (temp) + liveData->params.sdcardCanNotify = true; } // Send AT command to obd