From f501c2e8f1ea9051117bf016d599f4a6c754f207 Mon Sep 17 00:00:00 2001 From: Jim Whitelaw Date: Fri, 5 Jan 2024 02:30:53 -0700 Subject: [PATCH] Update for fix for #211 --- src/ELMduino.cpp | 12 ++++++------ src/ELMduino.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ELMduino.cpp b/src/ELMduino.cpp index f794553..f0f41b9 100644 --- a/src/ELMduino.cpp +++ b/src/ELMduino.cpp @@ -393,7 +393,7 @@ int8_t ELM327::nextIndex(char const *str, } /* - void ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) + double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) Description: ------------ @@ -408,9 +408,9 @@ int8_t ELM327::nextIndex(char const *str, Return: ------- - * float - Converted numerical value + * double - Converted numerical value */ -double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) +double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const double &scaleFactor, const float &bias) { uint8_t numExpectedPayChars = numExpectedBytes * 2; uint8_t payCharDiff = numPayChars - numExpectedPayChars; @@ -475,7 +475,7 @@ double ELM327::conditionResponse(const uint8_t &numExpectedBytes, const float &s } else { - return ((double)(response >> (4 * payCharDiff)) * scaleFactor) + bias; + return ((response >> (4 * payCharDiff)) * scaleFactor) + bias; } } @@ -575,7 +575,7 @@ bool ELM327::queryPID(char queryStr[]) } /* - float ELM327::processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor, const float& bias) + double ELM327::processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor, const float& bias) Description: ------------ @@ -597,7 +597,7 @@ bool ELM327::queryPID(char queryStr[]) ------- * float - The PID value if successfully received, else 0.0 */ -double ELM327::processPID(const uint8_t &service, const uint16_t &pid, const uint8_t &num_responses, const uint8_t &numExpectedBytes, const float &scaleFactor, const float &bias) +double ELM327::processPID(const uint8_t &service, const uint16_t &pid, const uint8_t &num_responses, const uint8_t &numExpectedBytes, const double &scaleFactor, const float &bias) { if (nb_query_state == SEND_COMMAND) { diff --git a/src/ELMduino.h b/src/ELMduino.h index b7f63ec..4b9f8da 100644 --- a/src/ELMduino.h +++ b/src/ELMduino.h @@ -318,12 +318,12 @@ class ELM327 uint64_t findResponse(); bool queryPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses = 1); bool queryPID(char queryStr[]); - double processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const float& scaleFactor = 1, const float& bias = 0); + double processPID(const uint8_t& service, const uint16_t& pid, const uint8_t& num_responses, const uint8_t& numExpectedBytes, const double& scaleFactor = 1, const float& bias = 0); void sendCommand(const char *cmd); int8_t sendCommand_Blocking(const char *cmd); int8_t get_response(); bool timeout(); - double conditionResponse(const uint8_t& numExpectedBytes, const float& scaleFactor = 1, const float& bias = 0); + double conditionResponse(const uint8_t& numExpectedBytes, const double& scaleFactor = 1, const float& bias = 0); float batteryVoltage(void); int8_t get_vin_blocking(char vin[]);