Commit 77f4c7b5fe01cfbce44ebaac7222fbc641583670
1 parent
8c511e69
Small fixes and performance improvements
Showing
18 changed files
with
479 additions
and
384 deletions
openhantek/ChangeLog
| @@ -164,3 +164,8 @@ | @@ -164,3 +164,8 @@ | ||
| 164 | 164 | ||
| 165 | 2012-10-07 Oliver Haag <oliver.haag@gmail.com> | 165 | 2012-10-07 Oliver Haag <oliver.haag@gmail.com> |
| 166 | * Ignore errors after first packet was received by Hantek::Device::bulkReadMulti | 166 | * Ignore errors after first packet was received by Hantek::Device::bulkReadMulti |
| 167 | + | ||
| 168 | +2012-10-17 Oliver Haag <oliver.haag@gmail.com> | ||
| 169 | +* Change back workaround for Mac OS that is most probably not required anymore | ||
| 170 | +* Various performance improvements and small fixes | ||
| 171 | +* New cppcheck build target |
openhantek/OpenHantek.pro
| 1 | +# Helper functions | ||
| 2 | +defineReplace(surround) { | ||
| 3 | + elements = $$1 | ||
| 4 | + prefix = $$2 | ||
| 5 | + postfix = $$3 | ||
| 6 | + result = | ||
| 7 | + for(element, elements) { | ||
| 8 | + result += "$${prefix}$${element}$${postfix}" | ||
| 9 | + } | ||
| 10 | + return($${result}) | ||
| 11 | +} | ||
| 12 | + | ||
| 1 | TEMPLATE = app | 13 | TEMPLATE = app |
| 2 | 14 | ||
| 3 | # Configuration | 15 | # Configuration |
| 4 | -CONFIG += warn_on \ | ||
| 5 | - qt | 16 | +CONFIG += \ |
| 17 | + warn_on \ | ||
| 18 | + qt | ||
| 6 | QT += opengl | 19 | QT += opengl |
| 7 | LIBS += -lfftw3 | 20 | LIBS += -lfftw3 |
| 8 | 21 | ||
| 9 | # Source files | 22 | # Source files |
| 10 | -SOURCES += src/colorbox.cpp \ | ||
| 11 | - src/configdialog.cpp \ | ||
| 12 | - src/configpages.cpp \ | ||
| 13 | - src/dataanalyzer.cpp \ | ||
| 14 | - src/dockwindows.cpp \ | ||
| 15 | - src/dsocontrol.cpp \ | ||
| 16 | - src/dsowidget.cpp \ | ||
| 17 | - src/exporter.cpp \ | ||
| 18 | - src/glgenerator.cpp \ | ||
| 19 | - src/glscope.cpp \ | ||
| 20 | - src/helper.cpp \ | ||
| 21 | - src/levelslider.cpp \ | ||
| 22 | - src/main.cpp \ | ||
| 23 | - src/openhantek.cpp \ | ||
| 24 | - src/settings.cpp \ | ||
| 25 | - src/hantek/control.cpp \ | ||
| 26 | - src/hantek/device.cpp \ | ||
| 27 | - src/hantek/types.cpp \ | ||
| 28 | - src/dso.cpp | ||
| 29 | -HEADERS += src/colorbox.h \ | ||
| 30 | - src/configdialog.h \ | ||
| 31 | - src/configpages.h \ | ||
| 32 | - src/dataanalyzer.h \ | ||
| 33 | - src/dockwindows.h \ | ||
| 34 | - src/dsocontrol.h \ | ||
| 35 | - src/dsowidget.h \ | ||
| 36 | - src/exporter.h \ | ||
| 37 | - src/glscope.h \ | ||
| 38 | - src/glgenerator.h \ | ||
| 39 | - src/helper.h \ | ||
| 40 | - src/levelslider.h \ | ||
| 41 | - src/openhantek.h \ | ||
| 42 | - src/settings.h \ | ||
| 43 | - src/hantek/control.h \ | ||
| 44 | - src/hantek/device.h \ | ||
| 45 | - src/hantek/types.h \ | ||
| 46 | - src/dso.h | 23 | +SOURCES += \ |
| 24 | + src/colorbox.cpp \ | ||
| 25 | + src/configdialog.cpp \ | ||
| 26 | + src/configpages.cpp \ | ||
| 27 | + src/dataanalyzer.cpp \ | ||
| 28 | + src/dockwindows.cpp \ | ||
| 29 | + src/dsocontrol.cpp \ | ||
| 30 | + src/dsowidget.cpp \ | ||
| 31 | + src/exporter.cpp \ | ||
| 32 | + src/glgenerator.cpp \ | ||
| 33 | + src/glscope.cpp \ | ||
| 34 | + src/helper.cpp \ | ||
| 35 | + src/levelslider.cpp \ | ||
| 36 | + src/main.cpp \ | ||
| 37 | + src/openhantek.cpp \ | ||
| 38 | + src/settings.cpp \ | ||
| 39 | + src/hantek/control.cpp \ | ||
| 40 | + src/hantek/device.cpp \ | ||
| 41 | + src/hantek/types.cpp \ | ||
| 42 | + src/dso.cpp | ||
| 43 | +HEADERS += \ | ||
| 44 | + src/colorbox.h \ | ||
| 45 | + src/configdialog.h \ | ||
| 46 | + src/configpages.h \ | ||
| 47 | + src/dataanalyzer.h \ | ||
| 48 | + src/dockwindows.h \ | ||
| 49 | + src/dsocontrol.h \ | ||
| 50 | + src/dsowidget.h \ | ||
| 51 | + src/exporter.h \ | ||
| 52 | + src/glscope.h \ | ||
| 53 | + src/glgenerator.h \ | ||
| 54 | + src/helper.h \ | ||
| 55 | + src/levelslider.h \ | ||
| 56 | + src/openhantek.h \ | ||
| 57 | + src/settings.h \ | ||
| 58 | + src/hantek/control.h \ | ||
| 59 | + src/hantek/device.h \ | ||
| 60 | + src/hantek/types.h \ | ||
| 61 | + src/dso.h | ||
| 47 | 62 | ||
| 48 | # Ressource files | 63 | # Ressource files |
| 49 | -RESOURCES += res/application.qrc \ | ||
| 50 | - res/configdialog.qrc | 64 | +RESOURCES += \ |
| 65 | + res/application.qrc \ | ||
| 66 | + res/configdialog.qrc | ||
| 51 | 67 | ||
| 52 | # Doxygen files | 68 | # Doxygen files |
| 53 | -DOXYFILES += Doxyfile \ | ||
| 54 | - mainpage.dox \ | ||
| 55 | - roadmap.dox | 69 | +DOXYFILES += \ |
| 70 | + Doxyfile \ | ||
| 71 | + mainpage.dox \ | ||
| 72 | + roadmap.dox | ||
| 56 | 73 | ||
| 57 | # Files copied into the distribution package | 74 | # Files copied into the distribution package |
| 58 | -DISTFILES += ChangeLog \ | ||
| 59 | - COPYING \ | ||
| 60 | - INSTALL \ | ||
| 61 | - res/images/*.png \ | ||
| 62 | - res/images/*.icns \ | ||
| 63 | - res/images/*.svg \ | ||
| 64 | - translations/*.qm \ | ||
| 65 | - translations/*.ts \ | ||
| 66 | - $${DOXYFILES} | 75 | +DISTFILES += \ |
| 76 | + ChangeLog \ | ||
| 77 | + COPYING \ | ||
| 78 | + INSTALL \ | ||
| 79 | + res/images/*.png \ | ||
| 80 | + res/images/*.icns \ | ||
| 81 | + res/images/*.svg \ | ||
| 82 | + translations/*.qm \ | ||
| 83 | + translations/*.ts \ | ||
| 84 | + $${DOXYFILES} | ||
| 67 | 85 | ||
| 68 | # Translations | 86 | # Translations |
| 69 | TRANSLATIONS += translations/openhantek_de.ts | 87 | TRANSLATIONS += translations/openhantek_de.ts |
| @@ -82,15 +100,14 @@ OBJECTS_DIR = build/obj | @@ -82,15 +100,14 @@ OBJECTS_DIR = build/obj | ||
| 82 | UI_DIR = build/ui | 100 | UI_DIR = build/ui |
| 83 | MOC_DIR = build/moc | 101 | MOC_DIR = build/moc |
| 84 | 102 | ||
| 85 | -# Include directory | ||
| 86 | -QMAKE_CXXFLAGS += "-iquote $${IN_PWD}/src" | ||
| 87 | - | ||
| 88 | # libusb version | 103 | # libusb version |
| 89 | LIBUSB_VERSION = $$(LIBUSB_VERSION) | 104 | LIBUSB_VERSION = $$(LIBUSB_VERSION) |
| 90 | -contains(LIBUSB_VERSION, 0): LIBS += -lusb | 105 | +contains(LIBUSB_VERSION, 0) { |
| 106 | + LIBS += -lusb | ||
| 107 | +} | ||
| 91 | else { | 108 | else { |
| 92 | - LIBUSB_VERSION = 1 | ||
| 93 | - LIBS += -lusb-1.0 | 109 | + LIBUSB_VERSION = 1 |
| 110 | + LIBS += -lusb-1.0 | ||
| 94 | } | 111 | } |
| 95 | DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} | 112 | DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} |
| 96 | 113 | ||
| @@ -98,49 +115,74 @@ DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} | @@ -98,49 +115,74 @@ DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} | ||
| 98 | CONFIG(debug, debug|release): DEFINES += DEBUG | 115 | CONFIG(debug, debug|release): DEFINES += DEBUG |
| 99 | else: DEFINES += QT_NO_DEBUG_OUTPUT | 116 | else: DEFINES += QT_NO_DEBUG_OUTPUT |
| 100 | 117 | ||
| 118 | +# Quoted include directories | ||
| 119 | +INCLUDEPATH_QUOTE = "$${IN_PWD}/src" | ||
| 120 | + | ||
| 121 | +# Include directory | ||
| 122 | +QMAKE_CXXFLAGS += "-iquote $${INCLUDEPATH_QUOTE}" | ||
| 123 | + | ||
| 101 | # Settings for different operating systems | 124 | # Settings for different operating systems |
| 102 | unix:!macx { | 125 | unix:!macx { |
| 103 | - isEmpty(PREFIX):PREFIX = /usr/local | ||
| 104 | - TARGET = openhantek | ||
| 105 | - | ||
| 106 | - # Installation directories | ||
| 107 | - target.path = $${PREFIX}/bin | ||
| 108 | - translations.path = $${PREFIX}/share/apps/openhantek/translations | ||
| 109 | - INCLUDEPATH += /usr/include/libusb | ||
| 110 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\\\"$${translations.path}\\\" \ | ||
| 111 | - OS_UNIX VERSION=\\\"$${VERSION}\\\" | 126 | + isEmpty(PREFIX): PREFIX = /usr/local |
| 127 | + TARGET = openhantek | ||
| 128 | + | ||
| 129 | + # Installation directories | ||
| 130 | + target.path = $${PREFIX}/bin | ||
| 131 | + translations.path = $${PREFIX}/share/apps/openhantek/translations | ||
| 132 | + contains(LIBUSB_VERSION, 0) { | ||
| 133 | + INCLUDEPATH += /usr/include/libusb | ||
| 134 | + } | ||
| 135 | + else { | ||
| 136 | + INCLUDEPATH += /usr/include/libusb-1.0 | ||
| 137 | + } | ||
| 138 | + DEFINES += \ | ||
| 139 | + QMAKE_TRANSLATIONS_PATH=\\\"$${translations.path}\\\" \ | ||
| 140 | + OS_UNIX VERSION=\\\"$${VERSION}\\\" | ||
| 112 | } | 141 | } |
| 113 | macx { | 142 | macx { |
| 114 | - isEmpty(PREFIX):PREFIX = OpenHantek.app | ||
| 115 | - TARGET = OpenHantek | ||
| 116 | - | ||
| 117 | - # Installation directories | ||
| 118 | - target.path = $${PREFIX}/Contents/MacOS | ||
| 119 | - translations.path = $${PREFIX}/Contents/Resources/translations | ||
| 120 | - INCLUDEPATH += src | ||
| 121 | - LIBS += -framework IOKit -framework CoreFoundation | ||
| 122 | - ICON = res/images/openhantek.icns | ||
| 123 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\"Contents/Resources/translations\" \ | ||
| 124 | - OS_DARWIN VERSION=\"$${VERSION}\" | 143 | + isEmpty(PREFIX): PREFIX = OpenHantek.app |
| 144 | + TARGET = OpenHantek | ||
| 145 | + | ||
| 146 | + # Installation directories | ||
| 147 | + target.path = $${PREFIX}/Contents/MacOS | ||
| 148 | + translations.path = $${PREFIX}/Contents/Resources/translations | ||
| 149 | + INCLUDEPATH += $${INCLUDEPATH_QUOTE} | ||
| 150 | + LIBS += -framework IOKit -framework CoreFoundation | ||
| 151 | + ICON = res/images/openhantek.icns | ||
| 152 | + DEFINES += \ | ||
| 153 | + QMAKE_TRANSLATIONS_PATH=\\\"Contents/Resources/translations\\\" \ | ||
| 154 | + OS_DARWIN VERSION=\\\"$${VERSION}\\\" | ||
| 125 | } | 155 | } |
| 126 | win32 { | 156 | win32 { |
| 127 | - isEmpty(PREFIX):PREFIX = OpenHantek | ||
| 128 | - TARGET = OpenHantek | ||
| 129 | - | ||
| 130 | - # Installation directories | ||
| 131 | - target.path = $${PREFIX} | ||
| 132 | - translations.path = $${PREFIX}/translations | ||
| 133 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\\\"translations\\\" \ | ||
| 134 | - OS_WINDOWS VERSION=\\\"$${VERSION}\\\" | 157 | + isEmpty(PREFIX): PREFIX = OpenHantek |
| 158 | + TARGET = OpenHantek | ||
| 159 | + | ||
| 160 | + # Installation directories | ||
| 161 | + target.path = $${PREFIX} | ||
| 162 | + translations.path = $${PREFIX}/translations | ||
| 163 | + INCLUDEPATH += $${INCLUDEPATH_QUOTE} | ||
| 164 | + DEFINES += \ | ||
| 165 | + QMAKE_TRANSLATIONS_PATH=\\\"translations\\\" \ | ||
| 166 | + OS_WINDOWS VERSION=\\\"$${VERSION}\\\" | ||
| 135 | } | 167 | } |
| 136 | translations.files += translations/*.qm | 168 | translations.files += translations/*.qm |
| 137 | -INSTALLS += target \ | ||
| 138 | - translations | 169 | +INSTALLS += \ |
| 170 | + target \ | ||
| 171 | + translations | ||
| 172 | + | ||
| 173 | +# Custom target "cppcheck" for Cppcheck | ||
| 174 | +INCLUDEPARAMETERS = $$surround($${INCLUDEPATH} $${INCLUDEPATH_QUOTE}, "-I \"", "\"") | ||
| 175 | +cppcheck.commands = "cppcheck --enable=all $${INCLUDEPARAMETERS} -q $${SOURCES} --template=\"{file}:{line}: {severity}: {message}\"" | ||
| 176 | +cppcheck.depends = $${SOURCES} | ||
| 139 | 177 | ||
| 140 | # Custom target "doc" for Doxygen | 178 | # Custom target "doc" for Doxygen |
| 141 | -doxygen.target = doc | 179 | +doxygen.target = "doc" |
| 142 | doxygen.commands = "rm -r doc/; env DEFINES=\"$${DEFINES}\" doxygen Doxyfile" | 180 | doxygen.commands = "rm -r doc/; env DEFINES=\"$${DEFINES}\" doxygen Doxyfile" |
| 143 | -doxygen.depends = $${SOURCES} \ | ||
| 144 | - $${HEADERS} \ | ||
| 145 | - $${DOXYFILES} | ||
| 146 | -QMAKE_EXTRA_TARGETS += doxygen | 181 | +doxygen.depends = \ |
| 182 | + $${SOURCES} \ | ||
| 183 | + $${HEADERS} \ | ||
| 184 | + $${DOXYFILES} | ||
| 185 | + | ||
| 186 | +QMAKE_EXTRA_TARGETS += \ | ||
| 187 | + cppcheck \ | ||
| 188 | + doxygen |
openhantek/src/configpages.cpp
| @@ -170,7 +170,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | @@ -170,7 +170,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | ||
| 170 | this->channelLabel->setAlignment(Qt::AlignHCenter); | 170 | this->channelLabel->setAlignment(Qt::AlignHCenter); |
| 171 | this->spectrumLabel = new QLabel(tr("Spectrum")); | 171 | this->spectrumLabel = new QLabel(tr("Spectrum")); |
| 172 | this->spectrumLabel->setAlignment(Qt::AlignHCenter); | 172 | this->spectrumLabel->setAlignment(Qt::AlignHCenter); |
| 173 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 173 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 174 | this->colorLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); | 174 | this->colorLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); |
| 175 | this->channelColorBox.append(new ColorBox(this->settings->view.color.screen.voltage[channel])); | 175 | this->channelColorBox.append(new ColorBox(this->settings->view.color.screen.voltage[channel])); |
| 176 | this->spectrumColorBox.append(new ColorBox(this->settings->view.color.screen.spectrum[channel])); | 176 | this->spectrumColorBox.append(new ColorBox(this->settings->view.color.screen.spectrum[channel])); |
| @@ -182,7 +182,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | @@ -182,7 +182,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | ||
| 182 | this->graphLayout->setColumnMinimumWidth(2, 80); | 182 | this->graphLayout->setColumnMinimumWidth(2, 80); |
| 183 | this->graphLayout->addWidget(this->channelLabel, 0, 1); | 183 | this->graphLayout->addWidget(this->channelLabel, 0, 1); |
| 184 | this->graphLayout->addWidget(this->spectrumLabel, 0, 2); | 184 | this->graphLayout->addWidget(this->spectrumLabel, 0, 2); |
| 185 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 185 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 186 | this->graphLayout->addWidget(this->colorLabel[channel], channel + 1, 0); | 186 | this->graphLayout->addWidget(this->colorLabel[channel], channel + 1, 0); |
| 187 | this->graphLayout->addWidget(this->channelColorBox[channel], channel + 1, 1); | 187 | this->graphLayout->addWidget(this->channelColorBox[channel], channel + 1, 1); |
| 188 | this->graphLayout->addWidget(this->spectrumColorBox[channel], channel + 1, 2); | 188 | this->graphLayout->addWidget(this->spectrumColorBox[channel], channel + 1, 2); |
| @@ -215,7 +215,7 @@ void DsoConfigColorsPage::saveSettings() { | @@ -215,7 +215,7 @@ void DsoConfigColorsPage::saveSettings() { | ||
| 215 | this->settings->view.color.screen.text = this->textColorBox->getColor(); | 215 | this->settings->view.color.screen.text = this->textColorBox->getColor(); |
| 216 | 216 | ||
| 217 | // Graph category | 217 | // Graph category |
| 218 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 218 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 219 | this->settings->view.color.screen.voltage[channel] = this->channelColorBox[channel]->getColor(); | 219 | this->settings->view.color.screen.voltage[channel] = this->channelColorBox[channel]->getColor(); |
| 220 | this->settings->view.color.screen.spectrum[channel] = this->spectrumColorBox[channel]->getColor(); | 220 | this->settings->view.color.screen.spectrum[channel] = this->spectrumColorBox[channel]->getColor(); |
| 221 | } | 221 | } |
openhantek/src/dataanalyzer.cpp
| @@ -50,15 +50,22 @@ DataAnalyzer::DataAnalyzer(DsoSettings *settings, QObject *parent) : QThread(par | @@ -50,15 +50,22 @@ DataAnalyzer::DataAnalyzer(DsoSettings *settings, QObject *parent) : QThread(par | ||
| 50 | this->window = 0; | 50 | this->window = 0; |
| 51 | 51 | ||
| 52 | this->analyzedDataMutex = new QMutex(); | 52 | this->analyzedDataMutex = new QMutex(); |
| 53 | + | ||
| 54 | + this->maxSamples = 0; | ||
| 55 | + | ||
| 56 | + this->waitingDataSamplerate = 0.0; | ||
| 57 | + this->waitingDataMutex = 0; | ||
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | /// \brief Deallocates the buffers. | 60 | /// \brief Deallocates the buffers. |
| 56 | DataAnalyzer::~DataAnalyzer() { | 61 | DataAnalyzer::~DataAnalyzer() { |
| 57 | - for(int channel = 0; channel < this->analyzedData.count(); channel++) { | ||
| 58 | - if(this->analyzedData[channel]->samples.voltage.sample) | ||
| 59 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | ||
| 60 | - if(this->analyzedData[channel]->samples.spectrum.sample) | ||
| 61 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | 62 | + for(int channel = 0; channel < this->analyzedData.count(); ++channel) { |
| 63 | + AnalyzedData *channelData = this->analyzedData[channel]; | ||
| 64 | + | ||
| 65 | + if(channelData->samples.voltage.sample) | ||
| 66 | + delete[] channelData->samples.voltage.sample; | ||
| 67 | + if(channelData->samples.spectrum.sample) | ||
| 68 | + delete[] channelData->samples.spectrum.sample; | ||
| 62 | } | 69 | } |
| 63 | } | 70 | } |
| 64 | 71 | ||
| @@ -89,32 +96,48 @@ void DataAnalyzer::run() { | @@ -89,32 +96,48 @@ void DataAnalyzer::run() { | ||
| 89 | this->analyzedDataMutex->lock(); | 96 | this->analyzedDataMutex->lock(); |
| 90 | 97 | ||
| 91 | unsigned long int maxSamples = 0; | 98 | unsigned long int maxSamples = 0; |
| 99 | + unsigned int channelCount = (unsigned int) this->settings->scope.voltage.count(); | ||
| 92 | 100 | ||
| 93 | // Adapt the number of channels for analyzed data | 101 | // Adapt the number of channels for analyzed data |
| 94 | - for(int channel = this->analyzedData.count(); channel < this->settings->scope.voltage.count(); channel++) { | ||
| 95 | - this->analyzedData.append(new AnalyzedData); | ||
| 96 | - this->analyzedData[channel]->samples.voltage.count = 0; | ||
| 97 | - this->analyzedData[channel]->samples.voltage.interval = 0; | ||
| 98 | - this->analyzedData[channel]->samples.voltage.sample = 0; | ||
| 99 | - this->analyzedData[channel]->samples.spectrum.count = 0; | ||
| 100 | - this->analyzedData[channel]->samples.spectrum.interval = 0; | ||
| 101 | - this->analyzedData[channel]->samples.spectrum.sample = 0; | ||
| 102 | - this->analyzedData[channel]->amplitude = 0; | ||
| 103 | - this->analyzedData[channel]->frequency = 0; | 102 | + for(unsigned int channel = this->analyzedData.count(); channel < channelCount; ++channel) { |
| 103 | + AnalyzedData *channelData = new AnalyzedData; | ||
| 104 | + channelData->samples.voltage.count = 0; | ||
| 105 | + channelData->samples.voltage.interval = 0; | ||
| 106 | + channelData->samples.voltage.sample = 0; | ||
| 107 | + channelData->samples.spectrum.count = 0; | ||
| 108 | + channelData->samples.spectrum.interval = 0; | ||
| 109 | + channelData->samples.spectrum.sample = 0; | ||
| 110 | + channelData->amplitude = 0; | ||
| 111 | + channelData->frequency = 0; | ||
| 112 | + this->analyzedData.append(channelData); | ||
| 104 | } | 113 | } |
| 105 | - for(int channel = this->settings->scope.voltage.count(); channel < this->analyzedData.count(); channel++) { | ||
| 106 | - if(this->analyzedData.last()->samples.voltage.sample) | ||
| 107 | - delete[] this->analyzedData.last()->samples.voltage.sample; | ||
| 108 | - if(this->analyzedData.last()->samples.spectrum.sample) | ||
| 109 | - delete[] this->analyzedData.last()->samples.spectrum.sample; | 114 | + for(unsigned int channel = this->analyzedData.count(); channel > channelCount; --channel) { |
| 115 | + AnalyzedData *channelData = this->analyzedData.last(); | ||
| 116 | + if(channelData->samples.voltage.sample) | ||
| 117 | + delete[] channelData->samples.voltage.sample; | ||
| 118 | + if(channelData->samples.spectrum.sample) | ||
| 119 | + delete[] channelData->samples.spectrum.sample; | ||
| 110 | this->analyzedData.removeLast(); | 120 | this->analyzedData.removeLast(); |
| 111 | } | 121 | } |
| 112 | 122 | ||
| 113 | - for(unsigned int channel = 0; channel < (unsigned int) this->analyzedData.count(); channel++) { | ||
| 114 | - // Check if we got data for this channel or if it's a math channel that can be calculated | ||
| 115 | - if(((channel < this->settings->scope.physicalChannels) && channel < (unsigned int) this->waitingData.count() && this->waitingData[channel]) || ((channel >= this->settings->scope.physicalChannels) && (this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->analyzedData.count() >= 2 && this->analyzedData[0]->samples.voltage.sample && this->analyzedData[1]->samples.voltage.sample)) { | 123 | + for(unsigned int channel = 0; channel < channelCount; ++channel) { |
| 124 | + AnalyzedData *channelData = this->analyzedData[channel]; | ||
| 125 | + | ||
| 126 | + if( // Check... | ||
| 127 | + ( // ...if we got data for this channel... | ||
| 128 | + channel < this->settings->scope.physicalChannels && | ||
| 129 | + channel < (unsigned int) this->waitingData.count() && | ||
| 130 | + this->waitingData[channel]) || | ||
| 131 | + ( // ...or if it's a math channel that can be calculated | ||
| 132 | + channel >= this->settings->scope.physicalChannels && | ||
| 133 | + (this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && | ||
| 134 | + this->analyzedData.count() >= 2 && | ||
| 135 | + this->analyzedData[0]->samples.voltage.sample && | ||
| 136 | + this->analyzedData[1]->samples.voltage.sample | ||
| 137 | + ) | ||
| 138 | + ) { | ||
| 116 | // Set sampling interval | 139 | // Set sampling interval |
| 117 | - this->analyzedData[channel]->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; | 140 | + channelData->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; |
| 118 | 141 | ||
| 119 | unsigned int size; | 142 | unsigned int size; |
| 120 | if(channel < this->settings->scope.physicalChannels) { | 143 | if(channel < this->settings->scope.physicalChannels) { |
| @@ -125,19 +148,19 @@ void DataAnalyzer::run() { | @@ -125,19 +148,19 @@ void DataAnalyzer::run() { | ||
| 125 | else | 148 | else |
| 126 | size = maxSamples; | 149 | size = maxSamples; |
| 127 | // Reallocate memory for samples if the sample count has changed | 150 | // Reallocate memory for samples if the sample count has changed |
| 128 | - if(this->analyzedData[channel]->samples.voltage.count != size) { | ||
| 129 | - this->analyzedData[channel]->samples.voltage.count = size; | ||
| 130 | - if(this->analyzedData[channel]->samples.voltage.sample) | ||
| 131 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | ||
| 132 | - this->analyzedData[channel]->samples.voltage.sample = new double[size]; | 151 | + if(channelData->samples.voltage.count != size) { |
| 152 | + channelData->samples.voltage.count = size; | ||
| 153 | + if(channelData->samples.voltage.sample) | ||
| 154 | + delete[] channelData->samples.voltage.sample; | ||
| 155 | + channelData->samples.voltage.sample = new double[size]; | ||
| 133 | } | 156 | } |
| 134 | 157 | ||
| 135 | // Physical channels | 158 | // Physical channels |
| 136 | if(channel < this->settings->scope.physicalChannels) { | 159 | if(channel < this->settings->scope.physicalChannels) { |
| 137 | // Copy the buffer of the oscilloscope into the sample buffer | 160 | // Copy the buffer of the oscilloscope into the sample buffer |
| 138 | if(channel < (unsigned int) this->waitingData.count()) | 161 | if(channel < (unsigned int) this->waitingData.count()) |
| 139 | - for(unsigned int position = 0; position < this->waitingDataSize[channel]; position++) | ||
| 140 | - this->analyzedData[channel]->samples.voltage.sample[position] = this->waitingData[channel][position]; | 162 | + for(unsigned int position = 0; position < this->waitingDataSize[channel]; ++position) |
| 163 | + channelData->samples.voltage.sample[position] = this->waitingData[channel][position]; | ||
| 141 | } | 164 | } |
| 142 | // Math channel | 165 | // Math channel |
| 143 | else { | 166 | else { |
| @@ -153,7 +176,7 @@ void DataAnalyzer::run() { | @@ -153,7 +176,7 @@ void DataAnalyzer::run() { | ||
| 153 | } | 176 | } |
| 154 | 177 | ||
| 155 | // Calculate values and write them into the sample buffer | 178 | // Calculate values and write them into the sample buffer |
| 156 | - for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; realPosition++) { | 179 | + for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) { |
| 157 | switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) { | 180 | switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) { |
| 158 | case Dso::MATHMODE_1ADD2: | 181 | case Dso::MATHMODE_1ADD2: |
| 159 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.sample[realPosition] = this->analyzedData[0]->samples.voltage.sample[realPosition] + this->analyzedData[1]->samples.voltage.sample[realPosition]; | 182 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.sample[realPosition] = this->analyzedData[0]->samples.voltage.sample[realPosition] + this->analyzedData[1]->samples.voltage.sample[realPosition]; |
| @@ -170,11 +193,11 @@ void DataAnalyzer::run() { | @@ -170,11 +193,11 @@ void DataAnalyzer::run() { | ||
| 170 | } | 193 | } |
| 171 | else { | 194 | else { |
| 172 | // Clear unused channels | 195 | // Clear unused channels |
| 173 | - this->analyzedData[channel]->samples.voltage.count = 0; | 196 | + channelData->samples.voltage.count = 0; |
| 174 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.interval = 0; | 197 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.interval = 0; |
| 175 | - if(this->analyzedData[channel]->samples.voltage.sample) { | ||
| 176 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | ||
| 177 | - this->analyzedData[channel]->samples.voltage.sample = 0; | 198 | + if(channelData->samples.voltage.sample) { |
| 199 | + delete[] channelData->samples.voltage.sample; | ||
| 200 | + channelData->samples.voltage.sample = 0; | ||
| 178 | } | 201 | } |
| 179 | } | 202 | } |
| 180 | } | 203 | } |
| @@ -186,12 +209,14 @@ void DataAnalyzer::run() { | @@ -186,12 +209,14 @@ void DataAnalyzer::run() { | ||
| 186 | 209 | ||
| 187 | 210 | ||
| 188 | // Calculate frequencies, peak-to-peak voltages and spectrums | 211 | // Calculate frequencies, peak-to-peak voltages and spectrums |
| 189 | - for(int channel = 0; channel < this->analyzedData.count(); channel++) { | ||
| 190 | - if(this->analyzedData[channel]->samples.voltage.sample) { | 212 | + for(int channel = 0; channel < this->analyzedData.count(); ++channel) { |
| 213 | + AnalyzedData *channelData = this->analyzedData[channel]; | ||
| 214 | + | ||
| 215 | + if(channelData->samples.voltage.sample) { | ||
| 191 | // Calculate new window | 216 | // Calculate new window |
| 192 | - if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { | ||
| 193 | - if(this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { | ||
| 194 | - this->lastRecordLength = this->analyzedData[channel]->samples.voltage.count; | 217 | + if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastRecordLength != channelData->samples.voltage.count) { |
| 218 | + if(this->lastRecordLength != channelData->samples.voltage.count) { | ||
| 219 | + this->lastRecordLength = channelData->samples.voltage.count; | ||
| 195 | 220 | ||
| 196 | if(this->window) | 221 | if(this->window) |
| 197 | fftw_free(this->window); | 222 | fftw_free(this->window); |
| @@ -203,19 +228,19 @@ void DataAnalyzer::run() { | @@ -203,19 +228,19 @@ void DataAnalyzer::run() { | ||
| 203 | 228 | ||
| 204 | switch(this->settings->scope.spectrumWindow) { | 229 | switch(this->settings->scope.spectrumWindow) { |
| 205 | case Dso::WINDOW_HAMMING: | 230 | case Dso::WINDOW_HAMMING: |
| 206 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 231 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 207 | *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); | 232 | *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 208 | break; | 233 | break; |
| 209 | case Dso::WINDOW_HANN: | 234 | case Dso::WINDOW_HANN: |
| 210 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 235 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 211 | *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); | 236 | *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); |
| 212 | break; | 237 | break; |
| 213 | case Dso::WINDOW_COSINE: | 238 | case Dso::WINDOW_COSINE: |
| 214 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 239 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 215 | *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); | 240 | *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); |
| 216 | break; | 241 | break; |
| 217 | case Dso::WINDOW_LANCZOS: | 242 | case Dso::WINDOW_LANCZOS: |
| 218 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) { | 243 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) { |
| 219 | double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; | 244 | double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; |
| 220 | if(sincParameter == 0) | 245 | if(sincParameter == 0) |
| 221 | *(this->window + windowPosition) = 1; | 246 | *(this->window + windowPosition) = 1; |
| @@ -224,82 +249,82 @@ void DataAnalyzer::run() { | @@ -224,82 +249,82 @@ void DataAnalyzer::run() { | ||
| 224 | } | 249 | } |
| 225 | break; | 250 | break; |
| 226 | case Dso::WINDOW_BARTLETT: | 251 | case Dso::WINDOW_BARTLETT: |
| 227 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 252 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 228 | *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); | 253 | *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); |
| 229 | break; | 254 | break; |
| 230 | case Dso::WINDOW_TRIANGULAR: | 255 | case Dso::WINDOW_TRIANGULAR: |
| 231 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 256 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 232 | *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2)); | 257 | *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2)); |
| 233 | break; | 258 | break; |
| 234 | case Dso::WINDOW_GAUSS: | 259 | case Dso::WINDOW_GAUSS: |
| 235 | { | 260 | { |
| 236 | double sigma = 0.4; | 261 | double sigma = 0.4; |
| 237 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 262 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 238 | *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); | 263 | *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); |
| 239 | } | 264 | } |
| 240 | break; | 265 | break; |
| 241 | case Dso::WINDOW_BARTLETTHANN: | 266 | case Dso::WINDOW_BARTLETTHANN: |
| 242 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 267 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 243 | *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); | 268 | *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 244 | break; | 269 | break; |
| 245 | case Dso::WINDOW_BLACKMAN: | 270 | case Dso::WINDOW_BLACKMAN: |
| 246 | { | 271 | { |
| 247 | double alpha = 0.16; | 272 | double alpha = 0.16; |
| 248 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 273 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 249 | *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); | 274 | *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); |
| 250 | } | 275 | } |
| 251 | break; | 276 | break; |
| 252 | //case WINDOW_KAISER: | 277 | //case WINDOW_KAISER: |
| 253 | // TODO | 278 | // TODO |
| 254 | //double alpha = 3.0; | 279 | //double alpha = 3.0; |
| 255 | - //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 280 | + //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 256 | //*(this->window + windowPosition) = ; | 281 | //*(this->window + windowPosition) = ; |
| 257 | //break; | 282 | //break; |
| 258 | case Dso::WINDOW_NUTTALL: | 283 | case Dso::WINDOW_NUTTALL: |
| 259 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 284 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 260 | *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); | 285 | *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); |
| 261 | break; | 286 | break; |
| 262 | case Dso::WINDOW_BLACKMANHARRIS: | 287 | case Dso::WINDOW_BLACKMANHARRIS: |
| 263 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 288 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 264 | *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); | 289 | *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); |
| 265 | break; | 290 | break; |
| 266 | case Dso::WINDOW_BLACKMANNUTTALL: | 291 | case Dso::WINDOW_BLACKMANNUTTALL: |
| 267 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 292 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 268 | *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); | 293 | *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); |
| 269 | break; | 294 | break; |
| 270 | case Dso::WINDOW_FLATTOP: | 295 | case Dso::WINDOW_FLATTOP: |
| 271 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 296 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 272 | *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); | 297 | *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); |
| 273 | break; | 298 | break; |
| 274 | default: // Dso::WINDOW_RECTANGULAR | 299 | default: // Dso::WINDOW_RECTANGULAR |
| 275 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | 300 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) |
| 276 | *(this->window + windowPosition) = 1.0; | 301 | *(this->window + windowPosition) = 1.0; |
| 277 | } | 302 | } |
| 278 | } | 303 | } |
| 279 | 304 | ||
| 280 | // Set sampling interval | 305 | // Set sampling interval |
| 281 | - this->analyzedData[channel]->samples.spectrum.interval = 1.0 / this->analyzedData[channel]->samples.voltage.interval / this->analyzedData[channel]->samples.voltage.count; | 306 | + channelData->samples.spectrum.interval = 1.0 / channelData->samples.voltage.interval / channelData->samples.voltage.count; |
| 282 | 307 | ||
| 283 | // Number of real/complex samples | 308 | // Number of real/complex samples |
| 284 | - unsigned int dftLength = this->analyzedData[channel]->samples.voltage.count / 2; | 309 | + unsigned int dftLength = channelData->samples.voltage.count / 2; |
| 285 | 310 | ||
| 286 | // Reallocate memory for samples if the sample count has changed | 311 | // Reallocate memory for samples if the sample count has changed |
| 287 | - if(this->analyzedData[channel]->samples.spectrum.count != dftLength) { | ||
| 288 | - this->analyzedData[channel]->samples.spectrum.count = dftLength; | ||
| 289 | - if(this->analyzedData[channel]->samples.spectrum.sample) | ||
| 290 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | ||
| 291 | - this->analyzedData[channel]->samples.spectrum.sample = new double[this->analyzedData[channel]->samples.voltage.count]; | 312 | + if(channelData->samples.spectrum.count != dftLength) { |
| 313 | + channelData->samples.spectrum.count = dftLength; | ||
| 314 | + if(channelData->samples.spectrum.sample) | ||
| 315 | + delete[] channelData->samples.spectrum.sample; | ||
| 316 | + channelData->samples.spectrum.sample = new double[channelData->samples.voltage.count]; | ||
| 292 | } | 317 | } |
| 293 | 318 | ||
| 294 | // Create sample buffer and apply window | 319 | // Create sample buffer and apply window |
| 295 | - double *windowedValues = new double[this->analyzedData[channel]->samples.voltage.count]; | ||
| 296 | - for(unsigned int position = 0; position < this->analyzedData[channel]->samples.voltage.count; position++) | ||
| 297 | - windowedValues[position] = this->window[position] * this->analyzedData[channel]->samples.voltage.sample[position]; | 320 | + double *windowedValues = new double[channelData->samples.voltage.count]; |
| 321 | + for(unsigned int position = 0; position < channelData->samples.voltage.count; ++position) | ||
| 322 | + windowedValues[position] = this->window[position] * channelData->samples.voltage.sample[position]; | ||
| 298 | 323 | ||
| 299 | // Do discrete real to half-complex transformation | 324 | // Do discrete real to half-complex transformation |
| 300 | /// \todo Check if record length is multiple of 2 | 325 | /// \todo Check if record length is multiple of 2 |
| 301 | /// \todo Reuse plan and use FFTW_MEASURE to get fastest algorithm | 326 | /// \todo Reuse plan and use FFTW_MEASURE to get fastest algorithm |
| 302 | - fftw_plan fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, windowedValues, this->analyzedData[channel]->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); | 327 | + fftw_plan fftPlan = fftw_plan_r2r_1d(channelData->samples.voltage.count, windowedValues, channelData->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); |
| 303 | fftw_execute(fftPlan); | 328 | fftw_execute(fftPlan); |
| 304 | fftw_destroy_plan(fftPlan); | 329 | fftw_destroy_plan(fftPlan); |
| 305 | 330 | ||
| @@ -309,40 +334,40 @@ void DataAnalyzer::run() { | @@ -309,40 +334,40 @@ void DataAnalyzer::run() { | ||
| 309 | // Real values | 334 | // Real values |
| 310 | unsigned int position; | 335 | unsigned int position; |
| 311 | double correctionFactor = 1.0 / dftLength / dftLength; | 336 | double correctionFactor = 1.0 / dftLength / dftLength; |
| 312 | - conjugateComplex[0] = (this->analyzedData[channel]->samples.spectrum.sample[0] * this->analyzedData[channel]->samples.spectrum.sample[0]) * correctionFactor; | ||
| 313 | - for(position = 1; position < dftLength; position++) | ||
| 314 | - conjugateComplex[position] = (this->analyzedData[channel]->samples.spectrum.sample[position] * this->analyzedData[channel]->samples.spectrum.sample[position] + this->analyzedData[channel]->samples.spectrum.sample[this->analyzedData[channel]->samples.voltage.count - position] * this->analyzedData[channel]->samples.spectrum.sample[this->analyzedData[channel]->samples.voltage.count - position]) * correctionFactor; | 337 | + conjugateComplex[0] = (channelData->samples.spectrum.sample[0] * channelData->samples.spectrum.sample[0]) * correctionFactor; |
| 338 | + for(position = 1; position < dftLength; ++position) | ||
| 339 | + conjugateComplex[position] = (channelData->samples.spectrum.sample[position] * channelData->samples.spectrum.sample[position] + channelData->samples.spectrum.sample[channelData->samples.voltage.count - position] * channelData->samples.spectrum.sample[channelData->samples.voltage.count - position]) * correctionFactor; | ||
| 315 | // Complex values, all zero for autocorrelation | 340 | // Complex values, all zero for autocorrelation |
| 316 | - conjugateComplex[dftLength] = (this->analyzedData[channel]->samples.spectrum.sample[dftLength] * this->analyzedData[channel]->samples.spectrum.sample[dftLength]) * correctionFactor; | ||
| 317 | - for(position++; position < this->analyzedData[channel]->samples.voltage.count; position++) | 341 | + conjugateComplex[dftLength] = (channelData->samples.spectrum.sample[dftLength] * channelData->samples.spectrum.sample[dftLength]) * correctionFactor; |
| 342 | + for(++position; position < channelData->samples.voltage.count; ++position) | ||
| 318 | conjugateComplex[position] = 0; | 343 | conjugateComplex[position] = 0; |
| 319 | 344 | ||
| 320 | // Do half-complex to real inverse transformation | 345 | // Do half-complex to real inverse transformation |
| 321 | - double *correlation = new double[this->analyzedData[channel]->samples.voltage.count]; | ||
| 322 | - fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, conjugateComplex, correlation, FFTW_HC2R, FFTW_ESTIMATE); | 346 | + double *correlation = new double[channelData->samples.voltage.count]; |
| 347 | + fftPlan = fftw_plan_r2r_1d(channelData->samples.voltage.count, conjugateComplex, correlation, FFTW_HC2R, FFTW_ESTIMATE); | ||
| 323 | fftw_execute(fftPlan); | 348 | fftw_execute(fftPlan); |
| 324 | fftw_destroy_plan(fftPlan); | 349 | fftw_destroy_plan(fftPlan); |
| 325 | delete[] conjugateComplex; | 350 | delete[] conjugateComplex; |
| 326 | 351 | ||
| 327 | // Calculate peak-to-peak voltage | 352 | // Calculate peak-to-peak voltage |
| 328 | double minimalVoltage, maximalVoltage; | 353 | double minimalVoltage, maximalVoltage; |
| 329 | - minimalVoltage = maximalVoltage = this->analyzedData[channel]->samples.voltage.sample[0]; | 354 | + minimalVoltage = maximalVoltage = channelData->samples.voltage.sample[0]; |
| 330 | 355 | ||
| 331 | - for(unsigned int position = 1; position < this->analyzedData[channel]->samples.voltage.count; position++) { | ||
| 332 | - if(this->analyzedData[channel]->samples.voltage.sample[position] < minimalVoltage) | ||
| 333 | - minimalVoltage = this->analyzedData[channel]->samples.voltage.sample[position]; | ||
| 334 | - else if(this->analyzedData[channel]->samples.voltage.sample[position] > maximalVoltage) | ||
| 335 | - maximalVoltage = this->analyzedData[channel]->samples.voltage.sample[position]; | 356 | + for(unsigned int position = 1; position < channelData->samples.voltage.count; ++position) { |
| 357 | + if(channelData->samples.voltage.sample[position] < minimalVoltage) | ||
| 358 | + minimalVoltage = channelData->samples.voltage.sample[position]; | ||
| 359 | + else if(channelData->samples.voltage.sample[position] > maximalVoltage) | ||
| 360 | + maximalVoltage = channelData->samples.voltage.sample[position]; | ||
| 336 | } | 361 | } |
| 337 | 362 | ||
| 338 | - this->analyzedData[channel]->amplitude = maximalVoltage - minimalVoltage; | 363 | + channelData->amplitude = maximalVoltage - minimalVoltage; |
| 339 | 364 | ||
| 340 | // Get the frequency from the correlation results | 365 | // Get the frequency from the correlation results |
| 341 | double minimumCorrelation = correlation[0]; | 366 | double minimumCorrelation = correlation[0]; |
| 342 | double peakCorrelation = 0; | 367 | double peakCorrelation = 0; |
| 343 | unsigned int peakPosition = 0; | 368 | unsigned int peakPosition = 0; |
| 344 | 369 | ||
| 345 | - for(unsigned int position = 1; position < this->analyzedData[channel]->samples.voltage.count / 2; position++) { | 370 | + for(unsigned int position = 1; position < channelData->samples.voltage.count / 2; ++position) { |
| 346 | if(correlation[position] > peakCorrelation && correlation[position] > minimumCorrelation * 2) { | 371 | if(correlation[position] > peakCorrelation && correlation[position] > minimumCorrelation * 2) { |
| 347 | peakCorrelation = correlation[position]; | 372 | peakCorrelation = correlation[position]; |
| 348 | peakPosition = position; | 373 | peakPosition = position; |
| @@ -354,30 +379,30 @@ void DataAnalyzer::run() { | @@ -354,30 +379,30 @@ void DataAnalyzer::run() { | ||
| 354 | 379 | ||
| 355 | // Calculate the frequency in Hz | 380 | // Calculate the frequency in Hz |
| 356 | if(peakPosition) | 381 | if(peakPosition) |
| 357 | - this->analyzedData[channel]->frequency = 1.0 / (this->analyzedData[channel]->samples.voltage.interval * peakPosition); | 382 | + channelData->frequency = 1.0 / (channelData->samples.voltage.interval * peakPosition); |
| 358 | else | 383 | else |
| 359 | - this->analyzedData[channel]->frequency = 0; | 384 | + channelData->frequency = 0; |
| 360 | 385 | ||
| 361 | // Finally calculate the real spectrum if we want it | 386 | // Finally calculate the real spectrum if we want it |
| 362 | if(this->settings->scope.spectrum[channel].used) { | 387 | if(this->settings->scope.spectrum[channel].used) { |
| 363 | // Convert values into dB (Relative to the reference level) | 388 | // Convert values into dB (Relative to the reference level) |
| 364 | double offset = 60 - this->settings->scope.spectrumReference - 20 * log10(dftLength); | 389 | double offset = 60 - this->settings->scope.spectrumReference - 20 * log10(dftLength); |
| 365 | double offsetLimit = this->settings->scope.spectrumLimit - this->settings->scope.spectrumReference; | 390 | double offsetLimit = this->settings->scope.spectrumLimit - this->settings->scope.spectrumReference; |
| 366 | - for(unsigned int position = 0; position < this->analyzedData[channel]->samples.spectrum.count; position++) { | ||
| 367 | - this->analyzedData[channel]->samples.spectrum.sample[position] = 20 * log10(fabs(this->analyzedData[channel]->samples.spectrum.sample[position])) + offset; | 391 | + for(unsigned int position = 0; position < channelData->samples.spectrum.count; ++position) { |
| 392 | + channelData->samples.spectrum.sample[position] = 20 * log10(fabs(channelData->samples.spectrum.sample[position])) + offset; | ||
| 368 | 393 | ||
| 369 | // Check if this value has to be limited | 394 | // Check if this value has to be limited |
| 370 | - if(offsetLimit > this->analyzedData[channel]->samples.spectrum.sample[position]) | ||
| 371 | - this->analyzedData[channel]->samples.spectrum.sample[position] = offsetLimit; | 395 | + if(offsetLimit > channelData->samples.spectrum.sample[position]) |
| 396 | + channelData->samples.spectrum.sample[position] = offsetLimit; | ||
| 372 | } | 397 | } |
| 373 | } | 398 | } |
| 374 | } | 399 | } |
| 375 | - else if(this->analyzedData[channel]->samples.spectrum.sample) { | 400 | + else if(channelData->samples.spectrum.sample) { |
| 376 | // Clear unused channels | 401 | // Clear unused channels |
| 377 | - this->analyzedData[channel]->samples.spectrum.count = 0; | ||
| 378 | - this->analyzedData[channel]->samples.spectrum.interval = 0; | ||
| 379 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | ||
| 380 | - this->analyzedData[channel]->samples.spectrum.sample = 0; | 402 | + channelData->samples.spectrum.count = 0; |
| 403 | + channelData->samples.spectrum.interval = 0; | ||
| 404 | + delete[] channelData->samples.spectrum.sample; | ||
| 405 | + channelData->samples.spectrum.sample = 0; | ||
| 381 | } | 406 | } |
| 382 | } | 407 | } |
| 383 | 408 |
openhantek/src/dockwindows.cpp
| @@ -50,13 +50,13 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo | @@ -50,13 +50,13 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo | ||
| 50 | << 1e-3 << 2e-3 << 4e-3 << 1e-2 << 2e-2 << 4e-2 << 1e-1 << 2e-1 << 4e-1 | 50 | << 1e-3 << 2e-3 << 4e-3 << 1e-2 << 2e-2 << 4e-2 << 1e-1 << 2e-1 << 4e-1 |
| 51 | << 1e0 << 2e0 << 4e0 << 1e1 << 2e1 << 4e1 << 6e1 << 12e1 << 24e1 | 51 | << 1e0 << 2e0 << 4e0 << 1e1 << 2e1 << 4e1 << 6e1 << 12e1 << 24e1 |
| 52 | << 6e2 << 12e2 << 24e2 << 36e2; ///< Timebase steps in seconds/div | 52 | << 6e2 << 12e2 << 24e2 << 36e2; ///< Timebase steps in seconds/div |
| 53 | - for(QList<double>::iterator timebase = this->timebaseSteps.begin(); timebase != this->timebaseSteps.end(); timebase++) | 53 | + for(QList<double>::iterator timebase = this->timebaseSteps.begin(); timebase != this->timebaseSteps.end(); ++timebase) |
| 54 | this->timebaseStrings << Helper::valueToString(*timebase, Helper::UNIT_SECONDS, 0); | 54 | this->timebaseStrings << Helper::valueToString(*timebase, Helper::UNIT_SECONDS, 0); |
| 55 | this->frequencybaseSteps | 55 | this->frequencybaseSteps |
| 56 | << 1.0 << 2.0 << 5.0 << 1e1 << 2e1 << 5e1 << 1e2 << 2e2 << 5e2 | 56 | << 1.0 << 2.0 << 5.0 << 1e1 << 2e1 << 5e1 << 1e2 << 2e2 << 5e2 |
| 57 | << 1e3 << 2e3 << 5e3 << 1e4 << 2e4 << 4e4 << 1e5 << 2e5 << 5e5 | 57 | << 1e3 << 2e3 << 5e3 << 1e4 << 2e4 << 4e4 << 1e5 << 2e5 << 5e5 |
| 58 | << 1e6 << 2e6 << 5e6 << 1e7; ///< Frequencybase steps in Hz/div | 58 | << 1e6 << 2e6 << 5e6 << 1e7; ///< Frequencybase steps in Hz/div |
| 59 | - for(QList<double>::iterator frequencybase = this->frequencybaseSteps.begin(); frequencybase != this->frequencybaseSteps.end(); frequencybase++) | 59 | + for(QList<double>::iterator frequencybase = this->frequencybaseSteps.begin(); frequencybase != this->frequencybaseSteps.end(); ++frequencybase) |
| 60 | this->frequencybaseStrings << Helper::valueToString(*frequencybase, Helper::UNIT_HERTZ, 0); | 60 | this->frequencybaseStrings << Helper::valueToString(*frequencybase, Helper::UNIT_HERTZ, 0); |
| 61 | 61 | ||
| 62 | // Initialize elements | 62 | // Initialize elements |
| @@ -70,7 +70,7 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo | @@ -70,7 +70,7 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo | ||
| 70 | 70 | ||
| 71 | this->formatLabel = new QLabel(tr("Format")); | 71 | this->formatLabel = new QLabel(tr("Format")); |
| 72 | this->formatComboBox = new QComboBox(); | 72 | this->formatComboBox = new QComboBox(); |
| 73 | - for(int format = Dso::GRAPHFORMAT_TY; format < Dso::GRAPHFORMAT_COUNT; format++) | 73 | + for(int format = Dso::GRAPHFORMAT_TY; format < Dso::GRAPHFORMAT_COUNT; ++format) |
| 74 | this->formatComboBox->addItem(Dso::graphFormatString((Dso::GraphFormat) format)); | 74 | this->formatComboBox->addItem(Dso::graphFormatString((Dso::GraphFormat) format)); |
| 75 | 75 | ||
| 76 | this->dockLayout = new QGridLayout(); | 76 | this->dockLayout = new QGridLayout(); |
| @@ -181,19 +181,19 @@ TriggerDock::TriggerDock(DsoSettings *settings, const QStringList *specialTrigge | @@ -181,19 +181,19 @@ TriggerDock::TriggerDock(DsoSettings *settings, const QStringList *specialTrigge | ||
| 181 | this->settings = settings; | 181 | this->settings = settings; |
| 182 | 182 | ||
| 183 | // Initialize lists for comboboxes | 183 | // Initialize lists for comboboxes |
| 184 | - for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; channel++) | 184 | + for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; ++channel) |
| 185 | this->sourceStandardStrings << tr("CH%1").arg(channel + 1); | 185 | this->sourceStandardStrings << tr("CH%1").arg(channel + 1); |
| 186 | this->sourceSpecialStrings << *specialTriggers; | 186 | this->sourceSpecialStrings << *specialTriggers; |
| 187 | 187 | ||
| 188 | // Initialize elements | 188 | // Initialize elements |
| 189 | this->modeLabel = new QLabel(tr("Mode")); | 189 | this->modeLabel = new QLabel(tr("Mode")); |
| 190 | this->modeComboBox = new QComboBox(); | 190 | this->modeComboBox = new QComboBox(); |
| 191 | - for(int mode = Dso::TRIGGERMODE_AUTO; mode < Dso::TRIGGERMODE_COUNT; mode++) | 191 | + for(int mode = Dso::TRIGGERMODE_AUTO; mode < Dso::TRIGGERMODE_COUNT; ++mode) |
| 192 | this->modeComboBox->addItem(Dso::triggerModeString((Dso::TriggerMode) mode)); | 192 | this->modeComboBox->addItem(Dso::triggerModeString((Dso::TriggerMode) mode)); |
| 193 | 193 | ||
| 194 | this->slopeLabel = new QLabel(tr("Slope")); | 194 | this->slopeLabel = new QLabel(tr("Slope")); |
| 195 | this->slopeComboBox = new QComboBox(); | 195 | this->slopeComboBox = new QComboBox(); |
| 196 | - for(int slope = Dso::SLOPE_POSITIVE; slope < Dso::SLOPE_COUNT; slope++) | 196 | + for(int slope = Dso::SLOPE_POSITIVE; slope < Dso::SLOPE_COUNT; ++slope) |
| 197 | this->slopeComboBox->addItem(Dso::slopeString((Dso::Slope) slope)); | 197 | this->slopeComboBox->addItem(Dso::slopeString((Dso::Slope) slope)); |
| 198 | 198 | ||
| 199 | this->sourceLabel = new QLabel(tr("Source")); | 199 | this->sourceLabel = new QLabel(tr("Source")); |
| @@ -323,11 +323,11 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -323,11 +323,11 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 323 | // Initialize lists for comboboxes | 323 | // Initialize lists for comboboxes |
| 324 | this->magnitudeSteps << 1e0 << 2e0 << 3e0 << 6e0 | 324 | this->magnitudeSteps << 1e0 << 2e0 << 3e0 << 6e0 |
| 325 | << 1e1 << 2e1 << 3e1 << 6e1 << 1e2 << 2e2 << 3e2 << 6e2; ///< Magnitude steps in dB/div | 325 | << 1e1 << 2e1 << 3e1 << 6e1 << 1e2 << 2e2 << 3e2 << 6e2; ///< Magnitude steps in dB/div |
| 326 | - for(QList<double>::iterator magnitude = this->magnitudeSteps.begin(); magnitude != this->magnitudeSteps.end(); magnitude++) | 326 | + for(QList<double>::iterator magnitude = this->magnitudeSteps.begin(); magnitude != this->magnitudeSteps.end(); ++magnitude) |
| 327 | this->magnitudeStrings << Helper::valueToString(*magnitude, Helper::UNIT_DECIBEL, 0); | 327 | this->magnitudeStrings << Helper::valueToString(*magnitude, Helper::UNIT_DECIBEL, 0); |
| 328 | 328 | ||
| 329 | // Initialize elements | 329 | // Initialize elements |
| 330 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 330 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 331 | this->magnitudeComboBox.append(new QComboBox()); | 331 | this->magnitudeComboBox.append(new QComboBox()); |
| 332 | this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); | 332 | this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); |
| 333 | 333 | ||
| @@ -337,7 +337,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -337,7 +337,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 337 | this->dockLayout = new QGridLayout(); | 337 | this->dockLayout = new QGridLayout(); |
| 338 | this->dockLayout->setColumnMinimumWidth(0, 64); | 338 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 339 | this->dockLayout->setColumnStretch(1, 1); | 339 | this->dockLayout->setColumnStretch(1, 1); |
| 340 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 340 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 341 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); | 341 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); |
| 342 | this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); | 342 | this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); |
| 343 | } | 343 | } |
| @@ -349,13 +349,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -349,13 +349,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 349 | this->setWidget(this->dockWidget); | 349 | this->setWidget(this->dockWidget); |
| 350 | 350 | ||
| 351 | // Connect signals and slots | 351 | // Connect signals and slots |
| 352 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 352 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 353 | connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); | 353 | connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); |
| 354 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); | 354 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | // Set values | 357 | // Set values |
| 358 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 358 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 359 | this->setMagnitude(channel, this->settings->scope.spectrum[channel].magnitude); | 359 | this->setMagnitude(channel, this->settings->scope.spectrum[channel].magnitude); |
| 360 | this->setUsed(channel, this->settings->scope.spectrum[channel].used); | 360 | this->setUsed(channel, this->settings->scope.spectrum[channel].used); |
| 361 | } | 361 | } |
| @@ -407,7 +407,7 @@ void SpectrumDock::magnitudeSelected(int index) { | @@ -407,7 +407,7 @@ void SpectrumDock::magnitudeSelected(int index) { | ||
| 407 | int channel; | 407 | int channel; |
| 408 | 408 | ||
| 409 | // Which combobox was it? | 409 | // Which combobox was it? |
| 410 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | 410 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) |
| 411 | if(this->sender() == this->magnitudeComboBox[channel]) | 411 | if(this->sender() == this->magnitudeComboBox[channel]) |
| 412 | break; | 412 | break; |
| 413 | 413 | ||
| @@ -424,7 +424,7 @@ void SpectrumDock::usedSwitched(bool checked) { | @@ -424,7 +424,7 @@ void SpectrumDock::usedSwitched(bool checked) { | ||
| 424 | int channel; | 424 | int channel; |
| 425 | 425 | ||
| 426 | // Which checkbox was it? | 426 | // Which checkbox was it? |
| 427 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | 427 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) |
| 428 | if(this->sender() == this->usedCheckBox[channel]) | 428 | if(this->sender() == this->usedCheckBox[channel]) |
| 429 | break; | 429 | break; |
| 430 | 430 | ||
| @@ -446,19 +446,19 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -446,19 +446,19 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 446 | this->settings = settings; | 446 | this->settings = settings; |
| 447 | 447 | ||
| 448 | // Initialize lists for comboboxes | 448 | // Initialize lists for comboboxes |
| 449 | - for(int coupling = Dso::COUPLING_AC; coupling < Dso::COUPLING_COUNT; coupling++) | 449 | + for(int coupling = Dso::COUPLING_AC; coupling < Dso::COUPLING_COUNT; ++coupling) |
| 450 | this->couplingStrings.append(Dso::couplingString((Dso::Coupling) coupling)); | 450 | this->couplingStrings.append(Dso::couplingString((Dso::Coupling) coupling)); |
| 451 | 451 | ||
| 452 | - for(int mode = Dso::MATHMODE_1ADD2; mode < Dso::MATHMODE_COUNT; mode++) | 452 | + for(int mode = Dso::MATHMODE_1ADD2; mode < Dso::MATHMODE_COUNT; ++mode) |
| 453 | this->modeStrings.append(Dso::mathModeString((Dso::MathMode) mode)); | 453 | this->modeStrings.append(Dso::mathModeString((Dso::MathMode) mode)); |
| 454 | 454 | ||
| 455 | this->gainSteps << 1e-2 << 2e-2 << 5e-2 << 1e-1 << 2e-1 << 5e-1 | 455 | this->gainSteps << 1e-2 << 2e-2 << 5e-2 << 1e-1 << 2e-1 << 5e-1 |
| 456 | << 1e0 << 2e0 << 5e0; ///< Voltage steps in V/div | 456 | << 1e0 << 2e0 << 5e0; ///< Voltage steps in V/div |
| 457 | - for(QList<double>::iterator gain = this->gainSteps.begin(); gain != this->gainSteps.end(); gain++) | 457 | + for(QList<double>::iterator gain = this->gainSteps.begin(); gain != this->gainSteps.end(); ++gain) |
| 458 | this->gainStrings << Helper::valueToString(*gain, Helper::UNIT_VOLTS, 0); | 458 | this->gainStrings << Helper::valueToString(*gain, Helper::UNIT_VOLTS, 0); |
| 459 | 459 | ||
| 460 | // Initialize elements | 460 | // Initialize elements |
| 461 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 461 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 462 | this->miscComboBox.append(new QComboBox()); | 462 | this->miscComboBox.append(new QComboBox()); |
| 463 | if(channel < (int) this->settings->scope.physicalChannels) | 463 | if(channel < (int) this->settings->scope.physicalChannels) |
| 464 | this->miscComboBox[channel]->addItems(this->couplingStrings); | 464 | this->miscComboBox[channel]->addItems(this->couplingStrings); |
| @@ -474,7 +474,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -474,7 +474,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 474 | this->dockLayout = new QGridLayout(); | 474 | this->dockLayout = new QGridLayout(); |
| 475 | this->dockLayout->setColumnMinimumWidth(0, 64); | 475 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 476 | this->dockLayout->setColumnStretch(1, 1); | 476 | this->dockLayout->setColumnStretch(1, 1); |
| 477 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 477 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 478 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 2, 0); | 478 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 2, 0); |
| 479 | this->dockLayout->addWidget(this->gainComboBox[channel], channel * 2, 1); | 479 | this->dockLayout->addWidget(this->gainComboBox[channel], channel * 2, 1); |
| 480 | this->dockLayout->addWidget(this->miscComboBox[channel], channel * 2 + 1, 1); | 480 | this->dockLayout->addWidget(this->miscComboBox[channel], channel * 2 + 1, 1); |
| @@ -487,14 +487,14 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -487,14 +487,14 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 487 | this->setWidget(this->dockWidget); | 487 | this->setWidget(this->dockWidget); |
| 488 | 488 | ||
| 489 | // Connect signals and slots | 489 | // Connect signals and slots |
| 490 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 490 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 491 | connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); | 491 | connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); |
| 492 | connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); | 492 | connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); |
| 493 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); | 493 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | // Set values | 496 | // Set values |
| 497 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 497 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 498 | if(channel < (int) this->settings->scope.physicalChannels) | 498 | if(channel < (int) this->settings->scope.physicalChannels) |
| 499 | this->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); | 499 | this->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); |
| 500 | else | 500 | else |
| @@ -576,7 +576,7 @@ void VoltageDock::gainSelected(int index) { | @@ -576,7 +576,7 @@ void VoltageDock::gainSelected(int index) { | ||
| 576 | int channel; | 576 | int channel; |
| 577 | 577 | ||
| 578 | // Which combobox was it? | 578 | // Which combobox was it? |
| 579 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | 579 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) |
| 580 | if(this->sender() == this->gainComboBox[channel]) | 580 | if(this->sender() == this->gainComboBox[channel]) |
| 581 | break; | 581 | break; |
| 582 | 582 | ||
| @@ -594,7 +594,7 @@ void VoltageDock::miscSelected(int index) { | @@ -594,7 +594,7 @@ void VoltageDock::miscSelected(int index) { | ||
| 594 | int channel; | 594 | int channel; |
| 595 | 595 | ||
| 596 | // Which combobox was it? | 596 | // Which combobox was it? |
| 597 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | 597 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) |
| 598 | if(this->sender() == this->miscComboBox[channel]) | 598 | if(this->sender() == this->miscComboBox[channel]) |
| 599 | break; | 599 | break; |
| 600 | 600 | ||
| @@ -614,7 +614,7 @@ void VoltageDock::usedSwitched(bool checked) { | @@ -614,7 +614,7 @@ void VoltageDock::usedSwitched(bool checked) { | ||
| 614 | int channel; | 614 | int channel; |
| 615 | 615 | ||
| 616 | // Which checkbox was it? | 616 | // Which checkbox was it? |
| 617 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | 617 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) |
| 618 | if(this->sender() == this->usedCheckBox[channel]) | 618 | if(this->sender() == this->usedCheckBox[channel]) |
| 619 | break; | 619 | break; |
| 620 | 620 |
openhantek/src/dsowidget.cpp
| @@ -66,7 +66,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -66,7 +66,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 66 | 66 | ||
| 67 | // The offset sliders for all possible channels | 67 | // The offset sliders for all possible channels |
| 68 | this->offsetSlider = new LevelSlider(Qt::RightArrow); | 68 | this->offsetSlider = new LevelSlider(Qt::RightArrow); |
| 69 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 69 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 70 | this->offsetSlider->addSlider(this->settings->scope.voltage[channel].name, channel); | 70 | this->offsetSlider->addSlider(this->settings->scope.voltage[channel].name, channel); |
| 71 | this->offsetSlider->setColor(channel, this->settings->view.color.screen.voltage[channel]); | 71 | this->offsetSlider->setColor(channel, this->settings->view.color.screen.voltage[channel]); |
| 72 | this->offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); | 72 | this->offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); |
| @@ -74,7 +74,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -74,7 +74,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 74 | this->offsetSlider->setValue(channel, this->settings->scope.voltage[channel].offset); | 74 | this->offsetSlider->setValue(channel, this->settings->scope.voltage[channel].offset); |
| 75 | this->offsetSlider->setVisible(channel, this->settings->scope.voltage[channel].used); | 75 | this->offsetSlider->setVisible(channel, this->settings->scope.voltage[channel].used); |
| 76 | } | 76 | } |
| 77 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 77 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 78 | this->offsetSlider->addSlider(this->settings->scope.spectrum[channel].name, this->settings->scope.voltage.count() + channel); | 78 | this->offsetSlider->addSlider(this->settings->scope.spectrum[channel].name, this->settings->scope.voltage.count() + channel); |
| 79 | this->offsetSlider->setColor(this->settings->scope.voltage.count() + channel, this->settings->view.color.screen.spectrum[channel]); | 79 | this->offsetSlider->setColor(this->settings->scope.voltage.count() + channel, this->settings->view.color.screen.spectrum[channel]); |
| 80 | this->offsetSlider->setLimits(this->settings->scope.voltage.count() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); | 80 | this->offsetSlider->setLimits(this->settings->scope.voltage.count() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); |
| @@ -93,7 +93,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -93,7 +93,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 93 | 93 | ||
| 94 | // The sliders for the trigger levels | 94 | // The sliders for the trigger levels |
| 95 | this->triggerLevelSlider = new LevelSlider(Qt::LeftArrow); | 95 | this->triggerLevelSlider = new LevelSlider(Qt::LeftArrow); |
| 96 | - for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; channel++) { | 96 | + for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; ++channel) { |
| 97 | this->triggerLevelSlider->addSlider(channel); | 97 | this->triggerLevelSlider->addSlider(channel); |
| 98 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); | 98 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); |
| 99 | this->adaptTriggerLevelSlider(channel); | 99 | this->adaptTriggerLevelSlider(channel); |
| @@ -103,7 +103,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -103,7 +103,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 103 | 103 | ||
| 104 | // The marker slider | 104 | // The marker slider |
| 105 | this->markerSlider = new LevelSlider(Qt::UpArrow); | 105 | this->markerSlider = new LevelSlider(Qt::UpArrow); |
| 106 | - for(int marker = 0; marker < MARKER_COUNT; marker++) { | 106 | + for(int marker = 0; marker < MARKER_COUNT; ++marker) { |
| 107 | this->markerSlider->addSlider(QString::number(marker + 1), marker); | 107 | this->markerSlider->addSlider(QString::number(marker + 1), marker); |
| 108 | this->markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); | 108 | this->markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); |
| 109 | this->markerSlider->setStep(marker, 0.2); | 109 | this->markerSlider->setStep(marker, 0.2); |
| @@ -165,7 +165,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | @@ -165,7 +165,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget | ||
| 165 | this->measurementLayout->setColumnStretch(3, 2); | 165 | this->measurementLayout->setColumnStretch(3, 2); |
| 166 | this->measurementLayout->setColumnStretch(4, 3); | 166 | this->measurementLayout->setColumnStretch(4, 3); |
| 167 | this->measurementLayout->setColumnStretch(5, 3); | 167 | this->measurementLayout->setColumnStretch(5, 3); |
| 168 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 168 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 169 | tablePalette.setColor(QPalette::WindowText, this->settings->view.color.screen.voltage[channel]); | 169 | tablePalette.setColor(QPalette::WindowText, this->settings->view.color.screen.voltage[channel]); |
| 170 | this->measurementNameLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); | 170 | this->measurementNameLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); |
| 171 | this->measurementNameLabel[channel]->setPalette(tablePalette); | 171 | this->measurementNameLabel[channel]->setPalette(tablePalette); |
| @@ -378,7 +378,7 @@ void DsoWidget::updateTriggerSource() { | @@ -378,7 +378,7 @@ void DsoWidget::updateTriggerSource() { | ||
| 378 | else | 378 | else |
| 379 | this->triggerPositionSlider->setColor(0, this->settings->view.color.screen.voltage[this->settings->scope.trigger.source]); | 379 | this->triggerPositionSlider->setColor(0, this->settings->view.color.screen.voltage[this->settings->scope.trigger.source]); |
| 380 | 380 | ||
| 381 | - for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; channel++) | 381 | + for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; ++channel) |
| 382 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); | 382 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); |
| 383 | 383 | ||
| 384 | this->updateTriggerDetails(); | 384 | this->updateTriggerDetails(); |
| @@ -439,13 +439,13 @@ bool DsoWidget::exportAs() { | @@ -439,13 +439,13 @@ bool DsoWidget::exportAs() { | ||
| 439 | << tr("Image (*.png *.xpm *.jpg)") | 439 | << tr("Image (*.png *.xpm *.jpg)") |
| 440 | << tr("Comma-Separated Values (*.csv)"); | 440 | << tr("Comma-Separated Values (*.csv)"); |
| 441 | 441 | ||
| 442 | - QFileDialog fileDialog((QWidget *) this->parent(), tr("Export file..."), QString(), filters.join(";;")); | 442 | + QFileDialog fileDialog(static_cast<QWidget *>(this->parent()), tr("Export file..."), QString(), filters.join(";;")); |
| 443 | fileDialog.setFileMode(QFileDialog::AnyFile); | 443 | fileDialog.setFileMode(QFileDialog::AnyFile); |
| 444 | fileDialog.setAcceptMode(QFileDialog::AcceptSave); | 444 | fileDialog.setAcceptMode(QFileDialog::AcceptSave); |
| 445 | if(fileDialog.exec() != QDialog::Accepted) | 445 | if(fileDialog.exec() != QDialog::Accepted) |
| 446 | return false; | 446 | return false; |
| 447 | 447 | ||
| 448 | - Exporter exporter(this->settings, this->dataAnalyzer, (QWidget *) this->parent()); | 448 | + Exporter exporter(this->settings, this->dataAnalyzer, static_cast<QWidget *>(this->parent())); |
| 449 | exporter.setFilename(fileDialog.selectedFiles().first()); | 449 | exporter.setFilename(fileDialog.selectedFiles().first()); |
| 450 | exporter.setFormat((ExportFormat) (EXPORT_FORMAT_PDF + filters.indexOf(fileDialog.selectedFilter()))); | 450 | exporter.setFormat((ExportFormat) (EXPORT_FORMAT_PDF + filters.indexOf(fileDialog.selectedFilter()))); |
| 451 | 451 | ||
| @@ -455,7 +455,7 @@ bool DsoWidget::exportAs() { | @@ -455,7 +455,7 @@ bool DsoWidget::exportAs() { | ||
| 455 | /// \brief Print the oscilloscope screen. | 455 | /// \brief Print the oscilloscope screen. |
| 456 | /// \return true if the document was sent to the printer successfully. | 456 | /// \return true if the document was sent to the printer successfully. |
| 457 | bool DsoWidget::print() { | 457 | bool DsoWidget::print() { |
| 458 | - Exporter exporter(this->settings, this->dataAnalyzer, (QWidget *) this->parent()); | 458 | + Exporter exporter(this->settings, this->dataAnalyzer, static_cast<QWidget *>(this->parent())); |
| 459 | exporter.setFormat(EXPORT_FORMAT_PRINTER); | 459 | exporter.setFormat(EXPORT_FORMAT_PRINTER); |
| 460 | 460 | ||
| 461 | return exporter.doExport(); | 461 | return exporter.doExport(); |
| @@ -481,7 +481,7 @@ void DsoWidget::updateZoom(bool enabled) { | @@ -481,7 +481,7 @@ void DsoWidget::updateZoom(bool enabled) { | ||
| 481 | 481 | ||
| 482 | /// \brief Prints analyzed data. | 482 | /// \brief Prints analyzed data. |
| 483 | void DsoWidget::dataAnalyzed() { | 483 | void DsoWidget::dataAnalyzed() { |
| 484 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 484 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 485 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { | 485 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 486 | // Amplitude string representation (4 significant digits) | 486 | // Amplitude string representation (4 significant digits) |
| 487 | this->measurementAmplitudeLabel[channel]->setText(Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4)); | 487 | this->measurementAmplitudeLabel[channel]->setText(Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4)); |
openhantek/src/exporter.cpp
| @@ -84,26 +84,28 @@ bool Exporter::doExport() { | @@ -84,26 +84,28 @@ bool Exporter::doExport() { | ||
| 84 | if(this->format < EXPORT_FORMAT_IMAGE) { | 84 | if(this->format < EXPORT_FORMAT_IMAGE) { |
| 85 | // We need a QPrinter for printing, pdf- and ps-export | 85 | // We need a QPrinter for printing, pdf- and ps-export |
| 86 | paintDevice = new QPrinter(QPrinter::HighResolution); | 86 | paintDevice = new QPrinter(QPrinter::HighResolution); |
| 87 | - ((QPrinter *) paintDevice)->setOrientation(this->settings->view.zoom ? QPrinter::Portrait : QPrinter::Landscape); | ||
| 88 | - ((QPrinter *) paintDevice)->setPageMargins(20, 20, 20, 20, QPrinter::Millimeter); | 87 | + static_cast<QPrinter *>(paintDevice)->setOrientation(this->settings->view.zoom ? QPrinter::Portrait : QPrinter::Landscape); |
| 88 | + static_cast<QPrinter *>(paintDevice)->setPageMargins(20, 20, 20, 20, QPrinter::Millimeter); | ||
| 89 | 89 | ||
| 90 | if(this->format == EXPORT_FORMAT_PRINTER) { | 90 | if(this->format == EXPORT_FORMAT_PRINTER) { |
| 91 | // Show the printing dialog | 91 | // Show the printing dialog |
| 92 | - QPrintDialog *dialog = new QPrintDialog((QPrinter *) paintDevice, (QWidget *) this->parent()); | ||
| 93 | - dialog->setWindowTitle(tr("Print oscillograph")); | ||
| 94 | - if(dialog->exec() != QDialog::Accepted) | 92 | + QPrintDialog dialog(static_cast<QPrinter *>(paintDevice), static_cast<QWidget *>(this->parent())); |
| 93 | + dialog.setWindowTitle(tr("Print oscillograph")); | ||
| 94 | + if(dialog.exec() != QDialog::Accepted) { | ||
| 95 | + delete paintDevice; | ||
| 95 | return false; | 96 | return false; |
| 97 | + } | ||
| 96 | } | 98 | } |
| 97 | else { | 99 | else { |
| 98 | // Configure the QPrinter | 100 | // Configure the QPrinter |
| 99 | - ((QPrinter *) paintDevice)->setOutputFileName(this->filename); | ||
| 100 | - ((QPrinter *) paintDevice)->setOutputFormat((this->format == EXPORT_FORMAT_PDF) ? QPrinter::PdfFormat : QPrinter::PostScriptFormat); | 101 | + static_cast<QPrinter *>(paintDevice)->setOutputFileName(this->filename); |
| 102 | + static_cast<QPrinter *>(paintDevice)->setOutputFormat((this->format == EXPORT_FORMAT_PDF) ? QPrinter::PdfFormat : QPrinter::PostScriptFormat); | ||
| 101 | } | 103 | } |
| 102 | } | 104 | } |
| 103 | else { | 105 | else { |
| 104 | // We need a QPixmap for image-export | 106 | // We need a QPixmap for image-export |
| 105 | paintDevice = new QPixmap(this->settings->options.imageSize); | 107 | paintDevice = new QPixmap(this->settings->options.imageSize); |
| 106 | - ((QPixmap *) paintDevice)->fill(colorValues->background); | 108 | + static_cast<QPixmap *>(paintDevice)->fill(colorValues->background); |
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | // Create a painter for our device | 111 | // Create a painter for our device |
| @@ -142,7 +144,7 @@ bool Exporter::doExport() { | @@ -142,7 +144,7 @@ bool Exporter::doExport() { | ||
| 142 | int channelCount = 0; | 144 | int channelCount = 0; |
| 143 | for(int channel = this->settings->scope.voltage.count() - 1; channel >= 0; channel--) { | 145 | for(int channel = this->settings->scope.voltage.count() - 1; channel >= 0; channel--) { |
| 144 | if((this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel)) { | 146 | if((this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel)) { |
| 145 | - channelCount++; | 147 | + ++channelCount; |
| 146 | double top = (double) paintDevice->height() - channelCount * lineHeight; | 148 | double top = (double) paintDevice->height() - channelCount * lineHeight; |
| 147 | 149 | ||
| 148 | // Print label | 150 | // Print label |
| @@ -208,11 +210,11 @@ bool Exporter::doExport() { | @@ -208,11 +210,11 @@ bool Exporter::doExport() { | ||
| 208 | painter.setRenderHint(QPainter::Antialiasing); | 210 | painter.setRenderHint(QPainter::Antialiasing); |
| 209 | painter.setBrush(Qt::NoBrush); | 211 | painter.setBrush(Qt::NoBrush); |
| 210 | 212 | ||
| 211 | - for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); zoomed++) { | 213 | + for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); ++zoomed) { |
| 212 | switch(this->settings->scope.horizontal.format) { | 214 | switch(this->settings->scope.horizontal.format) { |
| 213 | case Dso::GRAPHFORMAT_TY: | 215 | case Dso::GRAPHFORMAT_TY: |
| 214 | // Add graphs for channels | 216 | // Add graphs for channels |
| 215 | - for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | 217 | + for(int channel = 0 ; channel < this->settings->scope.voltage.count(); ++channel) { |
| 216 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { | 218 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 217 | painter.setPen(colorValues->voltage[channel]); | 219 | painter.setPen(colorValues->voltage[channel]); |
| 218 | 220 | ||
| @@ -233,14 +235,17 @@ bool Exporter::doExport() { | @@ -233,14 +235,17 @@ bool Exporter::doExport() { | ||
| 233 | 235 | ||
| 234 | // Draw graph | 236 | // Draw graph |
| 235 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; | 237 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; |
| 236 | - for(unsigned int position = firstPosition; position <= lastPosition; position++) | 238 | + |
| 239 | + for(unsigned int position = firstPosition; position <= lastPosition; ++position) | ||
| 237 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset); | 240 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset); |
| 241 | + | ||
| 238 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); | 242 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); |
| 243 | + delete[] graph; | ||
| 239 | } | 244 | } |
| 240 | } | 245 | } |
| 241 | 246 | ||
| 242 | // Add spectrum graphs | 247 | // Add spectrum graphs |
| 243 | - for (int channel = 0; channel < this->settings->scope.spectrum.count(); channel++) { | 248 | + for (int channel = 0; channel < this->settings->scope.spectrum.count(); ++channel) { |
| 244 | if(this->settings->scope.spectrum[channel].used && this->dataAnalyzer->data(channel)) { | 249 | if(this->settings->scope.spectrum[channel].used && this->dataAnalyzer->data(channel)) { |
| 245 | painter.setPen(colorValues->spectrum[channel]); | 250 | painter.setPen(colorValues->spectrum[channel]); |
| 246 | 251 | ||
| @@ -261,9 +266,12 @@ bool Exporter::doExport() { | @@ -261,9 +266,12 @@ bool Exporter::doExport() { | ||
| 261 | 266 | ||
| 262 | // Draw graph | 267 | // Draw graph |
| 263 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; | 268 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; |
| 264 | - for(unsigned int position = firstPosition; position <= lastPosition; position++) | 269 | + |
| 270 | + for(unsigned int position = firstPosition; position <= lastPosition; ++position) | ||
| 265 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset); | 271 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset); |
| 272 | + | ||
| 266 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); | 273 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); |
| 274 | + delete[] graph; | ||
| 267 | } | 275 | } |
| 268 | } | 276 | } |
| 269 | break; | 277 | break; |
| @@ -283,7 +291,7 @@ bool Exporter::doExport() { | @@ -283,7 +291,7 @@ bool Exporter::doExport() { | ||
| 283 | 291 | ||
| 284 | // Draw grids | 292 | // Draw grids |
| 285 | painter.setRenderHint(QPainter::Antialiasing, false); | 293 | painter.setRenderHint(QPainter::Antialiasing, false); |
| 286 | - for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); zoomed++) { | 294 | + for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); ++zoomed) { |
| 287 | // Set DIVS_TIME x DIVS_VOLTAGE matrix for oscillograph | 295 | // Set DIVS_TIME x DIVS_VOLTAGE matrix for oscillograph |
| 288 | painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME, 0, 0, -(scopeHeight - 1) / DIVS_VOLTAGE, (double) (paintDevice->width() - 1) / 2, (scopeHeight - 1) * (zoomed + 0.5) + lineHeight * 1.5 + lineHeight * 2.5 * zoomed), false); | 296 | painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME, 0, 0, -(scopeHeight - 1) / DIVS_VOLTAGE, (double) (paintDevice->width() - 1) / 2, (scopeHeight - 1) * (zoomed + 0.5) + lineHeight * 1.5 + lineHeight * 2.5 * zoomed), false); |
| 289 | 297 | ||
| @@ -292,8 +300,8 @@ bool Exporter::doExport() { | @@ -292,8 +300,8 @@ bool Exporter::doExport() { | ||
| 292 | 300 | ||
| 293 | if(this->format < EXPORT_FORMAT_IMAGE) { | 301 | if(this->format < EXPORT_FORMAT_IMAGE) { |
| 294 | // Draw vertical lines | 302 | // Draw vertical lines |
| 295 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | ||
| 296 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; dot++) { | 303 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { |
| 304 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; ++dot) { | ||
| 297 | painter.drawLine(QPointF((double) -div - 0.02, (double) -dot / 5), QPointF((double) -div + 0.02, (double) -dot / 5)); | 305 | painter.drawLine(QPointF((double) -div - 0.02, (double) -dot / 5), QPointF((double) -div + 0.02, (double) -dot / 5)); |
| 298 | painter.drawLine(QPointF((double) -div - 0.02, (double) dot / 5), QPointF((double) -div + 0.02, (double) dot / 5)); | 306 | painter.drawLine(QPointF((double) -div - 0.02, (double) dot / 5), QPointF((double) -div + 0.02, (double) dot / 5)); |
| 299 | painter.drawLine(QPointF((double) div - 0.02, (double) -dot / 5), QPointF((double) div + 0.02, (double) -dot / 5)); | 307 | painter.drawLine(QPointF((double) div - 0.02, (double) -dot / 5), QPointF((double) div + 0.02, (double) -dot / 5)); |
| @@ -301,8 +309,8 @@ bool Exporter::doExport() { | @@ -301,8 +309,8 @@ bool Exporter::doExport() { | ||
| 301 | } | 309 | } |
| 302 | } | 310 | } |
| 303 | // Draw horizontal lines | 311 | // Draw horizontal lines |
| 304 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | ||
| 305 | - for(int dot = 1; dot < DIVS_TIME / 2 * 5; dot++) { | 312 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { |
| 313 | + for(int dot = 1; dot < DIVS_TIME / 2 * 5; ++dot) { | ||
| 306 | painter.drawLine(QPointF((double) -dot / 5, (double) -div - 0.02), QPointF((double) -dot / 5, (double) -div + 0.02)); | 314 | painter.drawLine(QPointF((double) -dot / 5, (double) -div - 0.02), QPointF((double) -dot / 5, (double) -div + 0.02)); |
| 307 | painter.drawLine(QPointF((double) dot / 5, (double) -div - 0.02), QPointF((double) dot / 5, (double) -div + 0.02)); | 315 | painter.drawLine(QPointF((double) dot / 5, (double) -div - 0.02), QPointF((double) dot / 5, (double) -div + 0.02)); |
| 308 | painter.drawLine(QPointF((double) -dot / 5, (double) div - 0.02), QPointF((double) -dot / 5, (double) div + 0.02)); | 316 | painter.drawLine(QPointF((double) -dot / 5, (double) div - 0.02), QPointF((double) -dot / 5, (double) div + 0.02)); |
| @@ -312,8 +320,8 @@ bool Exporter::doExport() { | @@ -312,8 +320,8 @@ bool Exporter::doExport() { | ||
| 312 | } | 320 | } |
| 313 | else { | 321 | else { |
| 314 | // Draw vertical lines | 322 | // Draw vertical lines |
| 315 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | ||
| 316 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; dot++) { | 323 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { |
| 324 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; ++dot) { | ||
| 317 | painter.drawPoint(QPointF(-div, (double) -dot / 5)); | 325 | painter.drawPoint(QPointF(-div, (double) -dot / 5)); |
| 318 | painter.drawPoint(QPointF(-div, (double) dot / 5)); | 326 | painter.drawPoint(QPointF(-div, (double) dot / 5)); |
| 319 | painter.drawPoint(QPointF(div, (double) -dot / 5)); | 327 | painter.drawPoint(QPointF(div, (double) -dot / 5)); |
| @@ -321,8 +329,8 @@ bool Exporter::doExport() { | @@ -321,8 +329,8 @@ bool Exporter::doExport() { | ||
| 321 | } | 329 | } |
| 322 | } | 330 | } |
| 323 | // Draw horizontal lines | 331 | // Draw horizontal lines |
| 324 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | ||
| 325 | - for(int dot = 1; dot < DIVS_TIME / 2 * 5; dot++) { | 332 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { |
| 333 | + for(int dot = 1; dot < DIVS_TIME / 2 * 5; ++dot) { | ||
| 326 | if(dot % 5 == 0) | 334 | if(dot % 5 == 0) |
| 327 | continue; // Already done by vertical lines | 335 | continue; // Already done by vertical lines |
| 328 | painter.drawPoint(QPointF((double) -dot / 5, -div)); | 336 | painter.drawPoint(QPointF((double) -dot / 5, -div)); |
| @@ -354,7 +362,9 @@ bool Exporter::doExport() { | @@ -354,7 +362,9 @@ bool Exporter::doExport() { | ||
| 354 | painter.end(); | 362 | painter.end(); |
| 355 | 363 | ||
| 356 | if(this->format == EXPORT_FORMAT_IMAGE) | 364 | if(this->format == EXPORT_FORMAT_IMAGE) |
| 357 | - ((QPixmap *) paintDevice)->save(this->filename); | 365 | + static_cast<QPixmap *>(paintDevice)->save(this->filename); |
| 366 | + | ||
| 367 | + delete paintDevice; | ||
| 358 | 368 | ||
| 359 | return true; | 369 | return true; |
| 360 | } | 370 | } |
| @@ -365,14 +375,14 @@ bool Exporter::doExport() { | @@ -365,14 +375,14 @@ bool Exporter::doExport() { | ||
| 365 | 375 | ||
| 366 | QTextStream csvStream(&csvFile); | 376 | QTextStream csvStream(&csvFile); |
| 367 | 377 | ||
| 368 | - for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | 378 | + for(int channel = 0 ; channel < this->settings->scope.voltage.count(); ++channel) { |
| 369 | if(this->dataAnalyzer->data(channel)) { | 379 | if(this->dataAnalyzer->data(channel)) { |
| 370 | if(this->settings->scope.voltage[channel].used) { | 380 | if(this->settings->scope.voltage[channel].used) { |
| 371 | // Start with channel name and the sample interval | 381 | // Start with channel name and the sample interval |
| 372 | csvStream << "\"" << this->settings->scope.voltage[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.voltage.interval; | 382 | csvStream << "\"" << this->settings->scope.voltage[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.voltage.interval; |
| 373 | 383 | ||
| 374 | // And now all sample values in volts | 384 | // And now all sample values in volts |
| 375 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) | 385 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) |
| 376 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.voltage.sample[position]; | 386 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.voltage.sample[position]; |
| 377 | 387 | ||
| 378 | // Finally a newline | 388 | // Finally a newline |
| @@ -384,7 +394,7 @@ bool Exporter::doExport() { | @@ -384,7 +394,7 @@ bool Exporter::doExport() { | ||
| 384 | csvStream << "\"" << this->settings->scope.spectrum[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.spectrum.interval; | 394 | csvStream << "\"" << this->settings->scope.spectrum[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.spectrum.interval; |
| 385 | 395 | ||
| 386 | // And now all magnitudes in dB | 396 | // And now all magnitudes in dB |
| 387 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) | 397 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; ++position) |
| 388 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.spectrum.sample[position]; | 398 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.spectrum.sample[position]; |
| 389 | 399 | ||
| 390 | // Finally a newline | 400 | // Finally a newline |
openhantek/src/glgenerator.cpp
| @@ -104,10 +104,10 @@ void GlGenerator::generateGraphs() { | @@ -104,10 +104,10 @@ void GlGenerator::generateGraphs() { | ||
| 104 | return; | 104 | return; |
| 105 | 105 | ||
| 106 | // Adapt the number of graphs | 106 | // Adapt the number of graphs |
| 107 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | ||
| 108 | - for(int channel = this->vaChannel[mode].count(); channel < this->settings->scope.voltage.count(); channel++) | 107 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 108 | + for(int channel = this->vaChannel[mode].count(); channel < this->settings->scope.voltage.count(); ++channel) | ||
| 109 | this->vaChannel[mode].append(QList<GlArray *>()); | 109 | this->vaChannel[mode].append(QList<GlArray *>()); |
| 110 | - for(int channel = this->settings->scope.voltage.count(); channel < this->vaChannel[mode].count(); channel++) | 110 | + for(int channel = this->settings->scope.voltage.count(); channel < this->vaChannel[mode].count(); ++channel) |
| 111 | this->vaChannel[mode].removeLast(); | 111 | this->vaChannel[mode].removeLast(); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| @@ -118,13 +118,13 @@ void GlGenerator::generateGraphs() { | @@ -118,13 +118,13 @@ void GlGenerator::generateGraphs() { | ||
| 118 | this->digitalPhosphorDepth = 1; | 118 | this->digitalPhosphorDepth = 1; |
| 119 | 119 | ||
| 120 | // Handle all digital phosphor related list manipulations | 120 | // Handle all digital phosphor related list manipulations |
| 121 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | ||
| 122 | - for(int channel = 0; channel < this->vaChannel[mode].count(); channel++) { | 121 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 122 | + for(int channel = 0; channel < this->vaChannel[mode].count(); ++channel) { | ||
| 123 | // Resize lists for vector array if the digital phosphor depth has changed | 123 | // Resize lists for vector array if the digital phosphor depth has changed |
| 124 | if(this->vaChannel[mode][channel].count() != this->digitalPhosphorDepth) | 124 | if(this->vaChannel[mode][channel].count() != this->digitalPhosphorDepth) |
| 125 | - for(int index = this->vaChannel[mode][channel].count(); index < this->digitalPhosphorDepth; index++) | 125 | + for(int index = this->vaChannel[mode][channel].count(); index < this->digitalPhosphorDepth; ++index) |
| 126 | this->vaChannel[mode][channel].append(new GlArray()); | 126 | this->vaChannel[mode][channel].append(new GlArray()); |
| 127 | - for(int index = this->digitalPhosphorDepth; index < this->vaChannel[mode][channel].count(); index++) { | 127 | + for(int index = this->digitalPhosphorDepth; index < this->vaChannel[mode][channel].count(); ++index) { |
| 128 | delete this->vaChannel[mode][channel].last(); | 128 | delete this->vaChannel[mode][channel].last(); |
| 129 | this->vaChannel[mode][channel].removeLast(); | 129 | this->vaChannel[mode][channel].removeLast(); |
| 130 | } | 130 | } |
| @@ -139,13 +139,13 @@ void GlGenerator::generateGraphs() { | @@ -139,13 +139,13 @@ void GlGenerator::generateGraphs() { | ||
| 139 | switch(this->settings->scope.horizontal.format) { | 139 | switch(this->settings->scope.horizontal.format) { |
| 140 | case Dso::GRAPHFORMAT_TY: | 140 | case Dso::GRAPHFORMAT_TY: |
| 141 | // Add graphs for channels | 141 | // Add graphs for channels |
| 142 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | ||
| 143 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 142 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 143 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | ||
| 144 | // Check if this channel is used and available at the data analyzer | 144 | // Check if this channel is used and available at the data analyzer |
| 145 | if(((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample) { | 145 | if(((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample) { |
| 146 | // Check if the sample count has changed | 146 | // Check if the sample count has changed |
| 147 | unsigned int neededSize = ((mode == Dso::CHANNELMODE_VOLTAGE) ? this->dataAnalyzer->data(channel)->samples.voltage.count : this->dataAnalyzer->data(channel)->samples.spectrum.count) * 2; | 147 | unsigned int neededSize = ((mode == Dso::CHANNELMODE_VOLTAGE) ? this->dataAnalyzer->data(channel)->samples.voltage.count : this->dataAnalyzer->data(channel)->samples.spectrum.count) * 2; |
| 148 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) { | 148 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) { |
| 149 | if(this->vaChannel[mode][channel][index]->getSize() != neededSize) | 149 | if(this->vaChannel[mode][channel][index]->getSize() != neededSize) |
| 150 | this->vaChannel[mode][channel][index]->setSize(0); | 150 | this->vaChannel[mode][channel][index]->setSize(0); |
| 151 | } | 151 | } |
| @@ -166,13 +166,13 @@ void GlGenerator::generateGraphs() { | @@ -166,13 +166,13 @@ void GlGenerator::generateGraphs() { | ||
| 166 | // Fill vector array | 166 | // Fill vector array |
| 167 | unsigned int arrayPosition = 0; | 167 | unsigned int arrayPosition = 0; |
| 168 | if(mode == Dso::CHANNELMODE_VOLTAGE) { | 168 | if(mode == Dso::CHANNELMODE_VOLTAGE) { |
| 169 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) { | 169 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) { |
| 170 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; | 170 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; |
| 171 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset; | 171 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset; |
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | else { | 174 | else { |
| 175 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) { | 175 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; ++position) { |
| 176 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; | 176 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; |
| 177 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset; | 177 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset; |
| 178 | } | 178 | } |
| @@ -180,7 +180,7 @@ void GlGenerator::generateGraphs() { | @@ -180,7 +180,7 @@ void GlGenerator::generateGraphs() { | ||
| 180 | } | 180 | } |
| 181 | else { | 181 | else { |
| 182 | // Delete all vector arrays | 182 | // Delete all vector arrays |
| 183 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | 183 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) |
| 184 | this->vaChannel[mode][channel][index]->setSize(0); | 184 | this->vaChannel[mode][channel][index]->setSize(0); |
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| @@ -188,12 +188,12 @@ void GlGenerator::generateGraphs() { | @@ -188,12 +188,12 @@ void GlGenerator::generateGraphs() { | ||
| 188 | break; | 188 | break; |
| 189 | 189 | ||
| 190 | case Dso::GRAPHFORMAT_XY: | 190 | case Dso::GRAPHFORMAT_XY: |
| 191 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel ++) { | 191 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { |
| 192 | // For even channel numbers check if this channel is used and this and the following channel are available at the data analyzer | 192 | // For even channel numbers check if this channel is used and this and the following channel are available at the data analyzer |
| 193 | if(channel % 2 == 0 && channel + 1 < this->settings->scope.voltage.count() && this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample && this->dataAnalyzer->data(channel + 1) && this->dataAnalyzer->data(channel + 1)->samples.voltage.sample) { | 193 | if(channel % 2 == 0 && channel + 1 < this->settings->scope.voltage.count() && this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample && this->dataAnalyzer->data(channel + 1) && this->dataAnalyzer->data(channel + 1)->samples.voltage.sample) { |
| 194 | // Check if the sample count has changed | 194 | // Check if the sample count has changed |
| 195 | unsigned int neededSize = qMin(this->dataAnalyzer->data(channel)->samples.voltage.count, this->dataAnalyzer->data(channel + 1)->samples.voltage.count) * 2; | 195 | unsigned int neededSize = qMin(this->dataAnalyzer->data(channel)->samples.voltage.count, this->dataAnalyzer->data(channel + 1)->samples.voltage.count) * 2; |
| 196 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) { | 196 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) { |
| 197 | if(this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->getSize() != neededSize) | 197 | if(this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->getSize() != neededSize) |
| 198 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); | 198 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); |
| 199 | } | 199 | } |
| @@ -208,19 +208,19 @@ void GlGenerator::generateGraphs() { | @@ -208,19 +208,19 @@ void GlGenerator::generateGraphs() { | ||
| 208 | unsigned int arrayPosition = 0; | 208 | unsigned int arrayPosition = 0; |
| 209 | unsigned int xChannel = channel; | 209 | unsigned int xChannel = channel; |
| 210 | unsigned int yChannel = channel + 1; | 210 | unsigned int yChannel = channel + 1; |
| 211 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) { | 211 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) { |
| 212 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(xChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[xChannel].gain + this->settings->scope.voltage[xChannel].offset; | 212 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(xChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[xChannel].gain + this->settings->scope.voltage[xChannel].offset; |
| 213 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(yChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[yChannel].gain + this->settings->scope.voltage[yChannel].offset; | 213 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(yChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[yChannel].gain + this->settings->scope.voltage[yChannel].offset; |
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | else { | 216 | else { |
| 217 | // Delete all vector arrays | 217 | // Delete all vector arrays |
| 218 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | 218 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) |
| 219 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); | 219 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | // Delete all spectrum graphs | 222 | // Delete all spectrum graphs |
| 223 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | 223 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) |
| 224 | this->vaChannel[Dso::CHANNELMODE_SPECTRUM][channel][index]->setSize(0); | 224 | this->vaChannel[Dso::CHANNELMODE_SPECTRUM][channel][index]->setSize(0); |
| 225 | } | 225 | } |
| 226 | break; | 226 | break; |
| @@ -240,8 +240,8 @@ void GlGenerator::generateGrid() { | @@ -240,8 +240,8 @@ void GlGenerator::generateGrid() { | ||
| 240 | this->vaGrid[0].setSize(((DIVS_TIME * DIVS_SUB - 2) * (DIVS_VOLTAGE - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2) * (DIVS_TIME - 2) - ((DIVS_TIME - 2) * (DIVS_VOLTAGE - 2))) * 2); | 240 | this->vaGrid[0].setSize(((DIVS_TIME * DIVS_SUB - 2) * (DIVS_VOLTAGE - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2) * (DIVS_TIME - 2) - ((DIVS_TIME - 2) * (DIVS_VOLTAGE - 2))) * 2); |
| 241 | int pointIndex = 0; | 241 | int pointIndex = 0; |
| 242 | // Draw vertical lines | 242 | // Draw vertical lines |
| 243 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | ||
| 244 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * DIVS_SUB; dot++) { | 243 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { |
| 244 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * DIVS_SUB; ++dot) { | ||
| 245 | float dotPosition = (float) dot / DIVS_SUB; | 245 | float dotPosition = (float) dot / DIVS_SUB; |
| 246 | this->vaGrid[0].data[pointIndex++] = -div; | 246 | this->vaGrid[0].data[pointIndex++] = -div; |
| 247 | this->vaGrid[0].data[pointIndex++] = -dotPosition; | 247 | this->vaGrid[0].data[pointIndex++] = -dotPosition; |
| @@ -254,8 +254,8 @@ void GlGenerator::generateGrid() { | @@ -254,8 +254,8 @@ void GlGenerator::generateGrid() { | ||
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| 256 | // Draw horizontal lines | 256 | // Draw horizontal lines |
| 257 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | ||
| 258 | - for(int dot = 1; dot < DIVS_TIME / 2 * DIVS_SUB; dot++) { | 257 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { |
| 258 | + for(int dot = 1; dot < DIVS_TIME / 2 * DIVS_SUB; ++dot) { | ||
| 259 | if(dot % DIVS_SUB == 0) | 259 | if(dot % DIVS_SUB == 0) |
| 260 | continue; // Already done by vertical lines | 260 | continue; // Already done by vertical lines |
| 261 | float dotPosition = (float) dot / DIVS_SUB; | 261 | float dotPosition = (float) dot / DIVS_SUB; |
| @@ -284,7 +284,7 @@ void GlGenerator::generateGrid() { | @@ -284,7 +284,7 @@ void GlGenerator::generateGrid() { | ||
| 284 | this->vaGrid[1].data[pointIndex++] = 0; | 284 | this->vaGrid[1].data[pointIndex++] = 0; |
| 285 | this->vaGrid[1].data[pointIndex++] = DIVS_VOLTAGE / 2; | 285 | this->vaGrid[1].data[pointIndex++] = DIVS_VOLTAGE / 2; |
| 286 | // Subdiv lines on horizontal axis | 286 | // Subdiv lines on horizontal axis |
| 287 | - for(int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; line++) { | 287 | + for(int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; ++line) { |
| 288 | float linePosition = (float) line / DIVS_SUB; | 288 | float linePosition = (float) line / DIVS_SUB; |
| 289 | this->vaGrid[1].data[pointIndex++] = linePosition; | 289 | this->vaGrid[1].data[pointIndex++] = linePosition; |
| 290 | this->vaGrid[1].data[pointIndex++] = -0.05; | 290 | this->vaGrid[1].data[pointIndex++] = -0.05; |
| @@ -296,7 +296,7 @@ void GlGenerator::generateGrid() { | @@ -296,7 +296,7 @@ void GlGenerator::generateGrid() { | ||
| 296 | this->vaGrid[1].data[pointIndex++] = 0.05; | 296 | this->vaGrid[1].data[pointIndex++] = 0.05; |
| 297 | } | 297 | } |
| 298 | // Subdiv lines on vertical axis | 298 | // Subdiv lines on vertical axis |
| 299 | - for(int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; line++) { | 299 | + for(int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; ++line) { |
| 300 | float linePosition = (float) line / DIVS_SUB; | 300 | float linePosition = (float) line / DIVS_SUB; |
| 301 | this->vaGrid[1].data[pointIndex++] = -0.05; | 301 | this->vaGrid[1].data[pointIndex++] = -0.05; |
| 302 | this->vaGrid[1].data[pointIndex++] = linePosition; | 302 | this->vaGrid[1].data[pointIndex++] = linePosition; |
openhantek/src/glscope.cpp
| @@ -96,14 +96,14 @@ void GlScope::paintGL() { | @@ -96,14 +96,14 @@ void GlScope::paintGL() { | ||
| 96 | double *fadingFactor = new double[this->generator->digitalPhosphorDepth]; | 96 | double *fadingFactor = new double[this->generator->digitalPhosphorDepth]; |
| 97 | fadingFactor[0] = 100; | 97 | fadingFactor[0] = 100; |
| 98 | double fadingRatio = pow(10.0, 2.0 / this->generator->digitalPhosphorDepth); | 98 | double fadingRatio = pow(10.0, 2.0 / this->generator->digitalPhosphorDepth); |
| 99 | - for(int index = 1; index < this->generator->digitalPhosphorDepth; index++) | 99 | + for(int index = 1; index < this->generator->digitalPhosphorDepth; ++index) |
| 100 | fadingFactor[index] = fadingFactor[index - 1] * fadingRatio; | 100 | fadingFactor[index] = fadingFactor[index - 1] * fadingRatio; |
| 101 | 101 | ||
| 102 | switch(this->settings->scope.horizontal.format) { | 102 | switch(this->settings->scope.horizontal.format) { |
| 103 | case Dso::GRAPHFORMAT_TY: | 103 | case Dso::GRAPHFORMAT_TY: |
| 104 | // Real and virtual channels | 104 | // Real and virtual channels |
| 105 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | ||
| 106 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | 105 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 106 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | ||
| 107 | if((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) { | 107 | if((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) { |
| 108 | // Draw graph for all available depths | 108 | // Draw graph for all available depths |
| 109 | for(int index = this->generator->digitalPhosphorDepth - 1; index >= 0; index--) { | 109 | for(int index = this->generator->digitalPhosphorDepth - 1; index >= 0; index--) { |
| @@ -155,7 +155,7 @@ void GlScope::paintGL() { | @@ -155,7 +155,7 @@ void GlScope::paintGL() { | ||
| 155 | glEnable(GL_LINE_STIPPLE); | 155 | glEnable(GL_LINE_STIPPLE); |
| 156 | this->qglColor(this->settings->view.color.screen.markers); | 156 | this->qglColor(this->settings->view.color.screen.markers); |
| 157 | 157 | ||
| 158 | - for(int marker = 0; marker < MARKER_COUNT; marker++) { | 158 | + for(int marker = 0; marker < MARKER_COUNT; ++marker) { |
| 159 | if(!this->vaMarker[marker].data) { | 159 | if(!this->vaMarker[marker].data) { |
| 160 | this->vaMarker[marker].setSize(2 * 2); | 160 | this->vaMarker[marker].setSize(2 * 2); |
| 161 | this->vaMarker[marker].data[1] = - DIVS_VOLTAGE; | 161 | this->vaMarker[marker].data[1] = - DIVS_VOLTAGE; |
openhantek/src/hantek/control.cpp
| @@ -58,21 +58,32 @@ namespace Hantek { | @@ -58,21 +58,32 @@ namespace Hantek { | ||
| 58 | this->specification.samplerate.multi.base = 100e6; | 58 | this->specification.samplerate.multi.base = 100e6; |
| 59 | this->specification.samplerate.multi.max = 100e6; | 59 | this->specification.samplerate.multi.max = 100e6; |
| 60 | 60 | ||
| 61 | - for(unsigned int channel = 0; channel < HANTEK_CHANNELS; channel++) { | ||
| 62 | - for(unsigned int gainId = 0; gainId < 9; gainId++) { | 61 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { |
| 62 | + for(unsigned int gainId = 0; gainId < 9; ++gainId) { | ||
| 63 | this->specification.offsetLimit[channel][gainId][OFFSET_START] = 0x0000; | 63 | this->specification.offsetLimit[channel][gainId][OFFSET_START] = 0x0000; |
| 64 | this->specification.offsetLimit[channel][gainId][OFFSET_END] = 0xffff; | 64 | this->specification.offsetLimit[channel][gainId][OFFSET_END] = 0xffff; |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // Set settings to default values | 68 | // Set settings to default values |
| 69 | - this->settings.recordLengthId = 0; | ||
| 70 | this->settings.samplerate.limits = &(this->specification.samplerate.single); | 69 | this->settings.samplerate.limits = &(this->specification.samplerate.single); |
| 71 | this->settings.samplerate.downsampling = 1; | 70 | this->settings.samplerate.downsampling = 1; |
| 71 | + this->settings.samplerate.current = 0.0; | ||
| 72 | this->settings.trigger.position = 0; | 72 | this->settings.trigger.position = 0; |
| 73 | + this->settings.trigger.point = 0; | ||
| 74 | + this->settings.trigger.mode = Dso::TRIGGERMODE_NORMAL; | ||
| 73 | this->settings.trigger.slope = Dso::SLOPE_POSITIVE; | 75 | this->settings.trigger.slope = Dso::SLOPE_POSITIVE; |
| 74 | this->settings.trigger.special = false; | 76 | this->settings.trigger.special = false; |
| 75 | this->settings.trigger.source = 0; | 77 | this->settings.trigger.source = 0; |
| 78 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { | ||
| 79 | + this->settings.trigger.level[channel] = 0.0; | ||
| 80 | + this->settings.voltage[channel].gain = 0; | ||
| 81 | + this->settings.voltage[channel].offset = 0.0; | ||
| 82 | + this->settings.voltage[channel].offsetReal = 0.0; | ||
| 83 | + this->settings.voltage[channel].used = false; | ||
| 84 | + } | ||
| 85 | + this->settings.recordLengthId = 0; | ||
| 86 | + this->settings.usedChannels = 0; | ||
| 76 | 87 | ||
| 77 | // Special trigger sources | 88 | // Special trigger sources |
| 78 | this->specialTriggerSources << tr("EXT") << tr("EXT/10"); | 89 | this->specialTriggerSources << tr("EXT") << tr("EXT/10"); |
| @@ -89,14 +100,14 @@ namespace Hantek { | @@ -89,14 +100,14 @@ namespace Hantek { | ||
| 89 | this->control[CONTROLINDEX_SETRELAYS] = new ControlSetRelays(); | 100 | this->control[CONTROLINDEX_SETRELAYS] = new ControlSetRelays(); |
| 90 | this->controlCode[CONTROLINDEX_SETRELAYS] = CONTROL_SETRELAYS; | 101 | this->controlCode[CONTROLINDEX_SETRELAYS] = CONTROL_SETRELAYS; |
| 91 | 102 | ||
| 92 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) | 103 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) |
| 93 | this->controlPending[control] = false; | 104 | this->controlPending[control] = false; |
| 94 | 105 | ||
| 95 | // USB device | 106 | // USB device |
| 96 | this->device = new Device(this); | 107 | this->device = new Device(this); |
| 97 | 108 | ||
| 98 | // Sample buffers | 109 | // Sample buffers |
| 99 | - for(unsigned int channel = 0; channel < HANTEK_CHANNELS; channel++) { | 110 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { |
| 100 | this->samples.append(0); | 111 | this->samples.append(0); |
| 101 | this->samplesSize.append(0); | 112 | this->samplesSize.append(0); |
| 102 | } | 113 | } |
| @@ -132,7 +143,7 @@ namespace Hantek { | @@ -132,7 +143,7 @@ namespace Hantek { | ||
| 132 | 143 | ||
| 133 | while(captureState != LIBUSB_ERROR_NO_DEVICE && !this->terminate) { | 144 | while(captureState != LIBUSB_ERROR_NO_DEVICE && !this->terminate) { |
| 134 | // Send all pending bulk commands | 145 | // Send all pending bulk commands |
| 135 | - for(int command = 0; command < BULK_COUNT; command++) { | 146 | + for(int command = 0; command < BULK_COUNT; ++command) { |
| 136 | if(!this->commandPending[command]) | 147 | if(!this->commandPending[command]) |
| 137 | continue; | 148 | continue; |
| 138 | 149 | ||
| @@ -142,7 +153,7 @@ namespace Hantek { | @@ -142,7 +153,7 @@ namespace Hantek { | ||
| 142 | 153 | ||
| 143 | errorCode = this->device->bulkCommand(this->command[command]); | 154 | errorCode = this->device->bulkCommand(this->command[command]); |
| 144 | if(errorCode < 0) { | 155 | if(errorCode < 0) { |
| 145 | - qWarning("Sending bulk command 0x%02x failed: %s", command, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | 156 | + qWarning("Sending bulk command %02x failed: %s", command, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); |
| 146 | 157 | ||
| 147 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { | 158 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { |
| 148 | captureState = LIBUSB_ERROR_NO_DEVICE; | 159 | captureState = LIBUSB_ERROR_NO_DEVICE; |
| @@ -156,17 +167,17 @@ namespace Hantek { | @@ -156,17 +167,17 @@ namespace Hantek { | ||
| 156 | break; | 167 | break; |
| 157 | 168 | ||
| 158 | // Send all pending control commands | 169 | // Send all pending control commands |
| 159 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) { | 170 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) { |
| 160 | if(!this->controlPending[control]) | 171 | if(!this->controlPending[control]) |
| 161 | continue; | 172 | continue; |
| 162 | 173 | ||
| 163 | #ifdef DEBUG | 174 | #ifdef DEBUG |
| 164 | - qDebug("Sending control command 0x%02x:%s", control, Helper::hexDump(this->control[control]->data(), this->control[control]->getSize()).toLocal8Bit().data()); | 175 | + qDebug("Sending control command %02x:%s", this->controlCode[control], Helper::hexDump(this->control[control]->data(), this->control[control]->getSize()).toLocal8Bit().data()); |
| 165 | #endif | 176 | #endif |
| 166 | 177 | ||
| 167 | errorCode = this->device->controlWrite(this->controlCode[control], this->control[control]->data(), this->control[control]->getSize()); | 178 | errorCode = this->device->controlWrite(this->controlCode[control], this->control[control]->data(), this->control[control]->getSize()); |
| 168 | if(errorCode < 0) { | 179 | if(errorCode < 0) { |
| 169 | - qWarning("Sending control command 0x%2x failed: %s", control, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | 180 | + qWarning("Sending control command %2x failed: %s", this->controlCode[control], Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); |
| 170 | 181 | ||
| 171 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { | 182 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { |
| 172 | captureState = LIBUSB_ERROR_NO_DEVICE; | 183 | captureState = LIBUSB_ERROR_NO_DEVICE; |
| @@ -181,7 +192,7 @@ namespace Hantek { | @@ -181,7 +192,7 @@ namespace Hantek { | ||
| 181 | 192 | ||
| 182 | // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled | 193 | // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled |
| 183 | // Not more often than every 10 ms though | 194 | // Not more often than every 10 ms though |
| 184 | - int cycleTime = qMax((unsigned long int) (this->specification.recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), (long unsigned int) 10); | 195 | + int cycleTime = qMax((unsigned long int) (this->specification.recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10lu); |
| 185 | this->msleep(cycleTime); | 196 | this->msleep(cycleTime); |
| 186 | 197 | ||
| 187 | if(!this->sampling) { | 198 | if(!this->sampling) { |
| @@ -225,7 +236,7 @@ namespace Hantek { | @@ -225,7 +236,7 @@ namespace Hantek { | ||
| 225 | 236 | ||
| 226 | case CAPTURE_WAITING: | 237 | case CAPTURE_WAITING: |
| 227 | if(samplingStarted && lastTriggerMode == this->settings.trigger.mode) { | 238 | if(samplingStarted && lastTriggerMode == this->settings.trigger.mode) { |
| 228 | - cycleCounter++; | 239 | + ++cycleCounter; |
| 229 | 240 | ||
| 230 | if(cycleCounter == startCycle) { | 241 | if(cycleCounter == startCycle) { |
| 231 | // Buffer refilled completely since start of sampling, enable the trigger now | 242 | // Buffer refilled completely since start of sampling, enable the trigger now |
| @@ -249,7 +260,7 @@ namespace Hantek { | @@ -249,7 +260,7 @@ namespace Hantek { | ||
| 249 | #endif | 260 | #endif |
| 250 | } | 261 | } |
| 251 | 262 | ||
| 252 | - if(cycleCounter < 50 || cycleCounter < 4000 / cycleTime) | 263 | + if(cycleCounter < 20 || cycleCounter < 4000 / cycleTime) |
| 253 | break; | 264 | break; |
| 254 | } | 265 | } |
| 255 | 266 | ||
| @@ -356,7 +367,7 @@ namespace Hantek { | @@ -356,7 +367,7 @@ namespace Hantek { | ||
| 356 | } | 367 | } |
| 357 | 368 | ||
| 358 | // Clear unused channels | 369 | // Clear unused channels |
| 359 | - for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; channelCounter++) | 370 | + for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; ++channelCounter) |
| 360 | if(channelCounter != channel && this->samples[channelCounter]) { | 371 | if(channelCounter != channel && this->samples[channelCounter]) { |
| 361 | 372 | ||
| 362 | delete this->samples[channelCounter]; | 373 | delete this->samples[channelCounter]; |
| @@ -380,7 +391,7 @@ namespace Hantek { | @@ -380,7 +391,7 @@ namespace Hantek { | ||
| 380 | unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits | 391 | unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits |
| 381 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction | 392 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction |
| 382 | 393 | ||
| 383 | - for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { | 394 | + for(unsigned int realPosition = 0; realPosition < dataCount; ++realPosition, ++bufferPosition) { |
| 384 | if(bufferPosition >= dataCount) | 395 | if(bufferPosition >= dataCount) |
| 385 | bufferPosition %= dataCount; | 396 | bufferPosition %= dataCount; |
| 386 | 397 | ||
| @@ -390,7 +401,7 @@ namespace Hantek { | @@ -390,7 +401,7 @@ namespace Hantek { | ||
| 390 | } | 401 | } |
| 391 | } | 402 | } |
| 392 | else { | 403 | else { |
| 393 | - for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { | 404 | + for(unsigned int realPosition = 0; realPosition < dataCount; ++realPosition, ++bufferPosition) { |
| 394 | if(bufferPosition >= dataCount) | 405 | if(bufferPosition >= dataCount) |
| 395 | bufferPosition %= dataCount; | 406 | bufferPosition %= dataCount; |
| 396 | 407 | ||
| @@ -403,7 +414,7 @@ namespace Hantek { | @@ -403,7 +414,7 @@ namespace Hantek { | ||
| 403 | // Normal mode, channels are using their separate buffers | 414 | // Normal mode, channels are using their separate buffers |
| 404 | unsigned int channelDataCount = dataCount / HANTEK_CHANNELS; | 415 | unsigned int channelDataCount = dataCount / HANTEK_CHANNELS; |
| 405 | 416 | ||
| 406 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) { | 417 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) { |
| 407 | if(this->settings.voltage[channel].used) { | 418 | if(this->settings.voltage[channel].used) { |
| 408 | // Reallocate memory for samples if the sample count has changed | 419 | // Reallocate memory for samples if the sample count has changed |
| 409 | if(!this->samples[channel] || this->samplesSize[channel] != channelDataCount) { | 420 | if(!this->samples[channel] || this->samplesSize[channel] != channelDataCount) { |
| @@ -421,7 +432,7 @@ namespace Hantek { | @@ -421,7 +432,7 @@ namespace Hantek { | ||
| 421 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction | 432 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction |
| 422 | unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction | 433 | unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction |
| 423 | 434 | ||
| 424 | - for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { | 435 | + for(unsigned int realPosition = 0; realPosition < channelDataCount; ++realPosition, bufferPosition += 2) { |
| 425 | if(bufferPosition >= dataCount) | 436 | if(bufferPosition >= dataCount) |
| 426 | bufferPosition %= dataCount; | 437 | bufferPosition %= dataCount; |
| 427 | 438 | ||
| @@ -429,7 +440,7 @@ namespace Hantek { | @@ -429,7 +440,7 @@ namespace Hantek { | ||
| 429 | } | 440 | } |
| 430 | } | 441 | } |
| 431 | else { | 442 | else { |
| 432 | - for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { | 443 | + for(unsigned int realPosition = 0; realPosition < channelDataCount; ++realPosition, bufferPosition += 2) { |
| 433 | if(bufferPosition >= dataCount) | 444 | if(bufferPosition >= dataCount) |
| 434 | bufferPosition %= dataCount; | 445 | bufferPosition %= dataCount; |
| 435 | 446 | ||
| @@ -459,7 +470,7 @@ namespace Hantek { | @@ -459,7 +470,7 @@ namespace Hantek { | ||
| 459 | unsigned long int Control::updateRecordLength(unsigned long int size) { | 470 | unsigned long int Control::updateRecordLength(unsigned long int size) { |
| 460 | // Get the record length supporting the highest samplerate while meeting the requirement | 471 | // Get the record length supporting the highest samplerate while meeting the requirement |
| 461 | int bestSizeId = -1; | 472 | int bestSizeId = -1; |
| 462 | - for(int sizeId = 0; sizeId < this->specification.recordLengths.count(); sizeId++) { | 473 | + for(int sizeId = 0; sizeId < this->specification.recordLengths.count(); ++sizeId) { |
| 463 | if(this->specification.recordLengths[sizeId] >= size) { | 474 | if(this->specification.recordLengths[sizeId] >= size) { |
| 464 | // We meet the size-requirement, check if we provide the highest possible samplerate | 475 | // We meet the size-requirement, check if we provide the highest possible samplerate |
| 465 | if(bestSizeId == -1 || this->specification.recordLengths[bestSizeId] < size || this->specification.bufferDividers[sizeId] < this->specification.bufferDividers[bestSizeId]) | 476 | if(bestSizeId == -1 || this->specification.recordLengths[bestSizeId] < size || this->specification.bufferDividers[sizeId] < this->specification.bufferDividers[bestSizeId]) |
| @@ -475,7 +486,7 @@ namespace Hantek { | @@ -475,7 +486,7 @@ namespace Hantek { | ||
| 475 | switch(this->specification.command.bulk.setRecordLength) { | 486 | switch(this->specification.command.bulk.setRecordLength) { |
| 476 | case BULK_SETTRIGGERANDSAMPLERATE: | 487 | case BULK_SETTRIGGERANDSAMPLERATE: |
| 477 | // SetTriggerAndSamplerate bulk command for record length | 488 | // SetTriggerAndSamplerate bulk command for record length |
| 478 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(bestSizeId); | 489 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(bestSizeId); |
| 479 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 490 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 480 | 491 | ||
| 481 | break; | 492 | break; |
| @@ -483,8 +494,8 @@ namespace Hantek { | @@ -483,8 +494,8 @@ namespace Hantek { | ||
| 483 | case BULK_DSETBUFFER: | 494 | case BULK_DSETBUFFER: |
| 484 | if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { | 495 | if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { |
| 485 | // Pointers to needed commands | 496 | // Pointers to needed commands |
| 486 | - BulkSetRecordLength2250 *commandSetRecordLength2250 = (BulkSetRecordLength2250 *) this->command[BULK_DSETBUFFER]; | ||
| 487 | - BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | 497 | + BulkSetRecordLength2250 *commandSetRecordLength2250 = static_cast<BulkSetRecordLength2250 *>(this->command[BULK_DSETBUFFER]); |
| 498 | + BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]); | ||
| 488 | 499 | ||
| 489 | commandSetRecordLength2250->setRecordLength(bestSizeId); | 500 | commandSetRecordLength2250->setRecordLength(bestSizeId); |
| 490 | commandSetBuffer2250->setUsedPre(FTRIGGERPOSITION_ON); | 501 | commandSetBuffer2250->setUsedPre(FTRIGGERPOSITION_ON); |
| @@ -497,7 +508,7 @@ namespace Hantek { | @@ -497,7 +508,7 @@ namespace Hantek { | ||
| 497 | } | 508 | } |
| 498 | else { | 509 | else { |
| 499 | // SetBuffer5200 bulk command for record length | 510 | // SetBuffer5200 bulk command for record length |
| 500 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | 511 | + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]); |
| 501 | commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); | 512 | commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); |
| 502 | commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); | 513 | commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); |
| 503 | commandSetBuffer5200->setRecordLength(bestSizeId); | 514 | commandSetBuffer5200->setRecordLength(bestSizeId); |
| @@ -617,14 +628,14 @@ namespace Hantek { | @@ -617,14 +628,14 @@ namespace Hantek { | ||
| 617 | if(unsupported) | 628 | if(unsupported) |
| 618 | qWarning("Warning: This Hantek DSO model isn't supported officially, so it may not be working as expected. Reports about your experiences are very welcome though (Please open a feature request in the tracker at https://sf.net/projects/openhantek/ or email me directly to oliver.haag@gmail.com). If it's working perfectly I can remove this warning, if not it should be possible to get it working with your help soon."); | 629 | qWarning("Warning: This Hantek DSO model isn't supported officially, so it may not be working as expected. Reports about your experiences are very welcome though (Please open a feature request in the tracker at https://sf.net/projects/openhantek/ or email me directly to oliver.haag@gmail.com). If it's working perfectly I can remove this warning, if not it should be possible to get it working with your help soon."); |
| 619 | 630 | ||
| 620 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) | 631 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) |
| 621 | this->controlPending[control] = true; | 632 | this->controlPending[control] = true; |
| 622 | 633 | ||
| 623 | // Maximum possible samplerate for a single channel and dividers for record lengths | 634 | // Maximum possible samplerate for a single channel and dividers for record lengths |
| 624 | this->specification.bufferDividers.clear(); | 635 | this->specification.bufferDividers.clear(); |
| 625 | this->specification.recordLengths.clear(); | 636 | this->specification.recordLengths.clear(); |
| 626 | this->specification.gainSteps.clear(); | 637 | this->specification.gainSteps.clear(); |
| 627 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 638 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) |
| 628 | this->specification.voltageLimit[channel].clear(); | 639 | this->specification.voltageLimit[channel].clear(); |
| 629 | 640 | ||
| 630 | switch(this->device->getModel()) { | 641 | switch(this->device->getModel()) { |
| @@ -639,7 +650,7 @@ namespace Hantek { | @@ -639,7 +650,7 @@ namespace Hantek { | ||
| 639 | this->specification.gainSteps | 650 | this->specification.gainSteps |
| 640 | << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; | 651 | << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; |
| 641 | /// \todo Use calibration data to get the DSO-5200(A) sample ranges | 652 | /// \todo Use calibration data to get the DSO-5200(A) sample ranges |
| 642 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 653 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) |
| 643 | this->specification.voltageLimit[channel] | 654 | this->specification.voltageLimit[channel] |
| 644 | << 368 << 454 << 908 << 368 << 454 << 908 << 368 << 454 << 908; | 655 | << 368 << 454 << 908 << 368 << 454 << 908 << 368 << 454 << 908; |
| 645 | this->specification.gainIndex | 656 | this->specification.gainIndex |
| @@ -656,7 +667,7 @@ namespace Hantek { | @@ -656,7 +667,7 @@ namespace Hantek { | ||
| 656 | this->specification.recordLengths << ULONG_MAX << 10240 << 524288; | 667 | this->specification.recordLengths << ULONG_MAX << 10240 << 524288; |
| 657 | this->specification.gainSteps | 668 | this->specification.gainSteps |
| 658 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | 669 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 659 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 670 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) |
| 660 | this->specification.voltageLimit[channel] | 671 | this->specification.voltageLimit[channel] |
| 661 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 672 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 662 | this->specification.gainIndex | 673 | this->specification.gainIndex |
| @@ -673,7 +684,7 @@ namespace Hantek { | @@ -673,7 +684,7 @@ namespace Hantek { | ||
| 673 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; | 684 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 674 | this->specification.gainSteps | 685 | this->specification.gainSteps |
| 675 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | 686 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 676 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 687 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) |
| 677 | this->specification.voltageLimit[channel] | 688 | this->specification.voltageLimit[channel] |
| 678 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 689 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 679 | this->specification.gainIndex | 690 | this->specification.gainIndex |
| @@ -690,7 +701,7 @@ namespace Hantek { | @@ -690,7 +701,7 @@ namespace Hantek { | ||
| 690 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; | 701 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 691 | this->specification.gainSteps | 702 | this->specification.gainSteps |
| 692 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; | 703 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 693 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | 704 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) |
| 694 | this->specification.voltageLimit[channel] | 705 | this->specification.voltageLimit[channel] |
| 695 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; | 706 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 696 | this->specification.gainIndex | 707 | this->specification.gainIndex |
| @@ -779,7 +790,7 @@ namespace Hantek { | @@ -779,7 +790,7 @@ namespace Hantek { | ||
| 779 | switch(this->specification.command.bulk.setSamplerate) { | 790 | switch(this->specification.command.bulk.setSamplerate) { |
| 780 | case BULK_SETTRIGGERANDSAMPLERATE: { | 791 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 781 | // Pointers to needed commands | 792 | // Pointers to needed commands |
| 782 | - BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE]; | 793 | + BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE]); |
| 783 | 794 | ||
| 784 | // Store samplerate fast value | 795 | // Store samplerate fast value |
| 785 | commandSetTriggerAndSamplerate->setSamplerateFast(valueFast); | 796 | commandSetTriggerAndSamplerate->setSamplerateFast(valueFast); |
| @@ -794,8 +805,8 @@ namespace Hantek { | @@ -794,8 +805,8 @@ namespace Hantek { | ||
| 794 | } | 805 | } |
| 795 | case BULK_CSETTRIGGERORSAMPLERATE: { | 806 | case BULK_CSETTRIGGERORSAMPLERATE: { |
| 796 | // Pointers to needed commands | 807 | // Pointers to needed commands |
| 797 | - BulkSetSamplerate5200 *commandSetSamplerate5200 = (BulkSetSamplerate5200 *) this->command[BULK_CSETTRIGGERORSAMPLERATE]; | ||
| 798 | - BulkSetTrigger5200 *commandSetTrigger5200 = (BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | 808 | + BulkSetSamplerate5200 *commandSetSamplerate5200 = static_cast<BulkSetSamplerate5200 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE]); |
| 809 | + BulkSetTrigger5200 *commandSetTrigger5200 = static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); | ||
| 799 | 810 | ||
| 800 | // Store samplerate fast value | 811 | // Store samplerate fast value |
| 801 | commandSetSamplerate5200->setSamplerateFast(4 - valueFast); | 812 | commandSetSamplerate5200->setSamplerateFast(4 - valueFast); |
| @@ -811,7 +822,7 @@ namespace Hantek { | @@ -811,7 +822,7 @@ namespace Hantek { | ||
| 811 | } | 822 | } |
| 812 | case BULK_ESETTRIGGERORSAMPLERATE: { | 823 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 813 | // Pointers to needed commands | 824 | // Pointers to needed commands |
| 814 | - BulkSetSamplerate2250 *commandSetSamplerate2250 = (BulkSetSamplerate2250 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | 825 | + BulkSetSamplerate2250 *commandSetSamplerate2250 = static_cast<BulkSetSamplerate2250 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); |
| 815 | 826 | ||
| 816 | // Store samplerate fast value | 827 | // Store samplerate fast value |
| 817 | commandSetSamplerate2250->setSamplerateFast(4 - valueFast); | 828 | commandSetSamplerate2250->setSamplerateFast(4 - valueFast); |
| @@ -848,7 +859,7 @@ namespace Hantek { | @@ -848,7 +859,7 @@ namespace Hantek { | ||
| 848 | switch(this->specification.command.bulk.setFilter) { | 859 | switch(this->specification.command.bulk.setFilter) { |
| 849 | case BULK_SETFILTER: { | 860 | case BULK_SETFILTER: { |
| 850 | // SetFilter bulk command for channel filter (used has to be inverted!) | 861 | // SetFilter bulk command for channel filter (used has to be inverted!) |
| 851 | - BulkSetFilter *commandSetFilter = (BulkSetFilter *) this->command[BULK_SETFILTER]; | 862 | + BulkSetFilter *commandSetFilter = static_cast<BulkSetFilter *>(this->command[BULK_SETFILTER]); |
| 852 | commandSetFilter->setChannel(channel, !used); | 863 | commandSetFilter->setChannel(channel, !used); |
| 853 | this->commandPending[BULK_SETFILTER] = true; | 864 | this->commandPending[BULK_SETFILTER] = true; |
| 854 | 865 | ||
| @@ -856,7 +867,7 @@ namespace Hantek { | @@ -856,7 +867,7 @@ namespace Hantek { | ||
| 856 | } | 867 | } |
| 857 | case BULK_BSETFILTER: { | 868 | case BULK_BSETFILTER: { |
| 858 | // SetFilter2250 bulk command for channel filter (used has to be inverted!) | 869 | // SetFilter2250 bulk command for channel filter (used has to be inverted!) |
| 859 | - BulkSetFilter2250 *commandSetFilter2250 = (BulkSetFilter2250 *) this->command[BULK_BSETFILTER]; | 870 | + BulkSetFilter2250 *commandSetFilter2250 = static_cast<BulkSetFilter2250 *>(this->command[BULK_BSETFILTER]); |
| 860 | commandSetFilter2250->setChannel(channel, !used); | 871 | commandSetFilter2250->setChannel(channel, !used); |
| 861 | this->commandPending[BULK_BSETFILTER] = true; | 872 | this->commandPending[BULK_BSETFILTER] = true; |
| 862 | 873 | ||
| @@ -889,13 +900,13 @@ namespace Hantek { | @@ -889,13 +900,13 @@ namespace Hantek { | ||
| 889 | switch(this->specification.command.bulk.setTrigger) { | 900 | switch(this->specification.command.bulk.setTrigger) { |
| 890 | case BULK_SETTRIGGERANDSAMPLERATE: { | 901 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 891 | // SetTriggerAndSamplerate bulk command for trigger source | 902 | // SetTriggerAndSamplerate bulk command for trigger source |
| 892 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); | 903 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); |
| 893 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 904 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 894 | break; | 905 | break; |
| 895 | } | 906 | } |
| 896 | case BULK_ESETTRIGGERORSAMPLERATE: { | 907 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 897 | // SetTrigger5200s bulk command for trigger source | 908 | // SetTrigger5200s bulk command for trigger source |
| 898 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels(usedChannels); | 909 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels(usedChannels); |
| 899 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | 910 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 900 | break; | 911 | break; |
| 901 | } | 912 | } |
| @@ -919,7 +930,7 @@ namespace Hantek { | @@ -919,7 +930,7 @@ namespace Hantek { | ||
| 919 | return Dso::ERROR_PARAMETER; | 930 | return Dso::ERROR_PARAMETER; |
| 920 | 931 | ||
| 921 | // SetRelays control command for coupling relays | 932 | // SetRelays control command for coupling relays |
| 922 | - ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); | 933 | + static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); |
| 923 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; | 934 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| 924 | 935 | ||
| 925 | return Dso::ERROR_NONE; | 936 | return Dso::ERROR_NONE; |
| @@ -938,16 +949,16 @@ namespace Hantek { | @@ -938,16 +949,16 @@ namespace Hantek { | ||
| 938 | 949 | ||
| 939 | // Find lowest gain voltage thats at least as high as the requested | 950 | // Find lowest gain voltage thats at least as high as the requested |
| 940 | int gainId; | 951 | int gainId; |
| 941 | - for(gainId = 0; gainId < this->specification.gainSteps.count() - 1; gainId++) | 952 | + for(gainId = 0; gainId < this->specification.gainSteps.count() - 1; ++gainId) |
| 942 | if(this->specification.gainSteps[gainId] >= gain) | 953 | if(this->specification.gainSteps[gainId] >= gain) |
| 943 | break; | 954 | break; |
| 944 | 955 | ||
| 945 | // SetGain bulk command for gain | 956 | // SetGain bulk command for gain |
| 946 | - ((BulkSetGain *) this->command[BULK_SETGAIN])->setGain(channel, this->specification.gainIndex[gainId]); | 957 | + static_cast<BulkSetGain *>(this->command[BULK_SETGAIN])->setGain(channel, this->specification.gainIndex[gainId]); |
| 947 | this->commandPending[BULK_SETGAIN] = true; | 958 | this->commandPending[BULK_SETGAIN] = true; |
| 948 | 959 | ||
| 949 | // SetRelays control command for gain relays | 960 | // SetRelays control command for gain relays |
| 950 | - ControlSetRelays *controlSetRelays = (ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS]; | 961 | + ControlSetRelays *controlSetRelays = static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS]); |
| 951 | controlSetRelays->setBelow1V(channel, gainId < 3); | 962 | controlSetRelays->setBelow1V(channel, gainId < 3); |
| 952 | controlSetRelays->setBelow100mV(channel, gainId < 6); | 963 | controlSetRelays->setBelow100mV(channel, gainId < 6); |
| 953 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; | 964 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| @@ -978,7 +989,7 @@ namespace Hantek { | @@ -978,7 +989,7 @@ namespace Hantek { | ||
| 978 | double offsetReal = (double) (offsetValue - minimum) / (maximum - minimum); | 989 | double offsetReal = (double) (offsetValue - minimum) / (maximum - minimum); |
| 979 | 990 | ||
| 980 | // SetOffset control command for channel offset | 991 | // SetOffset control command for channel offset |
| 981 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setChannel(channel, offsetValue); | 992 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setChannel(channel, offsetValue); |
| 982 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; | 993 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 983 | 994 | ||
| 984 | this->settings.voltage[channel].offset = offset; | 995 | this->settings.voltage[channel].offset = offset; |
| @@ -1023,19 +1034,19 @@ namespace Hantek { | @@ -1023,19 +1034,19 @@ namespace Hantek { | ||
| 1023 | switch(this->specification.command.bulk.setTrigger) { | 1034 | switch(this->specification.command.bulk.setTrigger) { |
| 1024 | case BULK_SETTRIGGERANDSAMPLERATE: | 1035 | case BULK_SETTRIGGERANDSAMPLERATE: |
| 1025 | // SetTriggerAndSamplerate bulk command for trigger source | 1036 | // SetTriggerAndSamplerate bulk command for trigger source |
| 1026 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); | 1037 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); |
| 1027 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1038 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1028 | break; | 1039 | break; |
| 1029 | 1040 | ||
| 1030 | case BULK_CSETTRIGGERORSAMPLERATE: | 1041 | case BULK_CSETTRIGGERORSAMPLERATE: |
| 1031 | // SetTrigger2250 bulk command for trigger source | 1042 | // SetTrigger2250 bulk command for trigger source |
| 1032 | - ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | 1043 | + static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); |
| 1033 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; | 1044 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 1034 | break; | 1045 | break; |
| 1035 | 1046 | ||
| 1036 | case BULK_ESETTRIGGERORSAMPLERATE: | 1047 | case BULK_ESETTRIGGERORSAMPLERATE: |
| 1037 | // SetTrigger5200 bulk command for trigger source | 1048 | // SetTrigger5200 bulk command for trigger source |
| 1038 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | 1049 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); |
| 1039 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | 1050 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 1040 | break; | 1051 | break; |
| 1041 | 1052 | ||
| @@ -1044,7 +1055,7 @@ namespace Hantek { | @@ -1044,7 +1055,7 @@ namespace Hantek { | ||
| 1044 | } | 1055 | } |
| 1045 | 1056 | ||
| 1046 | // SetRelays control command for external trigger relay | 1057 | // SetRelays control command for external trigger relay |
| 1047 | - ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setTrigger(special); | 1058 | + static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS])->setTrigger(special); |
| 1048 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; | 1059 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| 1049 | 1060 | ||
| 1050 | this->settings.trigger.special = special; | 1061 | this->settings.trigger.special = special; |
| @@ -1053,7 +1064,7 @@ namespace Hantek { | @@ -1053,7 +1064,7 @@ namespace Hantek { | ||
| 1053 | // Apply trigger level of the new source | 1064 | // Apply trigger level of the new source |
| 1054 | if(special) { | 1065 | if(special) { |
| 1055 | // SetOffset control command for changed trigger level | 1066 | // SetOffset control command for changed trigger level |
| 1056 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setTrigger(0x7f); | 1067 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setTrigger(0x7f); |
| 1057 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; | 1068 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 1058 | } | 1069 | } |
| 1059 | else | 1070 | else |
| @@ -1096,7 +1107,7 @@ namespace Hantek { | @@ -1096,7 +1107,7 @@ namespace Hantek { | ||
| 1096 | // Check if the set channel is the trigger source | 1107 | // Check if the set channel is the trigger source |
| 1097 | if(!this->settings.trigger.special && channel == this->settings.trigger.source) { | 1108 | if(!this->settings.trigger.special && channel == this->settings.trigger.source) { |
| 1098 | // SetOffset control command for trigger level | 1109 | // SetOffset control command for trigger level |
| 1099 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setTrigger(levelValue); | 1110 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setTrigger(levelValue); |
| 1100 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; | 1111 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 1101 | } | 1112 | } |
| 1102 | 1113 | ||
| @@ -1119,19 +1130,19 @@ namespace Hantek { | @@ -1119,19 +1130,19 @@ namespace Hantek { | ||
| 1119 | switch(this->specification.command.bulk.setTrigger) { | 1130 | switch(this->specification.command.bulk.setTrigger) { |
| 1120 | case BULK_SETTRIGGERANDSAMPLERATE: { | 1131 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 1121 | // SetTriggerAndSamplerate bulk command for trigger slope | 1132 | // SetTriggerAndSamplerate bulk command for trigger slope |
| 1122 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); | 1133 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); |
| 1123 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1134 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1124 | break; | 1135 | break; |
| 1125 | } | 1136 | } |
| 1126 | case BULK_CSETTRIGGERORSAMPLERATE: { | 1137 | case BULK_CSETTRIGGERORSAMPLERATE: { |
| 1127 | // SetTrigger2250 bulk command for trigger slope | 1138 | // SetTrigger2250 bulk command for trigger slope |
| 1128 | - ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | 1139 | + static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); |
| 1129 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; | 1140 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 1130 | break; | 1141 | break; |
| 1131 | } | 1142 | } |
| 1132 | case BULK_ESETTRIGGERORSAMPLERATE: { | 1143 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 1133 | // SetTrigger5200 bulk command for trigger slope | 1144 | // SetTrigger5200 bulk command for trigger slope |
| 1134 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | 1145 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); |
| 1135 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; | 1146 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 1136 | break; | 1147 | break; |
| 1137 | } | 1148 | } |
| @@ -1162,7 +1173,7 @@ namespace Hantek { | @@ -1162,7 +1173,7 @@ namespace Hantek { | ||
| 1162 | unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; | 1173 | unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1163 | 1174 | ||
| 1164 | // SetTriggerAndSamplerate bulk command for trigger position | 1175 | // SetTriggerAndSamplerate bulk command for trigger position |
| 1165 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); | 1176 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); |
| 1166 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; | 1177 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1167 | 1178 | ||
| 1168 | break; | 1179 | break; |
| @@ -1173,7 +1184,7 @@ namespace Hantek { | @@ -1173,7 +1184,7 @@ namespace Hantek { | ||
| 1173 | unsigned short int positionPost = 0xffff - positionSamples; | 1184 | unsigned short int positionPost = 0xffff - positionSamples; |
| 1174 | 1185 | ||
| 1175 | // SetBuffer2250 bulk command for trigger position | 1186 | // SetBuffer2250 bulk command for trigger position |
| 1176 | - BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | 1187 | + BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]); |
| 1177 | commandSetBuffer2250->setTriggerPositionPre(positionPre); | 1188 | commandSetBuffer2250->setTriggerPositionPre(positionPre); |
| 1178 | commandSetBuffer2250->setTriggerPositionPost(positionPost); | 1189 | commandSetBuffer2250->setTriggerPositionPost(positionPost); |
| 1179 | this->commandPending[BULK_FSETBUFFER] = true; | 1190 | this->commandPending[BULK_FSETBUFFER] = true; |
| @@ -1186,7 +1197,7 @@ namespace Hantek { | @@ -1186,7 +1197,7 @@ namespace Hantek { | ||
| 1186 | unsigned short int positionPost = 0xffff - positionSamples; | 1197 | unsigned short int positionPost = 0xffff - positionSamples; |
| 1187 | 1198 | ||
| 1188 | // SetBuffer5200 bulk command for trigger position | 1199 | // SetBuffer5200 bulk command for trigger position |
| 1189 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | 1200 | + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]); |
| 1190 | commandSetBuffer5200->setTriggerPositionPre(positionPre); | 1201 | commandSetBuffer5200->setTriggerPositionPre(positionPre); |
| 1191 | commandSetBuffer5200->setTriggerPositionPost(positionPost); | 1202 | commandSetBuffer5200->setTriggerPositionPost(positionPost); |
| 1192 | this->commandPending[BULK_DSETBUFFER] = true; | 1203 | this->commandPending[BULK_DSETBUFFER] = true; |
| @@ -1240,7 +1251,7 @@ namespace Hantek { | @@ -1240,7 +1251,7 @@ namespace Hantek { | ||
| 1240 | // Get control code from third part | 1251 | // Get control code from third part |
| 1241 | unsigned char controlCode = commandParts[2].toUShort(); | 1252 | unsigned char controlCode = commandParts[2].toUShort(); |
| 1242 | int control; | 1253 | int control; |
| 1243 | - for(control = 0; control < CONTROLINDEX_COUNT; control++) { | 1254 | + for(control = 0; control < CONTROLINDEX_COUNT; ++control) { |
| 1244 | if(this->controlCode[control] == controlCode) | 1255 | if(this->controlCode[control] == controlCode) |
| 1245 | break; | 1256 | break; |
| 1246 | } | 1257 | } |
openhantek/src/hantek/control.h
| @@ -133,7 +133,6 @@ namespace Hantek { | @@ -133,7 +133,6 @@ namespace Hantek { | ||
| 133 | /// \brief Stores the current samplerate settings of the device. | 133 | /// \brief Stores the current samplerate settings of the device. |
| 134 | struct ControlSettingsSamplerate { | 134 | struct ControlSettingsSamplerate { |
| 135 | ControlSamplerateLimits *limits; ///< The samplerate limits | 135 | ControlSamplerateLimits *limits; ///< The samplerate limits |
| 136 | - //unsigned long int divider; ///< The fixed samplerate divider | ||
| 137 | unsigned long int downsampling; ///< The variable downsampling factor | 136 | unsigned long int downsampling; ///< The variable downsampling factor |
| 138 | double current; ///< The current samplerate | 137 | double current; ///< The current samplerate |
| 139 | }; | 138 | }; |
| @@ -144,7 +143,7 @@ namespace Hantek { | @@ -144,7 +143,7 @@ namespace Hantek { | ||
| 144 | struct ControlSettingsTrigger { | 143 | struct ControlSettingsTrigger { |
| 145 | double level[HANTEK_CHANNELS]; ///< The trigger level for each channel in V | 144 | double level[HANTEK_CHANNELS]; ///< The trigger level for each channel in V |
| 146 | double position; ///< The current pretrigger position | 145 | double position; ///< The current pretrigger position |
| 147 | - unsigned int point; ///< The trigger point value | 146 | + unsigned int point; ///< The trigger position in Hantek coding |
| 148 | Dso::TriggerMode mode; ///< The trigger mode | 147 | Dso::TriggerMode mode; ///< The trigger mode |
| 149 | Dso::Slope slope; ///< The trigger slope | 148 | Dso::Slope slope; ///< The trigger slope |
| 150 | bool special; ///< true, if the trigger source is special | 149 | bool special; ///< true, if the trigger source is special |
openhantek/src/hantek/device.cpp
| @@ -51,6 +51,9 @@ namespace Hantek { | @@ -51,6 +51,9 @@ namespace Hantek { | ||
| 51 | this->handle = 0; | 51 | this->handle = 0; |
| 52 | this->interface = -1; | 52 | this->interface = -1; |
| 53 | 53 | ||
| 54 | + this->outPacketLength = 0; | ||
| 55 | + this->inPacketLength = 0; | ||
| 56 | + | ||
| 54 | #if LIBUSB_VERSION == 0 | 57 | #if LIBUSB_VERSION == 0 |
| 55 | usb_init(); | 58 | usb_init(); |
| 56 | this->error = LIBUSB_SUCCESS; | 59 | this->error = LIBUSB_SUCCESS; |
| @@ -107,7 +110,7 @@ namespace Hantek { | @@ -107,7 +110,7 @@ namespace Hantek { | ||
| 107 | struct usb_config_descriptor *configDescriptor = device->config; | 110 | struct usb_config_descriptor *configDescriptor = device->config; |
| 108 | struct usb_interface *interface; | 111 | struct usb_interface *interface; |
| 109 | struct usb_interface_descriptor *interfaceDescriptor; | 112 | struct usb_interface_descriptor *interfaceDescriptor; |
| 110 | - for(int interfaceIndex = 0; interfaceIndex < configDescriptor->bNumInterfaces; interfaceIndex++) { | 113 | + for(int interfaceIndex = 0; interfaceIndex < configDescriptor->bNumInterfaces; ++interfaceIndex) { |
| 111 | interface = &configDescriptor->interface[interfaceIndex]; | 114 | interface = &configDescriptor->interface[interfaceIndex]; |
| 112 | if(interface->num_altsetting < 1) | 115 | if(interface->num_altsetting < 1) |
| 113 | continue; | 116 | continue; |
| @@ -128,7 +131,7 @@ namespace Hantek { | @@ -128,7 +131,7 @@ namespace Hantek { | ||
| 128 | usb_endpoint_descriptor *endpointDescriptor; | 131 | usb_endpoint_descriptor *endpointDescriptor; |
| 129 | this->outPacketLength = 0; | 132 | this->outPacketLength = 0; |
| 130 | this->inPacketLength = 0; | 133 | this->inPacketLength = 0; |
| 131 | - for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; endpoint++) { | 134 | + for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; ++endpoint) { |
| 132 | endpointDescriptor = &interfaceDescriptor->endpoint[endpoint]; | 135 | endpointDescriptor = &interfaceDescriptor->endpoint[endpoint]; |
| 133 | switch(endpointDescriptor->bEndpointAddress) { | 136 | switch(endpointDescriptor->bEndpointAddress) { |
| 134 | case HANTEK_EP_OUT: | 137 | case HANTEK_EP_OUT: |
| @@ -163,7 +166,7 @@ namespace Hantek { | @@ -163,7 +166,7 @@ namespace Hantek { | ||
| 163 | 166 | ||
| 164 | // Iterate through all usb devices | 167 | // Iterate through all usb devices |
| 165 | this->model = MODEL_UNKNOWN; | 168 | this->model = MODEL_UNKNOWN; |
| 166 | - for(ssize_t deviceIterator = 0; deviceIterator < deviceCount; deviceIterator++) { | 169 | + for(ssize_t deviceIterator = 0; deviceIterator < deviceCount; ++deviceIterator) { |
| 167 | device = deviceList[deviceIterator]; | 170 | device = deviceList[deviceIterator]; |
| 168 | // Get device descriptor | 171 | // Get device descriptor |
| 169 | if(libusb_get_device_descriptor(device, &(this->descriptor)) < 0) | 172 | if(libusb_get_device_descriptor(device, &(this->descriptor)) < 0) |
| @@ -188,7 +191,7 @@ namespace Hantek { | @@ -188,7 +191,7 @@ namespace Hantek { | ||
| 188 | 191 | ||
| 189 | // Search for the needed interface | 192 | // Search for the needed interface |
| 190 | libusb_get_config_descriptor(device, 0, &configDescriptor); | 193 | libusb_get_config_descriptor(device, 0, &configDescriptor); |
| 191 | - for(int interfaceIndex = 0; interfaceIndex < (int) configDescriptor->bNumInterfaces; interfaceIndex++) { | 194 | + for(int interfaceIndex = 0; interfaceIndex < (int) configDescriptor->bNumInterfaces; ++interfaceIndex) { |
| 192 | interface = &configDescriptor->interface[interfaceIndex]; | 195 | interface = &configDescriptor->interface[interfaceIndex]; |
| 193 | if(interface->num_altsetting < 1) | 196 | if(interface->num_altsetting < 1) |
| 194 | continue; | 197 | continue; |
| @@ -209,7 +212,7 @@ namespace Hantek { | @@ -209,7 +212,7 @@ namespace Hantek { | ||
| 209 | const libusb_endpoint_descriptor *endpointDescriptor; | 212 | const libusb_endpoint_descriptor *endpointDescriptor; |
| 210 | this->outPacketLength = 0; | 213 | this->outPacketLength = 0; |
| 211 | this->inPacketLength = 0; | 214 | this->inPacketLength = 0; |
| 212 | - for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; endpoint++) { | 215 | + for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; ++endpoint) { |
| 213 | endpointDescriptor = &(interfaceDescriptor->endpoint[endpoint]); | 216 | endpointDescriptor = &(interfaceDescriptor->endpoint[endpoint]); |
| 214 | switch(endpointDescriptor->bEndpointAddress) { | 217 | switch(endpointDescriptor->bEndpointAddress) { |
| 215 | case HANTEK_EP_OUT: | 218 | case HANTEK_EP_OUT: |
| @@ -285,7 +288,7 @@ namespace Hantek { | @@ -285,7 +288,7 @@ namespace Hantek { | ||
| 285 | 288 | ||
| 286 | int errorCode = LIBUSB_ERROR_TIMEOUT; | 289 | int errorCode = LIBUSB_ERROR_TIMEOUT; |
| 287 | int transferred; | 290 | int transferred; |
| 288 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | 291 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) |
| 289 | errorCode = libusb_bulk_transfer(this->handle, endpoint, data, length, &transferred, HANTEK_TIMEOUT); | 292 | errorCode = libusb_bulk_transfer(this->handle, endpoint, data, length, &transferred, HANTEK_TIMEOUT); |
| 290 | 293 | ||
| 291 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) | 294 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| @@ -312,7 +315,7 @@ namespace Hantek { | @@ -312,7 +315,7 @@ namespace Hantek { | ||
| 312 | 315 | ||
| 313 | #if LIBUSB_VERSION == 0 | 316 | #if LIBUSB_VERSION == 0 |
| 314 | errorCode = LIBUSB_ERROR_TIMEOUT; | 317 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 315 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | 318 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) |
| 316 | errorCode = usb_bulk_write(this->handle, HANTEK_EP_OUT, (char *) data, length, HANTEK_TIMEOUT); | 319 | errorCode = usb_bulk_write(this->handle, HANTEK_EP_OUT, (char *) data, length, HANTEK_TIMEOUT); |
| 317 | 320 | ||
| 318 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) | 321 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| @@ -339,7 +342,7 @@ namespace Hantek { | @@ -339,7 +342,7 @@ namespace Hantek { | ||
| 339 | 342 | ||
| 340 | #if LIBUSB_VERSION == 0 | 343 | #if LIBUSB_VERSION == 0 |
| 341 | errorCode = LIBUSB_ERROR_TIMEOUT; | 344 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 342 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | 345 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) |
| 343 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data, length, HANTEK_TIMEOUT); | 346 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data, length, HANTEK_TIMEOUT); |
| 344 | 347 | ||
| 345 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) | 348 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| @@ -385,10 +388,10 @@ namespace Hantek { | @@ -385,10 +388,10 @@ namespace Hantek { | ||
| 385 | 388 | ||
| 386 | errorCode = this->inPacketLength; | 389 | errorCode = this->inPacketLength; |
| 387 | unsigned int packet, received = 0; | 390 | unsigned int packet, received = 0; |
| 388 | - for(packet = 0; received < length && errorCode == this->inPacketLength; packet++) { | 391 | + for(packet = 0; received < length && errorCode == this->inPacketLength; ++packet) { |
| 389 | #if LIBUSB_VERSION == 0 | 392 | #if LIBUSB_VERSION == 0 |
| 390 | errorCode = LIBUSB_ERROR_TIMEOUT; | 393 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 391 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | 394 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) |
| 392 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), HANTEK_TIMEOUT); | 395 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), HANTEK_TIMEOUT); |
| 393 | #else | 396 | #else |
| 394 | errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), attempts); | 397 | errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), attempts); |
| @@ -417,7 +420,7 @@ namespace Hantek { | @@ -417,7 +420,7 @@ namespace Hantek { | ||
| 417 | return LIBUSB_ERROR_NO_DEVICE; | 420 | return LIBUSB_ERROR_NO_DEVICE; |
| 418 | 421 | ||
| 419 | int errorCode = LIBUSB_ERROR_TIMEOUT; | 422 | int errorCode = LIBUSB_ERROR_TIMEOUT; |
| 420 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | 423 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) |
| 421 | #if LIBUSB_VERSION == 0 | 424 | #if LIBUSB_VERSION == 0 |
| 422 | errorCode = usb_control_msg(this->handle, type, request, value, index, (char *) data, length, HANTEK_TIMEOUT); | 425 | errorCode = usb_control_msg(this->handle, type, request, value, index, (char *) data, length, HANTEK_TIMEOUT); |
| 423 | #else | 426 | #else |
| @@ -441,7 +444,7 @@ namespace Hantek { | @@ -441,7 +444,7 @@ namespace Hantek { | ||
| 441 | if(!this->handle) | 444 | if(!this->handle) |
| 442 | return LIBUSB_ERROR_NO_DEVICE; | 445 | return LIBUSB_ERROR_NO_DEVICE; |
| 443 | 446 | ||
| 444 | - return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, request, data, length, value, index,attempts); | 447 | + return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, request, data, length, value, index, attempts); |
| 445 | } | 448 | } |
| 446 | 449 | ||
| 447 | /// \brief Control read to the oscilloscope. | 450 | /// \brief Control read to the oscilloscope. |
openhantek/src/hantek/device.h
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | #define libusb_device_handle usb_device_handle | 37 | #define libusb_device_handle usb_device_handle |
| 38 | #define libusb_device_descriptor usb_device_descriptor | 38 | #define libusb_device_descriptor usb_device_descriptor |
| 39 | #else | 39 | #else |
| 40 | -#include <libusb-1.0/libusb.h> | 40 | +#include <libusb.h> |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | 43 |
openhantek/src/helper.cpp
| @@ -151,7 +151,7 @@ namespace Helper { | @@ -151,7 +151,7 @@ namespace Helper { | ||
| 151 | QString hexDump(unsigned char *data, unsigned int length) { | 151 | QString hexDump(unsigned char *data, unsigned int length) { |
| 152 | QString dumpString, byteString; | 152 | QString dumpString, byteString; |
| 153 | 153 | ||
| 154 | - for(unsigned int index = 0; index < length; index++) | 154 | + for(unsigned int index = 0; index < length; ++index) |
| 155 | dumpString.append(byteString.sprintf(" %02x", data[index])); | 155 | dumpString.append(byteString.sprintf(" %02x", data[index])); |
| 156 | 156 | ||
| 157 | return dumpString; | 157 | return dumpString; |
| @@ -168,7 +168,7 @@ namespace Helper { | @@ -168,7 +168,7 @@ namespace Helper { | ||
| 168 | QString byteString; | 168 | QString byteString; |
| 169 | unsigned int index; | 169 | unsigned int index; |
| 170 | 170 | ||
| 171 | - for(index = 0; index < length; index++) { | 171 | + for(index = 0; index < length; ++index) { |
| 172 | byteString = dumpString.mid(index * 2, 2); | 172 | byteString = dumpString.mid(index * 2, 2); |
| 173 | 173 | ||
| 174 | // Check if we reached the end of the string | 174 | // Check if we reached the end of the string |
openhantek/src/helper.h
| @@ -93,7 +93,7 @@ namespace Helper { | @@ -93,7 +93,7 @@ namespace Helper { | ||
| 93 | /// \param size Size of the data array. | 93 | /// \param size Size of the data array. |
| 94 | template <class T> DataArray<T>::DataArray(unsigned int size) { | 94 | template <class T> DataArray<T>::DataArray(unsigned int size) { |
| 95 | this->array = new T[size]; | 95 | this->array = new T[size]; |
| 96 | - for(unsigned int index = 0; index < size; index++) | 96 | + for(unsigned int index = 0; index < size; ++index) |
| 97 | this->array[index] = 0; | 97 | this->array[index] = 0; |
| 98 | this->size = size; | 98 | this->size = size; |
| 99 | } | 99 | } |
openhantek/src/levelslider.cpp
| @@ -353,7 +353,7 @@ void LevelSlider::mousePressEvent(QMouseEvent *event) { | @@ -353,7 +353,7 @@ void LevelSlider::mousePressEvent(QMouseEvent *event) { | ||
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | this->pressedSlider = -1; | 355 | this->pressedSlider = -1; |
| 356 | - for(int sliderId = 0; sliderId < this->slider.count(); sliderId++) { | 356 | + for(int sliderId = 0; sliderId < this->slider.count(); ++sliderId) { |
| 357 | if(this->slider[sliderId]->visible && this->slider[sliderId]->rect.contains(event->pos())) { | 357 | if(this->slider[sliderId]->visible && this->slider[sliderId]->rect.contains(event->pos())) { |
| 358 | this->pressedSlider = sliderId; | 358 | this->pressedSlider = sliderId; |
| 359 | break; | 359 | break; |
| @@ -400,7 +400,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { | @@ -400,7 +400,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { | ||
| 400 | 400 | ||
| 401 | QList<LevelSliderParameters *>::iterator slider = this->slider.end(); | 401 | QList<LevelSliderParameters *>::iterator slider = this->slider.end(); |
| 402 | while(slider != this->slider.begin()) { | 402 | while(slider != this->slider.begin()) { |
| 403 | - slider--; | 403 | + --slider; |
| 404 | 404 | ||
| 405 | if(!(*slider)->visible) | 405 | if(!(*slider)->visible) |
| 406 | continue; | 406 | continue; |
| @@ -475,7 +475,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { | @@ -475,7 +475,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { | ||
| 475 | void LevelSlider::resizeEvent(QResizeEvent *event) { | 475 | void LevelSlider::resizeEvent(QResizeEvent *event) { |
| 476 | Q_UNUSED(event); | 476 | Q_UNUSED(event); |
| 477 | 477 | ||
| 478 | - for(int sliderId = 0; sliderId < this->slider.count(); sliderId++) | 478 | + for(int sliderId = 0; sliderId < this->slider.count(); ++sliderId) |
| 479 | this->calculateRect(sliderId); | 479 | this->calculateRect(sliderId); |
| 480 | 480 | ||
| 481 | this->repaint(); | 481 | this->repaint(); |
openhantek/src/openhantek.cpp
| @@ -133,7 +133,7 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag | @@ -133,7 +133,7 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag | ||
| 133 | // Set up the oscilloscope | 133 | // Set up the oscilloscope |
| 134 | this->dsoControl->connectDevice(); | 134 | this->dsoControl->connectDevice(); |
| 135 | 135 | ||
| 136 | - for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; channel++) { | 136 | + for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; ++channel) { |
| 137 | this->dsoControl->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); | 137 | this->dsoControl->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); |
| 138 | this->updateVoltageGain(channel); | 138 | this->updateVoltageGain(channel); |
| 139 | this->updateOffset(channel); | 139 | this->updateOffset(channel); |
| @@ -489,7 +489,7 @@ void OpenHantekMainWindow::applySettings() { | @@ -489,7 +489,7 @@ void OpenHantekMainWindow::applySettings() { | ||
| 489 | 489 | ||
| 490 | QList<int> dockedWindows[2]; // Docks docked on the sides of the main window | 490 | QList<int> dockedWindows[2]; // Docks docked on the sides of the main window |
| 491 | 491 | ||
| 492 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | 492 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { |
| 493 | docks[dockId]->setVisible(dockSettings[dockId]->visible); | 493 | docks[dockId]->setVisible(dockSettings[dockId]->visible); |
| 494 | if(!dockSettings[dockId]->position.isNull()) { | 494 | if(!dockSettings[dockId]->position.isNull()) { |
| 495 | if(dockSettings[dockId]->floating) { | 495 | if(dockSettings[dockId]->floating) { |
| @@ -502,7 +502,7 @@ void OpenHantekMainWindow::applySettings() { | @@ -502,7 +502,7 @@ void OpenHantekMainWindow::applySettings() { | ||
| 502 | int side = (dockSettings[dockId]->position.x() < this->settings->options.window.size.width() / 2) ? 0 : 1; | 502 | int side = (dockSettings[dockId]->position.x() < this->settings->options.window.size.width() / 2) ? 0 : 1; |
| 503 | int index = 0; | 503 | int index = 0; |
| 504 | while(index < dockedWindows[side].size() && dockSettings[dockedWindows[side][index]]->position.y() <= dockSettings[dockId]->position.y()) | 504 | while(index < dockedWindows[side].size() && dockSettings[dockedWindows[side][index]]->position.y() <= dockSettings[dockId]->position.y()) |
| 505 | - index++; | 505 | + ++index; |
| 506 | dockedWindows[side].insert(index, dockId); | 506 | dockedWindows[side].insert(index, dockId); |
| 507 | } | 507 | } |
| 508 | } | 508 | } |
| @@ -512,9 +512,9 @@ void OpenHantekMainWindow::applySettings() { | @@ -512,9 +512,9 @@ void OpenHantekMainWindow::applySettings() { | ||
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | // Put the docked docking windows into the main window | 514 | // Put the docked docking windows into the main window |
| 515 | - for(int position = 0; position < dockedWindows[0].size(); position++) | 515 | + for(int position = 0; position < dockedWindows[0].size(); ++position) |
| 516 | this->addDockWidget(Qt::LeftDockWidgetArea, docks[dockedWindows[0][position]]); | 516 | this->addDockWidget(Qt::LeftDockWidgetArea, docks[dockedWindows[0][position]]); |
| 517 | - for(int position = 0; position < dockedWindows[1].size(); position++) | 517 | + for(int position = 0; position < dockedWindows[1].size(); ++position) |
| 518 | this->addDockWidget(Qt::RightDockWidgetArea, docks[dockedWindows[1][position]]); | 518 | this->addDockWidget(Qt::RightDockWidgetArea, docks[dockedWindows[1][position]]); |
| 519 | 519 | ||
| 520 | // Toolbars | 520 | // Toolbars |
| @@ -530,7 +530,7 @@ void OpenHantekMainWindow::applySettings() { | @@ -530,7 +530,7 @@ void OpenHantekMainWindow::applySettings() { | ||
| 530 | 530 | ||
| 531 | QList<int> dockedToolbars; // Docks docked on the sides of the main window | 531 | QList<int> dockedToolbars; // Docks docked on the sides of the main window |
| 532 | 532 | ||
| 533 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | 533 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { |
| 534 | toolbars[toolbarId]->setVisible(toolbarSettings[toolbarId]->visible); | 534 | toolbars[toolbarId]->setVisible(toolbarSettings[toolbarId]->visible); |
| 535 | //toolbars[toolbarId]->setFloating(toolbarSettings[toolbarId]->floating); // setFloating missing, a bug in Qt? | 535 | //toolbars[toolbarId]->setFloating(toolbarSettings[toolbarId]->floating); // setFloating missing, a bug in Qt? |
| 536 | if(!toolbarSettings[toolbarId]->position.isNull() && !toolbarSettings[toolbarId]->floating) { | 536 | if(!toolbarSettings[toolbarId]->position.isNull() && !toolbarSettings[toolbarId]->floating) { |
| @@ -541,7 +541,7 @@ void OpenHantekMainWindow::applySettings() { | @@ -541,7 +541,7 @@ void OpenHantekMainWindow::applySettings() { | ||
| 541 | // Check in which order the toolbars where placed | 541 | // Check in which order the toolbars where placed |
| 542 | int index = 0; | 542 | int index = 0; |
| 543 | while(index < dockedToolbars.size() && toolbarSettings[dockedToolbars[index]]->position.x() <= toolbarSettings[toolbarId]->position.x()) | 543 | while(index < dockedToolbars.size() && toolbarSettings[dockedToolbars[index]]->position.x() <= toolbarSettings[toolbarId]->position.x()) |
| 544 | - index++; | 544 | + ++index; |
| 545 | dockedToolbars.insert(index, toolbarId); | 545 | dockedToolbars.insert(index, toolbarId); |
| 546 | } | 546 | } |
| 547 | } | 547 | } |
| @@ -551,7 +551,7 @@ void OpenHantekMainWindow::applySettings() { | @@ -551,7 +551,7 @@ void OpenHantekMainWindow::applySettings() { | ||
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | // Put the docked toolbars into the main window | 553 | // Put the docked toolbars into the main window |
| 554 | - for(int position = 0; position < dockedToolbars.size(); position++) | 554 | + for(int position = 0; position < dockedToolbars.size(); ++position) |
| 555 | this->addToolBar(toolbars[dockedToolbars[position]]); | 555 | this->addToolBar(toolbars[dockedToolbars[position]]); |
| 556 | } | 556 | } |
| 557 | 557 | ||
| @@ -574,7 +574,7 @@ void OpenHantekMainWindow::updateSettings() { | @@ -574,7 +574,7 @@ void OpenHantekMainWindow::updateSettings() { | ||
| 574 | dockSettings.append(&(this->settings->options.window.dock.trigger)); | 574 | dockSettings.append(&(this->settings->options.window.dock.trigger)); |
| 575 | dockSettings.append(&(this->settings->options.window.dock.voltage)); | 575 | dockSettings.append(&(this->settings->options.window.dock.voltage)); |
| 576 | 576 | ||
| 577 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | 577 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { |
| 578 | dockSettings[dockId]->floating = docks[dockId]->isFloating(); | 578 | dockSettings[dockId]->floating = docks[dockId]->isFloating(); |
| 579 | dockSettings[dockId]->position = docks[dockId]->pos(); | 579 | dockSettings[dockId]->position = docks[dockId]->pos(); |
| 580 | dockSettings[dockId]->visible = docks[dockId]->isVisible(); | 580 | dockSettings[dockId]->visible = docks[dockId]->isVisible(); |
| @@ -591,7 +591,7 @@ void OpenHantekMainWindow::updateSettings() { | @@ -591,7 +591,7 @@ void OpenHantekMainWindow::updateSettings() { | ||
| 591 | toolbarSettings.append(&(this->settings->options.window.toolbar.oscilloscope)); | 591 | toolbarSettings.append(&(this->settings->options.window.toolbar.oscilloscope)); |
| 592 | toolbarSettings.append(&(this->settings->options.window.toolbar.view)); | 592 | toolbarSettings.append(&(this->settings->options.window.toolbar.view)); |
| 593 | 593 | ||
| 594 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | 594 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { |
| 595 | toolbarSettings[toolbarId]->floating = toolbars[toolbarId]->isFloating(); | 595 | toolbarSettings[toolbarId]->floating = toolbars[toolbarId]->isFloating(); |
| 596 | toolbarSettings[toolbarId]->position = toolbars[toolbarId]->pos(); | 596 | toolbarSettings[toolbarId]->position = toolbars[toolbarId]->pos(); |
| 597 | toolbarSettings[toolbarId]->visible = toolbars[toolbarId]->isVisible(); | 597 | toolbarSettings[toolbarId]->visible = toolbars[toolbarId]->isVisible(); |
| @@ -636,7 +636,7 @@ void OpenHantekMainWindow::updateUsed(unsigned int channel) { | @@ -636,7 +636,7 @@ void OpenHantekMainWindow::updateUsed(unsigned int channel) { | ||
| 636 | this->dsoControl->setChannelUsed(channel, mathUsed | this->settings->scope.voltage[channel].used | this->settings->scope.spectrum[channel].used); | 636 | this->dsoControl->setChannelUsed(channel, mathUsed | this->settings->scope.voltage[channel].used | this->settings->scope.spectrum[channel].used); |
| 637 | // Math channel, update all channels | 637 | // Math channel, update all channels |
| 638 | else if(channel == this->settings->scope.physicalChannels) { | 638 | else if(channel == this->settings->scope.physicalChannels) { |
| 639 | - for(unsigned int channelCounter = 0; channelCounter < this->settings->scope.physicalChannels; channelCounter++) | 639 | + for(unsigned int channelCounter = 0; channelCounter < this->settings->scope.physicalChannels; ++channelCounter) |
| 640 | this->dsoControl->setChannelUsed(channelCounter, mathUsed | this->settings->scope.voltage[channelCounter].used | this->settings->scope.spectrum[channelCounter].used); | 640 | this->dsoControl->setChannelUsed(channelCounter, mathUsed | this->settings->scope.voltage[channelCounter].used | this->settings->scope.spectrum[channelCounter].used); |
| 641 | } | 641 | } |
| 642 | } | 642 | } |
openhantek/src/settings.cpp
| @@ -51,7 +51,7 @@ DsoSettings::DsoSettings(QWidget *parent) : QObject(parent) { | @@ -51,7 +51,7 @@ DsoSettings::DsoSettings(QWidget *parent) : QObject(parent) { | ||
| 51 | panels.append(&(this->options.window.toolbar.file)); | 51 | panels.append(&(this->options.window.toolbar.file)); |
| 52 | panels.append(&(this->options.window.toolbar.oscilloscope)); | 52 | panels.append(&(this->options.window.toolbar.oscilloscope)); |
| 53 | panels.append(&(this->options.window.toolbar.view)); | 53 | panels.append(&(this->options.window.toolbar.view)); |
| 54 | - for(int panelId = 0; panelId < panels.size(); panelId++) { | 54 | + for(int panelId = 0; panelId < panels.size(); ++panelId) { |
| 55 | panels[panelId]->floating = false; | 55 | panels[panelId]->floating = false; |
| 56 | panels[panelId]->position = QPoint(); | 56 | panels[panelId]->position = QPoint(); |
| 57 | panels[panelId]->visible = true; | 57 | panels[panelId]->visible = true; |
| @@ -126,7 +126,7 @@ void DsoSettings::setChannelCount(unsigned int channels) { | @@ -126,7 +126,7 @@ void DsoSettings::setChannelCount(unsigned int channels) { | ||
| 126 | this->scope.spectrum.removeAt(channel); | 126 | this->scope.spectrum.removeAt(channel); |
| 127 | 127 | ||
| 128 | // Add new channels to the list | 128 | // Add new channels to the list |
| 129 | - for(int channel = 0; channel < (int) channels; channel++) { | 129 | + for(int channel = 0; channel < (int) channels; ++channel) { |
| 130 | // Oscilloscope settings | 130 | // Oscilloscope settings |
| 131 | // Spectrum | 131 | // Spectrum |
| 132 | if(this->scope.spectrum.count() <= channel + 1) { | 132 | if(this->scope.spectrum.count() <= channel + 1) { |
| @@ -218,7 +218,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -218,7 +218,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 218 | docks.append(&(this->options.window.dock.voltage)); | 218 | docks.append(&(this->options.window.dock.voltage)); |
| 219 | QStringList dockNames; | 219 | QStringList dockNames; |
| 220 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; | 220 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; |
| 221 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | 221 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { |
| 222 | settingsLoader->beginGroup(dockNames[dockId]); | 222 | settingsLoader->beginGroup(dockNames[dockId]); |
| 223 | if(settingsLoader->contains("floating")) | 223 | if(settingsLoader->contains("floating")) |
| 224 | docks[dockId]->floating = settingsLoader->value("floating").toBool(); | 224 | docks[dockId]->floating = settingsLoader->value("floating").toBool(); |
| @@ -236,7 +236,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -236,7 +236,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 236 | toolbars.append(&(this->options.window.toolbar.view)); | 236 | toolbars.append(&(this->options.window.toolbar.view)); |
| 237 | QStringList toolbarNames; | 237 | QStringList toolbarNames; |
| 238 | toolbarNames << "file" << "oscilloscope" << "view"; | 238 | toolbarNames << "file" << "oscilloscope" << "view"; |
| 239 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | 239 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { |
| 240 | settingsLoader->beginGroup(toolbarNames[toolbarId]); | 240 | settingsLoader->beginGroup(toolbarNames[toolbarId]); |
| 241 | if(settingsLoader->contains("floating")) | 241 | if(settingsLoader->contains("floating")) |
| 242 | toolbars[toolbarId]->floating = settingsLoader->value("floating").toBool(); | 242 | toolbars[toolbarId]->floating = settingsLoader->value("floating").toBool(); |
| @@ -268,7 +268,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -268,7 +268,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 268 | this->scope.horizontal.format = (Dso::GraphFormat) settingsLoader->value("format").toInt(); | 268 | this->scope.horizontal.format = (Dso::GraphFormat) settingsLoader->value("format").toInt(); |
| 269 | if(settingsLoader->contains("frequencybase")) | 269 | if(settingsLoader->contains("frequencybase")) |
| 270 | this->scope.horizontal.frequencybase = settingsLoader->value("frequencybase").toDouble(); | 270 | this->scope.horizontal.frequencybase = settingsLoader->value("frequencybase").toDouble(); |
| 271 | - for(int marker = 0; marker < 2; marker++) { | 271 | + for(int marker = 0; marker < 2; ++marker) { |
| 272 | QString name; | 272 | QString name; |
| 273 | name = QString("marker%1").arg(marker); | 273 | name = QString("marker%1").arg(marker); |
| 274 | if(settingsLoader->contains(name)) | 274 | if(settingsLoader->contains(name)) |
| @@ -293,7 +293,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -293,7 +293,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 293 | this->scope.trigger.special = settingsLoader->value("special").toInt(); | 293 | this->scope.trigger.special = settingsLoader->value("special").toInt(); |
| 294 | settingsLoader->endGroup(); | 294 | settingsLoader->endGroup(); |
| 295 | // Spectrum | 295 | // Spectrum |
| 296 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | 296 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { |
| 297 | settingsLoader->beginGroup(QString("spectrum%1").arg(channel)); | 297 | settingsLoader->beginGroup(QString("spectrum%1").arg(channel)); |
| 298 | if(settingsLoader->contains("magnitude")) | 298 | if(settingsLoader->contains("magnitude")) |
| 299 | this->scope.spectrum[channel].magnitude = settingsLoader->value("magnitude").toDouble(); | 299 | this->scope.spectrum[channel].magnitude = settingsLoader->value("magnitude").toDouble(); |
| @@ -304,7 +304,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -304,7 +304,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 304 | settingsLoader->endGroup(); | 304 | settingsLoader->endGroup(); |
| 305 | } | 305 | } |
| 306 | // Vertical axis | 306 | // Vertical axis |
| 307 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | 307 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { |
| 308 | settingsLoader->beginGroup(QString("vertical%1").arg(channel)); | 308 | settingsLoader->beginGroup(QString("vertical%1").arg(channel)); |
| 309 | if(settingsLoader->contains("gain")) | 309 | if(settingsLoader->contains("gain")) |
| 310 | this->scope.voltage[channel].gain = settingsLoader->value("gain").toDouble(); | 310 | this->scope.voltage[channel].gain = settingsLoader->value("gain").toDouble(); |
| @@ -331,7 +331,7 @@ int DsoSettings::load(const QString &fileName) { | @@ -331,7 +331,7 @@ int DsoSettings::load(const QString &fileName) { | ||
| 331 | // Colors | 331 | // Colors |
| 332 | settingsLoader->beginGroup("color"); | 332 | settingsLoader->beginGroup("color"); |
| 333 | DsoSettingsColorValues *colors; | 333 | DsoSettingsColorValues *colors; |
| 334 | - for(int mode = 0; mode < 2; mode++) { | 334 | + for(int mode = 0; mode < 2; ++mode) { |
| 335 | if(mode == 0) { | 335 | if(mode == 0) { |
| 336 | colors = &this->view.color.screen; | 336 | colors = &this->view.color.screen; |
| 337 | settingsLoader->beginGroup("screen"); | 337 | settingsLoader->beginGroup("screen"); |
| @@ -351,14 +351,14 @@ int DsoSettings::load(const QString &fileName) { | @@ -351,14 +351,14 @@ int DsoSettings::load(const QString &fileName) { | ||
| 351 | colors->grid = settingsLoader->value("grid").value<QColor>(); | 351 | colors->grid = settingsLoader->value("grid").value<QColor>(); |
| 352 | if(settingsLoader->contains("markers")) | 352 | if(settingsLoader->contains("markers")) |
| 353 | colors->markers = settingsLoader->value("markers").value<QColor>(); | 353 | colors->markers = settingsLoader->value("markers").value<QColor>(); |
| 354 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | 354 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { |
| 355 | QString key = QString("spectrum%1").arg(channel); | 355 | QString key = QString("spectrum%1").arg(channel); |
| 356 | if(settingsLoader->contains(key)) | 356 | if(settingsLoader->contains(key)) |
| 357 | colors->spectrum[channel] = settingsLoader->value(key).value<QColor>(); | 357 | colors->spectrum[channel] = settingsLoader->value(key).value<QColor>(); |
| 358 | } | 358 | } |
| 359 | if(settingsLoader->contains("text")) | 359 | if(settingsLoader->contains("text")) |
| 360 | colors->text = settingsLoader->value("text").value<QColor>(); | 360 | colors->text = settingsLoader->value("text").value<QColor>(); |
| 361 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | 361 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { |
| 362 | QString key = QString("voltage%1").arg(channel); | 362 | QString key = QString("voltage%1").arg(channel); |
| 363 | if(settingsLoader->contains(key)) | 363 | if(settingsLoader->contains(key)) |
| 364 | colors->voltage[channel] = settingsLoader->value(key).value<QColor>(); | 364 | colors->voltage[channel] = settingsLoader->value(key).value<QColor>(); |
| @@ -409,7 +409,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -409,7 +409,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 409 | docks.append(&(this->options.window.dock.voltage)); | 409 | docks.append(&(this->options.window.dock.voltage)); |
| 410 | QStringList dockNames; | 410 | QStringList dockNames; |
| 411 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; | 411 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; |
| 412 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | 412 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { |
| 413 | settingsSaver->beginGroup(dockNames[dockId]); | 413 | settingsSaver->beginGroup(dockNames[dockId]); |
| 414 | settingsSaver->setValue("floating", docks[dockId]->floating); | 414 | settingsSaver->setValue("floating", docks[dockId]->floating); |
| 415 | settingsSaver->setValue("position", docks[dockId]->position); | 415 | settingsSaver->setValue("position", docks[dockId]->position); |
| @@ -424,7 +424,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -424,7 +424,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 424 | toolbars.append(&(this->options.window.toolbar.view)); | 424 | toolbars.append(&(this->options.window.toolbar.view)); |
| 425 | QStringList toolbarNames; | 425 | QStringList toolbarNames; |
| 426 | toolbarNames << "file" << "oscilloscope" << "view"; | 426 | toolbarNames << "file" << "oscilloscope" << "view"; |
| 427 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | 427 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { |
| 428 | settingsSaver->beginGroup(toolbarNames[toolbarId]); | 428 | settingsSaver->beginGroup(toolbarNames[toolbarId]); |
| 429 | settingsSaver->setValue("floating", toolbars[toolbarId]->floating); | 429 | settingsSaver->setValue("floating", toolbars[toolbarId]->floating); |
| 430 | settingsSaver->setValue("position", toolbars[toolbarId]->position); | 430 | settingsSaver->setValue("position", toolbars[toolbarId]->position); |
| @@ -446,7 +446,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -446,7 +446,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 446 | settingsSaver->beginGroup("horizontal"); | 446 | settingsSaver->beginGroup("horizontal"); |
| 447 | settingsSaver->setValue("format", this->scope.horizontal.format); | 447 | settingsSaver->setValue("format", this->scope.horizontal.format); |
| 448 | settingsSaver->setValue("frequencybase", this->scope.horizontal.frequencybase); | 448 | settingsSaver->setValue("frequencybase", this->scope.horizontal.frequencybase); |
| 449 | - for(int marker = 0; marker < 2; marker++) | 449 | + for(int marker = 0; marker < 2; ++marker) |
| 450 | settingsSaver->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); | 450 | settingsSaver->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); |
| 451 | settingsSaver->setValue("timebase", this->scope.horizontal.timebase); | 451 | settingsSaver->setValue("timebase", this->scope.horizontal.timebase); |
| 452 | settingsSaver->endGroup(); | 452 | settingsSaver->endGroup(); |
| @@ -459,7 +459,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -459,7 +459,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 459 | settingsSaver->setValue("source", this->scope.trigger.source); | 459 | settingsSaver->setValue("source", this->scope.trigger.source); |
| 460 | settingsSaver->endGroup(); | 460 | settingsSaver->endGroup(); |
| 461 | // Spectrum | 461 | // Spectrum |
| 462 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | 462 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { |
| 463 | settingsSaver->beginGroup(QString("spectrum%1").arg(channel)); | 463 | settingsSaver->beginGroup(QString("spectrum%1").arg(channel)); |
| 464 | settingsSaver->setValue("magnitude", this->scope.spectrum[channel].magnitude); | 464 | settingsSaver->setValue("magnitude", this->scope.spectrum[channel].magnitude); |
| 465 | settingsSaver->setValue("offset", this->scope.spectrum[channel].offset); | 465 | settingsSaver->setValue("offset", this->scope.spectrum[channel].offset); |
| @@ -467,7 +467,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -467,7 +467,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 467 | settingsSaver->endGroup(); | 467 | settingsSaver->endGroup(); |
| 468 | } | 468 | } |
| 469 | // Vertical axis | 469 | // Vertical axis |
| 470 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | 470 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { |
| 471 | settingsSaver->beginGroup(QString("vertical%1").arg(channel)); | 471 | settingsSaver->beginGroup(QString("vertical%1").arg(channel)); |
| 472 | settingsSaver->setValue("gain", this->scope.voltage[channel].gain); | 472 | settingsSaver->setValue("gain", this->scope.voltage[channel].gain); |
| 473 | settingsSaver->setValue("misc", this->scope.voltage[channel].misc); | 473 | settingsSaver->setValue("misc", this->scope.voltage[channel].misc); |
| @@ -487,7 +487,7 @@ int DsoSettings::save(const QString &fileName) { | @@ -487,7 +487,7 @@ int DsoSettings::save(const QString &fileName) { | ||
| 487 | if(complete) { | 487 | if(complete) { |
| 488 | settingsSaver->beginGroup("color"); | 488 | settingsSaver->beginGroup("color"); |
| 489 | DsoSettingsColorValues *colors; | 489 | DsoSettingsColorValues *colors; |
| 490 | - for(int mode = 0; mode < 2; mode++) { | 490 | + for(int mode = 0; mode < 2; ++mode) { |
| 491 | if(mode == 0) { | 491 | if(mode == 0) { |
| 492 | colors = &this->view.color.screen; | 492 | colors = &this->view.color.screen; |
| 493 | settingsSaver->beginGroup("screen"); | 493 | settingsSaver->beginGroup("screen"); |
| @@ -502,10 +502,10 @@ int DsoSettings::save(const QString &fileName) { | @@ -502,10 +502,10 @@ int DsoSettings::save(const QString &fileName) { | ||
| 502 | settingsSaver->setValue("border", colors->border); | 502 | settingsSaver->setValue("border", colors->border); |
| 503 | settingsSaver->setValue("grid", colors->grid); | 503 | settingsSaver->setValue("grid", colors->grid); |
| 504 | settingsSaver->setValue("markers", colors->markers); | 504 | settingsSaver->setValue("markers", colors->markers); |
| 505 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) | 505 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) |
| 506 | settingsSaver->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); | 506 | settingsSaver->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); |
| 507 | settingsSaver->setValue("text", colors->text); | 507 | settingsSaver->setValue("text", colors->text); |
| 508 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) | 508 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) |
| 509 | settingsSaver->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); | 509 | settingsSaver->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); |
| 510 | settingsSaver->endGroup(); | 510 | settingsSaver->endGroup(); |
| 511 | } | 511 | } |