opencardev / crankshaft

Crankshaft: A turnkey GNU/Linux solution that transforms a Raspberry Pi to an Android Auto head unit.
http://getcrankshaft.com
GNU General Public License v3.0
2.16k stars 262 forks source link

Attaching steering wheel button to the Pi #346

Closed agnoam closed 4 years ago

agnoam commented 5 years ago

Is there a way to activate the Google Assistant by my steering wheel voice command button ? I also have an answer and rejection call buttons in my steering wheel, can I use them too ?

image

toufou54 commented 5 years ago

Same for me, I have an ibus USB interface and nodejs. How can I interface it ?

gcharlie commented 5 years ago

I don't think this is something that can be addressed in the software and will vary vehicle to vehicle. Ultimately it's a hardware issue and the easiest way to make use of these buttons would be to trace the leads for the button and connect them to gpio pins. This is harder on newer vehicles that make use of more integrated pcb and fragile ribbon cables.

toufou54 commented 5 years ago

Hi, I wanted to know how to programaticely interface with AA and crankshaft. My USB interface coupled with node can interprete and decode ibus from my vehicle, I just don't want use gpio but addressing directly by soft. How can't I retrieve all crankshaft commands triggered by gpio ? I saw a lot of script named service.xxxx in opt but it seems not to be full commands. For example I already could launch the rearcam command when a capture ibus event from that car thru : crankshaft rearcam show | hide But how simulate AA navigation for example or Google voice activation ?

ryanjblajda commented 5 years ago

use an arduino, create a voltage divider to read the resistive SWC and connect it to your PI using USB and sending keyboard commands. That is what i am doing. I am still trying to figure out how to control the GPIO pins, but i think i will use a solid state relay (controlled by arduino) to connect the raspberry pi volume GPIO pins to ground.

priitpi commented 5 years ago

use an arduino, create a voltage divider to read the resistive SWC and connect it to your PI using USB and sending keyboard commands. That is what i am doing. I am still trying to figure out how to control the GPIO pins, but i think i will use a solid state relay (controlled by arduino) to connect the raspberry pi volume GPIO pins to ground.

I solved it same way. No need to mess with GPIO. With arduino HID project you can send keyboard media commands like volume up and down. https://github.com/NicoHood/HID

in arduino you can send command like this (with HID library added): Consumer.write(MEDIA_VOLUME_UP);

Then define key in triggerhappy.conf (boot -> crankshaft -> triggerhappy.conf) and add

KEY_VOLUMEUP 1 amixer -q sset 'Master' 5%+ KEY_VOLUMEUP 2 amixer -q sset 'Master' 5%+ KEY_VOLUMEDOWN 1 amixer -q sset 'Master' 5%- KEY_VOLUMEDOWN 2 amixer -q sset 'Master' 5%-

I think triggerhappy let's to define some keyboard combination aslo if you wish to skip setting it up acting as media keys.

meekys commented 5 years ago

Plenty of examples out there, I used this one as a starting point. https://www.instructables.com/id/Digispark-Volume-Control/ Then created another that did the whole voltage divider thing to figure out which button was pressed and send that command instead, then it's just like using the keyboard shortcuts in OpenAuto/Crankshaft.

Edit: Here's the implementation I use. https://github.com/meekys/swc_control/blob/master/swc_control.ino

ryanjblajda commented 5 years ago

use an arduino, create a voltage divider to read the resistive SWC and connect it to your PI using USB and sending keyboard commands. That is what i am doing. I am still trying to figure out how to control the GPIO pins, but i think i will use a solid state relay (controlled by arduino) to connect the raspberry pi volume GPIO pins to ground.

I solved it same way. No need to mess with GPIO. With arduino HID project you can send keyboard media commands like volume up and down. https://github.com/NicoHood/HID

in arduino you can send command like this (with HID library added): Consumer.write(MEDIA_VOLUME_UP);

Then define key in triggerhappy.conf (boot -> crankshaft -> triggerhappy.conf) and add

