Skip to content

Commit 83d7950

Browse files
committed
Add refreshTag function to refresh current tag in specified slot; update fastRx to use refreshTag
1 parent b197004 commit 83d7950

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ntag215.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,17 @@ function changeTag(slot, immediate) {
476476
}
477477
}
478478

479+
/**
480+
* Refreshes a tag in a specific slot if it is the current tag.
481+
*
482+
* @param {number} slot - The slot number of the tag to refresh.
483+
*/
484+
function refreshTag(slot) {
485+
if (currentTag === slot) {
486+
changeTag(slot);
487+
}
488+
}
489+
479490
/**
480491
* This will cycle through the first 7 slots.
481492
* @see - {@link changeTag} If you want to change to a specific slot.
@@ -890,6 +901,8 @@ function fastRx(data) {
890901
getTag(slot).set(rxData, 0, 0);
891902
}
892903

904+
refreshTag(slot);
905+
893906
_Bluetooth.write([COMMAND_FULL_WRITE, slot, receivedCrc32[0], receivedCrc32[1], receivedCrc32[2], receivedCrc32[3]]);
894907
});
895908

@@ -903,9 +916,7 @@ function fastRx(data) {
903916
tag = generateBlankTag();
904917
getTag(slot).set(tag);
905918

906-
if (currentTag == slot) {
907-
changeTag(slot);
908-
}
919+
refreshTag();
909920

910921
if (SAVE_TO_FLASH) {
911922
saveTag(slot);

0 commit comments

Comments
 (0)