Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dca33f80c7 | ||
|
|
faa8b094c9 | ||
|
|
7ac86f015f | ||
|
|
933439fa3f | ||
|
|
0d132c1391 |
No files matched your search
@@ -33,6 +33,8 @@ A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was
|
|||||||
|
|
||||||
A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available https://janderogee.com/projects/linear_clock/linear_clock.htm
|
A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available https://janderogee.com/projects/linear_clock/linear_clock.htm
|
||||||
|
|
||||||
|
Source and instructions for a gorgeous wooden MP3-playing clock, FM radio and a walkie-talkie using the ESP8266 and AVR microcontrollers is available https://github.com/zduka/mp3-player
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
First, make sure you are running the 2.6.3/later or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
|
First, make sure you are running the 2.6.3/later or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
"url": "https://github.com/earlephilhower/ESP8266Audio"
|
||||||
},
|
},
|
||||||
"version": "1.9.4",
|
"version": "1.9.5",
|
||||||
"homepage": "https://github.com/earlephilhower/ESP8266Audio",
|
"homepage": "https://github.com/earlephilhower/ESP8266Audio",
|
||||||
"frameworks": "Arduino",
|
"frameworks": "Arduino",
|
||||||
"examples": [
|
"examples": [
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name=ESP8266Audio
|
name=ESP8266Audio
|
||||||
version=1.9.4
|
version=1.9.5
|
||||||
author=Earle F. Philhower, III
|
author=Earle F. Philhower, III
|
||||||
maintainer=Earle F. Philhower, III
|
maintainer=Earle F. Philhower, III
|
||||||
sentence=Audio file and I2S sound playing routines for ESP8266, ESP32, and Raspberry Pi Pico RP2040
|
sentence=Audio file and I2S sound playing routines for ESP8266, ESP32, and Raspberry Pi Pico RP2040
|
||||||
|
|||||||
+29
-6
@@ -42,6 +42,7 @@ AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int
|
|||||||
|
|
||||||
//set defaults
|
//set defaults
|
||||||
mono = false;
|
mono = false;
|
||||||
|
lsb_justified = false;
|
||||||
bps = 16;
|
bps = 16;
|
||||||
channels = 2;
|
channels = 2;
|
||||||
hertz = 44100;
|
hertz = 44100;
|
||||||
@@ -148,6 +149,12 @@ bool AudioOutputI2S::SetOutputModeMono(bool mono)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AudioOutputI2S::SetLsbJustified(bool lsbJustified)
|
||||||
|
{
|
||||||
|
this->lsb_justified = lsbJustified;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool AudioOutputI2S::begin(bool txDAC)
|
bool AudioOutputI2S::begin(bool txDAC)
|
||||||
{
|
{
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
@@ -168,25 +175,41 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||||||
i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
|
i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
|
||||||
if (output_mode == INTERNAL_DAC)
|
if (output_mode == INTERNAL_DAC)
|
||||||
{
|
{
|
||||||
#ifdef I2S_MODE_DAC_BUILT_IN
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
|
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (output_mode == INTERNAL_PDM)
|
else if (output_mode == INTERNAL_PDM)
|
||||||
{
|
{
|
||||||
#ifdef I2S_MODE_PDM
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
|
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
i2s_comm_format_t comm_fmt = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
|
i2s_comm_format_t comm_fmt;
|
||||||
if (output_mode == INTERNAL_DAC)
|
if (output_mode == INTERNAL_DAC)
|
||||||
{
|
{
|
||||||
comm_fmt = (i2s_comm_format_t)I2S_COMM_FORMAT_I2S_MSB;
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||||
|
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
|
||||||
|
#else
|
||||||
|
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_I2S_MSB;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (lsb_justified)
|
||||||
|
{
|
||||||
|
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||||
|
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_STAND_I2S);
|
||||||
|
#else
|
||||||
|
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
i2s_config_t i2s_config_dac = {
|
i2s_config_t i2s_config_dac = {
|
||||||
@@ -207,7 +230,7 @@ bool AudioOutputI2S::begin(bool txDAC)
|
|||||||
}
|
}
|
||||||
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
|
||||||
{
|
{
|
||||||
#ifdef I2S_DAC_CHANNEL_BOTH_EN
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
i2s_set_pin((i2s_port_t)portNo, NULL);
|
i2s_set_pin((i2s_port_t)portNo, NULL);
|
||||||
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
|
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class AudioOutputI2S : public AudioOutput
|
|||||||
|
|
||||||
bool begin(bool txDAC);
|
bool begin(bool txDAC);
|
||||||
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
bool SetOutputModeMono(bool mono); // Force mono output no matter the input
|
||||||
|
bool SetLsbJustified(bool lsbJustified); // Allow supporting non-I2S chips, e.g. PT8211
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool SetPinout();
|
bool SetPinout();
|
||||||
@@ -51,6 +52,7 @@ class AudioOutputI2S : public AudioOutput
|
|||||||
uint8_t portNo;
|
uint8_t portNo;
|
||||||
int output_mode;
|
int output_mode;
|
||||||
bool mono;
|
bool mono;
|
||||||
|
int lsb_justified;
|
||||||
bool i2sOn;
|
bool i2sOn;
|
||||||
int dma_buf_count;
|
int dma_buf_count;
|
||||||
int use_apll;
|
int use_apll;
|
||||||
|
|||||||
@@ -94,7 +94,11 @@ AudioOutputSPDIF::AudioOutputSPDIF(int dout_pin, int port, int dma_buf_count)
|
|||||||
.sample_rate = 88200, // 2 x sampling_rate
|
.sample_rate = 88200, // 2 x sampling_rate
|
||||||
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, // 32bit words
|
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, // 32bit words
|
||||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // Right than left
|
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // Right than left
|
||||||
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
|
||||||
|
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S),
|
||||||
|
#else
|
||||||
|
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
|
||||||
|
#endif
|
||||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
|
||||||
.dma_buf_count = dma_buf_count,
|
.dma_buf_count = dma_buf_count,
|
||||||
.dma_buf_len = DMA_BUF_SIZE_DEFAULT, // bigger buffers, reduces interrupts
|
.dma_buf_len = DMA_BUF_SIZE_DEFAULT, // bigger buffers, reduces interrupts
|
||||||
|
|||||||
Reference in new issue
Block a user