Compare commits

...

1 Commits

Author SHA1 Message Date
70a41b3917 Fixed missing curly brace (wouldn't compile)
Fixed bug where holding down button decreased score until 0
2026-02-19 19:30:06 -05:00

View File

@@ -92,28 +92,30 @@ void loop() {
if (digitalRead(B1_IN) == 0) {
while (digitalRead(B1_IN) == 0) {
while (digitalRead(B2_IN) == 0) {} // Only execute remove point on button release.
if (digitalRead(B2_IN) == 0) {
while (digitalRead(B2_IN) == 0) {} // Only execute remove point on button release.
if (checkWin(score, 1) == 0) {
removePoint(score, 1);
displayOut[2] = setServeChar(servingChar, score, serving);
game = true;
}
else {
if (checkWin(score, 0) == 0) {}
else {
if (checkWin(score, 1) == 0) {
removePoint(score, 1);
if (checkWin(score, 0) == 0) {
displayOut[2] = servingChar;
game = false;
displayOut[2] = setServeChar(servingChar, score, serving);
game = true;
}
else {}
}
}
else {
if (checkWin(score, 0) == 0) {}
else {
removePoint(score, 1);
setDisplay(score, &matrix, displayOut);
delay(500); // to avoid calling twice.
if (checkWin(score, 0) == 0) {
displayOut[2] = servingChar;
game = false;
}
else {}
}
}
setDisplay(score, &matrix, displayOut);
delay(500); // to avoid calling twice.
}
} // Only execute add point on button release. Point removal if other button is pressed during while loop.
if (game == true) {
@@ -135,28 +137,30 @@ void loop() {
if (digitalRead(B2_IN) == 0) {
while (digitalRead(B2_IN) == 0) {
while (digitalRead(B1_IN) == 0) {} // Only execute remove point on button release.
if (digitalRead(B1_IN) == 0) {
while (digitalRead(B1_IN) == 0) {} // Only execute remove point on button release.
if (checkWin(score, 0) == 0) {
removePoint(score, 0);
displayOut[2] = setServeChar(servingChar, score, serving);
game = true;
}
else {
if (checkWin(score, 1) == 0) {}
else {
if (checkWin(score, 0) == 0) {
removePoint(score, 0);
if (checkWin(score, 1) == 0) {
displayOut[2] = servingChar;
game = false;
displayOut[2] = setServeChar(servingChar, score, serving);
game = true;
}
else {}
}
}
else {
if (checkWin(score, 1) == 0) {}
else {
removePoint(score, 0);
setDisplay(score, &matrix, displayOut);
delay(500); // to avoid calling twice.
if (checkWin(score, 1) == 0) {
displayOut[2] = servingChar;
game = false;
}
else {}
}
}
setDisplay(score, &matrix, displayOut);
delay(500); // to avoid calling twice.
}
} // Only execute add point on button release. Point removal if other button is pressed during while loop.
if (game == true) {
@@ -174,7 +178,7 @@ void loop() {
delay(500); // to avoid calling twice
}
}
}
}
// put function definitions here:
@@ -196,4 +200,3 @@ void setDisplay(int* score, MD_Parola* matrix, char* displayOut) {
matrix->print(displayOut);
}