From 8b75c47257cc6c09536c5a9da1154b0f170c19b4 Mon Sep 17 00:00:00 2001 From: dj1an Date: Thu, 24 Jun 2021 19:50:29 +0200 Subject: [PATCH] Added PTT Output for external Amplifier --- data/tracker.json | 8 ++++++++ src/LoRa_APRS_Tracker.cpp | 19 +++++++++++++++++++ src/configuration.cpp | 12 ++++++++++++ src/configuration.h | 13 +++++++++++++ 4 files changed, 52 insertions(+) diff --git a/data/tracker.json b/data/tracker.json index 43bb129..9ed6067 100644 --- a/data/tracker.json +++ b/data/tracker.json @@ -27,5 +27,13 @@ "spreading_factor":12, "signal_bandwidth":125000, "coding_rate4":5 + }, + "ptt_output": + { + "active":false, + "io_pin": 4, + "start_delay": 0, + "end_delay": 0, + "reverse":false } } diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 6c3a3e9..34067d0 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -60,6 +60,12 @@ void setup() setup_gps(); setup_lora(); + if (Config.ptt.active) + { + pinMode(Config.ptt.io_pin, OUTPUT); + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); + } + // make sure wifi and bt is off as we don't need it: WiFi.mode(WIFI_OFF); btStop(); @@ -244,6 +250,13 @@ void loop() String data = msg.encode(); logPrintlnD(data); show_display("<< TX >>", data); + + if (Config.ptt.active) + { + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? LOW : HIGH); + delay(Config.ptt.start_delay); + } + LoRa.beginPacket(); // Header: LoRa.write('<'); @@ -261,6 +274,12 @@ void loop() lastTxdistance = 0.0; lastTxTime = millis(); } + + if (Config.ptt.active) + { + delay(Config.ptt.end_delay); + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); + } } if(gps_time_update) diff --git a/src/configuration.cpp b/src/configuration.cpp index afac9a4..d887935 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -68,6 +68,12 @@ Configuration ConfigurationManagement::readConfiguration() conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5; + conf.ptt.active = data["ptt_output"]["active"] | false; + conf.ptt.io_pin = data["ptt_output"]["io_pin"] | 4; + conf.ptt.start_delay = data["ptt_output"]["start_delay"] | 0; + conf.ptt.end_delay = data["ptt_output"]["end_delay"] | 0; + conf.ptt.reverse = data["ptt_output"]["reverse"] | false; + return conf; } @@ -104,6 +110,12 @@ void ConfigurationManagement::writeConfiguration(Configuration conf) data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth; data["lora"]["coding_rate4"] = conf.lora.codingRate4; + data["ptt_out"]["active"] = conf.ptt.active; + data["ptt_out"]["io_pin"] = conf.ptt.io_pin; + data["ptt_out"]["start_delay"] = conf.ptt.start_delay; + data["ptt_out"]["end_delay"] = conf.ptt.end_delay; + data["ptt_out"]["reverse"] = conf.ptt.reverse; + serializeJson(data, file); file.close(); } diff --git a/src/configuration.h b/src/configuration.h index ab2e93d..3bfb8ae 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -47,6 +47,18 @@ public: int codingRate4; }; + class PTT + { + public: + PTT() : active(false), io_pin(4), start_delay(0), end_delay(0), reverse(false) {} + + bool active; + int io_pin; + int start_delay; + int end_delay; + bool reverse; + }; + Configuration() : callsign("NOCALL-10"), debug(false) {}; String callsign; @@ -54,6 +66,7 @@ public: Beacon beacon; Smart_Beacon smart_beacon; LoRa lora; + PTT ptt; }; class ConfigurationManagement