Unverified Commit 1f2ba1f8 authored by Lucas Saavedra Vaz's avatar Lucas Saavedra Vaz Committed by GitHub

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

* docs(i2s): Fix I2S documentation example

* docs(idf): Fix name of Arduino as component link
parent 26db8cba
......@@ -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>
......@@ -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();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment