mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-07 23:43:42 +00:00
Bugfixes and speed improvements
This commit is contained in:
parent
199535450d
commit
926392e5b9
37 changed files with 873 additions and 566 deletions
|
|
@ -105,6 +105,18 @@ uint8_t *USBInBuffer::getBuffer() const
|
|||
return buffer;
|
||||
}
|
||||
|
||||
static Protocol::DeviceLimits limits = {
|
||||
.minFreq = 1000000,
|
||||
.maxFreq = 6000000000,
|
||||
.minIFBW = 10,
|
||||
.maxIFBW = 10000,
|
||||
.maxPoints = 4501,
|
||||
.cdbm_min = -4000,
|
||||
.cdbm_max = -1000,
|
||||
.minRBW = 10,
|
||||
.maxRBW = 10000,
|
||||
};
|
||||
|
||||
Device::Device(QString serial)
|
||||
{
|
||||
qDebug() << "Starting device connection...";
|
||||
|
|
@ -162,6 +174,8 @@ Device::Device(QString serial)
|
|||
connect(&transmissionTimer, &QTimer::timeout, this, &Device::transmissionTimeout);
|
||||
transmissionTimer.setSingleShot(true);
|
||||
transmissionActive = false;
|
||||
// got a new connection, request limits
|
||||
SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceLimits);
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
|
|
@ -251,6 +265,11 @@ std::set<QString> Device::GetDevices()
|
|||
return serials;
|
||||
}
|
||||
|
||||
Protocol::DeviceLimits Device::Limits()
|
||||
{
|
||||
return limits;
|
||||
}
|
||||
|
||||
void Device::USBHandleThread()
|
||||
{
|
||||
qInfo() << "Receive thread started" << flush;
|
||||
|
|
@ -388,6 +407,9 @@ void Device::ReceivedData()
|
|||
emit NackReceived();
|
||||
// transmissionFinished(TransmissionResult::Nack);
|
||||
break;
|
||||
case Protocol::PacketType::DeviceLimits:
|
||||
limits = packet.limits;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,13 @@ public:
|
|||
bool SetManual(Protocol::ManualControl manual);
|
||||
bool SendFirmwareChunk(Protocol::FirmwarePacket &fw);
|
||||
bool SendCommandWithoutPayload(Protocol::PacketType type);
|
||||
// Returns serial numbers of all connected devices
|
||||
static std::set<QString> GetDevices();
|
||||
QString serial() const;
|
||||
Protocol::DeviceInfo getLastInfo() const;
|
||||
QString getLastDeviceInfoString();
|
||||
|
||||
// Returns serial numbers of all connected devices
|
||||
static std::set<QString> GetDevices();
|
||||
static Protocol::DeviceLimits Limits();
|
||||
signals:
|
||||
void DatapointReceived(Protocol::Datapoint);
|
||||
void ManualStatusReceived(Protocol::ManualStatus);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@ SignalgeneratorWidget::SignalgeneratorWidget(QWidget *parent) :
|
|||
ui->frequency->setPrefixes(" kMG");
|
||||
|
||||
connect(ui->frequency, &SIUnitEdit::valueChanged, [=](double newval) {
|
||||
// TODO centralize min/max values
|
||||
if(newval < 9000) {
|
||||
newval = 9000;
|
||||
} else if (newval > 6000000000) {
|
||||
newval = 6000000000;
|
||||
if(newval < Device::Limits().minFreq) {
|
||||
newval = Device::Limits().minFreq;
|
||||
} else if (newval > Device::Limits().maxFreq) {
|
||||
newval = Device::Limits().maxFreq;
|
||||
}
|
||||
ui->frequency->setValueQuiet(newval);
|
||||
emit SettingsChanged();
|
||||
|
|
|
|||
|
|
@ -295,8 +295,8 @@ void SpectrumAnalyzer::SetSpan(double span)
|
|||
|
||||
void SpectrumAnalyzer::SetFullSpan()
|
||||
{
|
||||
settings.f_start = 0;
|
||||
settings.f_stop = 6000000000;
|
||||
settings.f_start = Device::Limits().minFreq;
|
||||
settings.f_stop = Device::Limits().maxFreq;
|
||||
ConstrainAndUpdateFrequencies();
|
||||
}
|
||||
|
||||
|
|
@ -324,6 +324,11 @@ void SpectrumAnalyzer::SpanZoomOut()
|
|||
|
||||
void SpectrumAnalyzer::SetRBW(double bandwidth)
|
||||
{
|
||||
if(bandwidth > Device::Limits().maxRBW) {
|
||||
bandwidth = Device::Limits().maxRBW;
|
||||
} else if(bandwidth < Device::Limits().minRBW) {
|
||||
bandwidth = Device::Limits().minRBW;
|
||||
}
|
||||
settings.RBW = bandwidth;
|
||||
emit RBWChanged(settings.RBW);
|
||||
SettingsChanged();
|
||||
|
|
@ -339,13 +344,15 @@ void SpectrumAnalyzer::SetAveraging(unsigned int averages)
|
|||
|
||||
void SpectrumAnalyzer::ConstrainAndUpdateFrequencies()
|
||||
{
|
||||
// TODO central hardware limits
|
||||
if(settings.f_stop > 6000000000) {
|
||||
settings.f_stop = 6000000000;
|
||||
if(settings.f_stop > Device::Limits().maxFreq) {
|
||||
settings.f_stop = Device::Limits().maxFreq;
|
||||
}
|
||||
if(settings.f_start > settings.f_stop) {
|
||||
settings.f_start = settings.f_stop;
|
||||
}
|
||||
if(settings.f_start < Device::Limits().minFreq) {
|
||||
settings.f_start = Device::Limits().minFreq;
|
||||
}
|
||||
emit startFreqChanged(settings.f_start);
|
||||
emit stopFreqChanged(settings.f_stop);
|
||||
emit spanChanged(settings.f_stop - settings.f_start);
|
||||
|
|
|
|||
|
|
@ -600,8 +600,8 @@ void VNA::SetSpan(double span)
|
|||
|
||||
void VNA::SetFullSpan()
|
||||
{
|
||||
settings.f_start = 0;
|
||||
settings.f_stop = 6000000000;
|
||||
settings.f_start = Device::Limits().minFreq;
|
||||
settings.f_stop = Device::Limits().maxFreq;
|
||||
ConstrainAndUpdateFrequencies();
|
||||
}
|
||||
|
||||
|
|
@ -630,10 +630,10 @@ void VNA::SpanZoomOut()
|
|||
void VNA::SetSourceLevel(double level)
|
||||
{
|
||||
// TODO remove hardcoded limits
|
||||
if(level > -10.0) {
|
||||
level = -10.0;
|
||||
} else if(level < -42.0) {
|
||||
level = -42.0;
|
||||
if(level > Device::Limits().cdbm_max / 100.0) {
|
||||
level = Device::Limits().cdbm_max / 100.0;
|
||||
} else if(level < Device::Limits().cdbm_min / 100.0) {
|
||||
level = Device::Limits().cdbm_min / 100.0;
|
||||
}
|
||||
emit sourceLevelChanged(level);
|
||||
settings.cdbm_excitation = level * 100;
|
||||
|
|
@ -645,8 +645,8 @@ void VNA::SetPoints(unsigned int points)
|
|||
// TODO remove hardcoded limits
|
||||
if (points < 1) {
|
||||
points = 1;
|
||||
} else if(points > 4501) {
|
||||
points = 4501;
|
||||
} else if(points > Device::Limits().maxPoints) {
|
||||
points = Device::Limits().maxPoints;
|
||||
}
|
||||
emit pointsChanged(points);
|
||||
settings.points = points;
|
||||
|
|
@ -655,6 +655,11 @@ void VNA::SetPoints(unsigned int points)
|
|||
|
||||
void VNA::SetIFBandwidth(double bandwidth)
|
||||
{
|
||||
if(bandwidth > Device::Limits().maxIFBW) {
|
||||
bandwidth = Device::Limits().maxIFBW;
|
||||
} else if(bandwidth < Device::Limits().minIFBW) {
|
||||
bandwidth = Device::Limits().minIFBW;
|
||||
}
|
||||
settings.if_bandwidth = bandwidth;
|
||||
emit IFBandwidthChanged(bandwidth);
|
||||
SettingsChanged();
|
||||
|
|
@ -747,13 +752,15 @@ void VNA::StartCalibrationMeasurement(Calibration::Measurement m)
|
|||
|
||||
void VNA::ConstrainAndUpdateFrequencies()
|
||||
{
|
||||
// TODO central hardware limits
|
||||
if(settings.f_stop > 6000000000) {
|
||||
settings.f_stop = 6000000000;
|
||||
if(settings.f_stop > Device::Limits().maxFreq) {
|
||||
settings.f_stop = Device::Limits().maxFreq;
|
||||
}
|
||||
if(settings.f_start > settings.f_stop) {
|
||||
settings.f_start = settings.f_stop;
|
||||
}
|
||||
if(settings.f_start < Device::Limits().minFreq) {
|
||||
settings.f_start = Device::Limits().minFreq;
|
||||
}
|
||||
emit startFreqChanged(settings.f_start);
|
||||
emit stopFreqChanged(settings.f_stop);
|
||||
emit spanChanged(settings.f_stop - settings.f_start);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue