refactoring and little fix rapid fire tabie

This commit is contained in:
2020-09-14 01:41:01 +09:00
parent ee5ef7a696
commit ff5aee7c39

View File

@@ -1,11 +1,11 @@
#include <MsTimer2.h>
#include <SwitchControlLibrary.h>
#define tableSize 40
#define RapidFireTableSize 40
int loopCount = 0;
int state = 0;
int table[tableSize];
int rapidFireTable[RapidFireTableSize];
int index = 0;
int val = 1;
@@ -30,14 +30,14 @@ struct ButtonInfo buttonInfoTable[ButtonInfoTableSize];
void perms() {
if(val == 0){
if (table[index] == 1){
if (rapidFireTable[index] == 1){
SwitchControlLibrary().PressButtonA();
}
if (table[index] == 2){
if (rapidFireTable[index] == 2){
SwitchControlLibrary().ReleaseButtonA();
}
}
index = (index + 1) % 40;
index = (index + 1) % RapidFireTableSize;
}
@@ -51,8 +51,8 @@ void setupButton(ButtonInfo *but, int pinNumber, Button buttonSymbol) {
void setup()
{
table[0] = 1;
table[tableSize/2] = 2;
rapidFireTable[0] = 1;
rapidFireTable[RapidFireTableSize/2] = 2;
SwitchControlLibrary();
MsTimer2::set(1, perms);