KEY_VOLUMEUP 1 amixer -q sset 'Master' 5%+ KEY_VOLUMEUP 2 amixer -q sset 'Master' 5%+ KEY_VOLUMEDOWN 1 amixer -q sset 'Master' 5%- KEY_VOLUMEDOWN 2 amixer -q sset 'Master' 5%-

I think triggerhappy let's to define some keyboard combination aslo if you wish to skip setting it up acting as media keys.

Plenty of examples out there, I used this one as a starting point. https://www.instructables.com/id/Digispark-Volume-Control/ Then created another that did the whole voltage divider thing to figure out which button was pressed and send that command instead, then it's just like using the keyboard shortcuts in OpenAuto/Crankshaft.

Edit: Here's the implementation I use. https://github.com/meekys/swc_control/blob/master/swc_control.ino

will this allow the volume controls to work outside of Android Auto? with the GPIO they only work when it's running correct?

malcolm-fendick commented 5 years ago

Just tested and it worked in and out of Android Auto.

ryanjblajda commented 5 years ago

awesome.

ryanjblajda commented 5 years ago

Just tested and it worked in and out of Android Auto.

did you remove the GPIO mapping? i just tried this and it doesnt seem to work. the other keyboard mappings seem to work 'H' brings me to the audio screen in the main menu for some reason, but it works, but the Media keys are not.

** i think i figured it out. i left blank lines in triggerhappy.conf just went back and read the top part where it says dont do that.

** so far im still not seeing it change via the arduino trying to control it. i am able to send commands directly when SSH'd in and see the update however.

malcolm-fendick commented 5 years ago

I'm using an Arduino Micro. The keyboard input is via the Arduino's USB connection which is independent of GPIO configurations.

ryanjblajda commented 5 years ago

I'm using an Arduino Micro. The keyboard input is via the Arduino's USB connection which is independent of GPIO configurations.

i am using an an Adafruit trinket, doing the same thing. using the same library. i wrote a basic sketch to just increment the volume as a test and i didnt see it working.

priitpi commented 5 years ago

I'm using an Arduino Micro. The keyboard input is via the Arduino's USB connection which is independent of GPIO configurations.

i am using an an Adafruit trinket, doing the same thing. using the same library. i wrote a basic sketch to just increment the volume as a test and i didnt see it working.

I'm also using Pro Micro which has 32U4 chip. Your device has different chip and probably isn't supported by HID project

You said before that you are still able to send keyboard commands. Maybe just try sending it as function keys or any other key that Trinket can send. Then configure triggerhappy.conf

e.g vol down = F7, vol up= F8 KEY_F8 1 amixer -q sset 'Master' 5%+ KEY_F8 2 amixer -q sset 'Master' 5%+ KEY_F7 1 amixer -q sset 'Master' 5%- KEY_F7 2 amixer -q sset 'Master' 5%-

ryanjblajda commented 5 years ago

I'm using an Arduino Micro. The keyboard input is via the Arduino's USB connection which is independent of GPIO configurations.

i am using an an Adafruit trinket, doing the same thing. using the same library. i wrote a basic sketch to just increment the volume as a test and i didnt see it working.

I'm also using Pro Micro which has 32U4 chip. Your device has different chip and probably isn't supported by HID project

You said before that you are still able to send keyboard commands. Maybe just try sending it as function keys or any other key that Trinket can send. Then configure triggerhappy.conf

e.g vol down = F7, vol up= F8 KEY_F8 1 amixer -q sset 'Master' 5%+ KEY_F8 2 amixer -q sset 'Master' 5%+ KEY_F7 1 amixer -q sset 'Master' 5%- KEY_F7 2 amixer -q sset 'Master' 5%-

it works fine, i plugged the trinket into my windows PC and it responded to the Media keys.

do you actually see the slider moving up and down on-screen when you send these commands?

ryanjblajda commented 5 years ago

just wanted to let anyone who cares know, this is working, i set up exactly as described using media keys and it works great.

iofirag commented 5 years ago

With arduino?

thrill85 commented 5 years ago

Doesnt have anyone an examplecode to impliment this for a can bus based SWC?