You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, now that I have finally compiled the project I'm trying to use a piezoelectric (like this one) instead of regular buttons.
The thing is, this piezoelectric send voltage through its digital output only when touched, so connecting the GPIOs to the DO right now only introduce noise, as they are pull up at 3.3V. The piezoelectric I'm using works fine with 5V and 3.3V so I can power it using VBUS or VSYS.
To try to convert the pins to pull down I have changed this line
And I have identified in headers/gamepad.h, pressedButton (so far I'm trying to use B1-4 pins only) which I think is the method I have to change to get the desired behavior.
return (~state.buttons& ~mask) == ~mask; // Why not, the others didn't work xD
But the closer I have been is getting from B1 to B4 looping instantly between pressed-not pressed in hardwaretester.com/gamepad (which has an SSL issue right now) and then freezing to 1 if I tap the piezoelectric, and going back to looping if I tap again. Almost the desired behavior, but not exactly.
From what I've learn:
With pull up GPIOs, state.buttons represents the mapping of the GPIOs. I guess 1 when we press a button, 0 if not
mask is defined in other file (which I don't remember right now) where you tell to each GPIO its mask, for example I remember that B1 is 1U << 1. Which I think is 0000 (seven times) 0010
Therefore, in the default behavior when the button is pressed, the state.buttons became (If only B1 is pressed) 0000 (seven times) 0010 and when doing the bitwise with mask then, et boila, state.buttons & mask == mask
I'm missing something, because as I changed from pull up to pull down, my common sense tell me that I should only need to invert the mask, but doing ~mask didn't work...
Maybe should I also invert the value in these functions? So instead of 0, the value is 1?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, now that I have finally compiled the project I'm trying to use a piezoelectric (like this one) instead of regular buttons.
The thing is, this piezoelectric send voltage through its digital output only when touched, so connecting the GPIOs to the DO right now only introduce noise, as they are pull up at 3.3V. The piezoelectric I'm using works fine with 5V and 3.3V so I can power it using VBUS or VSYS.
To try to convert the pins to pull down I have changed this line
GP2040-CE/src/gp2040.cpp
Line 216 in b60551e
To
gpio_pull_down(pin)
And I have identified in headers/gamepad.h, pressedButton (so far I'm trying to use B1-4 pins only) which I think is the method I have to change to get the desired behavior.
I have tried multiple iterations of
GP2040-CE/headers/gamepad.h
Lines 64 to 66 in b60551e
Like
But the closer I have been is getting from B1 to B4 looping instantly between pressed-not pressed in hardwaretester.com/gamepad (which has an SSL issue right now) and then freezing to 1 if I tap the piezoelectric, and going back to looping if I tap again. Almost the desired behavior, but not exactly.
From what I've learn:
0000 (seven times) 0010
0000 (seven times) 0010
and when doing the bitwise withmask
then, et boila,state.buttons & mask == mask
I'm missing something, because as I changed from pull up to pull down, my common sense tell me that I should only need to invert the mask, but doing ~mask didn't work...
Maybe should I also invert the value in these functions? So instead of 0, the value is 1?
GP2040-CE/src/drivers/xinput/XInputDriver.cpp
Line 272 in b60551e
Beta Was this translation helpful? Give feedback.
All reactions