GDI progress
This commit is contained in:
parent
fb18bde752
commit
a4418487df
|
@ -36,6 +36,11 @@ function getTwoBytesLSB(data, offset, factor)
|
||||||
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
return (data[offset + 2] * 256 + data[offset + 1]) * factor
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function setTwoBytesLsb(data, offset, value)
|
||||||
|
value = math.floor(value)
|
||||||
|
data[offset + 2] = value >> 8
|
||||||
|
data[offset + 1] = value & 0xff
|
||||||
|
end
|
||||||
|
|
||||||
function onCanConfiguration(bus, id, dlc, data)
|
function onCanConfiguration(bus, id, dlc, data)
|
||||||
print('Received configuration ' ..arrayToString(data))
|
print('Received configuration ' ..arrayToString(data))
|
||||||
|
@ -49,11 +54,26 @@ canRxAdd(GDI4_BASE_ADDRESS, printPacket)
|
||||||
canRxAdd(GDI4_BASE_ADDRESS + 1, onCanConfiguration)
|
canRxAdd(GDI4_BASE_ADDRESS + 1, onCanConfiguration)
|
||||||
canRxAdd(GDI4_BASE_ADDRESS + 2, printPacket)
|
canRxAdd(GDI4_BASE_ADDRESS + 2, printPacket)
|
||||||
|
|
||||||
local data_0x1ae0092c = { 0x00, 0x00, 0x22, 0xe0, 0x41, 0x90, 0x00, 0x00 }
|
local data_set_voltage = { 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||||
|
|
||||||
|
FIXED_POINT = 100
|
||||||
|
|
||||||
function onTick()
|
function onTick()
|
||||||
|
|
||||||
txCan(1, 0x200, 1, data_0x1ae0092c)
|
boostVoltage = getCalibration("mc33_hvolt")
|
||||||
|
boostCurrent = getCalibration("mc33_i_boost") / 1000.0
|
||||||
|
peakCurrent = getCalibration("mc33_i_peak") / 1000.0
|
||||||
|
print(boostVoltage .." " ..boostCurrent .." " ..peakCurrent)
|
||||||
|
|
||||||
|
setTwoBytesLsb(data_set_voltage, 1, boostVoltage * FIXED_POINT)
|
||||||
|
setTwoBytesLsb(data_set_voltage, 3, boostCurrent * FIXED_POINT)
|
||||||
|
setTwoBytesLsb(data_set_voltage, 5, peakCurrent * FIXED_POINT)
|
||||||
|
print('Sending ' ..arrayToString(data_set_voltage))
|
||||||
|
|
||||||
|
holdCurrent = getCalibration("mc33_i_hold")
|
||||||
|
|
||||||
|
|
||||||
|
txCan(1, 0x201, 1, data_set_voltage)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue