lucasnicolau / nespad

Automatically exported from code.google.com/p/nespad
0 stars 0 forks source link

slightly wrong check for pressed buttons on SNES-pad #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
in the "SNESpad_LED"-example I noticed that the LED for button A doesn't work 
and a look into the header revealed: 
#define SNES_A       0x100
#define SNES_X       0x200
#define SNES_L       0x400
#define SNES_R       0x800
So I tested it for A,X,L,R: all 4 are not working.

digitalWrite(5,  state & SNES_A );

I don't know the signature of the digitalWrite function but it seems that there 
is some implicit cast or an overflow wich prevents that 4 buttons (which are 
bits 9-12 in the 'state' variable) testing the value to 'greater than 0' before 
passing it to the function solves the problem:

digitalWrite(5, (state & SNES_A)>0 );

Anyway, this lib is great, it is easy to use and you have 12 buttons in no time 
:D thanks for publishing it.

Original issue reported on code.google.com by darktemp...@gmail.com on 6 Jan 2011 at 9:56

GoogleCodeExporter commented 8 years ago
ah, forgot to mention:
That might be the problem of S.MartelJr (comment #1 in issue #1).

Original comment by darktemp...@gmail.com on 6 Jan 2011 at 9:58

GoogleCodeExporter commented 8 years ago
I too noticed this issue, thank you for the solution.

Confirmed that is does indeed fix the solution;

digitalWrite(A, (state & SNES_A) > 0);
digitalWrite(X, (state & SNES_X) > 0);
digitalWrite(L, (state & SNES_L) > 0);
digitalWrite(R, (state & SNES_R) > 0);

Original comment by ashley.v...@gmail.com on 22 Apr 2015 at 9:26

GoogleCodeExporter commented 8 years ago
Thanks for submitting and solving bugs. :) I haven't touched this library since 
I made it but people have been making good use of it so it's mostly doing its 
job. I'll incorporate this and anything else that people have discovered while 
I move the project over to github (Google Code is closing down). I'll credit 
everyone as well.

Original comment by rah...@gmail.com on 26 Apr 2015 at 3:21