If you are looking for some code for the i2c controller PCB... I wrote a program for a Teensy 3.2 that takes the i2c input and generates a keyboard HID output via the teensy usb port. It's a work in progress so I have to tweak some things... I have put it out here to help anyone else who is trying to interface to this board.
Dale
Code: Select all
#include "Arduino.h"
#include <i2c_t3.h>
#include <usb_keyboard.h>
byte port_a;
byte port_b;
//The setup function is called once at startup of the sketch
void setup()
{
// Add your initialization code here
Wire.begin(I2C_MASTER,0x20,I2C_PINS_18_19,I2C_PULLUP_INT,I2C_RATE_100); // wake up I2C bus
Wire.beginTransmission(0x20);
Wire.write(0x0c);
Wire.write(0xFF);
Wire.endTransmission();
//Wire.endTransmission(0x20);
Wire.beginTransmission(0x20);
Wire.write(0x0d);
Wire.write(0xFF);
Wire.endTransmission();
pinMode(13, OUTPUT);
//digitalWrite(13, HIGH);
//Serial.begin(9600);
}
// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
Wire.beginTransmission(0x20);
Wire.write(0x12);
Wire.endTransmission();
Wire.requestFrom(0x20, 1);
port_a = Wire.read();
Wire.beginTransmission(0x20);
Wire.write(0x13);
Wire.endTransmission();
Wire.requestFrom(0x20, 1);
port_b = Wire.read();
if (!((1 << 2) & port_a)) //B
usb_keyboard_press(KEY_L,0);
if (!((1 << 3) & port_a)) //A
usb_keyboard_press(KEY_P,0);
//if (!((1 << 4) & port_a)) //R2
if (!((1 << 5) & port_a)) //R1
usb_keyboard_press(KEY_E,0);
if (!((1 << 6) & port_a)) //X
usb_keyboard_press(KEY_K,0);
if (!((1 << 7) & port_a)) //Y
usb_keyboard_press(KEY_O,0);
if (!((1 << 0) & port_b)) //UP
usb_keyboard_press(KEY_W,0);
if (!((1 << 1) & port_b)) //L1
usb_keyboard_press(KEY_Q,0);
//if (!((1 << 2) & port_b)) //L2
if (!((1 << 3) & port_b)) //LEFT
usb_keyboard_press(KEY_A,0);
if (!((1 << 4) & port_b)) //RIGHT
usb_keyboard_press(KEY_D,0);
if (!((1 << 5) & port_b)) //DOWN
usb_keyboard_press(KEY_S,0);
if (!((1 << 6) & port_b)) //SELECT
usb_keyboard_press(KEY_Z,0);
if (!((1 << 7) & port_b)) //START
usb_keyboard_press(KEY_X,0);
delay(200);
}