Skip to content

Commit

Permalink
Add refreshTag function to refresh current tag in specified slot; upd…
Browse files Browse the repository at this point in the history
…ate fastRx to use refreshTag
  • Loading branch information
DanTheMan827 committed Jan 20, 2025
1 parent b197004 commit 83d7950
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ntag215.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,17 @@ function changeTag(slot, immediate) {
}
}

/**
* Refreshes a tag in a specific slot if it is the current tag.
*
* @param {number} slot - The slot number of the tag to refresh.
*/
function refreshTag(slot) {
if (currentTag === slot) {
changeTag(slot);
}
}

/**
* This will cycle through the first 7 slots.
* @see - {@link changeTag} If you want to change to a specific slot.
Expand Down Expand Up @@ -890,6 +901,8 @@ function fastRx(data) {
getTag(slot).set(rxData, 0, 0);
}

refreshTag(slot);

_Bluetooth.write([COMMAND_FULL_WRITE, slot, receivedCrc32[0], receivedCrc32[1], receivedCrc32[2], receivedCrc32[3]]);
});

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

if (currentTag == slot) {
changeTag(slot);
}
refreshTag();

if (SAVE_TO_FLASH) {
saveTag(slot);
Expand Down

0 comments on commit 83d7950

Please sign in to comment.