Option to compile without buzzer support

This commit is contained in:
Laura Hausmann 2023-05-19 19:43:51 +02:00
parent b44e7c300d
commit 63e261c9be
Signed by: zotan
GPG key ID: D044E84C5BE01605
2 changed files with 21 additions and 0 deletions

View file

@ -11,6 +11,8 @@
#define AFRAPAY_GIT_COMMIT "unknown"
#endif
//#define DISABLE_BUZZER
/*
* We're using an Az-Delivery ESP-32 Kit:
* Product: https://web.archive.org/web/20230420182915/https://www.azdelivery.de/en/products/esp32-developmentboard

View file

@ -306,6 +306,8 @@ void loop() {
break;
case STATE_TRANSACT_VERIFY:
oled.updateOLED(state, lastStatusText);
#ifndef DISABLE_BUZZER
if (PN532Reader::mode == PN532_MIFARE_ISO14443A) {
tone(PIN_BUZZER, NOTE_A5, 25);
tone(PIN_BUZZER, NOTE_NONE, 150);
@ -314,15 +316,20 @@ void loop() {
tone(PIN_BUZZER, NOTE_FS7, 100);
tone(PIN_BUZZER, NOTE_NONE, 150);
}
#endif
lastStatusText = cardTransaction(wifi, http, apiUrl, scannedCardId, String(GetTransactionAmount()), scannedCardReader->getReaderName());
if (lastStatusText.startsWith("S:")) {
#ifndef DISABLE_BUZZER
tone(PIN_BUZZER, NOTE_C7, 650);
#endif
state = STATE_RESULT_SUCCESS;
} else {
#ifndef DISABLE_BUZZER
tone(PIN_BUZZER, NOTE_CS5, 100);
tone(PIN_BUZZER, NOTE_NONE, 25);
tone(PIN_BUZZER, NOTE_CS5, 400);
#endif
state = STATE_RESULT_FAILURE;
}
lastStatusText = lastStatusText.substring(2);
@ -376,6 +383,8 @@ void loop() {
break;
case STATE_LINK_VERIFY:
oled.updateOLED(state, lastStatusText);
#ifndef DISABLE_BUZZER
if (PN532Reader::mode == PN532_MIFARE_ISO14443A) {
tone(PIN_BUZZER, NOTE_A5, 25);
tone(PIN_BUZZER, NOTE_NONE, 150);
@ -384,17 +393,22 @@ void loop() {
tone(PIN_BUZZER, NOTE_FS7, 100);
tone(PIN_BUZZER, NOTE_NONE, 150);
}
#endif
lastStatusText = cardLink(wifi, http, apiUrl, scannedCardId, scannedCardReader->getReaderName());
if (lastStatusText.startsWith("S:")) {
#ifndef DISABLE_BUZZER
tone(PIN_BUZZER, NOTE_C6, 100);
tone(PIN_BUZZER, NOTE_NONE, 10);
tone(PIN_BUZZER, NOTE_C6, 100);
#endif
state = STATE_RESULT_SUCCESS;
} else {
#ifndef DISABLE_BUZZER
tone(PIN_BUZZER, NOTE_CS5, 100);
tone(PIN_BUZZER, NOTE_NONE, 25);
tone(PIN_BUZZER, NOTE_CS5, 400);
#endif
state = STATE_RESULT_FAILURE;
}
lastStatusText = lastStatusText.substring(2);
@ -419,6 +433,8 @@ void loop() {
break;
case STATE_BALANCE_VERIFY:
oled.updateOLED(state, lastStatusText);
#ifndef DISABLE_BUZZER
if (PN532Reader::mode == PN532_MIFARE_ISO14443A) {
tone(PIN_BUZZER, NOTE_A5, 25);
tone(PIN_BUZZER, NOTE_NONE, 150);
@ -427,15 +443,18 @@ void loop() {
tone(PIN_BUZZER, NOTE_FS7, 100);
tone(PIN_BUZZER, NOTE_NONE, 150);
}
#endif
lastStatusText = cardBalance(wifi, http, apiUrl, scannedCardId, scannedCardReader->getReaderName());
if (lastStatusText.startsWith("S:")) {
lastStatusText = lastStatusText + ":" + cardIdDisplay(scannedCardId);
state = STATE_RESULT_DISPLAY;
} else {
#ifndef DISABLE_BUZZER
tone(PIN_BUZZER, NOTE_CS5, 100);
tone(PIN_BUZZER, NOTE_NONE, 25);
tone(PIN_BUZZER, NOTE_CS5, 400);
#endif
state = STATE_RESULT_FAILURE;
}
lastStatusText = lastStatusText.substring(2);