This commit is contained in:
parent
191e2efce9
commit
7055f32fd3
|
@ -1,20 +1,30 @@
|
|||
-- https://rusefi.com/forum/viewtopic.php?f=4&t=2325
|
||||
-- tested on 9286699
|
||||
|
||||
-- CAN Rx Channels
|
||||
IDRIVE_BUTTONS = 0x267
|
||||
IDRIVE_ROTARY = 0x264
|
||||
|
||||
CAN_BUTTONS = 0x267
|
||||
-- CAN Tx Channels
|
||||
IDRIVE_BRIGHTNESS = 0x202
|
||||
IDRIVE_HEARBEAT = 0x560
|
||||
IDRIVE_ROTARY_INIT = 0x273
|
||||
|
||||
brighness = 0
|
||||
|
||||
canRxAdd(0x264) -- rotation, I did not get it to work
|
||||
canRxAdd(CAN_BUTTONS) -- buttons
|
||||
canRxAdd(IDRIVE_ROTARY) -- rotation, I did not get it to work
|
||||
canRxAdd(IDRIVE_BUTTONS) -- buttons
|
||||
|
||||
setTickRate(5) -- set tick rate to 5hz
|
||||
|
||||
-- One time rotary initialisation
|
||||
|
||||
txCan(1, IDRIVE_ROTARY_INIT, 0, { 0x1D, 0xE1, 0x00, 0xF0, 0xFF, 0x7F, 0xDE, 0x04 })
|
||||
|
||||
function onCanRx(bus, id, dlc, data)
|
||||
-- print('got CAN id=' ..id ..' dlc=' ..dlc)
|
||||
|
||||
if id == CAN_BUTTONS then
|
||||
if id == IDRIVE_BUTTONS then
|
||||
-- print('got buttons @4=' ..data[4] ..' @6=' ..data[6])
|
||||
|
||||
if data[4] == 1 or data[4] == 2 then
|
||||
|
@ -31,11 +41,22 @@ function onCanRx(bus, id, dlc, data)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if id == IDRIVE_ROTARY then
|
||||
if data[5] == 0x80 then
|
||||
print('rotary turned right ' ..data[4] ..' clicks')
|
||||
end
|
||||
|
||||
if data[5] == 0x7f then
|
||||
print('rotary turned left ' ..255 - data[4] ..' clicks')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function onTick()
|
||||
-- wake up, need to send once every 1.5 second but we can send more often because why not
|
||||
txCan(1, 0x563, 0, { 3 })
|
||||
txCan(1, 0x202, 0, { brighness * 16 + 0xd })
|
||||
txCan(1, IDRIVE_HEARBEAT, 0, { 3 })
|
||||
txCan(1, IDRIVE_BRIGHTNESS, 0, { brighness * 16 + 0xd })
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue