1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

AM demod channel mode: fixed some frequency display inconsistencies

This commit is contained in:
f4exb 2023-11-28 07:25:40 +01:00
parent 003a04ed70
commit ee51ffd705

View File

@ -200,11 +200,13 @@ void AMDemodGUI::on_frequencyMode_currentIndexChanged(int index)
{
m_settings.m_frequencyMode = (AMDemodSettings::FrequencyMode) index;
ui->deltaFrequency->blockSignals(true);
if (m_settings.m_frequencyMode == AMDemodSettings::Offset)
{
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
ui->deltaUnits->setText("Hz");
if (m_settings.m_snap)
{
m_settings.m_snap = false;
@ -229,10 +231,14 @@ void AMDemodGUI::on_frequencyMode_currentIndexChanged(int index)
ui->deltaFrequency->setValue(freqToChannel(m_settings.m_frequency) / 1000);
ui->deltaUnits->setText("MHz");
}
ui->deltaFrequency->blockSignals(false);
if (m_settings.m_snap) {
applySnap();
}
updateAbsoluteCenterFrequency();
applySettings();
}
@ -256,11 +262,14 @@ void AMDemodGUI::calcOffset()
void AMDemodGUI::channelMarkerChangedByCursor()
{
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
if (m_settings.m_snap) {
applySnap();
}
m_settings.m_frequency = m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset;
int value = 0;
if (m_settings.m_frequencyMode == AMDemodSettings::Offset) {
value = m_settings.m_inputFrequencyOffset;
} else if (m_settings.m_frequencyMode == AMDemodSettings::MediumWave) {
@ -653,9 +662,32 @@ void AMDemodGUI::snapClicked()
} else {
m_settings.m_snap = !m_settings.m_snap;
}
if (m_settings.m_snap) {
if (m_settings.m_snap)
{
applySnap();
qint64 value;
if (m_settings.m_frequencyMode == AMDemodSettings::Offset) {
value = m_settings.m_inputFrequencyOffset;
} else if (m_settings.m_frequencyMode == AMDemodSettings::MediumWave) {
value = m_settings.m_frequency / 1000;
} else if (m_settings.m_frequencyMode == AMDemodSettings::Airband25k) {
value = m_settings.m_frequency / 1000;
} else if (m_settings.m_frequencyMode == AMDemodSettings::Airband8K) {
value = freqToChannel(m_settings.m_frequency) / 1000;
}
// We support finer tuning by marker than by deltaFrequency widget (unless in offset mode),
// so block signals so it doesn't truncate frequency to limit of widget
ui->deltaFrequency->blockSignals(true);
ui->deltaFrequency->setValue(value);
ui->deltaFrequency->blockSignals(false);
updateAbsoluteCenterFrequency();
}
displaySnap();
applySettings();
}
@ -667,6 +699,7 @@ void AMDemodGUI::applySnap()
}
qint64 frequency = m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset;
if (m_settings.m_frequencyMode == AMDemodSettings::MediumWave)
{
frequency = (frequency / 1000) * 1000;
@ -677,9 +710,11 @@ void AMDemodGUI::applySnap()
}
else if (m_settings.m_frequencyMode == AMDemodSettings::Airband8K)
{
frequency = std::round((frequency / 8333) * 8333.3);
frequency = std::round((frequency / 8333) * 8333.33333333);
}
m_settings.m_inputFrequencyOffset = frequency - m_deviceCenterFrequency;
m_settings.m_frequency = frequency;
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
}