1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-04 23:14:47 -04:00

PTT feature: GPIO and command support (1)

This commit is contained in:
f4exb
2023-03-06 21:20:40 +01:00
parent cf0489d96f
commit 5cad053158
18 changed files with 1265 additions and 452 deletions
@@ -25,6 +25,7 @@
#include "audio/audiodevicemanager.h"
#include "dsp/dspengine.h"
#include "util/db.h"
#include "channel/channelwebapiutils.h"
#include "simplepttreport.h"
#include "simplepttworker.h"
@@ -174,6 +175,7 @@ void SimplePTTWorker::sendPTT(bool tx)
if (m_settings.m_rxDeviceSetIndex >= 0)
{
m_tx = false;
preSwitch(true);
switchedOff = turnDevice(false);
}
@@ -188,6 +190,7 @@ void SimplePTTWorker::sendPTT(bool tx)
if (m_settings.m_txDeviceSetIndex >= 0)
{
m_tx = true;
preSwitch(false);
switchedOff = turnDevice(false);
}
@@ -249,6 +252,59 @@ bool SimplePTTWorker::turnDevice(bool on)
}
}
void SimplePTTWorker::preSwitch(bool tx)
{
double rxFrequency = 0;
double txFrequency = 0;
ChannelWebAPIUtils::getCenterFrequency(m_settings.m_rxDeviceSetIndex, rxFrequency);
ChannelWebAPIUtils::getCenterFrequency(m_settings.m_txDeviceSetIndex, txFrequency);
m_command.run(
tx ? m_settings.m_rx2txCommand : m_settings.m_tx2rxCommand,
m_settings.m_rxDeviceSetIndex,
rxFrequency,
m_settings.m_txDeviceSetIndex,
txFrequency
);
if (m_settings.m_gpioControl == SimplePTTSettings::GPIONone) {
return;
}
int gpioMask;
int gpioPins;
int gpioDir;
int deviceSetIndex = m_settings.m_gpioControl == SimplePTTSettings::GPIOTx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex;
if (!ChannelWebAPIUtils::getDeviceSetting(deviceSetIndex, "gpioDir", gpioDir))
{
qDebug() << "SimplePTTWorker::preSwitch - Failed to read gpioDir setting. Does this SDR support it?";
return;
}
gpioMask = tx ? m_settings.m_rx2txGPIOMask : m_settings.m_tx2rxGPIOMask;
gpioDir |= gpioMask; // set masked pins as outputs
if (!ChannelWebAPIUtils::patchDeviceSetting(deviceSetIndex, "gpioDir", gpioDir))
{
qDebug() << "SimplePTTWorker::preSwitch - Failed to write gpioDir setting. Does this SDR support it?";
return;
}
if (!ChannelWebAPIUtils::getDeviceSetting(deviceSetIndex, "gpioPins", gpioPins))
{
qDebug() << "SimplePTTWorker::preSwitch - Failed to read gpioPins setting. Does this SDR support it?";
return;
}
gpioPins != gpioMask & (tx ? m_settings.m_rx2txGPIOValues : m_settings.m_tx2rxGPIOValues);
gpioPins &= ~gpioMask | (tx ? m_settings.m_rx2txGPIOValues : m_settings.m_tx2rxGPIOValues);
if (!ChannelWebAPIUtils::patchDeviceSetting(deviceSetIndex, "gpioPins", gpioPins)) {
qDebug() << "SimplePTTWorker::preSwitch - Failed to write gpioPins setting. Does this SDR support it?";
}
}
void SimplePTTWorker::handleAudio()
{
unsigned int nbRead;