rp2040-rx : analog mic example

This commit is contained in:
Georgi Gerganov
2022-07-22 21:59:47 +03:00
parent 4680ff5f5e
commit 84cdf0a0bd
9 changed files with 537 additions and 17 deletions

View File

@@ -50,7 +50,7 @@
// Uncoment this line to enable long-range transmission
// The used protocols are slower and use more memory to decode, but are much more robust
//#define EXAMPLE_LONG_RANGE 1
//#define LONG_RANGE 1
#include <ggwave.h>
@@ -129,7 +129,7 @@ void send_text(GGWave & ggwave, uint8_t pin, const char * text, GGWave::TxProtoc
void setup() {
Serial.begin(57600);
//while (!Serial);
while (!Serial);
pinMode(kPinLED0, OUTPUT);
pinMode(kPinSpeaker, OUTPUT);
@@ -139,6 +139,8 @@ void setup() {
#ifdef DISPLAY_OUTPUT
{
Serial.println(F("Initializing display..."));
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
@@ -175,12 +177,15 @@ void setup() {
// Adjust the "ggwave" parameters to your needs.
// Make sure that the "payloadLength" parameter matches the one used on the transmitting side.
#ifdef EXAMPLE_LONG_RANGE
#ifdef LONG_RANGE
// The "FAST" protocols require 2x more memory, so we reduce the payload length to compensate:
p.payloadLength = 8;
#else
p.payloadLength = 16;
#endif
Serial.print(F("Using payload length: "));
Serial.println(p.payloadLength);
p.sampleRateInp = sampleRate;
p.sampleRateOut = sampleRate;
p.sampleRate = sampleRate;
@@ -204,12 +209,12 @@ void setup() {
// Remove the ones that you don't need to reduce memory usage
GGWave::Protocols::rx().disableAll();
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_NORMAL, true);
#ifdef EXAMPLE_LONG_RANGE
#ifdef LONG_RANGE
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_FAST, true);
#endif
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_FASTEST, true);
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_NORMAL, true);
#ifdef EXAMPLE_LONG_RANGE
#ifdef LONG_RANGE
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_FAST, true);
#endif
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_FASTEST, true);
@@ -249,7 +254,6 @@ void loop() {
int but0Prev = HIGH;
GGWave::TxRxData result;
GGWave::Spectrum rxSpectrum;
char resultLast[17];
int tLastReceive = -10000;
@@ -295,6 +299,7 @@ void loop() {
#ifdef DISPLAY_OUTPUT
const auto t = millis();
static GGWave::Spectrum rxSpectrum;
if (ggwave.rxTakeSpectrum(rxSpectrum) && t > 2000) {
const bool isNew = t - tLastReceive < 2000;