add button for rapid fire

This commit is contained in:
2020-09-08 20:24:36 +09:00
parent fc721f0537
commit c82c75997c

View File

@@ -6,14 +6,18 @@ int state = 0;
int table[40] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int table[40] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int index = 0; int index = 0;
void perms() { int val = 1;
if (table[index] == 1){ int prevVal = 1;
SwitchControlLibrary().PressButtonA();
}
if (table[index] == 2){
SwitchControlLibrary().ReleaseButtonA();
}
void perms() {
if(val == 0){
if (table[index] == 1){
SwitchControlLibrary().PressButtonA();
}
if (table[index] == 2){
SwitchControlLibrary().ReleaseButtonA();
}
}
index = (index + 1) % 40; index = (index + 1) % 40;
} }
/* /*
@@ -34,11 +38,21 @@ void setup()
SwitchControlLibrary(); SwitchControlLibrary();
MsTimer2::set(1, perms); MsTimer2::set(1, perms);
MsTimer2::start(); MsTimer2::start();
pinMode(2, INPUT_PULLUP);
} }
void loop() void loop()
{ {
val = digitalRead(2);
if(prevVal == 1 && val == 0){
SwitchControlLibrary().PressButtonA();
index = 1;
}
else if(val == 1){
SwitchControlLibrary().ReleaseButtonA();
}
prevVal = val;
} }