Look cool CAN bus joystick

Hardware inside and outside of the ECU
Post Reply
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Look cool CAN bus joystick

Post by AndreyB »

BMW 6582 9286699-02 https://forum.canny.ru/viewtopic.php?id=822

Code: Select all

idrive 6582 9286699-02      500 кбит/сек

старт
отправка сообщений
1.   202 fd 00   - 1 раз подсветка
2.   50e         - каждые 4 сек
3.   273 3d 01 00 00 ff 00 1e 01    -1 раз активация колеса

кнопки

media -     267    E1    FD    0C    00    C0    10          d3 01 нажата, 02 долгое нажатие, d2 счетчик, d5 какая кнопка
radio -    267    E1    FD    6C    00    C0    08              
tel   -        267    E1    FD    A0    00    C0    40           
nav   -       267    E1    FD    B0    00    C0    20           
back  -      267    E1    FD    BD    00    C0    02           
option-      267    E1    FD    EC    00    C0    04           
menu  -     267    E1    FD    F6    00    C0    01           

колесо наклоны

вперед  -      267    E1    FD    1C    00    DD    01        d3 11 нажата, 12 долгое нажатие,d2 счетчик, d5 какая кнопка
назад   -       267    E1    FD    36    00    DD    01             41         42   
влево   -       267    E1    FD    48    00    DD    01             81         82   
вправо  -      267    E1    FD    4B    00    DD    01             21         22
нажатие -     267    E1    FD    16    00    DE    01             01          02

колесо

по часовой      -        264    225    253    12    0    1    30    DEC d3 плюс 1 по часовой, до 255, после d4 плюс 1, d3 с нуля    , d2 счетчик   
против часовой  -       264    225    253    228    0    1    30    DEC d3 минус 1 ,пример 0, 255, 254       
                        264    225    253    220    0    0    158    ошибка    при долгом вращении обновить 273 3d 01 00 00 ff 00 1e 01
does it use АМР 968813-9 BMW8380696 09?
Attachments
bmw media switch controller back.jpg
bmw media switch controller back.jpg (356.72 KiB) Viewed 3396 times
bmw media switch controller.jpg
bmw media switch controller.jpg (292.19 KiB) Viewed 3396 times
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

Much cheaper than 3K208-2RN3AG :)

Original post seems to be https://www.bimmerfest.com/threads/k-can2-messages-to-wake-a-cic-idrive-controller.890419/#post-13182279 mentioning 9317695

1 +12v 1 |*|
2 -GND 2 |*|
3 CAN HIGH 3 |*|
4 CAN LOW 4 |* |
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

My 9286699 is alive
image.png
image.png (76.38 KiB) Viewed 3137 times
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

AndreyB wrote:
Wed May 04, 2022 5:12 pm
does it use АМР 968813-9 BMW8380696 09?
Jimmy, Kirby, any interest to try 968813-9 from aliexpress they seem to have plenty?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
kjn260
Posts: 9
Joined: Sun Nov 07, 2021 10:59 pm

Re: Look cool CAN bus joystick

Post by kjn260 »

RE: https://rusefi.com/forum/viewtopic.php?p=45788#p45788

learned some lua, did some code. Please report back.

Code: Select all

-- BMW iDrive LUA. Witten for BMW #ZE931769502
-- 5 Button with L/R Joystick.
 
-- Timer
t_heartbeat = Timer.new()
 
-- CAN Rx Channels
IDRIVE_BUTTONS = 0x267
IDRIVE_ROTARY = 0x264
 
-- CAN Tx Channels
IDRIVE_BRIGHTNESS = 0x202
IDRIVE_HEARBEAT = 0x560
IDRIVE_ROTARY_INIT = 0x273
 
 
-- Init
brighness = 0
previous_button = 0
current_button = 0
current_btn_state = 0
previous_btn_state = 0
 
 
-- Tables
button_names = { }
button_names[0x01] = "Menu"
button_names[0x02] = "Back"
button_names[0x04] = "Option"
button_names[0x08] = "Audio"
button_names[0x40] = "Tel"
button_names[0xDE] = "Knob"
button_names[0xDD] = "Knob Tilt"
 
 
button_states = { }
button_states[0x00] = "Released"
button_states[0x01] = "Pushed"
button_states[0x02] = "Held"
button_states[0x21] = "Right"
button_states[0x22] = "Held Right"
button_states[0x81] = "Left"
button_states[0x82] = "Held Left"
 
 
 
 
 
canRxAdd(IDRIVE_ROTARY) -- add Rx Handler for Rotary
canRxAdd(IDRIVE_BUTTONS) -- add Rx Handler for Buttons
 
 
setTickRate(50) -- set tick rate to 50hz
 
-- One time rotary initialisation
 
