minor progress

only:proteus_f7
This commit is contained in:
rusefillc 2023-03-05 18:56:26 -05:00
parent 6e604763bf
commit aefdf10a7b
1 changed files with 24 additions and 21 deletions

View File

@ -99,12 +99,6 @@ function onAirBag(bus, id, dlc, data)
hadIgnitionEvent = true
end
function setTwoBytes(data, offset, value)
value = math.floor(value)
data[offset + 2] = value >> 8
data[offset + 1] = value & 0xff
end
function xorChecksum(data, targetIndex)
local index = 1
local result = 0
@ -156,13 +150,7 @@ canRxAdd(TCU_1, onTcu1)
canRxAdd(TCU_2, onTcu2)
--canRxAdd(BRAKE_2)
function onMotor1(bus, id, dlc, data)
rpm = getSensor("RPM") or 0
tps = getSensor("TPS1") or 0
fakeTorque = interpolate(0, 6, 100, 60, tps)
function sendMotor1()
engineTorque = fakeTorque * 0.9
innerTorqWithoutExt = fakeTorque
torqueLoss = 20
@ -184,6 +172,22 @@ function onMotor1(bus, id, dlc, data)
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
end
function onMotor1(bus, id, dlc, data)
rpm = getSensor("RPM") or 0
tps = getSensor("TPS1") or 0
fakeTorque = interpolate(0, 6, 100, 60, tps)
engineTorque = fakeTorque * 0.9
innerTorqWithoutExt = fakeTorque
torqueLoss = 20
requestedTorque = fakeTorque
sendMotor1()
end
function sendMotor3()
iat = getSensor("IAT") or 0
tps = getSensor("TPS1") or 0
@ -264,7 +268,6 @@ canMotorInfoCounter = 0
function onMotorInfo(bus, id, dlc, data)
canMotorInfoTotalCounter = canMotorInfoTotalCounter + 1
canMotorInfoCounter = (canMotorInfoCounter + 1) % 16
-- canMotorInfoCounter = getBitRange(data, 0, 4)
baseByte = canMotorInfoTotalCounter < 6 and 0x80 or 0x90
canMotorInfo[1] = baseByte + (canMotorInfoCounter)