diff --git a/global.h b/global.h index 3ef44c0..2cb42e5 100644 --- a/global.h +++ b/global.h @@ -31,14 +31,12 @@ #define PROGRAM_NAME "DSRemote" -#define PROGRAM_VERSION "0.20_1506272131" +#define PROGRAM_VERSION "0.20_1506272231" #define MAX_PATHLEN 4096 #define MAX_CHNS 4 -#define SCREEN_TIMER_IVAL 50 - #define ADJDIAL_TIMER_IVAL_1 3000 #define ADJDIAL_TIMER_IVAL_2 2000 @@ -89,6 +87,8 @@ struct device_settings int modelserie; // 1=DS1000, 2=DS2000, etc. int hordivisions; // number of horizontal divisions + int screentimerival; + double samplerate; // Samplefrequency int memdepth; // Number of waveform points that the oscilloscope can store in a single trigger sample int channel_cnt; // Device has 2 or 4 channels diff --git a/interface.cpp b/interface.cpp index dc0f5c2..6d449b3 100644 --- a/interface.cpp +++ b/interface.cpp @@ -202,7 +202,7 @@ void UI_Mainwindow::navDialReleased() if(devparms.screenupdates_on == 1) { - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } waveForm->update(); @@ -2097,7 +2097,7 @@ void UI_Mainwindow::autoButtonClicked() get_device_settings(); - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } @@ -2224,7 +2224,7 @@ void UI_Mainwindow::horizontal_delayed_toggle() devparms.timebasedelayscale = atof(device->buf); - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 5d0c2a1..1e69146 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -300,7 +300,7 @@ void UI_Mainwindow::open_connection() devparms.screenupdates_on = 1; - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); return; @@ -2571,7 +2571,7 @@ void UI_Mainwindow::set_to_factory() QApplication::restoreOverrideCursor(); - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } diff --git a/mainwindow_constr.cpp b/mainwindow_constr.cpp index 81af213..0951282 100644 --- a/mainwindow_constr.cpp +++ b/mainwindow_constr.cpp @@ -58,6 +58,8 @@ UI_Mainwindow::UI_Mainwindow() QCoreApplication::setOrganizationDomain("teuniz.net"); QCoreApplication::setApplicationName(PROGRAM_NAME); + QSettings settings; + memset(&devparms, 0, sizeof(struct device_settings)); devparms.screenshot_buf = (char *)malloc(1024 * 1024 * 2); @@ -69,6 +71,15 @@ UI_Mainwindow::UI_Mainwindow() devparms.chanscale[i] = 1; } + devparms.screentimerival = settings.value("gui/refresh").toInt(); + + if((devparms.screentimerival < 50) || (devparms.screentimerival > 2000)) + { + devparms.screentimerival = 500; + + settings.setValue("gui/refresh", devparms.screentimerival); + } + devparms.displaygrid = 2; devparms.channel_cnt = 4; @@ -378,8 +389,6 @@ UI_Mainwindow::UI_Mainwindow() device = NULL; - QSettings settings; - strcpy(recent_savedir, settings.value("path/savedir").toString().toLocal8Bit().data()); strcpy(str, settings.value("connection/type").toString().toLatin1().data()); diff --git a/save_data.cpp b/save_data.cpp index 5b29a0f..dbd09e1 100644 --- a/save_data.cpp +++ b/save_data.cpp @@ -121,7 +121,7 @@ void UI_Mainwindow::save_screenshot() if(!strcmp(opath, "")) { - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); return; } @@ -134,13 +134,13 @@ void UI_Mainwindow::save_screenshot() goto OUT_ERROR; } - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); return; OUT_ERROR: - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); QMessageBox msgBox; msgBox.setIcon(QMessageBox::Critical); @@ -642,7 +642,7 @@ OUT_NORMAL: free(wavbuf[chn]); } - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); return; @@ -704,7 +704,7 @@ OUT_ERROR: free(wavbuf[chn]); } - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } @@ -1008,7 +1008,7 @@ OUT_NORMAL: free(wavbuf[chn]); } - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); return; @@ -1029,7 +1029,7 @@ OUT_ERROR: free(wavbuf[chn]); } - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } diff --git a/settings_dialog.cpp b/settings_dialog.cpp index d331590..676c193 100644 --- a/settings_dialog.cpp +++ b/settings_dialog.cpp @@ -40,8 +40,8 @@ UI_settings_window::UI_settings_window(QWidget *parnt) char dev_str[128]; - setMinimumSize(QSize(400, 200)); - setMaximumSize(QSize(400, 200)); + setMinimumSize(QSize(490, 200)); + setMaximumSize(QSize(490, 200)); setWindowTitle("Settings"); setModal(true); @@ -55,7 +55,7 @@ UI_settings_window::UI_settings_window(QWidget *parnt) lanRadioButton = new QRadioButton("LAN", this); lanRadioButton->setAutoExclusive(true); - lanRadioButton->setGeometry(260, 20, 110, 25); + lanRadioButton->setGeometry(220, 20, 110, 25); if(mainwindow->devparms.connectiontype == 1) { lanRadioButton->setChecked(true); @@ -75,7 +75,7 @@ UI_settings_window::UI_settings_window(QWidget *parnt) comboBox1->addItem("/dev/usbtmc9"); ipLineEdit = new QLineEdit(this); - ipLineEdit->setGeometry(240, 65, 110, 25); + ipLineEdit->setGeometry(200, 65, 110, 25); ipLineEdit->setInputMask("000.000.000.000;_"); if(settings.contains("connection/ip")) { @@ -86,12 +86,23 @@ UI_settings_window::UI_settings_window(QWidget *parnt) ipLineEdit->setText("192.168.001.088"); } + refreshLabel = new QLabel(this); + refreshLabel->setGeometry(370, 20, 120, 35); + refreshLabel->setText("Screen update\n interval"); + + refreshSpinbox = new QSpinBox(this); + refreshSpinbox->setGeometry(370, 65, 100, 25); + refreshSpinbox->setSuffix(" mS"); + refreshSpinbox->setRange(50, 2000); + refreshSpinbox->setSingleStep(10); + refreshSpinbox->setValue(mainwindow->devparms.screentimerival); + applyButton = new QPushButton(this); applyButton->setGeometry(20, 155, 100, 25); applyButton->setText("Apply"); cancelButton = new QPushButton(this); - cancelButton->setGeometry(240, 155, 100, 25); + cancelButton->setGeometry(200, 155, 100, 25); cancelButton->setText("Cancel"); strcpy(dev_str, settings.value("connection/device").toString().toLocal8Bit().data()); @@ -113,10 +124,11 @@ UI_settings_window::UI_settings_window(QWidget *parnt) } else { - QObject::connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked())); + QObject::connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked())); } - QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); + QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); + QObject::connect(refreshSpinbox, SIGNAL(valueChanged(int)), this, SLOT(refreshSpinboxChanged(int))); exec(); } @@ -158,8 +170,19 @@ void UI_settings_window::applyButtonClicked() } - - +void UI_settings_window::refreshSpinboxChanged(int value) +{ + QSettings settings; + + mainwindow->devparms.screentimerival = value; + + settings.setValue("gui/refresh", value); + + if(mainwindow->scrn_timer->isActive()) + { + mainwindow->scrn_timer->start(value); + } +} diff --git a/settings_dialog.h b/settings_dialog.h index b091976..fe3c501 100644 --- a/settings_dialog.h +++ b/settings_dialog.h @@ -42,6 +42,7 @@ #include #include #include +#include #include "mainwindow.h" #include "global.h" @@ -70,11 +71,16 @@ QComboBox *comboBox1; QLineEdit *ipLineEdit; +QSpinBox *refreshSpinbox; + +QLabel *refreshLabel; + UI_Mainwindow *mainwindow; private slots: void applyButtonClicked(); +void refreshSpinboxChanged(int); }; diff --git a/signalcurve.cpp b/signalcurve.cpp index 8798c4d..cee203c 100644 --- a/signalcurve.cpp +++ b/signalcurve.cpp @@ -1341,7 +1341,7 @@ void SignalCurve::mouseReleaseEvent(QMouseEvent *release_event) if(devparms->screenupdates_on == 1) { - mainwindow->scrn_timer->start(SCREEN_TIMER_IVAL); + mainwindow->scrn_timer->start(devparms->screentimerival); } if(trig_pos_arrow_moving) diff --git a/timer_handlers.cpp b/timer_handlers.cpp index be86517..7d6c5d1 100644 --- a/timer_handlers.cpp +++ b/timer_handlers.cpp @@ -61,7 +61,7 @@ void UI_Mainwindow::navDial_timer_handler() if(devparms.screenupdates_on == 1) { - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } } } @@ -120,7 +120,7 @@ void UI_Mainwindow::adjdial_timer_handler() if(devparms.screenupdates_on == 1) { - scrn_timer->start(SCREEN_TIMER_IVAL); + scrn_timer->start(devparms.screentimerival); } }