Compare commits
4 Commits
d3ec758ac7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 70a41b3917 | |||
| f78e734a5a | |||
| 9eae0f68ce | |||
| 64776b3b43 |
6
LICENSE
6
LICENSE
@@ -208,8 +208,8 @@ If you develop a new program, and you want it to be of the greatest possible use
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
testt
|
||||
Copyright (C) 2025 suseman
|
||||
pingpong-counter
|
||||
Copyright (C) 2025 Adrian Jaroszewski
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
@@ -221,7 +221,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
testt Copyright (C) 2025 suseman
|
||||
pingpong-counter Copyright (C) 2025 Adrian Jaroszewski
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
|
||||
126
src/main.cpp
126
src/main.cpp
@@ -55,16 +55,15 @@ void setup() {
|
||||
matrix.setTextAlignment(PA_CENTER);
|
||||
|
||||
matrix.setFont(pingpong_font);
|
||||
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
|
||||
while (digitalRead(B1_IN) == 1 && digitalRead(B2_IN) == 1) {
|
||||
|
||||
|
||||
}
|
||||
while (digitalRead(B1_IN) == 1 && digitalRead(B2_IN) == 1) {}
|
||||
|
||||
if (digitalRead(B1_IN) == 0) {
|
||||
while (digitalRead(B1_IN) == 0) {}
|
||||
|
||||
serving = 0;
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
@@ -77,48 +76,107 @@ void setup() {
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
delay(500); // to avoid calling twice
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
while (game == true) {
|
||||
|
||||
while (digitalRead(B1_IN) == 1 && digitalRead(B2_IN) == 1) {
|
||||
while (true) {
|
||||
|
||||
while (digitalRead(B1_IN) == 1 && digitalRead(B2_IN) == 1) {}
|
||||
|
||||
|
||||
}
|
||||
if (digitalRead(B1_IN) == 0) {
|
||||
while (digitalRead(B1_IN) == 0) {} // Only execute add point on button release
|
||||
scored(score, 0);
|
||||
if (checkWin(score, 0) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
game = false;
|
||||
}
|
||||
else {
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
while (digitalRead(B1_IN) == 0) {
|
||||
|
||||
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 {
|
||||
removePoint(score, 1);
|
||||
|
||||
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) {
|
||||
scored(score, 0);
|
||||
|
||||
if (checkWin(score, 0) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
game = false;
|
||||
}
|
||||
else {
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
}
|
||||
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
delay(500); // to avoid calling twice
|
||||
}
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
}
|
||||
|
||||
if (digitalRead(B2_IN) == 0) {
|
||||
while (digitalRead(B2_IN) == 0) {} // Only execute add point on button release
|
||||
scored(score, 1);
|
||||
if (checkWin(score, 1) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
game = false;
|
||||
}
|
||||
else {
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
while (digitalRead(B2_IN) == 0) {
|
||||
|
||||
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 {
|
||||
removePoint(score, 0);
|
||||
|
||||
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) {
|
||||
scored(score, 1);
|
||||
|
||||
if (checkWin(score, 1) == 0) {
|
||||
displayOut[2] = servingChar;
|
||||
game = false;
|
||||
}
|
||||
else {
|
||||
displayOut[2] = setServeChar(servingChar, score, serving);
|
||||
}
|
||||
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
delay(500); // to avoid calling twice
|
||||
}
|
||||
setDisplay(score, &matrix, displayOut);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +196,7 @@ void setDisplay(int* score, MD_Parola* matrix, char* displayOut) {
|
||||
displayOut[i*3] = convertASCII((*(score+i) - (*(score+i)%10)) / 10);
|
||||
displayOut[(i*3)+1] = convertASCII(*(score+i)%10);
|
||||
}
|
||||
|
||||
matrix->print(displayOut);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user