From b69c44c0b8d508bd3911ff542845beb5b15f1b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kolac=C3=AD?= Date: Thu, 24 Dec 2020 16:41:35 +0100 Subject: [PATCH] Ioniq auxPerc workaround - fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin KolacĂ­ --- CarHyundaiIoniq.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CarHyundaiIoniq.cpp b/CarHyundaiIoniq.cpp index 0e16094..5f3ec73 100644 --- a/CarHyundaiIoniq.cpp +++ b/CarHyundaiIoniq.cpp @@ -156,11 +156,20 @@ void CarHyundaiIoniq::parseRowMerged() { liveData->params.batFanStatus = liveData->hexToDecFromResponse(58, 60, 2, true); liveData->params.batFanFeedbackHz = liveData->hexToDecFromResponse(60, 62, 2, true); liveData->params.auxVoltage = liveData->hexToDecFromResponse(62, 64, 2, true) / 10.0; + float tmpAuxPerc; if(liveData->params.ignitionOn) { - liveData->params.auxPerc = map(liveData->params.auxVoltage, 12.8, 14.8, 0, 100); + tmpAuxPerc = map(liveData->params.auxVoltage * 10, 128, 148, 0, 1000) / 10; } else { - liveData->params.auxPerc = map(liveData->params.auxVoltage, 11.6, 12.8, 0, 100); + tmpAuxPerc = map(liveData->params.auxVoltage * 10, 116, 128, 0, 1000) / 10; } + if(tmpAuxPerc > 100) { + liveData->params.auxPerc = 100; + } else if(tmpAuxPerc < 0) { + liveData->params.auxPerc = 0; + } else { + liveData->params.auxPerc = tmpAuxPerc; + } + liveData->params.batPowerAmp = - liveData->hexToDecFromResponse(24, 28, 2, true) / 10.0; liveData->params.batVoltage = liveData->hexToDecFromResponse(28, 32, 2, false) / 10.0; liveData->params.batPowerKw = (liveData->params.batPowerAmp * liveData->params.batVoltage) / 1000.0;