Skip to content

Commit

Permalink
Merge pull request #107: Issue 106: Issue_106: Support LISP3 DF Player
Browse files Browse the repository at this point in the history
  • Loading branch information
boerge1 authored Sep 15, 2023
2 parents a5414ed + bded2a3 commit 7f00e63
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion TonUINO-TNG.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 9 additions & 1 deletion src/chip_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/);
}
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/mp3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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_ */
3 changes: 1 addition & 2 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
85 changes: 83 additions & 2 deletions test/libs/MFRC522.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/src/admin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] &&
Expand Down
2 changes: 1 addition & 1 deletion test/src/settings_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] &&
Expand Down
2 changes: 1 addition & 1 deletion test/src/tonuino_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7f00e63

Please sign in to comment.