keep pressing state for rapid fire button

This commit is contained in:
2020-11-04 00:47:02 +09:00
parent 3645548cdf
commit 5e431ffdea
7 changed files with 478 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
int loopCount = 0;
int state = 0;
int rapidFireTable[RapidFireTableSize];
bool rapidPressState = 0;
int index = 0;
int val = 1;
@@ -40,9 +41,11 @@ void perms() {
if(val == 0){
if (rapidFireTable[index] == 1){
SwitchControlLibrary().PressButtonA();
rapidPressState = true;
}
if (rapidFireTable[index] == 2){
SwitchControlLibrary().ReleaseButtonA();
rapidPressState = false;
}
}
index = (index + 1) % RapidFireTableSize;
@@ -121,10 +124,13 @@ void loop()
val = digitalRead(2);
if(prevVal == 1 && val == 0){
SwitchControlLibrary().PressButtonA();
rapidPressState = true;
index = 1;
}
else if(prevVal == 0 && val == 1){
SwitchControlLibrary().ReleaseButtonA();
if(rapidPressState){
SwitchControlLibrary().ReleaseButtonA();
}
}
prevVal = val;