diff --git a/openhantek/ChangeLog b/openhantek/ChangeLog index 12494c5..cc17bc6 100644 --- a/openhantek/ChangeLog +++ b/openhantek/ChangeLog @@ -37,3 +37,11 @@ 2010-08-18 Oliver Haag * Bugfix: Trigger levels weren't sent to the oscilloscope * Implemented single trigger mode + +2010-08-22 Oliver Haag +* Bugfix: Pretrigger position wasn't initialized correctly on startup +* Bugfix: Wrong samplerate values were sent to the oscilloscope +* Updated exporter class +* Moved constants.h to dso.h and added functions that return strings for enums +* Sample buffer size above scope shows real sample count got from oscilloscope +* Documentation updated diff --git a/openhantek/OpenHantek.pro b/openhantek/OpenHantek.pro index 2c1fc83..d7f007d 100644 --- a/openhantek/OpenHantek.pro +++ b/openhantek/OpenHantek.pro @@ -24,11 +24,11 @@ SOURCES += src/colorbox.cpp \ src/settings.cpp \ src/hantek/control.cpp \ src/hantek/device.cpp \ - src/hantek/types.cpp + src/hantek/types.cpp \ + src/dso.cpp HEADERS += src/colorbox.h \ src/configdialog.h \ src/configpages.h \ - src/constants.h \ src/dataanalyzer.h \ src/dockwindows.h \ src/dsocontrol.h \ @@ -42,7 +42,8 @@ HEADERS += src/colorbox.h \ src/settings.h \ src/hantek/control.h \ src/hantek/device.h \ - src/hantek/types.h + src/hantek/types.h \ + src/dso.h # Ressource files RESOURCES += res/application.qrc \ diff --git a/openhantek/mainpage.dox b/openhantek/mainpage.dox index dfcbdcf..f250e6a 100644 --- a/openhantek/mainpage.dox +++ b/openhantek/mainpage.dox @@ -10,9 +10,48 @@ OpenHantek is a free software for %Hantek (Voltcraft/Darkwire/Protek/Acetech) US You need the development packages for the following libraries to build OpenHantek from source: +\subsection ssec_dependencies Building +After installing these you can build it by running: +
+	$ qmake
+	$ make
+	$ make install
+
+ +\subsection ssec_dependencies Build options +You can set environment variables to set various build options (Done best by prepending env VARIABLE=value to the qmake command). The known environment variables are: + + +\section sec_firmware Installation of the firmware +\subsection ssec_drivers Gettings the Windows drivers +Before using OpenHantek you have to extract the firmware from the official Windows drivers. You can get them from the Hantek website (English translation). +\subsection ssec_dsoextractfw The firmware extraction tool +You need the tool dsoextractfw from the sourceforge page too extract the firmware. You have to install libbfd development files and build it by typing: +
+	$ make
+
+After building it you have to place the DSO*1.SYS file into the same directory and run the built binary: +
+	$ ./dsoextractfw
+
+This should create two .hex files. +\subsection ssec_firmware Installing the firmware +Place the extracted .hex files into /usr/local/share/hantekdso/ and copy the 90-hantek-dso.rules file to /etc/udev/rules.d/. To load the firmware you have to install fxload.
+After restarting udev your oscilloscope should be initialized automatically after connecting it to the computer (You have to reconnect it after installing this package).
+If you can't run OpenHantek as normal user, you have too add your user to the plugdev group. + **/ diff --git a/openhantek/src/configpages.cpp b/openhantek/src/configpages.cpp index 5a15eea..3c92965 100644 --- a/openhantek/src/configpages.cpp +++ b/openhantek/src/configpages.cpp @@ -274,7 +274,7 @@ DsoConfigScopePage::~DsoConfigScopePage() { /// \brief Saves the new settings. void DsoConfigScopePage::saveSettings() { this->settings->view.antialiasing = this->antialiasingCheckBox->isChecked(); - this->settings->view.interpolation = (GlInterpolationMode) this->interpolationComboBox->currentIndex(); + this->settings->view.interpolation = (Dso::InterpolationMode) this->interpolationComboBox->currentIndex(); this->settings->view.digitalPhosphorDepth = this->digitalPhosphorDepthSpinBox->value(); } diff --git a/openhantek/src/configpages.h b/openhantek/src/configpages.h index 4779a17..4ca14d4 100644 --- a/openhantek/src/configpages.h +++ b/openhantek/src/configpages.h @@ -31,7 +31,7 @@ #include "dsowidget.h" -#include "constants.h" +#include "dso.h" class ColorBox; diff --git a/openhantek/src/dataanalyzer.cpp b/openhantek/src/dataanalyzer.cpp index 5723f11..5e7100c 100644 --- a/openhantek/src/dataanalyzer.cpp +++ b/openhantek/src/dataanalyzer.cpp @@ -72,6 +72,12 @@ const AnalyzedData *DataAnalyzer::data(int channel) const { return this->analyzedData[channel]; } +/// \brief Returns the sample count of the analyzed data. +/// \return The maximum sample count of the last analyzed data. +unsigned long int DataAnalyzer::sampleCount() { + return this->maxSamples; +} + /// \brief Returns the mutex for the data. /// \return Mutex for the analyzed data. QMutex *DataAnalyzer::mutex() const { @@ -82,6 +88,8 @@ QMutex *DataAnalyzer::mutex() const { void DataAnalyzer::run() { this->analyzedDataMutex->lock(); + unsigned long int maxSamples = 0; + // Adapt the number of channels for analyzed data for(int channel = this->analyzedData.count(); channel < this->settings->scope.voltage.count(); channel++) { this->analyzedData.append(new AnalyzedData); @@ -109,10 +117,13 @@ void DataAnalyzer::run() { this->analyzedData[channel]->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; unsigned int size; - if(channel < this->settings->scope.physicalChannels) + if(channel < this->settings->scope.physicalChannels) { size = this->waitingDataSize[channel]; + if(size > maxSamples) + maxSamples = size; + } else - size = this->waitingDataSize[0]; + size = maxSamples; // Reallocate memory for samples if the sample count has changed if(this->analyzedData[channel]->samples.voltage.count != size) { this->analyzedData[channel]->samples.voltage.count = size; @@ -356,6 +367,9 @@ void DataAnalyzer::run() { } } + this->maxSamples = maxSamples; + emit(analyzed(maxSamples)); + this->analyzedDataMutex->unlock(); } diff --git a/openhantek/src/dataanalyzer.h b/openhantek/src/dataanalyzer.h index a55507c..0a08c2e 100644 --- a/openhantek/src/dataanalyzer.h +++ b/openhantek/src/dataanalyzer.h @@ -30,7 +30,7 @@ #include -#include "constants.h" +#include "dso.h" #include "helper.h" @@ -78,6 +78,7 @@ class DataAnalyzer : public QThread { ~DataAnalyzer(); const AnalyzedData *data(int channel) const; + unsigned long int sampleCount(); QMutex *mutex() const; protected: @@ -88,7 +89,8 @@ class DataAnalyzer : public QThread { QList analyzedData; ///< The analyzed data for each channel QMutex *analyzedDataMutex; ///< A mutex for the analyzed data of all channels - unsigned int lastBufferSize; ///< The buffer size of the previously analyzed data + unsigned long int lastBufferSize; ///< The buffer size of the previously analyzed data + unsigned long int maxSamples; ///< The maximum buffer size of the analyzed data Dso::WindowFunction lastWindow; ///< The previously used dft window function double *window; ///< The array for the dft window factors @@ -99,6 +101,9 @@ class DataAnalyzer : public QThread { public slots: void analyze(const QList *data, const QList *size, double samplerate, QMutex *mutex); + + signals: + void analyzed(unsigned int samples); ///< The data with that much samples has been analyzed }; #endif diff --git a/openhantek/src/dockwindows.cpp b/openhantek/src/dockwindows.cpp index 4b962fe..8ce57ae 100644 --- a/openhantek/src/dockwindows.cpp +++ b/openhantek/src/dockwindows.cpp @@ -58,7 +58,6 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo << 1e6 << 2e6 << 5e6 << 1e7; ///< Frequencybase steps in Hz/div for(QList::iterator frequencybase = this->frequencybaseSteps.begin(); frequencybase != this->frequencybaseSteps.end(); ++frequencybase) this->frequencybaseStrings << Helper::valueToString(*frequencybase, Helper::UNIT_HERTZ, 0); - this->formatStrings << tr("T - Y") << tr("X - Y"); // Initialize elements this->timebaseLabel = new QLabel(tr("Timebase")); @@ -71,7 +70,8 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo this->formatLabel = new QLabel(tr("Format")); this->formatComboBox = new QComboBox(); - this->formatComboBox->addItems(this->formatStrings); + for(int format = Dso::GRAPHFORMAT_TY; format < Dso::GRAPHFORMAT_COUNT; format++) + this->formatComboBox->addItem(Dso::graphFormatString((Dso::GraphFormat) format)); this->dockLayout = new QGridLayout(); this->dockLayout->setColumnMinimumWidth(0, 64); @@ -181,20 +181,20 @@ TriggerDock::TriggerDock(DsoSettings *settings, const QStringList *specialTrigge this->settings = settings; // Initialize lists for comboboxes - this->modeStrings << tr("Auto") << tr("Normal") << tr("Single"); for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; channel++) this->sourceStandardStrings << tr("CH%1").arg(channel + 1); this->sourceSpecialStrings << *specialTriggers; - this->slopeStrings << QString::fromUtf8("\u2197") << QString::fromUtf8("\u2198"); // Initialize elements this->modeLabel = new QLabel(tr("Mode")); this->modeComboBox = new QComboBox(); - this->modeComboBox->addItems(this->modeStrings); + for(int mode = Dso::TRIGGERMODE_AUTO; mode < Dso::TRIGGERMODE_COUNT; mode++) + this->modeComboBox->addItem(Dso::triggerModeString((Dso::TriggerMode) mode)); this->slopeLabel = new QLabel(tr("Slope")); this->slopeComboBox = new QComboBox(); - this->slopeComboBox->addItems(this->slopeStrings); + for(int slope = Dso::SLOPE_POSITIVE; slope < Dso::SLOPE_COUNT; slope++) + this->slopeComboBox->addItem(Dso::slopeString((Dso::Slope) slope)); this->sourceLabel = new QLabel(tr("Source")); this->sourceComboBox = new QComboBox(); @@ -446,9 +446,11 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags this->settings = settings; // Initialize lists for comboboxes - this->couplingStrings << tr("AC") << tr("DC") << tr("GND"); + for(int coupling = Dso::COUPLING_AC; coupling < Dso::COUPLING_COUNT; coupling++) + this->couplingStrings.append(Dso::couplingString((Dso::Coupling) coupling)); - this->modeStrings << tr("CH1 + CH2") << tr("CH1 - CH2") << tr("CH2 - CH1"); + for(int mode = Dso::MATHMODE_1ADD2; mode < Dso::MATHMODE_COUNT; mode++) + this->modeStrings.append(Dso::mathModeString((Dso::MathMode) mode)); this->gainSteps << 1e-2 << 2e-2 << 5e-2 << 1e-1 << 2e-1 << 5e-1 << 1e0 << 2e0 << 5e0; ///< Voltage steps in V/div diff --git a/openhantek/src/dockwindows.h b/openhantek/src/dockwindows.h index 9387249..9ecccf6 100644 --- a/openhantek/src/dockwindows.h +++ b/openhantek/src/dockwindows.h @@ -31,7 +31,7 @@ #include -#include "constants.h" +#include "dso.h" #include "settings.h" diff --git a/openhantek/src/dso.cpp b/openhantek/src/dso.cpp new file mode 100644 index 0000000..db44acf --- /dev/null +++ b/openhantek/src/dso.cpp @@ -0,0 +1,177 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// OpenHantek +// dso.cpp +// +// Copyright (C) 2010 Oliver Haag +// oliver.haag@gmail.com +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +//////////////////////////////////////////////////////////////////////////////// + + +#include + + +#include "dso.h" + + +namespace Dso { + /// \brief Return string representation of the given channel mode. + /// \param mode The #ChannelMode that should be returned as string. + /// \return The string that should be used in labels etc., empty when invalid. + QString channelModeString(ChannelMode mode) { + switch(mode) { + case CHANNELMODE_VOLTAGE: + return QApplication::tr("Voltage"); + case CHANNELMODE_SPECTRUM: + return QApplication::tr("Spectrum"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given graph format. + /// \param format The #GraphFormat that should be returned as string. + /// \return The string that should be used in labels etc. + QString graphFormatString(GraphFormat format) { + switch(format) { + case GRAPHFORMAT_TY: + return QApplication::tr("T - Y"); + case GRAPHFORMAT_XY: + return QApplication::tr("X - Y"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given channel coupling. + /// \param coupling The #Coupling that should be returned as string. + /// \return The string that should be used in labels etc. + QString couplingString(Coupling coupling) { + switch(coupling) { + case COUPLING_AC: + return QApplication::tr("AC"); + case COUPLING_DC: + return QApplication::tr("DC"); + case COUPLING_GND: + return QApplication::tr("GND"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given math mode. + /// \param mode The #MathMode that should be returned as string. + /// \return The string that should be used in labels etc. + QString mathModeString(MathMode mode) { + switch(mode) { + case MATHMODE_1ADD2: + return QApplication::tr("CH1 + CH2"); + case MATHMODE_1SUB2: + return QApplication::tr("CH1 - CH2"); + case MATHMODE_2SUB1: + return QApplication::tr("CH2 - CH1"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given trigger mode. + /// \param mode The #TriggerMode that should be returned as string. + /// \return The string that should be used in labels etc. + QString triggerModeString(TriggerMode mode) { + switch(mode) { + case TRIGGERMODE_AUTO: + return QApplication::tr("Auto"); + case TRIGGERMODE_NORMAL: + return QApplication::tr("Normal"); + case TRIGGERMODE_SINGLE: + return QApplication::tr("Single"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given trigger slope. + /// \param slope The #Slope that should be returned as string. + /// \return The string that should be used in labels etc. + QString slopeString(Slope slope) { + switch(slope) { + case SLOPE_POSITIVE: + return QString::fromUtf8("\u2197"); + case SLOPE_NEGATIVE: + return QString::fromUtf8("\u2198"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given dft window function. + /// \param window The #WindowFunction that should be returned as string. + /// \return The string that should be used in labels etc. + QString windowFunctionString(WindowFunction window) { + switch(window) { + case WINDOW_RECTANGULAR: + return QApplication::tr("Rectangular"); + case WINDOW_HAMMING: + return QApplication::tr("Hamming"); + case WINDOW_HANN: + return QApplication::tr("Hann"); + case WINDOW_COSINE: + return QApplication::tr("Cosine"); + case WINDOW_LANCZOS: + return QApplication::tr("Lanczos"); + case WINDOW_BARTLETT: + return QApplication::tr("Bartlett"); + case WINDOW_TRIANGULAR: + return QApplication::tr("Triangular"); + case WINDOW_GAUSS: + return QApplication::tr("Gauss"); + case WINDOW_BARTLETTHANN: + return QApplication::tr("Bartlett-Hann"); + case WINDOW_BLACKMAN: + return QApplication::tr("Blackman"); + //case WINDOW_KAISER: + // return QApplication::tr("Kaiser"); + case WINDOW_NUTTALL: + return QApplication::tr("Nuttall"); + case WINDOW_BLACKMANHARRIS: + return QApplication::tr("Blackman-Harris"); + case WINDOW_BLACKMANNUTTALL: + return QApplication::tr("Blackman-Nuttall"); + case WINDOW_FLATTOP: + return QApplication::tr("Flat top"); + default: + return QString(); + } + } + + /// \brief Return string representation of the given graph interpolation mode. + /// \param interpolation The #InterpolationMode that should be returned as string. + /// \return The string that should be used in labels etc. + QString interpolationModeString(InterpolationMode interpolation) { + switch(interpolation) { + case INTERPOLATION_OFF: + return QApplication::tr("Off"); + case INTERPOLATION_LINEAR: + return QApplication::tr("Linear"); + case INTERPOLATION_SINC: + return QApplication::tr("Sinc"); + default: + return QString(); + } + } +} diff --git a/openhantek/src/constants.h b/openhantek/src/dso.h index 8482931..9b3b773 100644 --- a/openhantek/src/constants.h +++ b/openhantek/src/dso.h @@ -1,8 +1,8 @@ //////////////////////////////////////////////////////////////////////////////// // // OpenHantek -/// \file constants.h -/// \brief Defines global constants and enums. +/// \file dso.h +/// \brief Defines various constants, enums and functions for DSO settings. // // Copyright (C) 2010 Oliver Haag // oliver.haag@gmail.com @@ -23,20 +23,22 @@ //////////////////////////////////////////////////////////////////////////////// -#ifndef CONSTANTS_H -#define CONSTANTS_H +#ifndef DSO_H +#define DSO_H + + +#include #define MARKER_COUNT 2 ///< Number of markers -//#define PHYS_CHANNEL_COUNT 2 ///< Number of real channels //////////////////////////////////////////////////////////////////////////////// -/// \namespace Dso constants.h -/// \brief All DSO specific enums for different modes and so on. +/// \namespace Dso dso.h +/// \brief All DSO specific things for different modes and so on. namespace Dso { ////////////////////////////////////////////////////////////////////////////// - /// \enum ChannelMode constants.h + /// \enum ChannelMode dso.h /// \brief The channel display modes. enum ChannelMode { CHANNELMODE_VOLTAGE, ///< Standard voltage view @@ -45,50 +47,55 @@ namespace Dso { }; ////////////////////////////////////////////////////////////////////////////// - /// \enum GraphFormat constants.h + /// \enum GraphFormat dso.h /// \brief The possible viewing formats for the graphs on the scope. enum GraphFormat { GRAPHFORMAT_TY, ///< The standard mode - GRAPHFORMAT_XY ///< CH1 on X-axis, CH2 on Y-axis + GRAPHFORMAT_XY, ///< CH1 on X-axis, CH2 on Y-axis + GRAPHFORMAT_COUNT ///< The total number of formats }; ////////////////////////////////////////////////////////////////////////////// - /// \enum Coupling constants.h + /// \enum Coupling dso.h /// \brief The coupling modes for the channels. enum Coupling { COUPLING_AC, ///< Offset filtered out by condensator COUPLING_DC, ///< No filtering - COUPLING_GND ///< Channel is grounded + COUPLING_GND, ///< Channel is grounded + COUPLING_COUNT ///< The total number of coupling modes }; ////////////////////////////////////////////////////////////////////////////// - /// \enum Slope constants.h - /// \brief The slope that causes a trigger. - enum Slope { - SLOPE_POSITIVE, ///< From lower to higher voltage - SLOPE_NEGATIVE ///< From higher to lower voltage + /// \enum MathMode dso.h + /// \brief The different math modes for the math-channel. + enum MathMode { + MATHMODE_1ADD2, ///< Add the values of the channels + MATHMODE_1SUB2, ///< Subtract CH2 from CH1 + MATHMODE_2SUB1, ///< Subtract CH1 from CH2 + MATHMODE_COUNT ///< The total number of math modes }; ////////////////////////////////////////////////////////////////////////////// - /// \enum TriggerMode constants.h + /// \enum TriggerMode dso.h /// \brief The different triggering modes. enum TriggerMode { TRIGGERMODE_AUTO, ///< Automatic without trigger event TRIGGERMODE_NORMAL, ///< Normal mode - TRIGGERMODE_SINGLE ///< Stop after the first trigger event + TRIGGERMODE_SINGLE, ///< Stop after the first trigger event + TRIGGERMODE_COUNT ///< The total number of modes }; ////////////////////////////////////////////////////////////////////////////// - /// \enum MathMode constants.h - /// \brief The different math modes for the math-channel. - enum MathMode { - MATHMODE_1ADD2, ///< Add the values of the channels - MATHMODE_1SUB2, ///< Subtract CH2 from CH1 - MATHMODE_2SUB1 ///< Subtract CH1 from CH2 + /// \enum Slope dso.h + /// \brief The slope that causes a trigger. + enum Slope { + SLOPE_POSITIVE, ///< From lower to higher voltage + SLOPE_NEGATIVE, ///< From higher to lower voltage + SLOPE_COUNT ///< Total number of trigger slopes }; ////////////////////////////////////////////////////////////////////////////// - /// \enum WindowFunction constants.h + /// \enum WindowFunction dso.h /// \brief The supported window functions. /// These are needed for spectrum analysis and are applied to the sample values /// before calculating the DFT. @@ -107,18 +114,29 @@ namespace Dso { WINDOW_NUTTALL, ///< Nuttall window, cont. first deriv. WINDOW_BLACKMANHARRIS, ///< Blackman-Harris window WINDOW_BLACKMANNUTTALL, ///< Blackman-Nuttall window - WINDOW_FLATTOP ///< Flat top window + WINDOW_FLATTOP, ///< Flat top window + WINDOW_COUNT ///< Total number of window functions }; + + //////////////////////////////////////////////////////////////////////////////// + /// \enum InterpolationMode dso.h + /// \brief The different interpolation modes for the graphs. + enum InterpolationMode { + INTERPOLATION_OFF = 0, ///< Just dots for each sample + INTERPOLATION_LINEAR, ///< Sample dots connected by lines + INTERPOLATION_SINC, ///< Smooth graph through the dots + INTERPOLATION_COUNT ///< Total number of interpolation modes + }; + + QString channelModeString(ChannelMode mode); + QString graphFormatString(GraphFormat format); + QString couplingString(Coupling coupling); + QString mathModeString(MathMode mode); + QString triggerModeString(TriggerMode mode); + QString slopeString(Slope slope); + QString windowFunctionString(WindowFunction window); + QString interpolationModeString(InterpolationMode interpolation); } -//////////////////////////////////////////////////////////////////////////////// -/// \enum GlInterpolationMode constants.h -/// \brief The different interpolation modes for the graphs. -enum GlInterpolationMode { - INTERPOLATION_OFF = 0, ///< Just dots for each sample - INTERPOLATION_LINEAR, ///< Sample dots connected by lines - INTERPOLATION_SINC ///< Smooth graph through the dots -}; - #endif diff --git a/openhantek/src/dsocontrol.h b/openhantek/src/dsocontrol.h index 72ecf9f..9ac702e 100644 --- a/openhantek/src/dsocontrol.h +++ b/openhantek/src/dsocontrol.h @@ -31,7 +31,7 @@ #include -#include "constants.h" +#include "dso.h" #include "helper.h" @@ -72,7 +72,7 @@ class DsoControl : public QThread { virtual void stopSampling(); virtual unsigned long int setSamplerate(unsigned long int samplerate) = 0; ///< Set the samplerate that should be met - virtual double setBufferSize(unsigned int size) = 0; ///< Set the needed buffer size + virtual unsigned long int setBufferSize(unsigned long int size) = 0; ///< Set the needed buffer size virtual int setTriggerMode(Dso::TriggerMode mode) = 0; ///< Set the trigger mode virtual int setTriggerSource(bool special, unsigned int id) = 0; ///< Set the trigger source diff --git a/openhantek/src/dsowidget.cpp b/openhantek/src/dsowidget.cpp index 52ab8ea..b894af7 100644 --- a/openhantek/src/dsowidget.cpp +++ b/openhantek/src/dsowidget.cpp @@ -31,6 +31,7 @@ #include "dsowidget.h" #include "dataanalyzer.h" +#include "dso.h" #include "exporter.h" #include "glscope.h" #include "helper.h" @@ -224,7 +225,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget // Apply settings and update measured values this->updateTriggerDetails(); - this->updateBufferSize(); + this->updateBufferSize(this->settings->scope.horizontal.samples); this->updateFrequencybase(); this->updateTimebase(); this->updateZoom(this->settings->view.zoom); @@ -244,7 +245,8 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget this->connect(this->markerSlider, SIGNAL(valueChanged(int, double)), this->zoomScope, SLOT(updateGL())); // Connect other signals - this->connect(this->dataAnalyzer, SIGNAL(finished()), this, SLOT(dataAnalyzed())); + this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(dataAnalyzed())); + this->connect(this->dataAnalyzer, SIGNAL(analyzed(unsigned int)), this, SLOT(updateBufferSize(unsigned int))); } /// \brief Stops the oscilloscope thread and the timer. @@ -303,15 +305,9 @@ void DsoWidget::updateTriggerDetails() { QPalette tablePalette = this->palette(); tablePalette.setColor(QPalette::WindowText, this->settings->view.color.screen.voltage[this->settings->scope.trigger.source]); this->settingsTriggerLabel->setPalette(tablePalette); - QString slopeString; - if(this->settings->scope.trigger.slope == Dso::SLOPE_POSITIVE) - slopeString = QString::fromUtf8("\u2197"); - else - slopeString = QString::fromUtf8("\u2198"); - QString levelString; - levelString = Helper::valueToString(this->settings->scope.voltage[this->settings->scope.trigger.source].trigger, Helper::UNIT_VOLTS, 3); + QString levelString = Helper::valueToString(this->settings->scope.voltage[this->settings->scope.trigger.source].trigger, Helper::UNIT_VOLTS, 3); QString pretriggerString = tr("%L1%").arg((int) (this->settings->scope.trigger.position * 100 + 0.5)); - this->settingsTriggerLabel->setText(tr("%1 %2 %3 %4").arg(this->settings->scope.voltage[this->settings->scope.trigger.source].name, slopeString, levelString, pretriggerString)); + this->settingsTriggerLabel->setText(tr("%1 %2 %3 %4").arg(this->settings->scope.voltage[this->settings->scope.trigger.source].name, Dso::slopeString(this->settings->scope.trigger.slope), levelString, pretriggerString)); /// \todo This won't work for special trigger sources } @@ -394,36 +390,14 @@ void DsoWidget::updateVoltageCoupling(unsigned int channel) { if(channel >= (unsigned int) this->settings->scope.voltage.count()) return; - if(this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) { - switch(this->settings->scope.voltage[channel].misc) { - case Dso::COUPLING_AC: - this->measurementMiscLabel[channel]->setText(tr("AC")); - break; - case Dso::COUPLING_DC: - this->measurementMiscLabel[channel]->setText(tr("DC")); - break; - case Dso::COUPLING_GND: - this->measurementMiscLabel[channel]->setText(tr("GND")); - break; - } - } + if(this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) + this->measurementMiscLabel[channel]->setText(Dso::couplingString((Dso::Coupling) this->settings->scope.voltage[channel].misc)); } /// \brief Handles modeChanged signal from the voltage dock. void DsoWidget::updateMathMode() { - if(this->settings->scope.voltage[this->settings->scope.physicalChannels].used || this->settings->scope.spectrum[this->settings->scope.physicalChannels].used) { - switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) { - case Dso::MATHMODE_1ADD2: - this->measurementMiscLabel[this->settings->scope.physicalChannels]->setText(tr("CH1 + CH2")); - break; - case Dso::MATHMODE_1SUB2: - this->measurementMiscLabel[this->settings->scope.physicalChannels]->setText(tr("CH1 - CH2")); - break; - case Dso::MATHMODE_2SUB1: - this->measurementMiscLabel[this->settings->scope.physicalChannels]->setText(tr("CH2 - CH1")); - break; - } - } + if(this->settings->scope.voltage[this->settings->scope.physicalChannels].used || this->settings->scope.spectrum[this->settings->scope.physicalChannels].used) + this->measurementMiscLabel[this->settings->scope.physicalChannels]->setText(Dso::mathModeString((Dso::MathMode) this->settings->scope.voltage[this->settings->scope.physicalChannels].misc)); } /// \brief Handles gainChanged signal from the voltage dock. @@ -453,8 +427,8 @@ void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { } /// \brief Change the buffer size. -void DsoWidget::updateBufferSize() { - this->settingsBufferLabel->setText(tr("%1 S").arg(this->settings->scope.horizontal.samples)); +void DsoWidget::updateBufferSize(unsigned int size) { + this->settingsBufferLabel->setText(tr("%1 S").arg(size)); } /// \brief Export the oscilloscope screen to a file. diff --git a/openhantek/src/dsowidget.h b/openhantek/src/dsowidget.h index da6881a..4acf38a 100644 --- a/openhantek/src/dsowidget.h +++ b/openhantek/src/dsowidget.h @@ -116,7 +116,7 @@ class DsoWidget : public QWidget { void updateVoltageUsed(unsigned int channel, bool used); // Menus - void updateBufferSize(); + void updateBufferSize(unsigned int size); // Export bool exportAs(); diff --git a/openhantek/src/exporter.cpp b/openhantek/src/exporter.cpp index a9622fa..5a5aa9c 100644 --- a/openhantek/src/exporter.cpp +++ b/openhantek/src/exporter.cpp @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -32,7 +33,8 @@ #include "exporter.h" #include "dataanalyzer.h" -#include "glscope.h" +#include "dso.h" +#include "glgenerator.h" #include "helper.h" #include "settings.h" @@ -84,7 +86,7 @@ bool Exporter::doExport() { if(this->format < EXPORT_FORMAT_IMAGE) { // We need a QPrinter for printing, pdf- and ps-export paintDevice = new QPrinter(QPrinter::HighResolution); - ((QPrinter *) paintDevice)->setOrientation(QPrinter::Landscape); + ((QPrinter *) paintDevice)->setOrientation(this->settings->view.zoom ? QPrinter::Portrait : QPrinter::Landscape); ((QPrinter *) paintDevice)->setPageMargins(20, 20, 20, 20, QPrinter::Millimeter); if(this->format == EXPORT_FORMAT_PRINTER) { @@ -113,39 +115,69 @@ bool Exporter::doExport() { QFont font; QFontMetrics fontMetrics(font, paintDevice); double lineHeight = fontMetrics.height(); - double valueColumnWidth = (double) (paintDevice->width() - lineHeight * 4) / 2; painter.setBrush(Qt::SolidPattern); + this->dataAnalyzer->mutex()->lock(); + + // Draw the settings table + double stretchBase = (double) (paintDevice->width() - lineHeight * 10) / 4; + + // Print trigger details + painter.setPen(colorValues->voltage[this->settings->scope.trigger.source]); + QString levelString = Helper::valueToString(this->settings->scope.voltage[this->settings->scope.trigger.source].trigger, Helper::UNIT_VOLTS, 3); + QString pretriggerString = tr("%L1%").arg((int) (this->settings->scope.trigger.position * 100 + 0.5)); + painter.drawText(QRectF(0, 0, lineHeight * 10, lineHeight), tr("%1 %2 %3 %4").arg(this->settings->scope.voltage[this->settings->scope.trigger.source].name, Dso::slopeString(this->settings->scope.trigger.slope), levelString, pretriggerString)); + + // Print sample count + painter.setPen(colorValues->text); + painter.drawText(QRectF(lineHeight * 10, 0, stretchBase, lineHeight), tr("%1 S").arg(this->dataAnalyzer->sampleCount()), QTextOption(Qt::AlignRight)); + // Print samplerate + painter.drawText(QRectF(lineHeight * 10 + stretchBase, 0, stretchBase, lineHeight), Helper::valueToString(this->settings->scope.horizontal.samplerate, Helper::UNIT_SAMPLES) + tr("/s"), QTextOption(Qt::AlignRight)); + // Print timebase + painter.drawText(QRectF(lineHeight * 10 + stretchBase * 2, 0, stretchBase, lineHeight), Helper::valueToString(this->settings->scope.horizontal.timebase, Helper::UNIT_SECONDS, 0) + tr("/div"), QTextOption(Qt::AlignRight)); + // Print frequencybase + painter.drawText(QRectF(lineHeight * 10 + stretchBase * 3, 0, stretchBase, lineHeight), Helper::valueToString(this->settings->scope.horizontal.frequencybase, Helper::UNIT_HERTZ, 0) + tr("/div"), QTextOption(Qt::AlignRight)); + + // Draw the measurement table + stretchBase = (double) (paintDevice->width() - lineHeight * 6) / 10; int channelCount = 0; for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { - if(this->settings->scope.voltage[channel].used) { + if(this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) { channelCount++; double top = (double) paintDevice->height() - channelCount * lineHeight; - painter.setPen(colorValues->voltage[channel]); - // Print label + painter.setPen(colorValues->voltage[channel]); painter.drawText(QRectF(0, top, lineHeight * 4, lineHeight), this->settings->scope.voltage[channel].name); + // Print coupling/math mode + if((unsigned int) channel < this->settings->scope.physicalChannels) + painter.drawText(QRectF(lineHeight * 4, top, lineHeight * 2, lineHeight), Dso::couplingString((Dso::Coupling) this->settings->scope.voltage[channel].misc)); + else + painter.drawText(QRectF(lineHeight * 4, top, lineHeight * 2, lineHeight), Dso::mathModeString((Dso::MathMode) this->settings->scope.voltage[channel].misc)); + + // Print voltage gain + painter.drawText(QRectF(lineHeight * 6, top, stretchBase * 2, lineHeight), Helper::valueToString(this->settings->scope.voltage[channel].gain, Helper::UNIT_VOLTS, 0) + tr("/div"), QTextOption(Qt::AlignRight)); + // Print spectrum magnitude + painter.setPen(colorValues->spectrum[channel]); + painter.drawText(QRectF(lineHeight * 6 + stretchBase * 2, top, stretchBase * 2, lineHeight), Helper::valueToString(this->settings->scope.spectrum[channel].magnitude, Helper::UNIT_DECIBEL, 0) + tr("/div"), QTextOption(Qt::AlignRight)); // Amplitude string representation (4 significant digits) - painter.drawText(QRectF(lineHeight * 4, top, valueColumnWidth, lineHeight), Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4), QTextOption(Qt::AlignRight)); + painter.setPen(colorValues->text); + painter.drawText(QRectF(lineHeight * 6 + stretchBase * 4, top, stretchBase * 3, lineHeight), Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4), QTextOption(Qt::AlignRight)); // Frequency string representation (5 significant digits) - painter.drawText(QRectF(lineHeight * 4 + valueColumnWidth, top, valueColumnWidth, lineHeight), Helper::valueToString(this->dataAnalyzer->data(channel)->frequency, Helper::UNIT_HERTZ, 5), QTextOption(Qt::AlignRight)); + painter.drawText(QRectF(lineHeight * 6 + stretchBase * 7, top, stretchBase * 3, lineHeight), Helper::valueToString(this->dataAnalyzer->data(channel)->frequency, Helper::UNIT_HERTZ, 5), QTextOption(Qt::AlignRight)); } } // Set DIVS_TIME x DIVS_VOLTAGE matrix for oscillograph - double screenHeight = (double) paintDevice->height() - (channelCount + 1) * lineHeight; - painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME, 0, 0, -(screenHeight - 1) / DIVS_VOLTAGE, (double) (paintDevice->width() - 1) / 2, (screenHeight - 1) / 2), false); - + double screenHeight = (double) paintDevice->height() - (channelCount + 3) * lineHeight; + painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME, 0, 0, -(screenHeight - 1) / DIVS_VOLTAGE, (double) (paintDevice->width() - 1) / 2, (screenHeight - 1) / 2 + lineHeight * 2), false); // Draw the graphs painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(Qt::NoBrush); - this->dataAnalyzer->mutex()->lock(); - switch(this->settings->scope.horizontal.format) { case Dso::GRAPHFORMAT_TY: // Add graphs for channels @@ -191,6 +223,9 @@ bool Exporter::doExport() { case Dso::GRAPHFORMAT_XY: break; + + default: + break; } this->dataAnalyzer->mutex()->unlock(); diff --git a/openhantek/src/glgenerator.cpp b/openhantek/src/glgenerator.cpp index 82fc292..7b32ff2 100644 --- a/openhantek/src/glgenerator.cpp +++ b/openhantek/src/glgenerator.cpp @@ -223,6 +223,9 @@ void GlGenerator::generateGraphs() { this->vaChannel[Dso::CHANNELMODE_SPECTRUM][channel][index]->setSize(0); } break; + + default: + break; } this->dataAnalyzer->mutex()->unlock(); diff --git a/openhantek/src/glgenerator.h b/openhantek/src/glgenerator.h index aa037c0..e572623 100644 --- a/openhantek/src/glgenerator.h +++ b/openhantek/src/glgenerator.h @@ -34,7 +34,7 @@ #include -#include "constants.h" +#include "dso.h" #define DIVS_TIME 10.0 ///< Number of horizontal screen divs diff --git a/openhantek/src/glscope.cpp b/openhantek/src/glscope.cpp index da6799b..8e20e18 100644 --- a/openhantek/src/glscope.cpp +++ b/openhantek/src/glscope.cpp @@ -113,7 +113,7 @@ void GlScope::paintGL() { else this->qglColor(this->settings->view.color.screen.spectrum[channel].darker(fadingFactor[index])); glVertexPointer(2, GL_FLOAT, 0, this->generator->vaChannel[mode][channel][index]->data); - glDrawArrays((this->settings->view.interpolation == INTERPOLATION_OFF) ? GL_POINTS : GL_LINE_STRIP, 0, this->generator->vaChannel[mode][channel][index]->getSize() / 2); + glDrawArrays((this->settings->view.interpolation == Dso::INTERPOLATION_OFF) ? GL_POINTS : GL_LINE_STRIP, 0, this->generator->vaChannel[mode][channel][index]->getSize() / 2); } } } @@ -130,12 +130,15 @@ void GlScope::paintGL() { if(this->generator->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->data) { this->qglColor(this->settings->view.color.screen.voltage[channel].darker(fadingFactor[index])); glVertexPointer(2, GL_FLOAT, 0, this->generator->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->data); - glDrawArrays((this->settings->view.interpolation == INTERPOLATION_OFF) ? GL_POINTS : GL_LINE_STRIP, 0, this->generator->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->getSize() / 2); + glDrawArrays((this->settings->view.interpolation == Dso::INTERPOLATION_OFF) ? GL_POINTS : GL_LINE_STRIP, 0, this->generator->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->getSize() / 2); } } } } break; + + default: + break; } delete[] fadingFactor; diff --git a/openhantek/src/glscope.h b/openhantek/src/glscope.h index 237dc64..ce994d8 100644 --- a/openhantek/src/glscope.h +++ b/openhantek/src/glscope.h @@ -33,7 +33,7 @@ #include "glgenerator.h" -#include "constants.h" +#include "dso.h" class DataAnalyzer; diff --git a/openhantek/src/hantek/control.cpp b/openhantek/src/hantek/control.cpp index 9cf090e..0dea9f1 100644 --- a/openhantek/src/hantek/control.cpp +++ b/openhantek/src/hantek/control.cpp @@ -86,7 +86,7 @@ namespace Hantek { this->setSamplerate(1e6); this->setBufferSize(BUFFER_SMALL); this->setTriggerMode(Dso::TRIGGERMODE_NORMAL); - this->setTriggerPosition(0.5); + this->setTriggerPosition(5e3 / this->samplerateSteps[this->samplerate]); this->setTriggerSlope(Dso::SLOPE_POSITIVE); this->setTriggerSource(false, 0); @@ -411,19 +411,31 @@ namespace Hantek { return 0; } - /// \brief Sets the size of the oscilloscopes sample buffer. + /// \brief Sets the size of the sample buffer without updating dependencies. /// \param size The buffer size that should be met (S). /// \return The buffer size that has been set. - double Control::setBufferSize(unsigned int size) { + unsigned long int Control::updateBufferSize(unsigned long int size) { unsigned int sizeId = (size <= BUFFER_SMALL) ? 1 : 2; // SetTriggerAndSamplerate bulk command for samplerate ((CommandSetTriggerAndSamplerate *) this->command[COMMAND_SETTRIGGERANDSAMPLERATE])->setSampleSize(sizeId); this->commandPending[COMMAND_SETTRIGGERANDSAMPLERATE] = true; + this->bufferSize = (sizeId == 1) ? BUFFER_SMALL : BUFFER_LARGE; + + return this->bufferSize; + } + + /// \brief Sets the size of the oscilloscopes sample buffer. + /// \param size The buffer size that should be met (S). + /// \return The buffer size that has been set. + unsigned long int Control::setBufferSize(unsigned long int size) { + this->updateBufferSize(size); + + this->setTriggerPosition(this->triggerPosition); this->setSamplerate(this->samplerateSteps[this->samplerate]); + this->setTriggerSlope(this->triggerSlope); - this->bufferSize = (sizeId == 1) ? BUFFER_SMALL : BUFFER_LARGE; return this->bufferSize; } @@ -441,23 +453,24 @@ namespace Hantek { samplerateId = SAMPLERATE_50MS; // The values that are understood by the oscilloscope + /// \todo Check large buffer values, seem to be crap static const unsigned char valueFastSmall[5] = {0, 1, 2, 3, 4}; static const unsigned char valueFastLarge[5] = {0, 0, 0, 2, 3}; - static const unsigned short int valueSlowSmall[13] = {0xffff, 0xfffc, 0xfff7, 0xffe8, 0xffce, 0xff9c, 0xff07, 0xfe0d, 0xfc19, 0xf63d, 0xec79, 0xd8f1, 0xffed}; - static const unsigned short int valueSlowLarge[13] = {0xffff, 0x0000, 0xfffc, 0xfff7, 0xffe8, 0xffce, 0xff9d, 0xff07, 0xfe0d, 0xfc19, 0xf63d, 0xec79, 0xffed}; /// \todo Check those values + static const unsigned short int valueSlowSmall[13] = {0xfffe, 0xfffc, 0xfff7, 0xffe8, 0xffce, 0xff9c, 0xff07, 0xfe0d, 0xfc19, 0xf63d, 0xec79, 0xd8f1, 0xffed}; + static const unsigned short int valueSlowLarge[13] = {0xffff, 0x0000, 0xfffc, 0xfff7, 0xffe8, 0xffce, 0xff9d, 0xff07, 0xfe0d, 0xfc19, 0xf63d, 0xec79, 0xffed}; // SetTriggerAndSamplerate bulk command for samplerate CommandSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (CommandSetTriggerAndSamplerate *) this->command[COMMAND_SETTRIGGERANDSAMPLERATE]; // Set SamplerateFast bits for high sampling rates if(samplerateId <= SAMPLERATE_5MS) - commandSetTriggerAndSamplerate->setSamplerateFast(this->bufferSize == BUFFER_SMALL ? valueFastSmall[samplerateId] : valueFastLarge[samplerateId]); + commandSetTriggerAndSamplerate->setSamplerateFast(this->bufferSize == BUFFER_SMALL ? valueFastSmall[samplerateId - SAMPLERATE_100MS] : valueFastLarge[samplerateId - SAMPLERATE_100MS]); else commandSetTriggerAndSamplerate->setSamplerateFast(4); // Set normal Samplerate value for lower sampling rates - if(samplerateId >= SAMPLERATE_2_5MS) - commandSetTriggerAndSamplerate->setSamplerate(this->bufferSize == BUFFER_SMALL ? valueSlowSmall[samplerateId - SAMPLERATE_2_5MS] : valueSlowLarge[samplerateId - SAMPLERATE_2_5MS]); + if(samplerateId >= SAMPLERATE_10MS) + commandSetTriggerAndSamplerate->setSamplerate(this->bufferSize == BUFFER_SMALL ? valueSlowSmall[samplerateId - SAMPLERATE_10MS] : valueSlowLarge[samplerateId - SAMPLERATE_10MS]); else commandSetTriggerAndSamplerate->setSamplerate(0x0000); @@ -467,6 +480,9 @@ namespace Hantek { this->commandPending[COMMAND_SETTRIGGERANDSAMPLERATE] = true; this->samplerate = (Samplerate) samplerateId; + + this->updateBufferSize(this->bufferSize); + this->setTriggerSlope(this->triggerSlope); return this->samplerateSteps[samplerateId]; } @@ -648,7 +664,7 @@ namespace Hantek { return -1; // SetTriggerAndSamplerate bulk command for trigger position - ((CommandSetTriggerAndSamplerate *) this->command[COMMAND_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); + ((CommandSetTriggerAndSamplerate *) this->command[COMMAND_SETTRIGGERANDSAMPLERATE])->setTriggerSlope((this->bufferSize != BUFFER_SMALL || this->samplerate > SAMPLERATE_10MS || (SAMPLERATE_10MS - this->samplerate) % 2) ? slope : Dso::SLOPE_NEGATIVE - slope); this->commandPending[COMMAND_SETTRIGGERANDSAMPLERATE] = true; return 0; @@ -667,6 +683,7 @@ namespace Hantek { ((CommandSetTriggerAndSamplerate *) this->command[COMMAND_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(positionValue); this->commandPending[COMMAND_SETTRIGGERANDSAMPLERATE] = true; + this->triggerPosition = position; return (double) (positionValue - positionStart) / this->samplerateSteps[this->samplerate]; } } diff --git a/openhantek/src/hantek/control.h b/openhantek/src/hantek/control.h index 0e2ba93..fe9aa8d 100644 --- a/openhantek/src/hantek/control.h +++ b/openhantek/src/hantek/control.h @@ -70,6 +70,7 @@ namespace Hantek { unsigned int calculateTriggerPoint(unsigned int value); int getCaptureState(); int getSamples(bool process); + unsigned long int updateBufferSize(unsigned long int size); Device *device; ///< The USB device for the oscilloscope @@ -88,9 +89,11 @@ namespace Hantek { double offset[HANTEK_CHANNELS]; ///< The current screen offset for each channel double offsetReal[HANTEK_CHANNELS]; ///< The real offset for each channel (Due to quantization) double triggerLevel[HANTEK_CHANNELS]; ///< The trigger level for each channel in V + double triggerPosition; ///< The current pretrigger position unsigned int bufferSize; ///< The buffer size in samples unsigned int triggerPoint; ///< The trigger point value Dso::TriggerMode triggerMode; ///< The trigger mode + Dso::Slope triggerSlope; ///< The trigger slope bool triggerSpecial; ///< true, if the trigger source is special unsigned int triggerSource; ///< The trigger source @@ -105,7 +108,7 @@ namespace Hantek { public slots: unsigned long int setSamplerate(unsigned long int samplerate); - double setBufferSize(unsigned int size); + unsigned long int setBufferSize(unsigned long int size); int setChannelUsed(unsigned int channel, bool used); int setCoupling(unsigned int channel, Dso::Coupling coupling); diff --git a/openhantek/src/hantek/types.h b/openhantek/src/hantek/types.h index decac24..302c84d 100644 --- a/openhantek/src/hantek/types.h +++ b/openhantek/src/hantek/types.h @@ -137,6 +137,7 @@ namespace Hantek { /// ... /// /// + /// Because of the 9 bit data model, the DSO-5200 transmits an additional MSB for each sample afterwards. COMMAND_GETDATA, /// This command checks the capture state: @@ -146,7 +147,7 @@ namespace Hantek { /// 0x00 /// /// - /// The oscilloscope returns it's capture state and the trigger point (Not sure about this, looks like 248 16-bit words with nearly constant values): + /// The oscilloscope returns it's capture state and the trigger point. Not sure about this, looks like 248 16-bit words with nearly constant values. These can be converted to the start address of the data in the buffer (See Hantek::Control::calculateTriggerPoint): /// /// /// @@ -214,10 +215,10 @@ namespace Hantek { /// \enum ControlCode hantek/types.h /// \brief All supported control commands. enum ControlCode { - /// This control read/write command gives access to a #ControlValue. - CONTROL_VALUE = 0xA2, + /// The 0xa2 control read/write command gives access to a #ControlValue. + CONTROL_VALUE = 0xa2, - /// This control read command gets the speed level of the USB connection: + /// The 0xb2 control read command gets the speed level of the USB connection: ///
#CaptureState
/// /// @@ -232,9 +233,9 @@ namespace Hantek { /// /// ///
#ConnectionSpeed0x00
- CONTROL_GETSPEED = 0xB2, + CONTROL_GETSPEED = 0xb2, - /// This control write command is sent before any bulk command: + /// The 0xb3 control write command is sent before any bulk command: /// /// /// @@ -249,9 +250,9 @@ namespace Hantek { /// /// ///
0x0f0x00
- CONTROL_BEGINCOMMAND = 0xB3, + CONTROL_BEGINCOMMAND = 0xb3, - /// This control write command sets the channel offsets: + /// The 0xb4 control write command sets the channel offsets: /// /// /// @@ -273,9 +274,9 @@ namespace Hantek { /// /// ///
Ch1Offset[1] | 0x200x00
- CONTROL_SETOFFSET = 0xB4, + CONTROL_SETOFFSET = 0xb4, - /// This control write command sets the internal relays: + /// The 0xb5 control write command sets the internal relays: /// /// /// @@ -297,7 +298,7 @@ namespace Hantek { /// /// ///
0x000x00
- CONTROL_SETRELAYS = 0xB5 + CONTROL_SETRELAYS = 0xb5 }; ////////////////////////////////////////////////////////////////////////////// @@ -446,7 +447,7 @@ namespace Hantek { /// \brief Trigger and samplerate bits (Byte 1). struct Tsr1Bits { unsigned char triggerSource:2; ///< The trigger source, see Hantek::TriggerSource - unsigned char sampleSize:3; ///< Buffer size, 1 = 10240 S, 2 = 32768 S + unsigned char sampleSize:3; ///< Buffer size, 0 = Roll, 1 = 10240 S, 2 = 32768 S unsigned char samplerateFast:3; ///< samplerate id for fast sampling rates }; diff --git a/openhantek/src/helper.cpp b/openhantek/src/helper.cpp index 46bd238..21f669a 100644 --- a/openhantek/src/helper.cpp +++ b/openhantek/src/helper.cpp @@ -44,33 +44,33 @@ namespace Helper { QString libUsbErrorString(int error) { switch(error) { case LIBUSB_SUCCESS: - return "Success (no error)"; + return QApplication::tr("Success (no error)"); case LIBUSB_ERROR_IO: - return "Input/output error"; + return QApplication::tr("Input/output error"); case LIBUSB_ERROR_INVALID_PARAM: - return "Invalid parameter"; + return QApplication::tr("Invalid parameter"); case LIBUSB_ERROR_ACCESS: - return "Access denied (insufficient permissions)"; + return QApplication::tr("Access denied (insufficient permissions)"); case LIBUSB_ERROR_NO_DEVICE: - return "No such device (it may have been disconnected)"; + return QApplication::tr("No such device (it may have been disconnected)"); case LIBUSB_ERROR_NOT_FOUND: - return "Entity not found"; + return QApplication::tr("Entity not found"); case LIBUSB_ERROR_BUSY: - return "Resource busy"; + return QApplication::tr("Resource busy"); case LIBUSB_ERROR_TIMEOUT: - return "Operation timed out"; + return QApplication::tr("Operation timed out"); case LIBUSB_ERROR_OVERFLOW: - return "Overflow"; + return QApplication::tr("Overflow"); case LIBUSB_ERROR_PIPE: - return "Pipe error"; + return QApplication::tr("Pipe error"); case LIBUSB_ERROR_INTERRUPTED: - return "System call interrupted (perhaps due to signal)"; + return QApplication::tr("System call interrupted (perhaps due to signal)"); case LIBUSB_ERROR_NO_MEM: - return "Insufficient memory"; + return QApplication::tr("Insufficient memory"); case LIBUSB_ERROR_NOT_SUPPORTED: - return "Operation not supported or unimplemented on this platform"; + return QApplication::tr("Operation not supported or unimplemented on this platform"); default: - return "Other error"; + return QApplication::tr("Other error"); } } diff --git a/openhantek/src/openhantek.cpp b/openhantek/src/openhantek.cpp index 22f71e8..af42158 100644 --- a/openhantek/src/openhantek.cpp +++ b/openhantek/src/openhantek.cpp @@ -139,7 +139,7 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag this->dsoControl->setBufferSize(this->settings->scope.horizontal.samples); this->updateTimebase(); this->dsoControl->setTriggerMode(this->settings->scope.trigger.mode); - this->dsoControl->setTriggerPosition(this->settings->scope.trigger.position); + this->dsoControl->setTriggerPosition(this->settings->scope.trigger.position * this->settings->scope.horizontal.timebase * DIVS_TIME); this->dsoControl->setTriggerSlope(this->settings->scope.trigger.slope); this->dsoControl->setTriggerSource(this->settings->scope.trigger.special, this->settings->scope.trigger.source); @@ -432,11 +432,11 @@ void OpenHantekMainWindow::readSettings(const QString &fileName) { if(settingsLoader->contains("digitalPhosphor")) this->settings->view.digitalPhosphor = settingsLoader->value("digitalPhosphor").toBool(); if(settingsLoader->contains("interpolation")) - this->settings->view.interpolation = (GlInterpolationMode) settingsLoader->value("interpolation").toInt(); + this->settings->view.interpolation = (Dso::InterpolationMode) settingsLoader->value("interpolation").toInt(); if(settingsLoader->contains("screenColorImages")) - this->settings->view.screenColorImages = (GlInterpolationMode) settingsLoader->value("screenColorImages").toBool(); + this->settings->view.screenColorImages = (Dso::InterpolationMode) settingsLoader->value("screenColorImages").toBool(); if(settingsLoader->contains("zoom")) - this->settings->view.zoom = (GlInterpolationMode) settingsLoader->value("zoom").toBool(); + this->settings->view.zoom = (Dso::InterpolationMode) settingsLoader->value("zoom").toBool(); settingsLoader->endGroup(); delete settingsLoader; diff --git a/openhantek/src/settings.cpp b/openhantek/src/settings.cpp index 7d4b8f4..3b24524 100644 --- a/openhantek/src/settings.cpp +++ b/openhantek/src/settings.cpp @@ -27,7 +27,7 @@ #include "settings.h" -#include "constants.h" +#include "dso.h" #include "dsowidget.h" @@ -81,7 +81,7 @@ DsoSettings::DsoSettings() { this->view.antialiasing = true; this->view.digitalPhosphor = false; this->view.digitalPhosphorDepth = 8; - this->view.interpolation = INTERPOLATION_LINEAR; + this->view.interpolation = Dso::INTERPOLATION_LINEAR; this->view.screenColorImages = false; this->view.zoom = false; } diff --git a/openhantek/src/settings.h b/openhantek/src/settings.h index 558ff29..2bcc4e2 100644 --- a/openhantek/src/settings.h +++ b/openhantek/src/settings.h @@ -32,7 +32,7 @@ #include -#include "constants.h" +#include "dso.h" //////////////////////////////////////////////////////////////////////////////// @@ -133,7 +133,7 @@ struct DsoSettingsView { bool antialiasing; ///< Antialiasing for the graphs bool digitalPhosphor; ///< true slowly fades out the previous graphs int digitalPhosphorDepth; ///< Number of channels shown at one time - GlInterpolationMode interpolation; ///< Interpolation mode for the graph + Dso::InterpolationMode interpolation; ///< Interpolation mode for the graph bool screenColorImages; ///< true exports images with screen colors bool zoom; ///< true if the magnified scope is enabled };