wiprfid
This commit is contained in:
35
src/main.cpp
35
src/main.cpp
@@ -43,7 +43,7 @@ File mp3File;
|
||||
|
||||
Audio audio;
|
||||
|
||||
uint volume = 18;
|
||||
uint volume = 12;
|
||||
|
||||
AsyncWebServer server(80);
|
||||
DNSServer dns;
|
||||
@@ -95,8 +95,10 @@ void playNextMp3()
|
||||
String mp3File = currentNode->getCurrentPlayingFilePath();
|
||||
Serial.println(mp3File.c_str());
|
||||
deactivateRFID();
|
||||
activateSD();
|
||||
audio.connecttoSD(mp3File.c_str());
|
||||
activateRFID();
|
||||
deactivateSD();
|
||||
blockState = false;
|
||||
}
|
||||
|
||||
@@ -199,7 +201,7 @@ void readRFID() {
|
||||
}
|
||||
|
||||
void clearInt(MFRC522 mfrc522) {
|
||||
mfrc522.PCD_WriteRegister(mfrc522.ComIrqReg, 0x7F);
|
||||
mfrc522.PCD_WriteRegister(mfrc522.ComIrqReg, 0x60);
|
||||
}
|
||||
|
||||
void IRAM_ATTR rfid_interrupt() {
|
||||
@@ -260,13 +262,15 @@ void setup()
|
||||
* Allow the ... irq to be propagated to the IRQ pin
|
||||
* For test purposes propagate the IdleIrq and loAlert
|
||||
*/
|
||||
//rfid.PCD_WriteRegister(rfid.ComIEnReg, 0xA0);
|
||||
attachInterrupt(IRQ_RFID, rfid_interrupt, FALLING);
|
||||
|
||||
do { //clear a spourious interrupt at start
|
||||
rfid.PCD_WriteRegister(rfid.ComIEnReg, 0x60);
|
||||
attachInterrupt(IRQ_RFID, rfid_interrupt, RISING);
|
||||
//clear a spourious interrupt at start
|
||||
/*
|
||||
do {
|
||||
;
|
||||
} while (!newRfidInt);
|
||||
newRfidInt = false; //interrupt flag
|
||||
*/
|
||||
} else {
|
||||
Serial.println("RFID Self Test failed!");
|
||||
}
|
||||
@@ -274,6 +278,7 @@ void setup()
|
||||
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
|
||||
audio.setVolume(volume); // 0...21
|
||||
|
||||
|
||||
Serial.println("Audio initialized.");
|
||||
|
||||
|
||||
@@ -311,22 +316,26 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
deactivateRFID();
|
||||
activateSD();
|
||||
audio.loop();
|
||||
deactivateSD();
|
||||
activateRFID();
|
||||
/*
|
||||
if(rfid.PICC_IsNewCardPresent()) {
|
||||
stop();
|
||||
readRFID();
|
||||
}*/
|
||||
|
||||
if (newRfidInt) {
|
||||
|
||||
Serial.println("Interrupt.");
|
||||
if(rfid.PICC_IsNewCardPresent()) {
|
||||
if(rfid.PICC_IsNewCardPresent()) {
|
||||
stop();
|
||||
readRFID();
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
clearInt(rfid);
|
||||
//clearInt(rfid);
|
||||
newRfidInt = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user