Controller PCB

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
Post Reply
User avatar
OrbitalPi
Posts: 38
Joined: Tue Oct 04, 2016 1:26 am
Location: London, UK
Has thanked: 20 times
Been thanked: 7 times

Controller PCB

Post by OrbitalPi » Wed Oct 05, 2016 5:38 am

Hi Guys,

I'm just kinda dipping my toe into the Gameboy Zero project and I need a bit of advice when it comes the button PCB. I unfortunately missed out on Helder's All in One PCB so I'm looking at other ideas.

The one that Kitsch Bent does (Link Below)
http://store.kitsch-bent.com/product/ex ... 2c-version

Would I still need the teensy controller with this or not? As Kitsch Bent do really put alot of info on there for people who are new to it.

Any help is much appreciated :)
Not all Those Who Wander Are Lost

chaosratt
Posts: 123
Joined: Sat Aug 20, 2016 7:36 pm
Has thanked: 12 times
Been thanked: 33 times

Re: Controller PCB

Post by chaosratt » Wed Oct 05, 2016 9:02 am

That is an I2C board. If you do not know what I2C is or how to use it, do not get that board, as to my knowledge there are no tutorials available on it.

What you need is one of the many "common ground" boards available here and on ebay. Kitch has one too: http://store.kitsch-bent.com/product/co ... button-pcb

These can be wired directly to the pi, adafruit has a guide for it for one of her retropie kits (this one I think), or you can use either a teensy or arduino (Leonardo clone) to 'fake' the keyboard/gamepad imputs.

User avatar
Ganreizu
Posts: 552
Joined: Thu May 05, 2016 8:20 am
Has thanked: 168 times
Been thanked: 97 times

Re: Controller PCB

Post by Ganreizu » Wed Oct 05, 2016 11:13 am

I would just wait for a second round of helder's AIO version 2.0. Cuts so much time and space in the case that by the time you finish it normally you'd have it received and assembled anyway and you can get a bigger battery.

User avatar
OrbitalPi
Posts: 38
Joined: Tue Oct 04, 2016 1:26 am
Location: London, UK
Has thanked: 20 times
Been thanked: 7 times

Re: Controller PCB

Post by OrbitalPi » Wed Oct 05, 2016 2:31 pm

Thanks guys. I think I'll just wait for Helder's next board. Too much faffing about otherwise and it gives me time to get the rest of the parts all together :)
Not all Those Who Wander Are Lost

User avatar
Tango
Posts: 15
Joined: Mon Nov 14, 2016 1:47 pm
Has thanked: 2 times
Been thanked: 6 times

Re: Controller PCB

Post by Tango » Fri Dec 09, 2016 7:55 pm

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);
}


User avatar
Helder
Trailblazer
Trailblazer
Posts: 2985
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1459 times
Been thanked: 3114 times

Re: Controller PCB

Post by Helder » Sat Dec 10, 2016 11:26 am

Tango wrote: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);
}

So you still need a Teensy? And instead of using the USB on the Pi you use the I2C pins on the Pi? I guess it works out well if you need to have that free USB port and don't use a hub.
Chat with me and other members On Discord

Don't contact me about obtaining my board files (as you will not get them). If my Boards or PCB Kits are sold out, they will be restocked as soon as I can get them and there is demand for them. You can join the mailing list on my Website to be notified when they are available.


Helder's Game Tech Website

We will not support any cloned work so don't come to us with technical issues to resolve, go talk to the cloner for help.

User avatar
Tango
Posts: 15
Joined: Mon Nov 14, 2016 1:47 pm
Has thanked: 2 times
Been thanked: 6 times

Re: Controller PCB

Post by Tango » Mon Dec 12, 2016 12:12 pm

The program above is for an Arduino (in my case a Teensy 3.2) where the pcb is connected via i2c (cuts down on the wiring).

I don't see why you couldn't use the Raspberry pi i2c bus also... you would have to write a daemon that ran on the pi to convert the i2c data into keyboard commands... it's certainly doable.

Updated Code... the old code above seemed to hang and not work very well... so tweaked a bit and seems to work a bit better.
The i2c_t3 library you can get from https://github.com/nox771/i2c_t3 as discussed here https://forum.pjrc.com/threads/21680-Ne ... or-Teensy3

Code: Select all

#include "Arduino.h"
#include <i2c_t3.h>

byte port_a;
byte port_b;

void setup()
{
	  Keyboard.begin();
	  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.beginTransmission(0x20);
	  Wire.write(0x0d);
	  Wire.write(0xFF);
	  Wire.endTransmission();

	  pinMode(13, OUTPUT);
	  digitalWrite(13, HIGH); //Comment out to reduce power consumption
}

void loop()
{
	  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
		  Keyboard.press('l');

	  if (!((1 << 3) & port_a)) //A
		  Keyboard.press('p');

	  //if (!((1 << 4) & port_a)) //R2

	  if (!((1 << 5) & port_a)) //R1
		  Keyboard.press('e');

	  if (!((1 << 6) & port_a)) //X
		  Keyboard.press('k');

	  if (!((1 << 7) & port_a)) //Y
		  Keyboard.press('o');

	  if (!((1 << 0) & port_b)) //UP
		  Keyboard.press('w');

	  if (!((1 << 1) & port_b)) //L1
		  Keyboard.press('q');

	  //if (!((1 << 2) & port_b)) //L2

	  if (!((1 << 3) & port_b)) //LEFT
		  Keyboard.press('a');

	  if (!((1 << 4) & port_b)) //RIGHT
		  Keyboard.press('d');

	  if (!((1 << 5) & port_b)) //DOWN
		  Keyboard.press('s');

	  if (!((1 << 6) & port_b)) //SELECT
		  Keyboard.press('z');

	  if (!((1 << 7) & port_b)) //START
		  Keyboard.press('x');

	  delay(200);
	  Keyboard.releaseAll();
}
Dale

majestic
Posts: 17
Joined: Sat Dec 03, 2016 4:11 pm
Has thanked: 5 times

Re: Controller PCB

Post by majestic » Tue Dec 13, 2016 9:25 am

I bought this board thinking it would make a gbz build easier and its made it a nightmare. All hooked up to the pi and nothing. Ive looked for 3months and tried all i can. Gutted its come to a halt.

User avatar
Tango
Posts: 15
Joined: Mon Nov 14, 2016 1:47 pm
Has thanked: 2 times
Been thanked: 6 times

Re: Controller PCB

Post by Tango » Sat Dec 17, 2016 4:10 am

majestic wrote:I bought this board thinking it would make a gbz build easier and its made it a nightmare. All hooked up to the pi and nothing. Ive looked for 3months and tried all i can. Gutted its come to a halt.
You can certainly use the i2c bus on the Pi... but you will have to write some code on the pi to translate the i2c commands from the PCB. I elected to use a Teensy as I am also using it for shutdown and battery monitoring.Ma

@Majestic Take a look here http://www.sudomod.com/forum/viewtopic.php?f=8&t=1989 It's not an exact driver as it also uses the GPIO on the pi, but its a start. I chose the Teensy route as it was easier to interface to and I have some coding knowledge with the teensy.

Dale

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest