docs(i2s): Fix I2S documentation example (#9916)

* docs(i2s): Fix I2S documentation example

* docs(idf): Fix name of Arduino as component link
This commit is contained in:
Lucas Saavedra Vaz 2024-06-24 04:23:47 -03:00 committed by GitHub
parent 26db8cba32
commit 1f2ba1f87f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -6,6 +6,6 @@ Advanced Utilities
:maxdepth: 2
Library Builder <lib_builder>
ESP-IDF as Component <esp-idf_component>
Arduino as an ESP-IDF component <esp-idf_component>
OTA Web Update <ota_web_update>
makeEspArduino <make>

View File

@ -536,7 +536,7 @@ Sample code
#include <ESP_I2S.h>
const int buff_size = 128;
int available, read;
int available_bytes, read_bytes;
uint8_t buffer[buff_size];
I2SClass I2S;
@ -544,13 +544,13 @@ Sample code
I2S.setPins(5, 25, 26, 35, 0); //SCK, WS, SDOUT, SDIN, MCLK
I2S.begin(I2S_MODE_STD, 16000, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO);
I2S.read();
available = I2S.available();
if(available < buff_size) {
read = I2S.read(buffer, available);
available_bytes = I2S.available();
if(available_bytes < buff_size) {
read_bytes = I2S.read(buffer, available_bytes);
} else {
read = I2S.read(buffer, buff_size);
read_bytes = I2S.read(buffer, buff_size);
}
I2S.write(buffer, read);
I2S.write(buffer, read_bytes);
I2S.end();
}