Compare commits
No commits in common. "776a4e252f2cb680fb91db7000e989114e20fb87" and "ade4c19d552d5a2d16e1014796e0dab3904ce551" have entirely different histories.
776a4e252f
...
ade4c19d55
5 changed files with 8 additions and 30 deletions
|
@ -42,7 +42,6 @@ se synchroniser avec le firmware et potentiellement le mettre à jour.
|
|||
- [ ] Contrôle des modules
|
||||
- [x] RFID (base)
|
||||
- [x] RFID (avancé, écriture des tags)
|
||||
- [x] RFID (deux lecteurs)
|
||||
- [x] LCD (base)
|
||||
- [x] LCD (animations)
|
||||
- [ ] LCD (UI)
|
||||
|
@ -204,8 +203,7 @@ Il contient l'ID de la figurine sur les bits 0-5 de l'octet, si la figurine
|
|||
est un personnage (1) ou une année (0) sur le bit 6 et si la figurine a été posée
|
||||
(0) ou retirée (1) sur le bit 7.
|
||||
Ainsi, si on interprète l'octet comme un nombre signé, si le nombre est négatif
|
||||
on sait que la figurine a été retirée.
|
||||
**_Dû à un détail d'implémentation, l'identifiant 127 est invalide et réservé._**
|
||||
on sait que la figurine a été retirée.
|
||||
|
||||
#### Schéma
|
||||
```
|
||||
|
|
|
@ -32,8 +32,6 @@ struct uidNode {
|
|||
class RFID {
|
||||
public:
|
||||
static constexpr int maxTags = 2;
|
||||
/* Error value returned when checking for new or gone tags. */
|
||||
static constexpr int8_t checkFail = -1;
|
||||
|
||||
/***
|
||||
* Use the main SPI port and NFC chip select by default, but allow choosing
|
||||
|
@ -50,8 +48,7 @@ public:
|
|||
* at a time, another call would be needed to get eventual concurrent events.
|
||||
* This updates the respective lists and returns the ID with the direction
|
||||
* of the change.
|
||||
* @return ID if new tag detected, ID & sign bit if the tag left
|
||||
* @return RFID::checkFail if no change or error.
|
||||
* @return 0 if no change, ID if new tag detected, ID & sign bit if the tag left.
|
||||
*/
|
||||
int8_t checkTags();
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace Com {
|
|||
usb_rawhid_send(buffer, 0);
|
||||
#else
|
||||
Serial.write((const char*)buffer);
|
||||
Serial.write('\n');
|
||||
#endif
|
||||
/* Clear the buffer. */
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
|
|
@ -52,21 +52,21 @@ int8_t RFID::checkTags() {
|
|||
if ( currentActiveTags >= maxTags ||
|
||||
!mfrc.PICC_IsNewCardPresent() ||
|
||||
!mfrc.PICC_ReadCardSerial()) {
|
||||
return checkFail;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Assume we have a new tag.
|
||||
uidNode* newTag = addActiveTag(mfrc.uid);
|
||||
// Tag ID is put in a specific block, which can be read after from comData.
|
||||
if ( !newTag ) {
|
||||
return checkFail;
|
||||
return 0;
|
||||
}
|
||||
// If the read fails, we cannot use this tag anyway so remove it from the list.
|
||||
if (!readBlock(newTag->uid, tagIdBlock) ) {
|
||||
removeActiveTag(newTag, nullptr);
|
||||
return checkFail;
|
||||
return 0;
|
||||
}
|
||||
// Don't check the ID, otherwise we cannot program the tag.
|
||||
// Don' t check the ID, otherwise we cannot program the tag.
|
||||
newTag->tag_ID = comData[0];
|
||||
return newTag->tag_ID;
|
||||
}
|
||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -16,13 +16,11 @@ __attribute__((noreturn)) int main() {
|
|||
pinMode(pin_Audio_AMP_GAIN_EN, OUTPUT);
|
||||
|
||||
pinMode(pin_NFC1_RST, OUTPUT);
|
||||
pinMode(pin_NFC2_RST, OUTPUT);
|
||||
pinMode(pin_LCD_RST, OUTPUT);
|
||||
|
||||
/* Preemptively disable what we can before the regulator is ON. */
|
||||
digitalWrite(pin_Audio_Amp_enable, LOW);
|
||||
digitalWrite(pin_NFC1_RST, LOW);
|
||||
digitalWrite(pin_NFC2_RST, LOW);
|
||||
digitalWrite(pin_LCD_RST, LOW);
|
||||
|
||||
pinMode(pin_BAT_SNS, INPUT);
|
||||
|
@ -47,11 +45,6 @@ __attribute__((noreturn)) int main() {
|
|||
digitalWrite(pin_NFC1_RST, HIGH);
|
||||
rfid.init();
|
||||
|
||||
SPI1.setMISO(pin_SPI1_CIPO);
|
||||
RFID rfid2(pin_NFC2_CS, SPI1);
|
||||
digitalWrite(pin_NFC2_RST, HIGH);
|
||||
rfid2.init();
|
||||
|
||||
if (!SD.begin(BUILTIN_SDCARD))
|
||||
Com::sendComment("Could not use the SD Card.");
|
||||
|
||||
|
@ -73,15 +66,8 @@ __attribute__((noreturn)) int main() {
|
|||
lcd.checkAndDisplay();
|
||||
speaker.checkPlayingAndDisable();
|
||||
|
||||
/*
|
||||
* In the unlikely case where two changes happen in the same cycle, we
|
||||
* can check the second RFID reader on the next one.
|
||||
*/
|
||||
tagEvent = rfid.checkTags();
|
||||
if (tagEvent == RFID::checkFail) {
|
||||
tagEvent = rfid2.checkTags();
|
||||
}
|
||||
if (tagEvent != RFID::checkFail) {
|
||||
if (tagEvent) {
|
||||
Com::sendFigUpdate(tagEvent);
|
||||
/* Currently, we only play effects when placing a new figurine. */
|
||||
if (!isIdGone(tagEvent)) {
|
||||
|
@ -94,11 +80,9 @@ __attribute__((noreturn)) int main() {
|
|||
Com::ReceivedMessage message = Com::receiveMessage();
|
||||
if (message == Com::TAG_INFO_REQUEST) {
|
||||
uint8_t tagCount = rfid.gatherTagInfo(Com::getTagRecords());
|
||||
tagCount += rfid2.gatherTagInfo(Com::getTagRecords() + tagCount);
|
||||
Com::sendTagInfo(tagCount);
|
||||
} else if (message == Com::TAG_PROGRAMMING) {
|
||||
if (!rfid.programTag(Com::getTagRecords()) &&
|
||||
!rfid2.programTag(Com::getTagRecords())) {
|
||||
if (!rfid.programTag(Com::getTagRecords())) {
|
||||
Com::sendComment("Tag programming failed.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue