Teensy + BMW E65 iDrive Controller

Status
Not open for further replies.

kubosh

New member
Hi Guys,
I'm working on idrive controller mod from my BMW E65 using Teensy 3.2.
I already did electrical and mechanical test so I'm sure that everything is up and running.

Button 0 (PIN0) -> Function key
Button 1 (PIN1) -> Menu key
Button 6 (PIN6) -> Knob key

and now arrows:
UP (Button 4 & 5)
DOWN (Button 2 & 3)
LEFT (Button 3 & 4)
RIGHT (Button 2 & 5)

Pins 7 & 8 are for rotary encoder (not configure but works)
Main case is when I push up knob button 4 & 5 should be as "KEY_UP", but I'm not sure how to conifgure two "buttons" to one function.

Here is a code:


#include <Bounce.h>

// Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10); // 10 ms debounce time is appropriate
Bounce button2 = Bounce(2, 10); // for most mechanical pushbuttons
Bounce button3 = Bounce(3, 10);
Bounce button4 = Bounce(4, 10); // if a button is too "sensitive"
Bounce button5 = Bounce(5, 10); // you can increase this time.
Bounce button6 = Bounce(6, 10);

void setup() {
// Configure the pins for input mode with pullup resistors.
// The pushbuttons connect from each pin to ground. When
// the button is pressed, the pin reads LOW because the button
// shorts it to ground. When released, the pin reads HIGH
// because the pullup resistor connects to +5 volts inside
// the chip.
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
}

void loop() {
// Update all the buttons. There should not be any long
// delays in loop(), so this runs repetitively at a rate
// faster than the buttons could be pressed and released.
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();

// Check each button for "falling" edge.
// falling = high (not pressed - voltage from pullup resistor)
// to low (pressed - button connects pin to ground)
if (button0.fallingEdge()) {
Keyboard.press(KEY_ENTER);
Keyboard.release(KEY_ENTER);
}
if (button1.fallingEdge()) {
Keyboard.press(KEY_ESC);
Keyboard.release(KEY_ESC);
}
if (button4.fallingEdge() && button5.fallingEdge()) {
Keyboard.press(KEY_UP);
Keyboard.release(KEY_UP);
}
if (button2.fallingEdge() && button3.fallingEdge()) {
Keyboard.press(KEY_DOWN);
Keyboard.release(KEY_DOWN);
}
if (button3.fallingEdge() && button4.fallingEdge()) {
Keyboard.press(KEY_LEFT);
Keyboard.release(KEY_LEFT);
}
if (button2.fallingEdge() && button5.fallingEdge()) {
Keyboard.press(KEY_RIGHT);
Keyboard.release(KEY_RIGHT);
}
if (button6.fallingEdge()) {
Keyboard.press(KEY_SPACE);
Keyboard.release(KEY_SPACE);
}

}

Can you help me a little bit how can I setup it please?

 
Last edited:
Code:
if (button4.fallingEdge() && button5.fallingEdge()) {
Keyboard.press(KEY_SPACE);
Keyboard.release(KEY_SPACE);
}

Shouldn't you KEY_UP instead of KEY_SPACE for 4 and 5?

Code:
and now arrows:
[COLOR="#FF0000"]UP (Button 4 & 5)[/COLOR]
DOWN (Button 2 & 3)
LEFT (Button 3 & 4)
RIGHT (Button 2 & 5)
 
Yeah, My bad i took "test" version of the code.
I did some changes to be sure about issues.
Btw now my topic is updated to correct code ;)

Thanks anyway :)
 
Status
Not open for further replies.
Back
Top