parent
2e81c448bf
commit
517cd42309
|
@ -139,11 +139,20 @@ setTickRate(100)
|
|||
function onCanConfiguration3(bus, id, dlc, data)
|
||||
-- print("Received configuration3 "..arrayToString(data))
|
||||
pumpPeak = getTwoBytesLSB(data, 6, 1 / 128)
|
||||
-- print("GDI4 says PumpPeakCurrent ".. pumpPeak)
|
||||
print("GDI4 says PumpPeakCurrent ".. pumpPeak)
|
||||
setLuaGauge(1, pumpPeak)
|
||||
end
|
||||
|
||||
function onCanVersion(bus, id, dlc, data)
|
||||
year = data[1] * 100 + data[2]
|
||||
month = data[3]
|
||||
day = data[4]
|
||||
-- print ("GDI4 firmware " ..year ..'/' ..month ..'/' ..day)
|
||||
end
|
||||
|
||||
canRxAdd(GDI4_BASE_ADDRESS + 3, onCanConfiguration3)
|
||||
canRxAdd(GDI4_BASE_ADDRESS + 5, onCanVersion)
|
||||
|
||||
|
||||
EMS_DCT11_128 = 0x80
|
||||
EMS_DCT12_129 = 0x81
|
||||
|
@ -171,42 +180,13 @@ speedSensor : setTimeout(3000)
|
|||
|
||||
function onCluPacket(bus, id, dlc, data)
|
||||
speedKph = getBitRange(data, 8, 9) * 0.5
|
||||
print('onCAR_SPEED ' ..speedKph)
|
||||
-- print('onCAR_SPEED ' ..speedKph)
|
||||
speedSensor : set(speedKph)
|
||||
end
|
||||
|
||||
canRxAdd(1, 1264, onCluPacket)
|
||||
|
||||
GDI4_BASE_ADDRESS = 0xBB20
|
||||
GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
|
||||
local data_set_settings = { GDI4_CAN_SET_TAG, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
||||
function onCanConfiguration3(bus, id, dlc, data)
|
||||
print("Received configuration3 "..arrayToString(data))
|
||||
print("GDI4 says HoldCurrent "..getTwoBytesLSB(data, 0, 1 / 128) )
|
||||
print("GDI4 says TholdOff "..getTwoBytesLSB(data, 2, 1) )
|
||||
print("GDI4 says THoldDuration "..getTwoBytesLSB(data, 4, 1) )
|
||||
pumpPeak = getTwoBytesLSB(data, 6, 1 / 128)
|
||||
print("GDI4 says PumpPeakCurrent ".. pumpPeak)
|
||||
setLuaGauge(1, pumpPeak)
|
||||
end
|
||||
|
||||
canRxAdd(GDI4_BASE_ADDRESS + 3, onCanConfiguration3)
|
||||
|
||||
function onTick()
|
||||
TholdOff = getCalibration("mc33_t_hold_off")
|
||||
THoldDuration = getCalibration("mc33_t_hold_tot")
|
||||
|
||||
pumpPeakCurrent = getCalibration("mc33_hpfp_i_peak")
|
||||
pumpHoldCurrent = getCalibration("mc33_hpfp_i_hold")
|
||||
|
||||
setTwoBytesLsb(data_set_settings, 1, TholdOff)
|
||||
setTwoBytesLsb(data_set_settings, 3, THoldDuration)
|
||||
-- set mc33_hpfp_i_peak 6
|
||||
setTwoBytesLsb(data_set_settings, 5, pumpPeakCurrent * FIXED_POINT)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
|
||||
|
||||
local RPMread = math.floor(getSensor("RPM") * 4)
|
||||
local RPMhi = RPMread >> 8
|
||||
local RPMlo = RPMread & 0xff
|
||||
|
@ -245,12 +225,12 @@ function onTick()
|
|||
setTwoBytesLsb(data_set_settings, 1, TholdOff)
|
||||
setTwoBytesLsb(data_set_settings, 3, THoldDuration)
|
||||
setTwoBytesLsb(data_set_settings, 5, pumpPeakCurrent * FIXED_POINT)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
-- print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
|
||||
|
||||
setTwoBytesLsb(data_set_settings, 1, pumpHoldCurrent * FIXED_POINT)
|
||||
setTwoBytesLsb(data_set_settings, 3, GDI4_BASE_ADDRESS)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
-- print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue