rusefi/firmware/config/engines/honda.cpp

88 lines
2.2 KiB
C++
Raw Normal View History

2023-07-14 11:48:07 -07:00
#include "pch.h"
#include "custom_engine.h"
2023-07-14 13:53:56 -07:00
// set engine_type 57
2023-07-14 11:48:07 -07:00
void setHondaCivicBcm() {
setBodyControlUnit();
2023-07-14 13:36:05 -07:00
engineConfiguration->totalGearsCount = 6;
2023-10-19 11:44:22 -07:00
engineConfiguration->gearRatio[0] = 12;
engineConfiguration->gearRatio[1] = 9;
engineConfiguration->gearRatio[2] = 6.2;
engineConfiguration->gearRatio[3] = 4.8;
engineConfiguration->gearRatio[4] = 3.7;
engineConfiguration->gearRatio[5] = 2.8;
2023-07-14 13:36:05 -07:00
engineConfiguration->isBoostControlEnabled = true;
2023-07-14 13:36:05 -07:00
#if HW_SMALL_CAN_BOARD
strncpy(config->luaScript, R"(
-- this controls onCanRx rate as well!
setTickRate(300)
timeout = 3000
rpmSensor = Sensor.new("rpm")
rpmSensor : setTimeout(timeout)
ppsSensor = Sensor.new("AcceleratorPedal")
ppsSensor : setTimeout(timeout)
speedSensor = Sensor.new("VehicleSpeed")
speedSensor : setTimeout(timeout)
2023-07-14 21:40:23 -07:00
canTimer = Timer.new()
canTimer : reset()
2023-07-14 13:36:05 -07:00
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
function getTwoBytesMSB(data, offset, factor)
return (data[offset + 1] * 256 + data[offset + 2]) * factor
end
function getTwoBytesLSB(data, offset, factor)
return (data[offset + 2] * 256 + data[offset + 1]) * factor
end
function onPOWERTRAIN_DATA(bus, id, dlc, data)
2023-07-14 21:40:23 -07:00
canTimer : reset()
-- print('onPOWERTRAIN_DATA ' ..arrayToString(data))
2023-07-14 13:36:05 -07:00
ppsValue = data[1] * 100.0 / 255
ppsSensor : set(ppsValue)
rpmValue = getTwoBytesMSB(data, 2, 1)
rpmSensor : set(rpmValue)
-- print('onPOWERTRAIN_DATA ' .. rpmValue .. ' pedal ' .. ppsValue)
end
function onCAR_SPEED(bus, id, dlc, data)
2023-07-14 21:40:23 -07:00
canTimer : reset()
2023-07-14 13:36:05 -07:00
speedKph = getTwoBytesLSB(data, 1, 0.01)
print('onCAR_SPEED ' .. speedKph)
speedSensor : set(speedKph)
print('onPOWERTRAIN_DATA speed' .. speedKph .. ' ratio ' .. (speedKph / rpmValue))
end
canRxAdd(1, 0x17C, onPOWERTRAIN_DATA)
canRxAdd(1, 0x309, onCAR_SPEED)
2023-07-14 21:40:23 -07:00
2023-10-19 09:13:45 -07:00
commTimer = Timer.new()
commTimer : reset()
canDelay = 1
commDelay = 20
2023-07-14 21:40:23 -07:00
function onTick()
2023-10-19 09:13:45 -07:00
if getOutput("isUsbConnected") == 1 then
commTimer : reset()
end
if (canTimer : getElapsedSeconds() > canDelay) and (commTimer : getElapsedSeconds() > commDelay) then
2023-07-14 21:40:23 -07:00
mcu_standby()
end
end
2023-07-14 13:36:05 -07:00
)", efi::size(config->luaScript));
#endif // HW_SMALL_CAN_BOARD
2023-07-14 11:48:07 -07:00
}