IDs: Introduce ID handling functions and data
IDs will be needed by multiple subsystems, so introduce the needed variables and handling functions.
This commit is contained in:
parent
da837ffbb4
commit
6c5a670366
5 changed files with 85 additions and 2 deletions
45
src/IDs.cpp
Normal file
45
src/IDs.cpp
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// Created by Teo-CD on 19/10/23.
|
||||
//
|
||||
|
||||
#include "IDs.h"
|
||||
|
||||
/* IDs are greater than one, offset the array to make it easier to use. */
|
||||
constexpr char promoDirs[][dirStrSize] = {
|
||||
"INVALIDE",
|
||||
"RANDONNEE",
|
||||
"RESTO",
|
||||
"AUTOBUS",
|
||||
"MAYO",
|
||||
"MADO",
|
||||
"COOP",
|
||||
"OURS",
|
||||
"BAGAR",
|
||||
"INCAPABLE",
|
||||
"MYSTERE"
|
||||
};
|
||||
constexpr char charDirs[][dirStrSize] = {
|
||||
"INVALIDE",
|
||||
"GUILLAUME",
|
||||
"MICHEL"
|
||||
};
|
||||
|
||||
bool isIdGone(int8_t ID) {
|
||||
return ID & idMaskGone;
|
||||
}
|
||||
|
||||
bool isIdCharacter(int8_t ID) {
|
||||
return ID & idMaskChar;
|
||||
}
|
||||
|
||||
uint8_t getRawId(int8_t ID) {
|
||||
return ID & ~(idMaskGone | idMaskChar);
|
||||
}
|
||||
|
||||
bool isValidId(int8_t ID) {
|
||||
uint8_t rawId = getRawId(ID);
|
||||
if (isIdCharacter(ID))
|
||||
return rawId < sizeof(charDirs) / dirStrSize;
|
||||
else
|
||||
return rawId < sizeof(promoDirs) / dirStrSize;
|
||||
}
|
|
@ -39,7 +39,7 @@ int8_t RFID::checkTags() {
|
|||
removeActiveTag(node, previousNode);
|
||||
// Return the ID with the sign bit set to signal it has gone.
|
||||
// If other tags are gone we can check on the next loop.
|
||||
return node->tag_ID | 1<<7;
|
||||
return node->tag_ID | idMaskGone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "Pinout.h"
|
||||
|
||||
#include "RFID.h"
|
||||
#include "Com.h"
|
||||
#include "RFID.h"
|
||||
|
||||
__attribute__((noreturn)) int main() {
|
||||
pinMode(pin_DBG_LED_1, OUTPUT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue