mr.Spinner: option to disable physical paddle support.

This commit is contained in:
sorgelig 2020-03-04 23:58:38 +08:00
parent 481b0349d9
commit 258467eda8
2 changed files with 29 additions and 7 deletions

View File

@ -77,6 +77,10 @@
// Comment it to dosable paddle emulation by spinner
#define PADDLE_EMU
// Comment it to disable the paddle (potentiomenter) support.
// Even if disabled, paddle can be emulated by spinner.
#define PADDLE_SUPPORT
// Optional parameter. Leave it commented out.
//#define SPINNER_SENSITIVITY 1
@ -113,11 +117,14 @@
// Additionally serial number is used to differentiate arduino projects to have different button maps!
const char *gp_serial = "MiSTer-S1 Spinner";
#include <ResponsiveAnalogRead.h>
#include "Gamepad.h"
Gamepad_ Gamepad[DEV_NUM];
ResponsiveAnalogRead analog[2] = {ResponsiveAnalogRead(pdlpin[0], true),ResponsiveAnalogRead(pdlpin[1], true)};
#ifdef PADDLE_SUPPORT
#include <ResponsiveAnalogRead.h>
ResponsiveAnalogRead analog[2] = {ResponsiveAnalogRead(pdlpin[0], true),ResponsiveAnalogRead(pdlpin[1], true)};
#endif
int8_t pdlena[2] = {0,0};
uint16_t drvpos[2];
@ -180,8 +187,11 @@ void setup()
pdlena[idx] = 0;
pinMode(pbtnpin[idx], INPUT_PULLUP);
pinMode(pdlpin[idx], INPUT);
#ifdef PADDLE_SUPPORT
analog[idx].setSnapMultiplier(snap);
analog[idx].setActivityThreshold(thresh);
#endif
}
}
@ -194,7 +204,10 @@ void loop()
for(int idx=0; idx<DEV_NUM; idx++)
{
#ifdef PADDLE_SUPPORT
analog[idx].update();
#endif
rep.buttons = 0;
rep.paddle = 0;
rep.spinner = 0;
@ -215,7 +228,9 @@ void loop()
if(pdlena[idx])
{
rep.paddle = (analog[idx].getValue()>>2);
#ifdef PADDLE_SUPPORT
rep.paddle = (analog[idx].getValue()>>2);
#endif
}
else
{

View File

@ -38,10 +38,17 @@ Connector 2:
| 7 | VCC | VCC | VCC |
| 8 | GND | GND | GND |
### Notes
1. You need to set correct SPINNER_PPR value in source according to used spinner.
2. Spinner emulates the paddle as well, So bassically the spinner is the only you need for both spinner and paddle control. If you don't need paddle emulation then comment out (or remove) the line ```#define PADDLE_EMU```
3. Adapter switches to paddle by pressing the button on paddle. It switches to spinner if spinner is moved or spinner button has been pressed.
### Source parameters
Firmware has several definitions to tweak for best experience:
1. BEETLE: support for miniature board version with USB plug integrated. Enable it if you use Beetle board - it uses other pins.
2. SPINNER_PPR: set the correct PPR value according to your spinner for correct work.
3. PADDLE_EMU: enable paddle emulation by spinner if defined. So bassically the spinner is the only you need for both spinner and paddle control.
4. PADDLE_SUPPORT: support for physical paddles. Even if this option is disabled, the paddle emulation mode by spinner will continue to work.
5. DEV_NUM: set it to 2 or 1. If you integrate the board into some controller's case with only single spinner/paddle, then 1 would be better.
### Dependencies
If PADDLE_SUPPORT is defined, then additional **ResponsiveAnalogRead** library is required. You can install it in library manager function of Arduino IDE.
## License
This project is licensed under the GNU General Public License v3.0.