OpenHantek
scopesettings.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0+
2 
3 #pragma once
4 
5 #include <QString>
6 #include <QPointF>
7 
9 #include "hantekdso/enums.h"
11 #include "viewconstants.h"
12 #include <vector>
13 
14 
17  enum CursorShape {
22  } shape = NONE;
23  QPointF pos[MARKER_COUNT] = {{-1.0, -1.0}, {1.0, 1.0}};
24 };
25 
29  double frequencybase = 1e3;
31 
32  unsigned int recordLength = 0;
33 
35  double timebase = 1e-3;
36  double samplerate = 1e6;
37  double calfreq = 1e3;
38 };
39 
44  double offset = 0.5;
46  unsigned int source = 0;
47  bool smooth = false;
48 };
49 
52  QString name;
53  bool used = false;
55 };
56 
59  double offset = 0.0;
60  double magnitude = 20.0;
61 };
62 
66  double offset = 0.0;
67  double trigger = 0.0;
68  unsigned gainStepIndex = 6;
69  unsigned couplingOrMathIndex = 0;
70  bool inverted = false;
71  double probeAttn = 1.0;
72 };
73 
76  std::vector<double> gainSteps = {2e-2, 5e-2, 1e-1, 2e-1,
77  5e-1, 1e0, 2e0, 5e0};
78  std::vector<DsoSettingsScopeSpectrum> spectrum;
79  std::vector<DsoSettingsScopeVoltage> voltage;
82 
83  bool histogram = false;
84 
85  double gain(unsigned channel) const {
86  return gainSteps[voltage[channel].gainStepIndex] * voltage[channel].probeAttn;
87  }
88 
89  bool anyUsed(ChannelID channel) { return voltage[channel].used | spectrum[channel].used; }
90 
91  Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification *deviceSpecification) const {
92  return deviceSpecification->couplings[voltage[channel].couplingOrMathIndex];
93  }
94  // Channels, including math channels
95  unsigned countChannels() const { return unsigned(voltage.size()); }
96 
97  double getMarker(unsigned int marker) const {
98  double x = qBound( MARGIN_LEFT, marker < MARKER_COUNT ? horizontal.cursor.pos[marker].x() : 0.0, MARGIN_RIGHT );
99  return x;
100  }
101 
102  void setMarker(unsigned int marker, double value) {
103  if (marker < MARKER_COUNT) horizontal.cursor.pos[marker].setX(value);
104  }
105 };
Definition: scopesettings.h:18
Slope
The slope that causes a trigger.
Definition: enums.h:44
unsigned int recordLength
Sample count.
Definition: scopesettings.h:32
enum DsoSettingsScopeCursor::CursorShape shape
unsigned couplingOrMathIndex
Different index: coupling for real- and mode for math-channels.
Definition: scopesettings.h:69
std::vector< DsoSettingsScopeSpectrum > spectrum
Spectrum analysis settings.
Definition: scopesettings.h:78
CursorShape
Definition: scopesettings.h:17
Holds the settings for the spectrum analysis.
Definition: scopesettings.h:58
bool inverted
true if the channel is inverted (mirrored on cross-axis)
Definition: scopesettings.h:70
unsigned int source
Channel that is used as trigger source.
Definition: scopesettings.h:46
std::vector< Coupling > couplings
Definition: controlspecification.h:65
double gain(unsigned channel) const
Definition: scopesettings.h:85
double trigger
Trigger level in V.
Definition: scopesettings.h:67
double getMarker(unsigned int marker) const
Definition: scopesettings.h:97
Coupling
The coupling modes for the channels.
Definition: enums.h:27
unsigned countChannels() const
Definition: scopesettings.h:95
double offset
Vertical offset in divs.
Definition: scopesettings.h:66
double frequencybase
Frequencybase in Hz/div.
Definition: scopesettings.h:29
#define MARKER_COUNT
Number of markers.
Definition: viewconstants.h:14
#define MARGIN_LEFT
Definition: viewconstants.h:11
Holds the settings for the trigger. TODO Use ControlSettingsTrigger.
Definition: scopesettings.h:42
#define MARGIN_RIGHT
Definition: viewconstants.h:12
std::vector< double > gainSteps
The selectable voltage gain steps in V/div.
Definition: scopesettings.h:76
void setMarker(unsigned int marker, double value)
Definition: scopesettings.h:102
double calfreq
The frequency of the calibration output.
Definition: scopesettings.h:37
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:71
double offset
Vertical offset in divs.
Definition: scopesettings.h:59
DsoSettingsScopeCursor cursor
Definition: scopesettings.h:54
Dso::TriggerMode mode
Automatic, normal or single trigger.
Definition: scopesettings.h:43
Dso::GraphFormat format
Graph drawing mode of the scope.
Definition: scopesettings.h:28
Definition: scopesettings.h:21
Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification *deviceSpecification) const
Definition: scopesettings.h:91
DsoSettingsScopeHorizontal horizontal
Settings for the horizontal axis.
Definition: scopesettings.h:80
bool smooth
Don&#39;t trigger on glitches.
Definition: scopesettings.h:47
bool anyUsed(ChannelID channel)
Definition: scopesettings.h:89
Holds the cursor parameters.
Definition: scopesettings.h:16
DsoSettingsScopeTrigger trigger
Settings for the trigger.
Definition: scopesettings.h:81
Stores the specifications of the currently connected device.
Definition: controlspecification.h:42
Holds the settings for the horizontal axis.
Definition: scopesettings.h:27
QPointF pos[MARKER_COUNT]
Position in div.
Definition: scopesettings.h:23
From lower to higher voltage.
bool used
true if the channel is turned on
Definition: scopesettings.h:53
bool histogram
Definition: scopesettings.h:83
unsigned ChannelID
Definition: types.h:6
double timebase
TODO Use ControlSettingsSamplerateTarget.
Definition: scopesettings.h:35
Dso::Slope slope
Rising or falling edge causes trigger.
Definition: scopesettings.h:45
double offset
Horizontal position for pretrigger (middle of screen)
Definition: scopesettings.h:44
Automatic without trigger event.
double samplerate
The samplerate of the oscilloscope in S.
Definition: scopesettings.h:36
unsigned gainStepIndex
The vertical resolution in V/div (default = 1.0)
Definition: scopesettings.h:68
Holds the settings for the oscilloscope.
Definition: scopesettings.h:75
DsoSettingsScopeCursor cursor
Definition: scopesettings.h:30
Definition: scopesettings.h:19
Definition: scopesettings.h:20
std::vector< DsoSettingsScopeVoltage > voltage
Settings for the normal graphs.
Definition: scopesettings.h:79
QString name
Name of this channel.
Definition: scopesettings.h:52
Holds the settings for the normal voltage graphs. TODO Use ControlSettingsVoltage.
Definition: scopesettings.h:65
Base for DsoSettingsScopeSpectrum and DsoSettingsScopeVoltage.
Definition: scopesettings.h:51
double magnitude
The vertical resolution in dB/div.
Definition: scopesettings.h:60