mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 08:37:59 +08:00
arduino-tx2 : fix example
This commit is contained in:
@@ -10,8 +10,10 @@ const int sampleRate = 6000;
|
||||
|
||||
GGWave * g_ggwave = nullptr;
|
||||
|
||||
char txt[64];
|
||||
#define P(str) (strcpy_P(txt, PSTR(str)), txt)
|
||||
|
||||
void send_text(GGWave & ggwave, uint8_t pin, const char * text, GGWave::TxProtocolId protocolId) {
|
||||
Serial.print(F("Sending text: "));
|
||||
Serial.println(text);
|
||||
|
||||
ggwave.init(text, protocolId);
|
||||
@@ -38,7 +40,7 @@ void setup() {
|
||||
pinMode(kPinButton0, INPUT);
|
||||
pinMode(kPinButton1, INPUT);
|
||||
|
||||
Serial.println(F("Trying to create ggwave instance"));
|
||||
Serial.println(P("Trying to create ggwave instance"));
|
||||
|
||||
auto p = GGWave::getDefaultParameters();
|
||||
p.payloadLength = 16;
|
||||
@@ -57,18 +59,13 @@ void setup() {
|
||||
|
||||
g_ggwave = &ggwave;
|
||||
|
||||
Serial.println(F("Instance initialized"));
|
||||
Serial.println(P("Instance initialized"));
|
||||
}
|
||||
|
||||
char txt[16];
|
||||
int pressed = 0;
|
||||
bool isDown = false;
|
||||
|
||||
#define P(str) (strcpy_P(txt, PSTR(str)), txt)
|
||||
|
||||
void loop() {
|
||||
Serial.println(F("Starting main loop"));
|
||||
|
||||
auto & ggwave = *g_ggwave;
|
||||
|
||||
delay(1000);
|
||||
@@ -112,6 +109,7 @@ void loop() {
|
||||
send_text(ggwave, kPinSpeaker, P("Press the button!"), GGWAVE_PROTOCOL_MT_FASTEST);
|
||||
digitalWrite(kPinLed0, LOW);
|
||||
|
||||
Serial.println(P("Starting main loop"));
|
||||
while (true) {
|
||||
int but0 = digitalRead(kPinButton0);
|
||||
int but1 = digitalRead(kPinButton1);
|
||||
|
||||
Reference in New Issue
Block a user