Merge pull request #34 from dj1an/dj1an-ptt

Added PTT Output for external Amplifier
This commit is contained in:
Peter Buchegger 2021-06-24 20:17:17 +02:00 committed by GitHub
commit 5a28898255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 0 deletions

View File

@ -28,5 +28,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
}
}

View File

@ -63,6 +63,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();
@ -263,6 +269,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('<');
@ -280,6 +293,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)

View File

@ -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;
}
@ -105,6 +111,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();
}

View File

@ -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), enhance_precision(true) {};
String callsign;
@ -55,6 +67,7 @@ public:
Beacon beacon;
Smart_Beacon smart_beacon;
LoRa lora;
PTT ptt;
};
class ConfigurationManagement