1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Add new settings to API.

This commit is contained in:
srcejon 2024-04-07 17:02:43 +01:00
parent 7b6bbe88f3
commit c9632b9fe3

View File

@ -233,9 +233,15 @@ void RadioClock::applySettings(const RadioClockSettings& settings, bool force)
QList<QString> reverseAPIKeys;
if ((settings.m_frequencyMode != m_settings.m_frequencyMode) || force) {
reverseAPIKeys.append("frequencyMode");
}
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
reverseAPIKeys.append("inputFrequencyOffset");
}
if ((settings.m_frequency != m_settings.m_frequency) || force) {
reverseAPIKeys.append("frequency");
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
@ -331,6 +337,13 @@ int RadioClock::webapiSettingsPutPatch(
RadioClockSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
// Ensure inputFrequencyOffset and frequency are consistent
if (channelSettingsKeys.contains("frequency") && !channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = settings.m_frequency - m_centerFrequency;
} else if (channelSettingsKeys.contains("inputFrequencyOffset") && !channelSettingsKeys.contains("frequency")) {
settings.m_frequency = m_centerFrequency + settings.m_inputFrequencyOffset;
}
MsgConfigureRadioClock *msg = MsgConfigureRadioClock::create(settings, force);
m_inputMessageQueue.push(msg);
@ -351,9 +364,15 @@ void RadioClock::webapiUpdateChannelSettings(
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response)
{
if (channelSettingsKeys.contains("frequencyMode")) {
settings.m_frequencyMode = (RadioClockSettings::FrequencyMode) response.getRadioClockSettings()->getFrequencyMode();
}
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getRadioClockSettings()->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("frequency")) {
settings.m_frequency = response.getRadioClockSettings()->getFrequency();
}
if (channelSettingsKeys.contains("rfBandwidth")) {
settings.m_rfBandwidth = response.getRadioClockSettings()->getRfBandwidth();
}
@ -403,7 +422,9 @@ void RadioClock::webapiUpdateChannelSettings(
void RadioClock::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RadioClockSettings& settings)
{
response.getRadioClockSettings()->setFrequencyMode((int)settings.m_frequencyMode);
response.getRadioClockSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getRadioClockSettings()->setFrequency(settings.m_frequency);
response.getRadioClockSettings()->setRfBandwidth(settings.m_rfBandwidth);
response.getRadioClockSettings()->setThreshold(settings.m_threshold);
response.getRadioClockSettings()->setModulation((int)settings.m_modulation);
@ -536,9 +557,15 @@ void RadioClock::webapiFormatChannelSettings(
// transfer data that has been modified. When force is on transfer all data except reverse API data
if (channelSettingsKeys.contains("frequencyMode") || force) {
swgRadioClockSettings->setFrequencyMode(settings.m_frequencyMode);
}
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
swgRadioClockSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
}
if (channelSettingsKeys.contains("frequency") || force) {
swgRadioClockSettings->setFrequency(settings.m_frequency);
}
if (channelSettingsKeys.contains("rfBandwidth") || force) {
swgRadioClockSettings->setRfBandwidth(settings.m_rfBandwidth);
}