fix: Reversed digitalRead to activate button press on DOWN

master
phga 2 years ago
parent 224a10fd88
commit bf6d7b9635
Signed by: phga
GPG Key ID: 5249548AA705F019

@ -43,7 +43,7 @@ void startupAnimation();
void resetPlayer(); void resetPlayer();
void setup() { void setup() {
// Serial.begin(9600); Serial.begin(9600);
// init pins // init pins
for (int i = 3; i <= LMAX; ++i) { for (int i = 3; i <= LMAX; ++i) {
@ -94,10 +94,10 @@ void loop() {
// Setzt Status des Playerbuttons // Setzt Status des Playerbuttons
void anticheat(int l) { void anticheat(int l) {
if (digitalRead(p1.id) && l != LMAX) { if (digitalRead(p1.id) == 0 && l != LMAX) {
p1.pressed = 1; p1.pressed = 1;
} }
if (digitalRead(p2.id) && l != LMIN) { if (digitalRead(p2.id) == 0 && l != LMIN) {
p2.pressed = 1; p2.pressed = 1;
} }
} }
@ -149,6 +149,11 @@ void ledActive(int l, dir d) {
// ret 1 wenn in zeit gedrückt, 0 sonst // ret 1 wenn in zeit gedrückt, 0 sonst
int pressLoop(player *p) { int pressLoop(player *p) {
// Falls gecheated wurde, aussetzen // Falls gecheated wurde, aussetzen
Serial.print("\nPressed: (");
Serial.print(p->id);
Serial.print(", ");
Serial.print(p->pressed);
Serial.print(")");
if (p->pressed) { if (p->pressed) {
delay(speed); delay(speed);
return 0; return 0;
@ -156,7 +161,7 @@ int pressLoop(player *p) {
// Abfrageloop // Abfrageloop
for (int i = 0; i < speed; ++i) { for (int i = 0; i < speed; ++i) {
if (digitalRead(p->id)) { if (digitalRead(p->id) == 0) {
return 1; return 1;
} }
delay(1); delay(1);

Loading…
Cancel
Save