1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 00:26:13 +01:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Ash-4
10c67c908f
Merge pull request #382 from DCC-EX/devel-ash-temp0102
Display network IP fix
2024-01-02 20:34:32 -06:00
Ash-4
957ad07456
Merge branch 'devel-stm32-cmri' into devel-ash-temp0102 2024-01-02 20:29:34 -06:00
Ash-4
a78a14b0d7
Merge pull request #381 from DCC-EX/I2CDFplayer
I2c dfplayer update
2024-01-02 20:24:33 -06:00
Harald Barth
74f7af1675 Display network IP fix 2024-01-03 02:36:07 +01:00
kempe63
0e9caa11c8 Update IO_I2CDFPlayer.h
Oops, fixed a typo
2024-01-01 20:39:37 +00:00
kempe63
46673007cc Update IO_I2CDFPlayer.h
Added SETAM, set the audio Mixer command to the supported EX-Rail commands.
the audio mixer can now be set at startup by using the configuration in myHall.cpp and it can be modified in an EX-Rail scripts.
Syntax:  PLAYSOUND(<vPin>, 0, <am>, SETAM)
Valid values for <am>: 1 or 2
2024-01-01 20:35:39 +00:00
4 changed files with 74 additions and 13 deletions

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202312251647Z" #define GITHUB_SHA "devel-202401030135Z"

View File

