Skip to content

Commit fa899cd

Browse files
committed
some edit
1 parent b4f5688 commit fa899cd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: libraries/ESP_I2S/examples/Simple_tone/Simple_tone.ino

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
2nd September 2021
2525
Lucas Saavedra Vaz (lucasssvaz)
2626
22nd December 2023
27-
anonZ
27+
anon
2828
10nd February 2025
2929
*/
3030

3131
#include <ESP_I2S.h>
3232

33-
// In fact, the GPIO pins are not fixed, most other pins can be used for the I2S function.
33+
// The GPIO pins are not fixed, most other pins can be used for the I2S function.
3434
#define I2S_LRC 25
3535
#define I2S_BCLK 5
3636
#define I2S_DIN 26
@@ -43,7 +43,7 @@ i2s_data_bit_width_t bps = I2S_DATA_BIT_WIDTH_16BIT;
4343
i2s_mode_t mode = I2S_MODE_STD;
4444
i2s_slot_mode_t slot = I2S_SLOT_MODE_STEREO;
4545

46-
const int halfWavelength = (sampleRate / frequency / 2); // half wavelength of square wave
46+
const int halfWavelength = sampleRate / frequency / 2; // half wavelength of square wave
4747

4848
int32_t sample = amplitude; // current sample value
4949
unsigned int count = 0;
@@ -70,9 +70,12 @@ void loop() {
7070
sample = -1 * sample;
7171
}
7272

73-
i2s.write(sample); // Right channel
73+
// Right channel, low 8 bit then hight 8 bit
74+
i2s.write(sample);
7475
i2s.write(sample >> 8);
75-
i2s.write(sample); // Left channel
76+
77+
// Left channel, low 8 bit then hight 8 bit
78+
i2s.write(sample);
7679
i2s.write(sample >> 8);
7780

7881
// increment the counter for the next sample

0 commit comments

Comments
 (0)