feat: enhance tag detection with countdown display during write operation
This commit is contained in:
1 parent
a5d9902149
commit
7b03b359ba
1 file changed
+15
-3
+15
-3
@@ -1650,15 +1650,16 @@ void writeJsonToTag(void *parameter) {
|
|||||||
sendNfcData();
|
sendNfcData();
|
||||||
vTaskDelay(pdMS_TO_TICKS(100));
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
// Show waiting message for tag detection
|
// Show initial waiting message with countdown
|
||||||
oledShowProgressBar(0, 1, "Write Tag", "Warte auf Tag");
|
oledShowProgressBar(0, 30, "Write Tag", "Warte... 30s");
|
||||||
oledSetPriority(DISPLAY_PRIORITY_ACTION, 2000);
|
oledSetPriority(DISPLAY_PRIORITY_ACTION, 1500);
|
||||||
|
|
||||||
// Wait up to 30 seconds for tag
|
// Wait up to 30 seconds for tag
|
||||||
uint8_t success = 0;
|
uint8_t success = 0;
|
||||||
String uidString = "";
|
String uidString = "";
|
||||||
uint8_t uidLength = 0;
|
uint8_t uidLength = 0;
|
||||||
unsigned long startTime = millis();
|
unsigned long startTime = millis();
|
||||||
|
uint8_t lastSecondsShown = 30;
|
||||||
|
|
||||||
while (millis() - startTime < 30000) {
|
while (millis() - startTime < 30000) {
|
||||||
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
|
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
|
||||||
@@ -1666,6 +1667,17 @@ void writeJsonToTag(void *parameter) {
|
|||||||
yield();
|
yield();
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
|
|
||||||
|
// Update countdown display every second
|
||||||
|
unsigned long elapsed = millis() - startTime;
|
||||||
|
uint8_t remainingSeconds = (30000 - elapsed) / 1000;
|
||||||
|
if (remainingSeconds != lastSecondsShown) {
|
||||||
|
lastSecondsShown = remainingSeconds;
|
||||||
|
char countdownText[20];
|
||||||
|
snprintf(countdownText, sizeof(countdownText), "Warte... %ds", remainingSeconds);
|
||||||
|
oledShowProgressBar(elapsed / 1000, 30, "Write Tag", countdownText);
|
||||||
|
oledSetPriority(DISPLAY_PRIORITY_ACTION, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 400);
|
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 400);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|||||||
Reference in new issue
Block a user