SD card - log every loop, added debug bms 220105/220106 for eniro, display gps ready state on speed screen + number of satellites

This commit is contained in:
Lubos Petrovic
2020-12-08 09:44:13 +01:00
parent 54a40ab24f
commit 048f254acc
6 changed files with 56 additions and 32 deletions

View File

@@ -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) {
@@ -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;
}
}

View File

@@ -193,15 +193,14 @@ void BoardInterface::loadSettings() {
}
/**
* After setup
*/
After setup
*/
void BoardInterface::afterSetup() {
// Init Comm iterface
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();
}
@@ -232,11 +231,11 @@ void BoardInterface::customConsoleCommand(String cmd) {
}
/**
* Serialize parameters
*/
Serialize parameters
*/
bool BoardInterface::serializeParamsToJson(File file, bool inclApiKey) {
StaticJsonDocument<1500> jsonData;
StaticJsonDocument<2048> jsonData;
if (inclApiKey)
jsonData["apiKey"] = liveData->settings.remoteApiKey;
@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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]);

View File

@@ -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;

View File

@@ -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