From dae34e46b114c9e50a04ab4592d377cc19b2fdca Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 11 Jun 2022 17:06:25 +0300 Subject: [PATCH] arduino-tx2 : fix example --- examples/arduino-tx2/arduino-tx2.ino | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/arduino-tx2/arduino-tx2.ino b/examples/arduino-tx2/arduino-tx2.ino index 8ccaf6e..d67b264 100644 --- a/examples/arduino-tx2/arduino-tx2.ino +++ b/examples/arduino-tx2/arduino-tx2.ino @@ -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);