diff --git a/Sources/Canta_Storie_DF_Player_02/Canta_Storie_DF_Player_02.ino~ b/Sources/Canta_Storie_DF_Player_02/Canta_Storie_DF_Player_02.ino~ deleted file mode 100644 index d2ef20d..0000000 --- a/Sources/Canta_Storie_DF_Player_02/Canta_Storie_DF_Player_02.ino~ +++ /dev/null @@ -1,250 +0,0 @@ -// this example will play a track and then -// every five seconds play another track -// -// it expects the sd card to contain these three mp3 files -// but doesn't care whats in them -// -// sd:/mp3/0001.mp3 -// sd:/mp3/0002.mp3 -// sd:/mp3/0003.mp3 - -#include -#include - - - #include - #include - #include - #include - - PN532_I2C pn532i2c(Wire); - PN532 nfc(pn532i2c); - -const uint8_t uid_ok1[] = { 0x4, 0xB1, 0x63, 0xDA, 0x31, 0x5B, 0x80 }; //UID SPT Subway -const uint8_t uid_ok2[] = { 0x4, 0x42, 0x55, 0x72, 0x62, 0x57, 0x80 }; //UID ciondolo viola -const uint8_t uid_ok3[] = { 0xF6, 0x99, 0xBD, 0xAC,0,0,0 }; //UID ciondolo rosso - - - - - -const int secondi=60; - -// implement a notification class, -// its member methods will get called -// -class Mp3Notify -{ -public: - static void OnError(uint16_t errorCode) - { - // see DfMp3_Error for code meaning - Serial.println(); - Serial.print("Com Error "); - Serial.println(errorCode); - } - - static void OnPlayFinished(uint16_t globalTrack) - { - Serial.println(); - Serial.print("Play finished for #"); - Serial.println(globalTrack); - } - - static void OnCardOnline(uint16_t code) - { - Serial.println(); - Serial.print("Card online "); - Serial.println(code); - } - - static void OnCardInserted(uint16_t code) - { - Serial.println(); - Serial.print("Card inserted "); - Serial.println(code); - } - - static void OnCardRemoved(uint16_t code) - { - Serial.println(); - Serial.print("Card removed "); - Serial.println(code); - } -}; - -// instance a DFMiniMp3 object, -// defined with the above notification class and the hardware serial class -// -//DFMiniMp3 mp3(Serial1); - -// Some arduino boards only have one hardware serial port, so a software serial port is needed instead. -// comment out the above definition and uncomment these lines -SoftwareSerial secondarySerial(10, 11); // RX, TX -DFMiniMp3 mp3(secondarySerial); - -void setup() -{ - Serial.begin(115200); - - Serial.println("initializing..."); - - mp3.begin(); - - uint16_t volume = mp3.getVolume(); - Serial.print("volume "); - Serial.println(volume); - mp3.setVolume(15); - - uint16_t count = mp3.getTotalTrackCount(); - Serial.print("files "); - Serial.println(count); - - Serial.println("starting..."); - - -//PN532 Setup - - nfc.begin(); - - uint32_t versiondata = nfc.getFirmwareVersion(); - if (! versiondata) { - Serial.print("Didn't find PN53x board"); - while (1); // halt - } -/* - // Got ok data, print it out! - Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); - Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); - Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC); -*/ - // Set the max number of retry attempts to read from a card - // This prevents us from waiting forever for a card, which is - // the default behaviour of the PN532. - nfc.setPassiveActivationRetries(0xFF); - - // configure board to read RFID tags - nfc.SAMConfig(); - - Serial.println("Waiting for an ISO14443A card"); - -} - -void waitMilliseconds(uint16_t msWait) -{ - uint32_t start = millis(); - - while ((millis() - start) < msWait) - { - // calling mp3.loop() periodically allows for notifications - // to be handled without interrupts - mp3.loop(); - delay(1); - } -} - -void loop() -{ -int test=1; - boolean success; - uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID - uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) - - // Wait for an ISO14443A type cards (Mifare, etc.). When one is found - // 'uid' will be populated with the UID, and uidLength will indicate - // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) - success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength); - - if (success) { - Serial.println("Found a card!"); - //Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes"); - Serial.print("UID Value: "); - for (uint8_t i=0; i < uidLength; i++) - { - Serial.print(" 0x");Serial.print(uid[i], HEX); - } - Serial.println(""); - // Wait 1 second before continuing - // delay(1000); - if(uidLength==7){ - test=memcmp(uid,uid_ok1,sizeof(uid)); - if (test==0) { - Serial.println("Carta SPT Subway"); - Serial.println("track 1"); - mp3.playMp3FolderTrack(1); // sd:/mp3/0001.mp3 - - } - test=memcmp(uid,uid_ok2,sizeof(uid)); - if (test==0) { - Serial.println("Ciondolo Viola"); - - } - } - if(uidLength==4){ - test=memcmp(uid,uid_ok3,sizeof(uid)); - if (test==0) { - Serial.println("Ciondolo Rosso"); - Serial.println("track 2"); - mp3.playMp3FolderTrack(2); // sd:/mp3/0002.mp3 - } - - } - Serial.println(""); - } - else - { - // PN532 probably timed out waiting for a card - // Serial.println("Timed out waiting for a card"); - } - delay(1000); - mp3.loop(); //controlla il lettore per messaggi - delay(1); - - - - -/* - Serial.println("track 1"); - mp3.playMp3FolderTrack(1); // sd:/mp3/0001.mp3 - - waitMilliseconds(secondi*1000); - - Serial.println("track 2"); - mp3.playMp3FolderTrack(2); // sd:/mp3/0002.mp3 - - waitMilliseconds(secondi*1000); - -mp3.setVolume(0); -waitMilliseconds(5*1000); -mp3.setVolume(15); - - - Serial.println("track 3"); - mp3.playMp3FolderTrack(3); // sd:/mp3/0003.mp3 - - waitMilliseconds(5000); - */ -} - -/* NOTE -https://github.com/Makuna/DFMiniMp3/blob/master/src/DFMiniMp3.h - -DfMp3_Error - // from device - DfMp3_Error_Busy = 1, - DfMp3_Error_Sleeping, - DfMp3_Error_SerialWrongStack, - DfMp3_Error_CheckSumNotMatch, - DfMp3_Error_FileIndexOut, - DfMp3_Error_FileMismatch, - DfMp3_Error_Advertise, - // from library - DfMp3_Error_PacketSize = 0x81, - DfMp3_Error_PacketHeader, - DfMp3_Error_PacketChecksum, - DfMp3_Error_General = 0xff - - */ - - -