tmp
This commit is contained in:
@@ -28,8 +28,11 @@ struct ButtonInfo {
|
||||
};
|
||||
|
||||
struct arrow arrowTable[4];
|
||||
struct arrow oldestArrow;
|
||||
struct arrow newestArrow;
|
||||
struct arrow oldestXArrow;
|
||||
struct arrow newestXArrow;
|
||||
struct arrow oldestYArrow;
|
||||
struct arrow newestYArrow;
|
||||
|
||||
|
||||
|
||||
#define ButtonInfoTableSize 9
|
||||
@@ -95,11 +98,17 @@ void setup()
|
||||
arrowTable[i].newer = NULL;
|
||||
}
|
||||
|
||||
oldestArrow.older = NULL;
|
||||
oldestArrow.newer = &newestArrow;
|
||||
oldestArrow.arrowSymbol = Hat::CENTER;
|
||||
newestArrow.older = &oldestArrow;
|
||||
newestArrow.newer = NULL;
|
||||
oldestXArrow.older = NULL;
|
||||
oldestXArrow.newer = &newestXArrow;
|
||||
oldestXArrow.arrowSymbol = Hat::CENTER;
|
||||
newestXArrow.older = &oldestXArrow;
|
||||
newestXArrow.newer = NULL;
|
||||
|
||||
oldestYArrow.older = NULL;
|
||||
oldestYArrow.newer = &newestYArrow;
|
||||
oldestYArrow.arrowSymbol = Hat::CENTER;
|
||||
newestYArrow.older = &oldestYArrow;
|
||||
newestYArrow.newer = NULL;
|
||||
|
||||
}
|
||||
|
||||
@@ -136,12 +145,21 @@ void loop()
|
||||
|
||||
for (int i=0; i<4; i++){
|
||||
arrowTable[i].current = digitalRead(arrowTable[i].pinNumber);
|
||||
|
||||
struct arrow *newestArrow;
|
||||
if(i % 2 == 0){ // Y axis
|
||||
newestArrow = &newestYArrow;
|
||||
}
|
||||
else { // X axis
|
||||
newestArrow = &newestXArrow;
|
||||
}
|
||||
|
||||
if(arrowTable[i].prev==1 && arrowTable[i].current==0){
|
||||
// add arrow to the tail of linked list
|
||||
arrowTable[i].older = newestArrow.older;
|
||||
arrowTable[i].newer = &newestArrow;
|
||||
newestArrow.older->newer = &(arrowTable[i]);
|
||||
newestArrow.older = &(arrowTable[i]);
|
||||
arrowTable[i].older = newestArrow->older;
|
||||
arrowTable[i].newer = newestArrow;
|
||||
newestArrow->older->newer = &(arrowTable[i]);
|
||||
newestArrow->older = &(arrowTable[i]);
|
||||
}
|
||||
else if (arrowTable[i].prev==0 && arrowTable[i].current==1){
|
||||
arrowTable[i].newer->older = arrowTable[i].older;
|
||||
@@ -153,7 +171,43 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(newestArrow.older->arrowSymbol));
|
||||
if(newestYArrow.older->arrowSymbol == Hat::TOP){
|
||||
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_LEFT));
|
||||
}
|
||||
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::TOP_RIGHT));
|
||||
}
|
||||
}
|
||||
else if(newestYArrow.older->arrowSymbol == Hat::CENTER){
|
||||
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::LEFT));
|
||||
}
|
||||
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::CENTER));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::RIGHT));
|
||||
}
|
||||
}
|
||||
else { // Hat::BOTTOM
|
||||
if(newestXArrow.older->arrowSymbol == Hat::LEFT){
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_LEFT));
|
||||
}
|
||||
else if(newestXArrow.older->arrowSymbol == Hat::CENTER) {
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM));
|
||||
}
|
||||
else { // Hat::RIGHT
|
||||
SwitchControlLibrary().MoveHat(static_cast<uint8_t>(Hat::BOTTOM_RIGHT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SwitchControlLibrary().MoveHat(static_cast<uint8_t>(newestArrow.older->arrowSymbol));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user