mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-27 22:49:02 +08:00
rp2040-rx : add Fritzing sketch
This commit is contained in:
@@ -261,6 +261,11 @@ void loop() {
|
|||||||
// Main loop ..
|
// Main loop ..
|
||||||
while (true) {
|
while (true) {
|
||||||
while (qsize >= samplesPerFrame) {
|
while (qsize >= samplesPerFrame) {
|
||||||
|
// Use this with the serial plotter to observe real-time audio signal
|
||||||
|
//for (int i = 0; i < samplesPerFrame; i++) {
|
||||||
|
// Serial.println(sampleBuffer[qhead + i]);
|
||||||
|
//}
|
||||||
|
|
||||||
// We have enough captured samples - try to decode any "ggwave" data:
|
// We have enough captured samples - try to decode any "ggwave" data:
|
||||||
auto tStart = millis();
|
auto tStart = millis();
|
||||||
|
|
||||||
|
|||||||
@@ -328,15 +328,15 @@ void loop() {
|
|||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
i2s_read(i2s_port, sampleBufferRaw, sizeof(TSampleInput)*samplesPerFrame, &bytes_read, portMAX_DELAY);
|
i2s_read(i2s_port, sampleBufferRaw, sizeof(TSampleInput)*samplesPerFrame, &bytes_read, portMAX_DELAY);
|
||||||
|
|
||||||
int samples_read = bytes_read/sizeof(TSampleInput);
|
int nSamples = bytes_read/sizeof(TSampleInput);
|
||||||
if (samples_read != samplesPerFrame) {
|
if (nSamples != samplesPerFrame) {
|
||||||
Serial.println("Failed to read samples");
|
Serial.println("Failed to read samples");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MIC_ANALOG)
|
#if defined(MIC_ANALOG)
|
||||||
// the ADC samples are 12-bit so we need to do some massaging to make them 16-bit
|
// the ADC samples are 12-bit so we need to do some massaging to make them 16-bit
|
||||||
for (int i = 0; i < samples_read; i += 2) {
|
for (int i = 0; i < nSamples; i += 2) {
|
||||||
auto & s0 = sampleBuffer[i];
|
auto & s0 = sampleBuffer[i];
|
||||||
auto & s1 = sampleBuffer[i + 1];
|
auto & s1 = sampleBuffer[i + 1];
|
||||||
|
|
||||||
@@ -350,14 +350,14 @@ void loop() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MIC_I2S) || defined(MIC_I2S_SPH0645)
|
#if defined(MIC_I2S) || defined(MIC_I2S_SPH0645)
|
||||||
for (int i = 0; i < samples_read; ++i) {
|
for (int i = 0; i < nSamples; ++i) {
|
||||||
sampleBuffer[i] = (sampleBufferRaw[i] & 0xFFFFFFF0) >> 11;
|
sampleBuffer[i] = (sampleBufferRaw[i] & 0xFFFFFFF0) >> 11;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this with the serial plotter to observe real-time audio signal
|
// Use this with the serial plotter to observe real-time audio signal
|
||||||
//for (int i = 0; i < samples_read; i++) {
|
//for (int i = 0; i < nSamples; i++) {
|
||||||
// Serial.println(sampleBuffer[i]);
|
// Serial.println(sampleBuffer[i]);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|||||||
BIN
examples/rp2040-rx/fritzing-sketch.fzz
Normal file
BIN
examples/rp2040-rx/fritzing-sketch.fzz
Normal file
Binary file not shown.
BIN
examples/rp2040-rx/fritzing-sketch_bb.png
Normal file
BIN
examples/rp2040-rx/fritzing-sketch_bb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 KiB |
@@ -203,7 +203,7 @@ void loop() {
|
|||||||
int nSamples = samplesRead;
|
int nSamples = samplesRead;
|
||||||
samplesRead = 0;
|
samplesRead = 0;
|
||||||
|
|
||||||
//// loop through any new collected samples
|
// Use this with the serial plotter to observe real-time audio signal
|
||||||
//for (int i = 0; i < nSamples; i++) {
|
//for (int i = 0; i < nSamples; i++) {
|
||||||
// Serial.printf("%d\n", sampleBuffer[i]);
|
// Serial.printf("%d\n", sampleBuffer[i]);
|
||||||
//}
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user