mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 00:36:13 +08:00
tmp
This commit is contained in:
@@ -1,15 +1,34 @@
|
||||
#include "ggwave/ggwave.h"
|
||||
|
||||
#include <soc/adc_channel.h>
|
||||
#include <driver/i2s.h>
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
|
||||
|
||||
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
|
||||
// The pins for I2C are defined by the Wire-library.
|
||||
// On an arduino UNO: A4(SDA), A5(SCL)
|
||||
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
|
||||
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
|
||||
// global GGwave instance
|
||||
GGWave ggwave;
|
||||
|
||||
using TSample = int16_t;
|
||||
const size_t kSampleSize_bytes = sizeof(TSample);
|
||||
|
||||
const int sampleRate = 12000;
|
||||
const int samplesPerFrame = 256;
|
||||
const int sampleRate = 24000;
|
||||
const int samplesPerFrame = 512;
|
||||
|
||||
TSample sampleBuffer[samplesPerFrame];
|
||||
|
||||
@@ -37,6 +56,28 @@ void setup() {
|
||||
while (!Serial);
|
||||
Serial.println(F("GGWave test for ESP32"));
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
}
|
||||
|
||||
// Show initial display buffer contents on the screen --
|
||||
// the library initializes this with an Adafruit splash screen.
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
// Clear the buffer
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Normal 1:1 pixel scale
|
||||
display.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
display.println(F("GGWave!"));
|
||||
|
||||
display.display();
|
||||
|
||||
{
|
||||
Serial.println(F("Trying to create ggwave instance"));
|
||||
|
||||
@@ -57,16 +98,16 @@ void setup() {
|
||||
//GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_DT_NORMAL, true);
|
||||
//GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_DT_FAST, true);
|
||||
//GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_DT_FASTEST, true);
|
||||
GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_MT_NORMAL, true);
|
||||
GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_MT_FAST, true);
|
||||
//GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_MT_NORMAL, true);
|
||||
//GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_MT_FAST, true);
|
||||
GGWave::Protocols::tx().toggle(GGWAVE_PROTOCOL_MT_FASTEST, true);
|
||||
|
||||
GGWave::Protocols::rx().disableAll();
|
||||
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_NORMAL, true);
|
||||
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_FAST, true);
|
||||
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_FASTEST, true);
|
||||
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_NORMAL, true);
|
||||
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_FAST, true);
|
||||
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_DT_FASTEST, true);
|
||||
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_NORMAL, true);
|
||||
//GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_FAST, true);
|
||||
GGWave::Protocols::rx().toggle(GGWAVE_PROTOCOL_MT_FASTEST, true);
|
||||
|
||||
ggwave.prepare(p);
|
||||
@@ -122,6 +163,10 @@ void loop() {
|
||||
s1 = s0 ^ s1;
|
||||
s0 = s0 ^ s1;
|
||||
}
|
||||
|
||||
//for (int i = 0; i < samples_read; i++) {
|
||||
// Serial.println(sampleBuffer[i]);
|
||||
//}
|
||||
}
|
||||
|
||||
auto tStart = millis();
|
||||
@@ -148,9 +193,15 @@ void loop() {
|
||||
Serial.println(F(" bytes:"));
|
||||
|
||||
Serial.println((char *) result.data());
|
||||
}
|
||||
|
||||
//for (int i = 0; i < samples_read; i++) {
|
||||
// Serial.println(samples[i]);
|
||||
//}
|
||||
display.clearDisplay();
|
||||
|
||||
display.setTextSize(2); // Normal 1:1 pixel scale
|
||||
display.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
display.println((char *) result.data());
|
||||
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user