From fc00d31505afa8626f0f6d07ea563ce0a3332b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kolac=C3=AD?= Date: Fri, 25 Dec 2020 21:15:20 +0100 Subject: [PATCH] Ioniq - Aux. batt percentage calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin KolacĂ­ --- CarHyundaiIoniq.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CarHyundaiIoniq.cpp b/CarHyundaiIoniq.cpp index 3e4f618..157075e 100644 --- a/CarHyundaiIoniq.cpp +++ b/CarHyundaiIoniq.cpp @@ -155,11 +155,12 @@ 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) { - tmpAuxPerc = map(liveData->params.auxVoltage * 10, 128, 148, 0, 1000) / 10; + tmpAuxPerc = (float)(liveData->params.auxVoltage - 12.8) * 100 / (float)(14.8 - 12.8); //min: 12.8V; max: 14.8V } else { - tmpAuxPerc = map(liveData->params.auxVoltage * 10, 116, 128, 0, 1000) / 10; + tmpAuxPerc = (float)(liveData->params.auxVoltage - 11.6) * 100 / (float)(12.8 - 11.6); //min 11.6V; max: 12.8V } if(tmpAuxPerc > 100) { liveData->params.auxPerc = 100;