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

LimeSDR input: NCO support basic

This commit is contained in:
f4exb 2017-04-20 20:18:50 +02:00
parent 826941ba80
commit 11e5b3a429
4 changed files with 203 additions and 223 deletions

View File

@ -18,7 +18,7 @@
#include <cstring>
#include "devicelimesdr.h"
bool DeviceLimeSDR::enableNCO(lms_device_t *device, bool dir_tx, std::size_t chan, float frequency, bool enable)
bool DeviceLimeSDR::enableNCO(lms_device_t *device, bool dir_tx, std::size_t chan, bool enable)
{
if (LMS_WriteParam(device, LMS7param(MAC), chan+1) < 0)
{
@ -55,8 +55,8 @@ bool DeviceLimeSDR::enableNCO(lms_device_t *device, bool dir_tx, std::size_t cha
bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size_t chan, float frequency)
{
bool positive;
float freqs[LMS_NCO_VAL_COUNT];
float phos[LMS_NCO_VAL_COUNT];
float_type freqs[LMS_NCO_VAL_COUNT];
float_type phos[LMS_NCO_VAL_COUNT];
if (LMS_GetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0)
{
@ -75,7 +75,7 @@ bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size
freqs[0] = frequency;
if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0)
if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, 0.0f) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set frequency to %f\n", frequency);
return false;
@ -95,8 +95,8 @@ bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size
if (enable)
{
bool positive;
float freqs[LMS_NCO_VAL_COUNT];
float phos[LMS_NCO_VAL_COUNT];
float_type freqs[LMS_NCO_VAL_COUNT];
float_type phos[LMS_NCO_VAL_COUNT];
if (LMS_GetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0)
{
@ -115,7 +115,7 @@ bool DeviceLimeSDR::setNCOFrequency(lms_device_t *device, bool dir_tx, std::size
freqs[0] = frequency;
if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, phos) < 0)
if (LMS_SetNCOFrequency(device, dir_tx, chan, freqs, 0.0f) < 0)
{
fprintf(stderr, "DeviceLimeSDR::setNCOFrequency: cannot set frequency to %f\n", frequency);
return false;

View File

@ -666,13 +666,13 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
m_settings.m_ncoFrequency))
{
doCalibration = true;
qDebug("LimeSDRInput::applySettings: %sd and set NCO to %f Hz",
qDebug("LimeSDRInput::applySettings: %sd and set NCO to %d Hz",
m_settings.m_ncoEnable ? "enable" : "disable",
m_settings.m_ncoFrequency);
}
else
{
qCritical("LimeSDRInput::applySettings: could %s and set LPF FIR to %f Hz",
qCritical("LimeSDRInput::applySettings: could not %s and set NCO to %d Hz",
m_settings.m_ncoEnable ? "enable" : "disable",
m_settings.m_ncoFrequency);
}

View File

@ -65,6 +65,9 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) :
ui->channelNumberText->setText(tr("#%1").arg(m_limeSDRInput->getChannelIndex()));
ui->hwDecimLabel->setText(QString::fromUtf8("H\u2193"));
ui->swDecimLabel->setText(QString::fromUtf8("S\u2193"));
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
@ -251,7 +254,7 @@ void LimeSDRInputGUI::displaySettings()
ui->ncoFrequency->setValueRange(7,
(m_settings.m_centerFrequency - ncoHalfRange)/1000,
(m_settings.m_centerFrequency + ncoHalfRange)/1000); // frequency dial is in kHz
ui->ncoFrequency->setValue(m_settings.m_centerFrequency + m_settings.m_ncoFrequency);
ui->ncoFrequency->setValue((m_settings.m_centerFrequency + m_settings.m_ncoFrequency)/1000);
}
void LimeSDRInputGUI::sendSettings()
@ -355,7 +358,8 @@ void LimeSDRInputGUI::on_centerFrequency_changed(quint64 value)
void LimeSDRInputGUI::on_ncoFrequency_changed(quint64 value)
{
m_settings.m_ncoFrequency = (int64_t) value - (int64_t) m_settings.m_centerFrequency;
m_settings.m_ncoFrequency = (int64_t) value - (int64_t) m_settings.m_centerFrequency/1000;
m_settings.m_ncoFrequency *= 1000;
sendSettings();
}
@ -368,7 +372,7 @@ void LimeSDRInputGUI::on_ncoEnable_toggled(bool checked)
void LimeSDRInputGUI::on_ncoReset_clicked(bool checked)
{
m_settings.m_ncoFrequency = 0;
ui->ncoFrequency->setValue(m_settings.m_centerFrequency);
ui->ncoFrequency->setValue(m_settings.m_centerFrequency/1000);
sendSettings();
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>265</height>
<width>350</width>
<height>290</height>
</rect>
</property>
<property name="sizePolicy">
@ -18,8 +18,8 @@
</property>
<property name="minimumSize">
<size>
<width>340</width>
<height>250</height>
<width>350</width>
<height>290</height>
</size>
</property>
<property name="font">
@ -49,6 +49,9 @@
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QVBoxLayout" name="deviceUILayout">
<item>
@ -190,18 +193,12 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="ncoSampleRateLayout">
<property name="leftMargin">
<number>6</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>2</number>
</property>
<item>
<widget class="ButtonSwitch" name="ncoEnable">
@ -230,7 +227,7 @@
</widget>
</item>
<item>
<widget class="QWidget" name="ncoFrequency" native="true">
<widget class="ValueDial" name="ncoFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@ -261,6 +258,165 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="ButtonSwitch" name="dcOffset">
<property name="toolTip">
<string>Automatic DC offset removal</string>
</property>
<property name="text">
<string>DC</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="iqImbalance">
<property name="toolTip">
<string>Automatic IQ imbalance correction</string>
</property>
<property name="text">
<string>IQ</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_lna">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="ncoSampleRateLayout">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="hwDecimLabel">
<property name="text">
<string>Hw</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="hwDecim">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
<item>
<property name="text">
<string>32</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="swDecimLabel">
<property name="text">
<string>Sw</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="swDecim">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Decimation factor</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
<item>
<property name="text">
<string>32</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
@ -325,186 +481,13 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="corrDecimLayout">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="corrLabel">
<property name="text">
<string>Auto</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="dcOffset">
<property name="toolTip">
<string>Automatic DC offset removal</string>
</property>
<property name="text">
<string>DC</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="iqImbalance">
<property name="toolTip">
<string>Automatic IQ imbalance correction</string>
</property>
<property name="text">
<string>IQ</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="hwDecimLabel">
<property name="text">
<string>HWDec</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="hwDecim">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
<item>
<property name="text">
<string>32</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="swDecimLabel">
<property name="text">
<string>SWDec</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="swDecim">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Decimation factor</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
<item>
<property name="text">
<string>32</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_lna">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="lpfLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>2</number>
</property>
<item>
<widget class="QLabel" name="lpfLabel">
@ -602,15 +585,14 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_vga1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="gainLayout">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="gainLabel">
<property name="text">
@ -670,17 +652,11 @@
</item>
<item>
<layout class="QHBoxLayout" name="statusLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>6</number>
<number>2</number>
</property>
<item>
<widget class="QLabel" name="streamStatusLabel">
@ -829,6 +805,13 @@ QToolTip{background-color: white; color: black;}</string>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_vga2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="padLayout">
<item>
@ -846,13 +829,6 @@ QToolTip{background-color: white; color: black;}</string>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_vga2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>