Skip to content

Commit

Permalink
disable ui refresh when device not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
nanovna committed Apr 3, 2020
1 parent 7d980f2 commit 9d9024a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions vna_qt/mainwindow.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MainWindow::MainWindow(QWidget *parent) :

vna = new VNADevice();
impdisp = new ImpedanceDisplay();
timer = new QTimer();
refreshTimer = new QTimer();

nv.init(ui->w_bottom->layout());
nv.xAxisValueStr = [](double val) {
Expand All @@ -79,15 +79,14 @@ MainWindow::MainWindow(QWidget *parent) :

((QBoxLayout*)ui->dock_impedance_contents->layout())->insertWidget(0,impdisp);

connect(timer, &QTimer::timeout, [this](){
connect(refreshTimer, &QTimer::timeout, [this](){
if(!ui->actionDisable_polarView_refresh->isChecked())
this->polarView->repaint();
//this->chartView->update();
nv.updateMarkerViews();
updateValueDisplays();
nv.updateBottomLabels();
});
timer->start(200);

setAttribute(Qt::WA_DeleteOnClose);

Expand All @@ -102,7 +101,7 @@ MainWindow::~MainWindow()
vna->stopScan();
vna->close();

delete timer;
delete refreshTimer;
//delete chartView;
//delete polarView;
delete vna;
Expand Down Expand Up @@ -268,6 +267,7 @@ void MainWindow::openDevice(string dev) {
if(vna->isTR()) ui->actionSwap_ports->setChecked(false);
vna->startScan();
enableUI(true);
refreshTimer->start(refreshIntervalMs);
} catch(logic_error& ex) {
if(strcmp(ex.what(), "DFU mode") == 0) {
auto resp = QMessageBox::question(this, "DFU mode", "Device is in DFU mode. Flash a new firmware?");
Expand All @@ -289,8 +289,9 @@ void MainWindow::openDevice(string dev) {

void MainWindow::handleBackgroundError(QString msg) {
vna->close();
QMessageBox::critical(this, "Error", msg);
enableUI(false);
refreshTimer->stop();
QMessageBox::critical(this, "Error", msg);
}

void MainWindow::s11MeasurementCompleted(QString fileName) {
Expand Down
3 changes: 2 additions & 1 deletion vna_qt/mainwindow.H
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ private:

public:
const char* calButtonDoneStyle = "background-color: #9999ff";
static const int refreshIntervalMs = 50;

VNADevice* vna = nullptr;
ImpedanceDisplay* impdisp = nullptr;
QTimer* timer = nullptr;
QTimer* refreshTimer = nullptr;
PolarView* polarView = nullptr;
NetworkView nv;
DTFWindow dtf;
Expand Down

0 comments on commit 9d9024a

Please sign in to comment.