txCan(1, IDRIVE_ROTARY_INIT, 0, { 0x1D, 0xE1, 0x00, 0xF0, 0xFF, 0x7F, 0xDE, 0x04 })
 
 
function onCanRx(bus, id, dlc, data)
 
 
	if id == IDRIVE_BUTTONS then
 
		if data[5] == 0xc0 then
			-- buttons
			-- print('button')
 
			-- update current and previous
			previous_button = current_button
			current_button = data[6]
 
			if (previous_button == current_button) then
				-- signal for the same button
 
				-- update the state
				previous_btn_state = current_btn_state
				current_btn_state = data[4]
 
				if (current_btn_state ~= previous_btn_state) then
					-- if the state has changed
 
					print(button_names[data[6]] ..' was ' ..button_states[data[4]]) -- print the state
 
				end
 
			else
				-- new button
 
				previous_btn_state = 0 -- clear the previous state
				current_btn_state = data[4] -- write the new state
 
				print(button_names[data[6]] ..' was ' ..button_states[data[4]]) -- print the state
 
			end
 
		end
 
		if data[5] == 0xde or data[5] == 0xdd then
 
			-- print('knob')
			-- knob push or tilt
 
			-- update current and previous
			previous_button = current_button
			current_button = data[5]
 
			if (previous_button == current_button) then
				-- signal for the same button
 
				-- update the state
				previous_btn_state = current_btn_state
				current_btn_state = data[4]
 
				if (current_btn_state ~= previous_btn_state) then
					-- if the state has changed
 
					print(button_names[data[5]] ..' was ' ..button_states[data[4]]) -- print the state
 
				end
 
			else
				-- new button
 
				previous_btn_state = 0 -- clear the previous state
				current_btn_state = data[4] -- write the new state
 
				print(button_names[data[5]] ..' was ' ..button_states[data[4]]) -- print the state
 
			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()
 
 
	-- iDrive heartbeat code - every 1000ms
 
	if t_heartbeat : getElapsedSeconds() > 1 then
 
		txCan(1, IDRIVE_HEARBEAT, 0, { 0x00, 0x00, 0x00, 0x00, 0x57, 0x2F, 0x00, 0x60 })
 
		txCan(1, 0x202, 0, { 0xff })
 
		t_heartbeat : reset()
 
	end
 
 
end
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

kjn260 wrote:
Mon Jul 04, 2022 11:19 am
learned some lua, did some code. Please report back.
Thank you!!!

Your version got the knob to function on my 9286699-02 but it's raising some errors looks like no button name for some cases? Can you please add 'nil' value handling?

Code: Select all

2022-08-12_16_17_14_276: EngineState: LUA: rotary turned right 0 clicks
2022-08-12_16_17_14_355: EngineState: LUA: rotary turned right 1 clicks
2022-08-12_16_17_14_355: EngineState: LUA: rotary turned right 2 clicks
2022-08-12_16_17_14_456: EngineState: LUA CAN RX error [string "-- BMW iDrive LUA. Witten for BMW #ZE93176950..."]:128: attempt to concatenate a nil value (field '?')
2022-08-12_16_17_14_662: EngineState: LUA: Knob Tilt was Released
2022-08-12_16_17_14_862: EngineState: LUA CAN RX error [string "-- BMW iDrive LUA. Witten for BMW #ZE93176950..."]:118: attempt to concatenate a nil value (field '?')
2022-08-12_16_17_15_063: EngineState: LUA: Knob was Pushed
2022-08-12_16_17_15_265: EngineState: LUA: Knob Tilt was Released
2022-08-12_16_17_15_265: EngineState: LUA: Knob was Released
2022-08-12_16_17_15_362: EngineState: LUA CAN RX error [string "-- BMW iDrive LUA. Witten for BMW #ZE93176950..."]:128: attempt to concatenate a nil value (field '?')
2022-08-12_16_17_15_463: EngineState: LUA: Knob Tilt was Released
2022-08-12_16_17_15_563: EngineState: LUA CAN RX error [string "-- BMW iDrive LUA. Witten for BMW #ZE93176950..."]:118: attempt to concatenate a nil value (field '?')
2022-08-12_16_17_15_665: EngineState: LUA: Knob was Pushed
2022-08-12_16_17_15_764: EngineState: LUA: Knob was Released
2022-08-12_16_17_15_865: EngineState: LUA: Knob Tilt was Released
I've improved https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/bmw-idrive.txt with your knob initialization https://github.com/rusefi/rusefi/commit/ef123e7f64a07c1a6e616f4c715b3474fc92db34 and https://github.com/rusefi/rusefi/commit/2aa1e13c0b228c8b8a7be3a148a51070e32b5866

I think we better take the github pull request approach if you are interested to improve the official https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/bmw-idrive.txt

I know your snipped has removed it but for now my preference is to keep the brightness adjustment logic in the example.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Look cool CAN bus joystick

Post by AndreyB »

I have two kinds. Looks like yours is similar to the left one while the one on the right has four extra buttons (it also has an aftermarket wheel enlargement in order to look bigger than it is in reality: do not ask, that's how I got it I promise!!!)
Attachments
ZE931769501-left-9286699-02-right.jpeg
ZE931769501-left-9286699-02-right.jpeg (187.25 KiB) Viewed 2272 times
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply