mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 01:11:22 +08:00
arduino-tx : trying to use original library
This commit is contained in:
5
examples/arduino-tx/.gitignore
vendored
Normal file
5
examples/arduino-tx/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
ggwave
|
||||
ggwave.cpp
|
||||
resampler.h
|
||||
resampler.cpp
|
||||
reed-solomon
|
||||
9
examples/arduino-tx/CMakeLists.txt
Normal file
9
examples/arduino-tx/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# arduino-tx
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/include/ggwave/ggwave.h ${CMAKE_CURRENT_SOURCE_DIR}/ggwave/ggwave.h COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/ggwave.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ggwave.cpp COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/reed-solomon/gf.hpp ${CMAKE_CURRENT_SOURCE_DIR}/reed-solomon/gf.hpp COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/reed-solomon/rs.hpp ${CMAKE_CURRENT_SOURCE_DIR}/reed-solomon/rs.hpp COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/reed-solomon/poly.hpp ${CMAKE_CURRENT_SOURCE_DIR}/reed-solomon/poly.hpp COPYONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/src/reed-solomon/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/reed-solomon/LICENSE COPYONLY)
|
||||
@@ -8,7 +8,7 @@ const int kPinButton0 = 2;
|
||||
const int kPinButton1 = 4;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(57600);
|
||||
Serial.begin(57600);
|
||||
|
||||
//pinMode(kPinLed0, OUTPUT);
|
||||
//pinMode(kPinSpeaker, OUTPUT);
|
||||
@@ -64,6 +64,20 @@ bool isDown = false;
|
||||
void loop() {
|
||||
Serial.println("hello");
|
||||
|
||||
auto p = GGWave::getDefaultParameters();
|
||||
p.sampleFormatInp = GGWAVE_SAMPLE_FORMAT_I16;
|
||||
p.samplesPerFrame = 128;
|
||||
p.payloadLength = 4;
|
||||
p.operatingMode = (ggwave_OperatingMode) (GGWAVE_OPERATING_MODE_TX | GGWAVE_OPERATING_MODE_TX_ONLY_TONES);
|
||||
|
||||
GGWave::getTxProtocols() = GGWave::TxProtocols({{ "[MT] Fastest", 24, 3, 1, 2, true, }});
|
||||
GGWave ggwave(p);
|
||||
|
||||
while (true) {
|
||||
delay(1000);
|
||||
Serial.println("working");
|
||||
}
|
||||
|
||||
//int but0 = digitalRead(kPinButton0);
|
||||
//int but1 = digitalRead(kPinButton1);
|
||||
|
||||
|
||||
86
examples/arduino-tx/arduino-tx.ino-working
Normal file
86
examples/arduino-tx/arduino-tx.ino-working
Normal file
@@ -0,0 +1,86 @@
|
||||
#include <ArduinoSTL.h>
|
||||
|
||||
#include "ggwave/ggwave.h"
|
||||
|
||||
const int kPinLed0 = 13;
|
||||
const int kPinSpeaker = 10;
|
||||
const int kPinButton0 = 2;
|
||||
const int kPinButton1 = 4;
|
||||
|
||||
void setup() {
|
||||
//Serial.begin(57600);
|
||||
|
||||
//pinMode(kPinLed0, OUTPUT);
|
||||
//pinMode(kPinSpeaker, OUTPUT);
|
||||
//pinMode(kPinButton0, INPUT);
|
||||
//pinMode(kPinButton1, INPUT);
|
||||
|
||||
//delay(3000);
|
||||
|
||||
//digitalWrite(kPinLed0, HIGH);
|
||||
//GGWave::send_text(kPinSpeaker, "Hello!", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//digitalWrite(kPinLed0, LOW);
|
||||
|
||||
//delay(2000);
|
||||
|
||||
//digitalWrite(kPinLed0, HIGH);
|
||||
//GGWave::send_text(kPinSpeaker, "This is a", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//GGWave::send_text(kPinSpeaker, "ggwave demo", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//digitalWrite(kPinLed0, LOW);
|
||||
|
||||
//delay(2000);
|
||||
|
||||
//digitalWrite(kPinLed0, HIGH);
|
||||
//GGWave::send_text(kPinSpeaker, "The arduino", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//delay(200);
|
||||
//GGWave::send_text(kPinSpeaker, "transmits data", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//delay(200);
|
||||
//GGWave::send_text(kPinSpeaker, "using sound", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//delay(200);
|
||||
//GGWave::send_text(kPinSpeaker, "through a buzzer", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//digitalWrite(kPinLed0, LOW);
|
||||
|
||||
//delay(1000);
|
||||
|
||||
//digitalWrite(kPinLed0, HIGH);
|
||||
//GGWave::send_text(kPinSpeaker, "The sound is", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//delay(200);
|
||||
//GGWave::send_text(kPinSpeaker, "decoded in a", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//delay(200);
|
||||
//GGWave::send_text(kPinSpeaker, "web page.", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//digitalWrite(kPinLed0, LOW);
|
||||
|
||||
//delay(1000);
|
||||
|
||||
//digitalWrite(kPinLed0, HIGH);
|
||||
//GGWave::send_text(kPinSpeaker, "Press the button!", GGWave::TX_ARDUINO_512_FASTEST);
|
||||
//digitalWrite(kPinLed0, LOW);
|
||||
}
|
||||
|
||||
char txt[16];
|
||||
int pressed = 0;
|
||||
bool isDown = false;
|
||||
|
||||
void loop() {
|
||||
Serial.println("hello");
|
||||
|
||||
//int but0 = digitalRead(kPinButton0);
|
||||
//int but1 = digitalRead(kPinButton1);
|
||||
|
||||
//if (but1 == LOW && isDown == false) {
|
||||
// delay(200);
|
||||
// ++pressed;
|
||||
// isDown = true;
|
||||
//} else if (but1 == HIGH) {
|
||||
// isDown = false;
|
||||
//}
|
||||
|
||||
//if (but0 == LOW) {
|
||||
// snprintf(txt, 16, "Pressed: %d", pressed);
|
||||
|
||||
// digitalWrite(kPinLed0, HIGH);
|
||||
// GGWave::send_text(kPinSpeaker, txt, GGWave::TX_ARDUINO_512_FASTEST);
|
||||
// digitalWrite(kPinLed0, LOW);
|
||||
// pressed = 0;
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user