refactoring - simplified usage of hexToDec (#10)
* refactoring - simplified usage of hexToDec - replaced by hexToDecFromResponse * refactoring - simplified usage of hexToDec - replaced by hexToDecFromResponse (applied to CarHyundaiIoniq.cpp) * refactoring - simplified usage of hexToDec - replaced by hexToDecFromResponse (applied to rest) * refactoring - simplified usage of hexToDec - replaced by hexToDecFromResponse (fix) * refactoring - simplified usage of float(strol(liveData->responseRowMerged.substring(...))) - as liveData->decFromResponse()
This commit is contained in:
17
LiveData.cpp
17
LiveData.cpp
@@ -138,6 +138,23 @@ float LiveData::hexToDec(String hexString, byte bytes, bool signedNum) {
|
||||
return (decValue > 32767 ? (float)decValue - 65536.0 : decValue);
|
||||
}
|
||||
|
||||
/**
|
||||
Parsed from merged response row:
|
||||
Hex to dec (1-2 byte values, signed/unsigned)
|
||||
For 4 byte change int to long and add part for signed numbers
|
||||
*/
|
||||
|
||||
float LiveData::hexToDecFromResponse(byte from, byte to, byte bytes, bool signedNum) {
|
||||
return hexToDec(responseRowMerged.substring(from, to).c_str(), bytes, signedNum);
|
||||
}
|
||||
|
||||
/**
|
||||
Combination of responseRowMerged.substring -> strtol -> float
|
||||
*/
|
||||
float LiveData::decFromResponse(byte from, byte to, char **str_end, int base) {
|
||||
return float(strtol(responseRowMerged.substring(from, to).c_str(), str_end, base));
|
||||
}
|
||||
|
||||
/**
|
||||
Convert km to km or miles
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user