OpenHantek
scopesettings.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0+
2 
3 #pragma once
4 
5 #include <QPointF>
6 #include <QString>
7 
9 #include "hantekdso/enums.h"
11 #include "viewconstants.h"
12 #include <vector>
13 
14 
18  QPointF pos[ 2 ] = { { -1.0, -1.0 }, { 1.0, 1.0 } };
19 };
20 
24  double frequencybase = 1e3;
26 
27  unsigned int recordLength = 0;
28  double timebase = 1e-3;
29  double maxTimebase = 1;
30 #ifdef Q_PROCESSOR_ARM
31  // RPi: Not more often than every 10 ms
32  double acquireInterval = 0.010;
33 #else
34  // other PC: Not more often than every 1 ms
35  double acquireInterval = 0.001;
36 #endif
37  double samplerate = 1e6;
38  double calfreq = 1e3;
39 };
40 
45  double position = 0.5;
47  int source = 0;
48  int smooth = 0;
49 };
50 
53  QString name;
54  bool used = false;
56 };
57 
60  double offset = 0.0;
61  double magnitude = 20.0;
62 };
63 
66  unsigned dummyLoad = 0;
67  bool calculateTHD = false;
68 };
69 
73  double offset = 0.0;
74  double trigger = 0.0;
75  unsigned gainStepIndex = 6;
76  unsigned couplingOrMathIndex = 0;
77  bool inverted = false;
78  double probeAttn = 1.0;
79 };
80 
83  std::vector< double > gainSteps = { 2e-2, 5e-2, 1e-1, 2e-1,
84  5e-1, 1e0, 2e0, 5e0 };
85  std::vector< DsoSettingsScopeSpectrum > spectrum;
86  std::vector< DsoSettingsScopeVoltage > voltage;
90 
91  unsigned verboseLevel = 0;
92  bool histogram = false;
93  bool hasACcoupling = false;
94  bool hasACmodification = false;
95 
96  double gain( unsigned channel ) const { return gainSteps[ voltage[ channel ].gainStepIndex ] * voltage[ channel ].probeAttn; }
97 
98  bool anyUsed( ChannelID channel ) { return voltage[ channel ].used | spectrum[ channel ].used; }
99 
100  Dso::Coupling coupling( ChannelID channel, const Dso::ControlSpecification *deviceSpecification ) const {
101  return deviceSpecification->couplings[ voltage[ channel ].couplingOrMathIndex ];
102  }
103  // Channels, including math channels
104  unsigned countChannels() const { return unsigned( voltage.size() ); }
105 
106  double getMarker( unsigned int marker ) const {
107  double x = qBound( MARGIN_LEFT, marker < 2 ? horizontal.cursor.pos[ marker ].x() : 0.0, MARGIN_RIGHT );
108  return x;
109  }
110 
111  void setMarker( unsigned int marker, double value ) {
112  if ( marker < 2 )
113  horizontal.cursor.pos[ marker ].setX( value );
114  }
115 };
Definition: scopesettings.h:17
std::vector< DsoSettingsScopeSpectrum > spectrum
Spectrum analysis settings.
Definition: scopesettings.h:85
DsoSettingsScopeAnalysis analysis
Settings for the analysis.
Definition: scopesettings.h:89
Slope
The slope that causes a trigger.
Definition: enums.h:45
unsigned int recordLength
Sample count.
Definition: scopesettings.h:27
enum DsoSettingsScopeCursor::CursorShape shape
unsigned couplingOrMathIndex
Different index: coupling for real- and mode for math-channels.
Definition: scopesettings.h:76
CursorShape
Definition: scopesettings.h:17
Holds the settings for the spectrum analysis.
Definition: scopesettings.h:59
int source
Channel that is used as trigger source.
Definition: scopesettings.h:47
bool inverted
true if the channel is inverted (mirrored on cross-axis)
Definition: scopesettings.h:77
QPointF pos[2]
Position in div.
Definition: scopesettings.h:18
double gain(unsigned channel) const
Definition: scopesettings.h:96
double trigger
Trigger level in V.
Definition: scopesettings.h:74
double getMarker(unsigned int marker) const
Definition: scopesettings.h:106
bool hasACcoupling
Definition: scopesettings.h:93
Coupling
The coupling modes for the channels.
Definition: enums.h:27
double maxTimebase
Allow very slow timebases 0.1 ... 10.0 s/div.
Definition: scopesettings.h:29
unsigned countChannels() const
Definition: scopesettings.h:104
std::vector< double > gainSteps
The selectable voltage gain steps in V/div.
Definition: scopesettings.h:83
double offset
Vertical offset in divs.
Definition: scopesettings.h:73
double frequencybase
Frequencybase in Hz/div.
Definition: scopesettings.h:24
unsigned dummyLoad
Dummy load in Ohms.
Definition: scopesettings.h:66
#define MARGIN_LEFT
Definition: viewconstants.h:9
Holds the settings for the trigger. TODO Use ControlSettingsTrigger.
Definition: scopesettings.h:43
#define MARGIN_RIGHT
Definition: viewconstants.h:10
void setMarker(unsigned int marker, double value)
Definition: scopesettings.h:111
int smooth
Don&#39;t trigger on glitches.
Definition: scopesettings.h:48
double calfreq
The frequency of the calibration output.
Definition: scopesettings.h:38
TriggerMode
The different triggering modes.
Definition: enums.h:35
GraphFormat
The possible viewing formats for the graphs on the scope.
Definition: enums.h:18
The standard mode.
Definition: enums.h:19
double probeAttn
attenuation of probe
Definition: scopesettings.h:78
double acquireInterval
Minimal time between captured frames.
Definition: scopesettings.h:35
std::vector< Coupling > couplings
Definition: controlspecification.h:66
double offset
Vertical offset in divs.
Definition: scopesettings.h:60
DsoSettingsScopeCursor cursor
Definition: scopesettings.h:55
bool hasACmodification
Definition: scopesettings.h:94
Dso::TriggerMode mode
Automatic, normal or single trigger.
Definition: scopesettings.h:44
Dso::GraphFormat format
Graph drawing mode of the scope.
Definition: scopesettings.h:23
Definition: scopesettings.h:17
Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification *deviceSpecification) const
Definition: scopesettings.h:100
DsoSettingsScopeHorizontal horizontal
Settings for the horizontal axis.
Definition: scopesettings.h:87
double position
Horizontal position for pretrigger (middle of screen)
Definition: scopesettings.h:45
bool anyUsed(ChannelID channel)
Definition: scopesettings.h:98
Holds the cursor parameters.
Definition: scopesettings.h:16
DsoSettingsScopeTrigger trigger
Settings for the trigger.
Definition: scopesettings.h:88
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
Holds the settings for the horizontal axis.
Definition: scopesettings.h:22
Holds the settings for the power analysis.
Definition: scopesettings.h:65
From lower to higher voltage.
bool used
true if the channel is turned on
Definition: scopesettings.h:54
bool histogram
Definition: scopesettings.h:92
unsigned ChannelID
Definition: types.h:6
double timebase
Timebase in s/div.
Definition: scopesettings.h:28
Dso::Slope slope
Rising or falling edge causes trigger.
Definition: scopesettings.h:46
bool calculateTHD
Definition: scopesettings.h:67
Automatic without trigger event.
double samplerate
The samplerate of the oscilloscope in S.
Definition: scopesettings.h:37
unsigned gainStepIndex
The vertical resolution in V/div (default = 1.0)
Definition: scopesettings.h:75
Holds the settings for the oscilloscope.
Definition: scopesettings.h:82
DsoSettingsScopeCursor cursor
Definition: scopesettings.h:25
Definition: scopesettings.h:17
std::vector< DsoSettingsScopeVoltage > voltage
Settings for the normal graphs.
Definition: scopesettings.h:86
Definition: scopesettings.h:17
unsigned verboseLevel
Definition: scopesettings.h:91
QString name
Name of this channel.
Definition: scopesettings.h:53
Holds the settings for the normal voltage graphs. TODO Use ControlSettingsVoltage.
Definition: scopesettings.h:72
Base for DsoSettingsScopeSpectrum and DsoSettingsScopeVoltage.
Definition: scopesettings.h:52
double magnitude
The vertical resolution in dB/div.
Definition: scopesettings.h:61