added arrow keys
This commit is contained in:
@@ -11,6 +11,13 @@ int index = 0;
|
|||||||
int val = 1;
|
int val = 1;
|
||||||
int prevVal = 1;
|
int prevVal = 1;
|
||||||
|
|
||||||
|
struct arrow {
|
||||||
|
int pinNumber;
|
||||||
|
int state;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct arrow arrowTable[4];
|
||||||
|
|
||||||
void perms() {
|
void perms() {
|
||||||
if(val == 0){
|
if(val == 0){
|
||||||
if (table[index] == 1){
|
if (table[index] == 1){
|
||||||
@@ -45,6 +52,17 @@ void setup()
|
|||||||
|
|
||||||
pinMode(2, INPUT_PULLUP);
|
pinMode(2, INPUT_PULLUP);
|
||||||
|
|
||||||
|
arrowTable[0].pinNumber = 10;
|
||||||
|
arrowTable[1].pinNumber = 7;
|
||||||
|
arrowTable[2].pinNumber = 8;
|
||||||
|
arrowTable[3].pinNumber = 9;
|
||||||
|
|
||||||
|
for (int i=0; i<4; i++){
|
||||||
|
pinMode(arrowTable[i].pinNumber, INPUT_PULLUP);
|
||||||
|
arrowTable[i].state = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,4 +77,25 @@ void loop()
|
|||||||
SwitchControlLibrary().ReleaseButtonA();
|
SwitchControlLibrary().ReleaseButtonA();
|
||||||
}
|
}
|
||||||
prevVal = val;
|
prevVal = val;
|
||||||
|
|
||||||
|
for (int i=0; i<4; i++){
|
||||||
|
arrowTable[i].state = digitalRead(arrowTable[i].pinNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(arrowTable[0].state == 0){
|
||||||
|
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP));
|
||||||
|
}
|
||||||
|
else if(arrowTable[2].state == 0){
|
||||||
|
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM));
|
||||||
|
}
|
||||||
|
else if(arrowTable[1].state == 0){
|
||||||
|
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::LEFT));
|
||||||
|
}
|
||||||
|
else if(arrowTable[3].state == 0){
|
||||||
|
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::RIGHT));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user