Fix odometer encoding in main.cpp to use bytes 0-2 and update calculation factor. Comment out debug print statements for RPM and speed to reduce output noise.
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -53,7 +53,7 @@ void loop() {
|
||||
#define ID_ENGINE_RPM 0x1F9 // bytes 2-3 BE, raw/8 = RPM
|
||||
#define ID_VEHICLE_SPEED 0x354 // bytes 0-1 BE, raw*0.01 = km/h
|
||||
#define ID_SPEED_2 0x645 // bytes 3-4 BE, raw*0.01 = km/h (dashboard backlight msg)
|
||||
#define ID_ODOMETER 0x5FD // bytes 2-4 BE, raw/13.0856 = km (cal: 114513)
|
||||
#define ID_ODOMETER 0x5FD // bytes 0-2 BE, raw/16 = km (fixed encoding)
|
||||
|
||||
static uint16_t lastRpm = 0xFFFF;
|
||||
static uint16_t lastSpeed = 0xFFFF;
|
||||
@@ -75,7 +75,7 @@ void decode_renault(const CanFrame& frame) {
|
||||
if (rpm >= 100 && rpm <= 7000 && (rpm != lastRpm || now - lastPrintMs > DEBOUNCE_MS)) {
|
||||
lastRpm = rpm;
|
||||
lastPrintMs = now;
|
||||
Serial.printf("RPM: %u\n", rpm);
|
||||
// Serial.printf("RPM: %u\n", rpm);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -87,7 +87,7 @@ void decode_renault(const CanFrame& frame) {
|
||||
if (kmh < 250 && (raw != lastSpeed || now - lastPrintMs > DEBOUNCE_MS)) {
|
||||
lastSpeed = raw;
|
||||
lastPrintMs = now;
|
||||
Serial.printf("Speed: %.1f km/h\n", kmh);
|
||||
// Serial.printf("Speed: %.1f km/h\n", kmh);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -99,15 +99,15 @@ void decode_renault(const CanFrame& frame) {
|
||||
if (kmh < 250 && (raw != lastSpeed || now - lastPrintMs > DEBOUNCE_MS)) {
|
||||
lastSpeed = raw;
|
||||
lastPrintMs = now;
|
||||
Serial.printf("Speed: %.1f km/h\n", kmh);
|
||||
// Serial.printf("Speed: %.1f km/h\n", kmh);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_ODOMETER: // 0x5FD x0r: bytes 0-2 = km. This car uses bytes 2-4.
|
||||
if (len >= 5) {
|
||||
uint32_t raw = (uint32_t)d[2] << 16 | (uint32_t)d[3] << 8 | d[4];
|
||||
uint32_t km = (uint32_t)(raw / 13.0834f); // cal: 114513
|
||||
case ID_ODOMETER: // 0x5FD bytes 0-2 BE: raw = km*16 (fixed factor, stable)
|
||||
if (len >= 3) {
|
||||
uint32_t raw02 = (uint32_t)d[0] << 16 | (uint32_t)d[1] << 8 | d[2];
|
||||
uint32_t km = raw02 / 16; // encoding: raw = km * 16 (constant)
|
||||
if (km < 999999 && (km != lastOdo || now - lastPrintMs > DEBOUNCE_MS)) {
|
||||
lastOdo = km;
|
||||
lastPrintMs = now;
|
||||
|
||||
Reference in New Issue
Block a user