Gamepad --> PC --> PyBoard

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Adixylian
Posts: 13
Joined: Thu Jan 21, 2016 7:21 pm

Gamepad --> PC --> PyBoard

Post by Adixylian » Wed Mar 02, 2016 1:33 pm

Greetings ya all.

So I am using gamepad with 2 analog "sticks". I am sending that signal via USB to PC, and from PC via usb to PyBoard.
The program works, I'm using bytearray and that struct.pack/unpack. It's perfectly fine.
But some of the buttons cause Keyboard Interrupt. Is it possible to turn the interrupts off?
I know that should be possible as it is an elementary thing in programming microcontrollers.

Thanks for help :)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Gamepad --> PC --> PyBoard

Post by Roberthh » Wed Mar 02, 2016 2:13 pm

Hello, I do not exactly know what you are looking form, but in class usb_vcp, usb_vcp.setinterrupt(-1) would disable Ctrl-C as interrupt character on the USB interface.

Code: Select all

import pyb
usb_vcp = pyb.USB_VCP()
usb_vcp.setinterrupt(-1)
To revert that, call setinterrupt with a value of 3 (= Ctrl-C)
Regards

Adixylian
Posts: 13
Joined: Thu Jan 21, 2016 7:21 pm

Re: Gamepad --> PC --> PyBoard

Post by Adixylian » Wed Mar 02, 2016 2:55 pm

Yes, exatly that.
Thank you, that helped a lot :)

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Gamepad --> PC --> PyBoard

Post by kfricke » Wed Mar 02, 2016 4:44 pm

Hello! How about this?

linuxcircle
Posts: 5
Joined: Mon Nov 07, 2016 2:50 am

Re: Gamepad --> PC --> PyBoard

Post by linuxcircle » Wed Nov 16, 2016 11:22 pm

How do I connect a generic SNES USB PC gamepad directly into pyboard?
I have the current setup:
USB gamepad -> usb female breakout -> pyboard -> PC via UART (to read values via screen /dev/ttyACM0)

USB Breakout wiring between the pad and pyboard:
USB red wire to V3.3
USB ground wire to to GND
D+ to X10
D- to X9

Is there a way to read the gamepad events via UART and just print the byte codes on the screen? Or is it not supposed to be connected that way?

I was able to read and detect USB on PC: Arch / Raspbian and read button presses using various Python 3 libraries like "input",
but without any OS on the pyboard is it possible to get external peripherals (mouse/gamepad/keyboard) working with MicroPython?

Post Reply