Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger and h-scale commands adjusted to work with my rigol 1052e #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QDebug>
#include <QFileDialog>
#include <QInputDialog>
#include <QRegularExpression>
#include "helpdialog.h"
#include "unistd.h"

Expand Down Expand Up @@ -635,7 +636,40 @@ void MainWindow::on_hscale_currentIndexChanged(int index)
{
Q_UNUSED(index);
if (!scope.connected()||nocommands) return;
scope.setTimeScale(ui->hscale->currentText());

QString curStringVal = ui->hscale->currentText();
int unitLocation = curStringVal.indexOf(QRegularExpression("[a-z]"));

int curRawVal = curStringVal.left(unitLocation).toInt();
QString unitOnly = curStringVal.mid(unitLocation);

QString prefix = "";

if (unitOnly == "ms")
{
prefix = "0.";
}
else if (unitOnly == "us")
{
prefix = "0.000";
}
else if (unitOnly == "ns")
{
prefix = "0.000000";
}
else
{
// assume seconds
}

// Make the integer string 3 digits long (prefix with zeros)
QString setValue = QString::number(curRawVal);
while(setValue.length() < 3)
{
setValue = "0" + setValue;
}

scope.setTimeScale(prefix + setValue);
}

void MainWindow::on_cdisp1_clicked()
Expand Down
2 changes: 1 addition & 1 deletion scopedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ScopeData : public QObject
bool setChanOffset(int chan,float f) { return command(":CHAN"+QString::number(chan)+":OFFS "+QString::number(f)); }
bool setChanScale(int chan, const QString &v) { return command(":CHAN" +QString::number(chan)+":SCAL "+v); }
bool setTrigMode(const QString &mod) { return command(":TRIG:MODE "+mod); }
bool setTrigLevel(const QString &mod, float f) { return command(":TRIG:"+mod+":LEV"+QString::number(f)); }
bool setTrigLevel(const QString &mod, float f) { return command(":TRIG:"+mod+":LEV "+QString::number(f)); }
bool setSweep(const QString &mod,const QString state) { return command(":TRIG:"+mod+":SWE "+state); }
bool setTrigSource(const QString &mod,const QString state) { return command(":TRIG:"+mod+":SOUR "+state); }
bool setTrigHoldUs(float f) { return command(":TRIG:HOLD"+QString::number(f/1000000.0f,'f')); }
Expand Down