Add spinner sensitivity setting.

This commit is contained in:
sorgelig 2020-02-20 23:39:53 +08:00
parent 9c4cfcbe71
commit c7314ba0bd
1 changed files with 16 additions and 13 deletions

View File

@ -67,6 +67,11 @@
//#define BEETLE //#define BEETLE
// Adjust the sensitivity of spinner. >= 1
// For arduino shield spinner set it to 1.
// For 600PPR spinners set it to 8..10 for comfortable control.
#define SPINNER_SENSITIVITY 10
// serial for special support in MiSTer // serial for special support in MiSTer
const char *gp_serial = "MiSTer PD/SP v1"; const char *gp_serial = "MiSTer PD/SP v1";
@ -180,20 +185,18 @@ void sendState(byte idx)
{ {
static int prev[2] = {0,0}; static int prev[2] = {0,0};
int16_t diff = drvpos[idx] - prev[idx]; int16_t diff = drvpos[idx] - prev[idx];
if(diff)
if(diff > SPINNER_SENSITIVITY)
{ {
if(diff>0) newR = 1;
{ prev[idx] += SPINNER_SENSITIVITY;
newR = 1; //Serial.println("RIGHT");
prev[idx]++; }
//Serial.println("RIGHT"); else if(diff < -SPINNER_SENSITIVITY)
} {
else newL = 1;
{ prev[idx] -= SPINNER_SENSITIVITY;
newL = 1; //Serial.println("LEFT");
prev[idx]--;
//Serial.println("LEFT");
}
} }
} }
} }