AlanChatham / UnoJoy

UnoJoy! allows you to easily turn an Arduino Uno (or Mega or Leonardo) into a PS3-compatible USB game controller
GNU General Public License v3.0
482 stars 130 forks source link

Logitech G2x shifter interfacing with MegaJoy #35

Open MineAngerBR opened 4 years ago

MineAngerBR commented 4 years ago

Hello, i'm trying to interface analog-based H-shifters, just like the common and available shifters from Logitech for the G series (G25, G27, and Logitech Driving Force Shifter for the G29/G920) I'm not a programmer in any means or stretch, just one enthusiast wanting to build something more integrated, so i don't need to have multiple boards for each part of the simulation mechanisms. With some code from the youtuber AMStudio, i got the basics of the interface (it actually works, changing the position of the analog axis activates the button), but it lags a lot (from 1,5 up to 5 seconds between shifts), while the other buttons work just as fast as they always worked, i would like to know how can i optimize it to shift faster

the file is for MegaJoy: MegaJoyArduinoG2xShifter.txt

AlanChatham commented 4 years ago

Hi!

Hmmm, if I had to guess, I might think that setting the input_pullup resistors on on your analog pins might be screwing up your analog reads?

My first suggestion would be to try a sketch that just outputs the values of your analog reads to the serial port without MegaJoy, to see if you're getting the sort of quick response on your shifter that you'd expect, so you can figure out if it's more of a problem with the electronics or the MegaJoy interface.

Hope this is helpful! -Chatham

On Tue, Jul 7, 2020, 10:21 AM MineAngerBR notifications@github.com wrote:

Hello, i'm trying to interface analog-based H-shifters, just like the common and available shifters from Logitech for the G series (G25, G27, and Logitech Driving Force Shifter for the G29/G920) I'm not a programmer in any means or stretch, just one enthusiast wanting to build something more integrated, so i don't need to have multiple boards for each part of the simulation mechanisms. With some code from the youtuber AMStudio, i got the basics of the interface (it actually works, changing the position of the analog axis activates the button), but it lags a lot (from 1,5 up to 5 seconds between shifts), while the other buttons work just as fast as they always worked, i would like to know how can i optimize it to shift faster

the file is for MegaJoy: MegaJoyArduinoG2xShifter.txt https://github.com/AlanChatham/UnoJoy/files/4886215/MegaJoyArduinoG2xShifter.txt

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlanChatham/UnoJoy/issues/35, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3JVMSAWBG7NTOMAQPSIDR2NKQPANCNFSM4OTC64EQ .

MineAngerBR commented 4 years ago

Hey Alan, thanks for answering me.

Yeah, i made a small sketch to test my analog reads and also to output as the gear selected, and they're being quick and responsive. And about the pullup resistors, i've removed that bit of code from the original sketch to test and the responses are still slow.

AlanChatham commented 4 years ago

Hm, the only thing that jumps out to me is the use of delay() in the code - I'm thinking that the way MegaJoy uses timers and interrupts may be interfering with those in a way that makes them take much longer? Try removing them and see what happens. If you're having issues with flickering, you might, instead of a delay, compare against a global value to make the code compare the shifter value across a couple of loops to make sure it's settled in a new position.

Hope it helps!

On Wed, Jul 8, 2020, 10:38 AM MineAngerBR notifications@github.com wrote:

Hey Alan, thanks for answering me.

Yeah, i made a small sketch to test my analog reads and also to output as the gear selected, and they're being quick and responsive. And about the pullup resistors, i've removed that bit of code from the original sketch to test and the responses are still slow.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AlanChatham/UnoJoy/issues/35#issuecomment-655659450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3JVO2R5P5TDGD463BTOTR2SVJ7ANCNFSM4OTC64EQ .

MineAngerBR commented 4 years ago

I removed the delay() to test, still no difference. The problem in MegaJoy isn't flickering, is the response time between moving the position in the XY axis, and the arduino "pressing" the correct button. All the buttons are okay and responding quickly, even the digital pins 3-8 when i pull them to GND with a jumper. Just the "XY-to-button" conversion is problematic.

AlanChatham commented 4 years ago

Hm. I'll poke around later today and try out your code - seems like an interesting puzzle....

On Wed, Jul 8, 2020, 11:29 AM MineAngerBR notifications@github.com wrote:

I removed the delay() to test, still no difference. The problem in MegaJoy isn't flickering, is the response time between moving the position in the XY axis, and the arduino "pressing" the correct button. All the buttons are okay and responding quickly, even the digital pins 3-8 when i pull them to GND with a jumper. Just the "XY-to-button" conversion is problematic.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AlanChatham/UnoJoy/issues/35#issuecomment-655684034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3JVNG57B3CDWHQKDA3ULR2S3KLANCNFSM4OTC64EQ .

MineAngerBR commented 4 years ago

Alright, i tried to optimize it messing with the "if-else" statements, but no change in the speed of the responses from the "XY-to-button" conversion, and the standard way (digital pin and ground) is still ok and working as quick as always