@ -75,8 +75,7 @@ private:
// SC16IS752 defines // SC16IS752 defines
I2CAddress _I2CAddress; I2CAddress _I2CAddress;
I2CRB _rb; I2CRB _rb;
uint8_t _UART_CH; uint8_t _UART_CH;
uint8_t _audioMixer = 0x01; // Default to output amplifier 1
// Communication parameters for the DFPlayer are fixed at 8 bit, No parity, 1 stopbit // Communication parameters for the DFPlayer are fixed at 8 bit, No parity, 1 stopbit
uint8_t WORD_LEN = 0x03; // Value LCR bit 0,1 uint8_t WORD_LEN = 0x03; // Value LCR bit 0,1
uint8_t STOP_BIT = 0x00; // Value LCR bit 2 uint8_t STOP_BIT = 0x00; // Value LCR bit 2
@ -100,6 +99,8 @@ private:
uint8_t _requestedEQValue = NORMAL; uint8_t _requestedEQValue = NORMAL;
uint8_t _currentEQvalue = NORMAL; // start equalizer value uint8_t _currentEQvalue = NORMAL; // start equalizer value
bool _daconCmd = false; bool _daconCmd = false;
uint8_t _audioMixer = 0x01; // Default to output amplifier 1
bool _setamCmd = false; // Set the Audio mixer channel
uint8_t _outbuffer [11]; // DFPlayer command is 10 bytes + 1 byte register address & UART channel uint8_t _outbuffer [11]; // DFPlayer command is 10 bytes + 1 byte register address & UART channel
uint8_t _inbuffer[10]; // expected DFPlayer return 10 bytes uint8_t _inbuffer[10]; // expected DFPlayer return 10 bytes
@ -356,6 +357,27 @@ public:
sendPacket(0x07,0x00,_currentEQvalue); sendPacket(0x07,0x00,_currentEQvalue);
} }
_eqCmd = false; _eqCmd = false;
} else if (_setamCmd == true){ // Set Audio mixer channel
setGPIO(); // Set the audio mixer channel
/*
if (_audioMixer == 1){ // set to audio mixer 1
if (_UART_CH == 0){
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 0 to high
} else { // must be UART 1
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 1 to high
}
//_setamCmd = false;
//UART_WriteRegister(REG_IOSTATE, TEMP_REG_VAL);
} else { // set to audio mixer 2
if (_UART_CH == 0){
TEMP_REG_VAL &= (0x00 << _UART_CH); //Set GPIO pin 0 to Low
} else { // must be UART 1
TEMP_REG_VAL &= (0x00 << _UART_CH); //Set GPIO pin 1 to Low
}
//_setamCmd = false;
//UART_WriteRegister(REG_IOSTATE, TEMP_REG_VAL);
}*/
_setamCmd = false;
} else if ((int32_t)currentMicros - _commandSendTime > 1000000) { } else if ((int32_t)currentMicros - _commandSendTime > 1000000) {
// Poll device every second that other commands aren't being sent, // Poll device every second that other commands aren't being sent,
// to check if it's still connected and responding. // to check if it's still connected and responding.
@ -417,7 +439,7 @@ public:
break; break;
case FOLDER: case FOLDER:
_folderCmd = true; _folderCmd = true;
if (volume <= 0 && volume > 99){ // Range checking if (volume <= 0 || volume > 99){ // Range checking, valid values 1-99, else default to 1
_requestedFolder = 0x01; // if outside range, default to folder 01 _requestedFolder = 0x01; // if outside range, default to folder 01
} else { } else {
_requestedFolder = volume; _requestedFolder = volume;
@ -442,11 +464,11 @@ public:
DIAG(F("I2CDFPlayer: WriteAnalog EQ: cmd: 0x%x, EQ value: 0x%x"), cmd, volume); DIAG(F("I2CDFPlayer: WriteAnalog EQ: cmd: 0x%x, EQ value: 0x%x"), cmd, volume);
#endif #endif
_eqCmd = true; _eqCmd = true;
if (volume <= NORMAL) { // to keep backward compatibility the volume parameter is used for values of the EQ cmd if (volume <= 0 || volume > 5) { // If out of range, default to NORMAL
_requestedEQValue = NORMAL; _requestedEQValue = NORMAL;
} else if (volume <= 0x05) { // Validate EQ parameters } else { // Valid EQ parameter range
_requestedEQValue = volume; _requestedEQValue = volume;
} }
break; break;
case RESET: case RESET:
_resetCmd = true; _resetCmd = true;
@ -457,6 +479,17 @@ public:
#endif #endif
_daconCmd = true; _daconCmd = true;
break; break;
case SETAM: // Set the audio mixer channel to 1 or 2
_setamCmd = true;
#ifdef DIAG_I2CDFplayer_playing
DIAG(F("I2CDFPlayer: WrtieAnalog SETAM: cmd: 0x%x"), cmd);
#endif
if (volume <= 0 || volume > 2) { // If out of range, default to 1
_audioMixer = 1;
} else { // Valid SETAM parameter in range
_audioMixer = volume; // _audioMixer valid values 1 or 2
}
break;
default: default:
break; break;
} }
@ -580,12 +613,15 @@ private:
UART_WriteRegister(REG_IODIR, TEMP_REG_VAL); UART_WriteRegister(REG_IODIR, TEMP_REG_VAL);
UART_ReadRegister(REG_IOSTATE); // Read current state as not to overwrite the other GPIO pins UART_ReadRegister(REG_IOSTATE); // Read current state as not to overwrite the other GPIO pins
TEMP_REG_VAL = _inbuffer[0]; TEMP_REG_VAL = _inbuffer[0];
if (_UART_CH == 0){ setGPIO(); // Set the audio mixer channel
/*
if (_UART_CH == 0){ // Set Audio mixer channel
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 0 to high TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 0 to high
} else { // must be UART 1 } else { // must be UART 1
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 1 to high TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 1 to high
} }
UART_WriteRegister(REG_IOSTATE, TEMP_REG_VAL); UART_WriteRegister(REG_IOSTATE, TEMP_REG_VAL);
*/
TEMP_REG_VAL = 0x07; // Reset FIFO, clear RX & TX FIFO TEMP_REG_VAL = 0x07; // Reset FIFO, clear RX & TX FIFO
UART_WriteRegister(REG_FCR, TEMP_REG_VAL); UART_WriteRegister(REG_FCR, TEMP_REG_VAL);
TEMP_REG_VAL = 0x00; // Set MCR to all 0, includes Clock divisor TEMP_REG_VAL = 0x00; // Set MCR to all 0, includes Clock divisor
@ -638,6 +674,29 @@ private:
TEMP_REG_VAL = 0x03; // Reset RX fifo TEMP_REG_VAL = 0x03; // Reset RX fifo
UART_WriteRegister(REG_FCR, TEMP_REG_VAL); UART_WriteRegister(REG_FCR, TEMP_REG_VAL);
} }
// Set or reset GPIO pin 0 and 1 depending on the UART ch
// This function may be modified in a future release to enable all 8 pins to be set or reset with EX-Rail
// for various auxilary functions
void setGPIO(){
UART_ReadRegister(REG_IOSTATE); // Get the current GPIO pins state from the IOSTATE register
TEMP_REG_VAL = _inbuffer[0];
if (_audioMixer == 1){ // set to audio mixer 1
if (_UART_CH == 0){
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 0 to high
} else { // must be UART 1
TEMP_REG_VAL |= (0x01 << _UART_CH); //Set GPIO pin 1 to high
}
} else { // set to audio mixer 2
if (_UART_CH == 0){
TEMP_REG_VAL &= ~(0x01 << _UART_CH); //Set GPIO pin 0 to Low
} else { // must be UART 1
TEMP_REG_VAL &= ~(0x01 << _UART_CH); //Set GPIO pin 1 to Low
}
}
UART_WriteRegister(REG_IOSTATE, TEMP_REG_VAL);
_setamCmd = false;
}
// Read the Tranmit FIFO Level register (TXLVL), return a single unsigned integer // Read the Tranmit FIFO Level register (TXLVL), return a single unsigned integer
@ -720,13 +779,14 @@ enum : uint8_t{
STOPPLAY = 0x16, STOPPLAY = 0x16,
EQ = 0x07, // Set equaliser, require parameter NORMAL, POP, ROCK, JAZZ, CLASSIC or BASS EQ = 0x07, // Set equaliser, require parameter NORMAL, POP, ROCK, JAZZ, CLASSIC or BASS
RESET = 0x0C, RESET = 0x0C,
DACON = 0x1A, // Not a DFLayer command,need to sent 0x1A and 3rd byte to 0x01 in processOutgoing() DACON = 0x1A,
SETAM = 0x2A, // Set audio mixer 1 or 2 for this DFPLayer
NORMAL = 0x00, // Equalizer parameters NORMAL = 0x00, // Equalizer parameters
POP = 0x01, POP = 0x01,
ROCK = 0x02, ROCK = 0x02,
JAZZ = 0x03, JAZZ = 0x03,
CLASSIC = 0x04, CLASSIC = 0x04,
BASS = 0x05, BASS = 0x05,
}; };
}; };

View File

@ -179,7 +179,7 @@ bool WifiESP::setup(const char *SSid,
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
// DIAG(F("Wifi STA IP %s"),WiFi.localIP().toString().c_str()); // DIAG(F("Wifi STA IP %s"),WiFi.localIP().toString().c_str());
DIAG(F("Wifi in STA mode")); DIAG(F("Wifi in STA mode"));
LCD(7, F("IP: %s"), WiFi.softAPIP().toString().c_str()); LCD(7, F("IP: %s"), WiFi.localIP().toString().c_str());
wifiUp = true; wifiUp = true;
} else { } else {
DIAG(F("Could not connect to Wifi SSID %s"),SSid); DIAG(F("Could not connect to Wifi SSID %s"),SSid);

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.2.17ethCdf" #define VERSION "5.2.18ethCdf"
// 5.2.18 - Display network IP fix
// 5.2.17 - ESP32 simplify network logic // 5.2.17 - ESP32 simplify network logic
// 5.2.16 - Bugfix to allow for devices using the EX-IOExpander protocol to have no analogue or no digital pins // 5.2.16 - Bugfix to allow for devices using the EX-IOExpander protocol to have no analogue or no digital pins
// df - I2C DFPlayper capability // df - I2C DFPlayper capability