Debounce button
This commit is contained in:
parent
0b1e6f069c
commit
49c26b7ed4
|
@ -39,6 +39,7 @@ String lastStatusText = "";
|
|||
int transactionAmount = 150;
|
||||
String transactionAmountDecimal = "1.50";
|
||||
|
||||
volatile bool toggleTransactionAmount = false;
|
||||
volatile bool interruptFired = false;
|
||||
unsigned long timer = 0;
|
||||
|
||||
|
@ -97,14 +98,7 @@ void IRAM_ATTR BalanceInterruptHandler() {
|
|||
PN532Reader::toggleMode = true;
|
||||
}
|
||||
else if (state == STATE_TRANSACT_CARDSCAN) {
|
||||
if (transactionAmount == 150) {
|
||||
transactionAmount = 200;
|
||||
transactionAmountDecimal = "2.00";
|
||||
}
|
||||
else {
|
||||
transactionAmount = 150;
|
||||
transactionAmountDecimal = "1.50";
|
||||
}
|
||||
toggleTransactionAmount = true;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
@ -224,6 +218,19 @@ void loop() {
|
|||
oled.updateOLED(state);
|
||||
break;
|
||||
case STATE_TRANSACT_CARDSCAN:
|
||||
if (toggleTransactionAmount && millis() - timer > 250) {
|
||||
if (transactionAmount == 150) {
|
||||
transactionAmount = 200;
|
||||
transactionAmountDecimal = "2.00";
|
||||
}
|
||||
else {
|
||||
transactionAmount = 150;
|
||||
transactionAmountDecimal = "1.50";
|
||||
}
|
||||
toggleTransactionAmount = false;
|
||||
timer = millis();
|
||||
}
|
||||
|
||||
for (Reader* reader : readers) {
|
||||
if (reader->isNewCardPresent()) {
|
||||
scannedCardId = reader->getCardUid();
|
||||
|
@ -233,6 +240,7 @@ void loop() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cooldownCheck(scanTimeout)) {
|
||||
if (PN532Reader::mode == PN532_MIFARE_ISO14443A)
|
||||
oled.updateOLED(state, transactionAmountDecimal + String("€"), String(cooldownSecondsRemaining(scanTimeout, timer)));
|
||||
|
|
Loading…
Reference in a new issue