Ensure correct Forza<>CAN gear encoding/decoding
This commit is contained in:
parent
0fce3efc2b
commit
6b63549de2
2 changed files with 6 additions and 2 deletions
|
@ -66,7 +66,11 @@ static void table_update(hexagram_schedule_slot *table,
|
||||||
table[0].frame.data[2] = engine_rpm & 0x00ff;
|
table[0].frame.data[2] = engine_rpm & 0x00ff;
|
||||||
|
|
||||||
/* Current gear */
|
/* Current gear */
|
||||||
table[3].frame.data[7] = 0xc | (packet->race.gear + 2) << 4;
|
if (packet->race.gear == 0) {
|
||||||
|
table[3].frame.data[7] = 0x30; /* Reverse gear */
|
||||||
|
} else {
|
||||||
|
table[3].frame.data[7] = 0xc | (packet->race.gear + 2) << 4;
|
||||||
|
}
|
||||||
|
|
||||||
/* Vehicle speed */
|
/* Vehicle speed */
|
||||||
table[4].frame.data[1] = (speed_rps & 0xff00) >> 8;
|
table[4].frame.data[1] = (speed_rps & 0xff00) >> 8;
|
||||||
|
|
|
@ -64,7 +64,7 @@ cdef cluster_update(cluster: Cluster,
|
||||||
if (frame.data[7] & 0xc) == 0xc:
|
if (frame.data[7] & 0xc) == 0xc:
|
||||||
cluster.tacho.gear = Gear(value)
|
cluster.tacho.gear = Gear(value)
|
||||||
else:
|
else:
|
||||||
cluster.tacho.gear = GEAR_VALUES[value]
|
cluster.tacho.gear = GEAR_VALUES.get(value, Gear.D)
|
||||||
elif frame.can_id == 0x5a0:
|
elif frame.can_id == 0x5a0:
|
||||||
rps = 0.001 * float(frame.data[1] | (frame.data[2] << 8))
|
rps = 0.001 * float(frame.data[1] | (frame.data[2] << 8))
|
||||||
kph = (2.00152 * rps * 3600) / 1000.0
|
kph = (2.00152 * rps * 3600) / 1000.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue