From b3b0bbc6302c2a4b289d2259406bd742e8ea2c74 Mon Sep 17 00:00:00 2001 From: boerge1 Date: Thu, 14 Sep 2023 11:38:36 +0200 Subject: [PATCH 1/4] Issue_106: Support LISP3 DF Player --- src/chip_card.cpp | 10 +++++++++- src/constants.hpp | 1 + src/mp3.cpp | 7 +++++++ src/mp3.hpp | 7 +++++++ src/settings.cpp | 3 +-- src/settings.hpp | 2 +- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/chip_card.cpp b/src/chip_card.cpp index d5d51c1..2c98d0c 100644 --- a/src/chip_card.cpp +++ b/src/chip_card.cpp @@ -239,7 +239,15 @@ void Chip_card::sleepCard() { void Chip_card::initCard() { SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 - LOG_CODE(card_log, s_debug, mfrc522.PCD_DumpVersionToSerial()); // Show details of PCD - MFRC522 Card Reader + LOG(card_log, s_info, F("MFRC522:"), mfrc522.PCD_ReadRegister(MFRC522::VersionReg)); + // Show MFRC522 Card Reader version + // 0 or 255: communication error) + // 136: (clone) + // 144: v0.0 + // 145: v1.0 + // 146: v2.0 + // 18: counterfeit chip + // else: unknown } void Chip_card::stopCard() { diff --git a/src/constants.hpp b/src/constants.hpp index e5ef8a0..836674a 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -34,6 +34,7 @@ */ //#define DFMiniMp3_T_CHIP_GD3200B //#define DFMiniMp3_T_CHIP_MH2024K16SS +//#define DFMiniMp3_T_CHIP_LISP3 #define DFMiniMp3_T_CHIP_Mp3ChipIncongruousNoAck /* uncomment the below line to disable shutdown via button (long press play/pause) diff --git a/src/mp3.cpp b/src/mp3.cpp index 79fbd9c..7fdda47 100644 --- a/src/mp3.cpp +++ b/src/mp3.cpp @@ -30,6 +30,10 @@ void Mp3Notify::OnPlayFinished(DfMp3&, DfMp3_PlaySources /*source*/, uint16_t tr return; else lastTrackFinished = track; +#ifdef DFMiniMp3_T_CHIP_LISP3 + if (Tonuino::getTonuino().getMp3().resetPlayingAdv()) + return; +#endif delay(1); Tonuino::getTonuino().nextTrack(1/*tracks*/, true/*fromOnPlayFinished*/); } @@ -78,6 +82,9 @@ void Mp3::waitForTrackToStart() { void Mp3::playAdvertisement(uint16_t track, bool olnyIfIsPlaying) { LOG(mp3_log, s_info, F("play adv: "), track); +#ifdef DFMiniMp3_T_CHIP_LISP3 + advPlaying = true; +#endif if (isPlaying()) { LOG(mp3_log, s_debug, F("playAdvertisement: "), track); Base::playAdvertisement(track); diff --git a/src/mp3.hpp b/src/mp3.hpp index c76442d..20d4a71 100644 --- a/src/mp3.hpp +++ b/src/mp3.hpp @@ -171,6 +171,9 @@ class Mp3: public DfMp3 { void clearAllQueue() { clearFolderQueue(); clearMp3Queue(); } bool isPlayingFolder() { return playing == play_folder; } bool isPlayingMp3 () { return playing == play_mp3 ; } +#ifdef DFMiniMp3_T_CHIP_LISP3 + bool resetPlayingAdv() { bool ret = advPlaying; advPlaying = false; return ret; } +#endif // firstTrack and lastTrack -> index in folder starting with 1 // currentTrack -> index in queue starting with 0 void enqueueTrack(uint8_t folder, uint8_t firstTrack, uint8_t lastTrack, uint8_t currentTrack = 0); @@ -231,6 +234,10 @@ class Mp3: public DfMp3 { Timer missingOnPlayFinishedTimer{}; bool isPause{}; #endif +#ifdef DFMiniMp3_T_CHIP_LISP3 + bool advPlaying{false}; +#endif + }; #endif /* SRC_MP3_HPP_ */ diff --git a/src/settings.cpp b/src/settings.cpp index ee7829b..eec22fb 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -53,7 +53,7 @@ void Settings::resetSettings() { minVolume = 5; initVolume = 15; eq = 1; - locked = false; + dummy = false; standbyTimer = 0; invertVolumeButtons = true; shortCuts[0] = { 0, pmode_t::none, 0, 0 }; @@ -97,7 +97,6 @@ void Settings::loadSettingsFromFlash() { LOG(settings_log, s_info, F("Ver:"), version); LOG(settings_log, s_info, F("Vol:"), maxVolume, F(" "), minVolume, F(" "), initVolume); LOG(settings_log, s_info, F("EQ:" ), eq); - LOG(settings_log, s_info, F("LOC:"), locked); LOG(settings_log, s_info, F("ST:" ), standbyTimer); LOG(settings_log, s_info, F("IB:" ), invertVolumeButtons); LOG(settings_log, s_info, F("AL:" ), adminMenuLocked); diff --git a/src/settings.hpp b/src/settings.hpp index edfc3a6..db7f262 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -37,7 +37,7 @@ struct Settings { uint8_t minVolume; uint8_t initVolume; uint8_t eq; - bool locked; + bool dummy; long standbyTimer; bool invertVolumeButtons; shortCuts_t shortCuts; From b1edde57c5b5bf390ded7472385ded3bcda443ab Mon Sep 17 00:00:00 2001 From: boerge1 Date: Thu, 14 Sep 2023 11:42:29 +0200 Subject: [PATCH 2/4] Issue_106: Support LISP3 DF Player --- README.md | 5 +++-- TonUINO-TNG.ino | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f69b77f..35e53a0 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,11 @@ Die SD Karte (Ordner mp3 und advert) hat sich gegenüber der Version 3.1.2 geän # Change Log +## Version 3.1.4 (14.09.2023) +- [Issue 106](https://github.com/tonuino/TonUINO-TNG/issues/106): Support LISP3 DF Player + ## Version 3.1.4 (08.09.2023) - [Issue 100](https://github.com/tonuino/TonUINO-TNG/issues/100): Support Nano Every with classic HW - -## Version 3.1.4 (07.09.2023) - [Issue 104](https://github.com/tonuino/TonUINO-TNG/issues/104): Use bad framework-lgt8fx - [Issue 099](https://github.com/tonuino/TonUINO-TNG/issues/99): Use new DFPlayer Mini Mp3 v1.2.1 Library diff --git a/TonUINO-TNG.ino b/TonUINO-TNG.ino index 93904bb..5ad6c1e 100644 --- a/TonUINO-TNG.ino +++ b/TonUINO-TNG.ino @@ -35,7 +35,7 @@ void setup() LOG(init_log, s_error, F("TonUINO Version 3.1 - refactored by Boerge1\n")); LOG(init_log, s_error, F("created by Thorsten Voß and licensed under GNU/GPL.")); LOG(init_log, s_error, F("Information and contribution at https://tonuino.de.\n")); - LOG(init_log, s_error, F("V3.1.4 08.09.23\n")); + LOG(init_log, s_error, F("V3.1.4 14.09.23\n")); Tonuino::getTonuino().setup(); } From 5ed6c61831b7e8ee6ae568ed42ce194146a602c0 Mon Sep 17 00:00:00 2001 From: boerge1 Date: Thu, 14 Sep 2023 12:00:40 +0200 Subject: [PATCH 3/4] Issue_106: Support LISP3 DF Player * fix module tests --- test/libs/MFRC522.h | 85 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/test/libs/MFRC522.h b/test/libs/MFRC522.h index 9c21c4e..edde5e5 100644 --- a/test/libs/MFRC522.h +++ b/test/libs/MFRC522.h @@ -13,7 +13,83 @@ class MFRC522 { public: - // Commands sent to the PICC. + // MFRC522 registers. Described in chapter 9 of the datasheet. + // When using SPI all addresses are shifted one bit left in the "SPI address byte" (section 8.1.2.3) + enum PCD_Register : byte { + // Page 0: Command and status + // 0x00 // reserved for future use + CommandReg = 0x01 << 1, // starts and stops command execution + ComIEnReg = 0x02 << 1, // enable and disable interrupt request control bits + DivIEnReg = 0x03 << 1, // enable and disable interrupt request control bits + ComIrqReg = 0x04 << 1, // interrupt request bits + DivIrqReg = 0x05 << 1, // interrupt request bits + ErrorReg = 0x06 << 1, // error bits showing the error status of the last command executed + Status1Reg = 0x07 << 1, // communication status bits + Status2Reg = 0x08 << 1, // receiver and transmitter status bits + FIFODataReg = 0x09 << 1, // input and output of 64 byte FIFO buffer + FIFOLevelReg = 0x0A << 1, // number of bytes stored in the FIFO buffer + WaterLevelReg = 0x0B << 1, // level for FIFO underflow and overflow warning + ControlReg = 0x0C << 1, // miscellaneous control registers + BitFramingReg = 0x0D << 1, // adjustments for bit-oriented frames + CollReg = 0x0E << 1, // bit position of the first bit-collision detected on the RF interface + // 0x0F // reserved for future use + + // Page 1: Command + // 0x10 // reserved for future use + ModeReg = 0x11 << 1, // defines general modes for transmitting and receiving + TxModeReg = 0x12 << 1, // defines transmission data rate and framing + RxModeReg = 0x13 << 1, // defines reception data rate and framing + TxControlReg = 0x14 << 1, // controls the logical behavior of the antenna driver pins TX1 and TX2 + TxASKReg = 0x15 << 1, // controls the setting of the transmission modulation + TxSelReg = 0x16 << 1, // selects the internal sources for the antenna driver + RxSelReg = 0x17 << 1, // selects internal receiver settings + RxThresholdReg = 0x18 << 1, // selects thresholds for the bit decoder + DemodReg = 0x19 << 1, // defines demodulator settings + // 0x1A // reserved for future use + // 0x1B // reserved for future use + MfTxReg = 0x1C << 1, // controls some MIFARE communication transmit parameters + MfRxReg = 0x1D << 1, // controls some MIFARE communication receive parameters + // 0x1E // reserved for future use + SerialSpeedReg = 0x1F << 1, // selects the speed of the serial UART interface + + // Page 2: Configuration + // 0x20 // reserved for future use + CRCResultRegH = 0x21 << 1, // shows the MSB and LSB values of the CRC calculation + CRCResultRegL = 0x22 << 1, + // 0x23 // reserved for future use + ModWidthReg = 0x24 << 1, // controls the ModWidth setting? + // 0x25 // reserved for future use + RFCfgReg = 0x26 << 1, // configures the receiver gain + GsNReg = 0x27 << 1, // selects the conductance of the antenna driver pins TX1 and TX2 for modulation + CWGsPReg = 0x28 << 1, // defines the conductance of the p-driver output during periods of no modulation + ModGsPReg = 0x29 << 1, // defines the conductance of the p-driver output during periods of modulation + TModeReg = 0x2A << 1, // defines settings for the internal timer + TPrescalerReg = 0x2B << 1, // the lower 8 bits of the TPrescaler value. The 4 high bits are in TModeReg. + TReloadRegH = 0x2C << 1, // defines the 16-bit timer reload value + TReloadRegL = 0x2D << 1, + TCounterValueRegH = 0x2E << 1, // shows the 16-bit timer value + TCounterValueRegL = 0x2F << 1, + + // Page 3: Test Registers + // 0x30 // reserved for future use + TestSel1Reg = 0x31 << 1, // general test signal configuration + TestSel2Reg = 0x32 << 1, // general test signal configuration + TestPinEnReg = 0x33 << 1, // enables pin output driver on pins D1 to D7 + TestPinValueReg = 0x34 << 1, // defines the values for D1 to D7 when it is used as an I/O bus + TestBusReg = 0x35 << 1, // shows the status of the internal test bus + AutoTestReg = 0x36 << 1, // controls the digital self-test + VersionReg = 0x37 << 1, // shows the software version + AnalogTestReg = 0x38 << 1, // controls the pins AUX1 and AUX2 + TestDAC1Reg = 0x39 << 1, // defines the test value for TestDAC1 + TestDAC2Reg = 0x3A << 1, // defines the test value for TestDAC2 + TestADCReg = 0x3B << 1 // shows the value of ADC I and Q channels + // 0x3C // reserved for production tests + // 0x3D // reserved for production tests + // 0x3E // reserved for production tests + // 0x3F // reserved for production tests + }; + + // Commands sent to the PICC. enum PICC_Command : byte { // The commands used by the PCD to manage communication with several PICCs (ISO 14443-3, Type A, section 6.4) PICC_CMD_REQA = 0x26, // REQuest command, Type A. Invites PICCs in state IDLE to go to READY and prepare for anticollision or selection. 7 bit frame. @@ -98,7 +174,12 @@ class MFRC522 { MFRC522(byte resetPowerDownPin) {} MFRC522(byte chipSelectPin, byte resetPowerDownPin) {} - ///////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////// + // Basic interface functions for communicating with the MFRC522 + ///////////////////////////////////////////////////////////////////////////////////// + byte PCD_ReadRegister(PCD_Register reg) { return 0x92; } + + ///////////////////////////////////////////////////////////////////////////////////// // Functions for manipulating the MFRC522 ///////////////////////////////////////////////////////////////////////////////////// bool called_Init = false; From bded2a3bbd8d3e245b32f918cc612a7ec73d83fc Mon Sep 17 00:00:00 2001 From: boerge1 Date: Thu, 14 Sep 2023 12:01:15 +0200 Subject: [PATCH 4/4] Issue_106: Support LISP3 DF Player * fix module tests II --- test/src/admin_tests.cpp | 2 +- test/src/settings_tests.cpp | 2 +- test/src/tonuino_tests.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/src/admin_tests.cpp b/test/src/admin_tests.cpp index d34885a..ad75b79 100644 --- a/test/src/admin_tests.cpp +++ b/test/src/admin_tests.cpp @@ -1197,7 +1197,7 @@ inline bool operator==(const Settings &lhs, const Settings &rhs) { lhs.minVolume == rhs.minVolume && lhs.initVolume == rhs.initVolume && lhs.eq == rhs.eq && - lhs.locked == rhs.locked && + lhs.dummy == rhs.dummy && lhs.standbyTimer == rhs.standbyTimer && lhs.invertVolumeButtons == rhs.invertVolumeButtons && lhs.shortCuts[0] == rhs.shortCuts[0] && diff --git a/test/src/settings_tests.cpp b/test/src/settings_tests.cpp index edb3cd2..33d8529 100644 --- a/test/src/settings_tests.cpp +++ b/test/src/settings_tests.cpp @@ -71,7 +71,7 @@ bool operator==(const Settings &lhs, const Settings &rhs) { lhs.minVolume == rhs.minVolume && lhs.initVolume == rhs.initVolume && lhs.eq == rhs.eq && - lhs.locked == rhs.locked && + lhs.dummy == rhs.dummy && lhs.standbyTimer == rhs.standbyTimer && lhs.invertVolumeButtons == rhs.invertVolumeButtons && lhs.shortCuts[0] == rhs.shortCuts[0] && diff --git a/test/src/tonuino_tests.cpp b/test/src/tonuino_tests.cpp index 1a5ed6a..da4876a 100644 --- a/test/src/tonuino_tests.cpp +++ b/test/src/tonuino_tests.cpp @@ -39,7 +39,7 @@ TEST_F(tonuino_test_fixture, initial_state) { EXPECT_EQ(getSettings().minVolume , 5); EXPECT_EQ(getSettings().initVolume , 15); EXPECT_EQ(getSettings().eq , 1); - EXPECT_EQ(getSettings().locked , false); + EXPECT_EQ(getSettings().dummy , false); EXPECT_EQ(getSettings().standbyTimer , 0); EXPECT_EQ(getSettings().invertVolumeButtons , 1); EXPECT_EQ(getSettings().shortCuts[0].folder , 0);