OpenHantek
Loading...
Searching...
No Matches
scopesettings.h
1// SPDX-License-Identifier: GPL-2.0+
2
3#pragma once
4
5#include <QString>
6#include <QPointF>
7
8#include "hantekdso/controlspecification.h"
9#include "hantekdso/enums.h"
10#include "hantekprotocol/definitions.h"
11#include <vector>
12
13#define MARKER_COUNT 2
14#define MARKER_STEP (DIVS_TIME / 100.0)
15
18 enum CursorShape {
19 NONE,
20 HORIZONTAL,
21 VERTICAL,
22 RECTANGULAR
23 } shape = NONE;
24 QPointF pos[MARKER_COUNT] = {{-1.0, -1.0}, {1.0, 1.0}};
25};
26
29 Dso::GraphFormat format = Dso::GraphFormat::TY;
30 double frequencybase = 1e3;
32
33 unsigned int recordLength = 0;
34
36 double timebase = 1e-3;
37 double samplerate = 1e6;
38 enum SamplerateSource { Samplerrate, Duration } samplerateSource = Samplerrate;
39};
40
44 Dso::TriggerMode mode = Dso::TriggerMode::HARDWARE_SOFTWARE;
45 double position = 0.0;
46 Dso::Slope slope = Dso::Slope::Positive;
47 unsigned int source = 0;
48 bool special = false;
49 unsigned swTriggerThreshold = 7;
50 unsigned swTriggerSampleSet = 11;
51};
52
55 QString name;
56 bool used = false;
58};
59
62 double offset = 0.0;
63 double magnitude = 20.0;
64};
65
69 double offset = 0.0;
70 double trigger = 0.0;
71 unsigned gainStepIndex = 6;
72 unsigned couplingOrMathIndex = 0;
73 bool inverted = false;
74};
75
78 std::vector<double> gainSteps = {1e-2, 2e-2, 5e-2, 1e-1, 2e-1,
79 5e-1, 1e0, 2e0, 5e0};
80 std::vector<DsoSettingsScopeSpectrum> spectrum;
81 std::vector<DsoSettingsScopeVoltage> voltage;
84
85 double gain(unsigned channel) const { return gainSteps[voltage[channel].gainStepIndex]; }
86 bool anyUsed(ChannelID channel) { return voltage[channel].used | spectrum[channel].used; }
87
88 Dso::Coupling coupling(ChannelID channel, const Dso::ControlSpecification *deviceSpecification) const {
89 return deviceSpecification->couplings[voltage[channel].couplingOrMathIndex];
90 }
91 // Channels, including math channels
92 unsigned countChannels() const { return (unsigned)voltage.size(); }
93
94 double getMarker(unsigned int marker) const {
95 return marker < MARKER_COUNT ? horizontal.cursor.pos[marker].x() : 0.0;
96 }
97 void setMarker(unsigned int marker, double value) {
98 if (marker < MARKER_COUNT) horizontal.cursor.pos[marker].setX(value);
99 }
100};
Base for DsoSettingsScopeSpectrum and DsoSettingsScopeVoltage.
Definition scopesettings.h:54
bool used
true if the channel is turned on
Definition scopesettings.h:56
QString name
Name of this channel.
Definition scopesettings.h:55
Holds the cursor parameters.
Definition scopesettings.h:17
QPointF pos[MARKER_COUNT]
Position in div.
Definition scopesettings.h:24
Holds the settings for the horizontal axis.
Definition scopesettings.h:28
Dso::GraphFormat format
Graph drawing mode of the scope.
Definition scopesettings.h:29
double frequencybase
Frequencybase in Hz/div.
Definition scopesettings.h:30
double samplerate
The samplerate of the oscilloscope in S.
Definition scopesettings.h:37
double timebase
TODO Use ControlSettingsSamplerateTarget.
Definition scopesettings.h:36
unsigned int recordLength
Sample count.
Definition scopesettings.h:33
Holds the settings for the spectrum analysis.
Definition scopesettings.h:61
double magnitude
The vertical resolution in dB/div.
Definition scopesettings.h:63
double offset
Vertical offset in divs.
Definition scopesettings.h:62
Holds the settings for the trigger. TODO Use ControlSettingsTrigger.
Definition scopesettings.h:43
Dso::Slope slope
Rising or falling edge causes trigger.
Definition scopesettings.h:46
unsigned swTriggerThreshold
Software trigger, threshold.
Definition scopesettings.h:49
double position
Horizontal position for pretrigger.
Definition scopesettings.h:45
unsigned int source
Channel that is used as trigger source.
Definition scopesettings.h:47
bool special
true if the trigger source is not a standard channel
Definition scopesettings.h:48
Dso::TriggerMode mode
Automatic, normal or single trigger.
Definition scopesettings.h:44
unsigned swTriggerSampleSet
Software trigger, sample set.
Definition scopesettings.h:50
Holds the settings for the normal voltage graphs. TODO Use ControlSettingsVoltage.
Definition scopesettings.h:68
double trigger
Trigger level in V.
Definition scopesettings.h:70
unsigned gainStepIndex
The vertical resolution in V/div (default = 1.0)
Definition scopesettings.h:71
bool inverted
true if the channel is inverted (mirrored on cross-axis)
Definition scopesettings.h:73
unsigned couplingOrMathIndex
Different index: coupling for real- and mode for math-channels.
Definition scopesettings.h:72
double offset
Vertical offset in divs.
Definition scopesettings.h:69
Holds the settings for the oscilloscope.
Definition scopesettings.h:77
std::vector< DsoSettingsScopeSpectrum > spectrum
Spectrum analysis settings.
Definition scopesettings.h:80
DsoSettingsScopeHorizontal horizontal
Settings for the horizontal axis.
Definition scopesettings.h:82
std::vector< DsoSettingsScopeVoltage > voltage
Settings for the normal graphs.
Definition scopesettings.h:81
std::vector< double > gainSteps
The selectable voltage gain steps in V/div.
Definition scopesettings.h:78
DsoSettingsScopeTrigger trigger
Settings for the trigger.
Definition scopesettings.h:83
Stores the specifications of the currently connected device.
Definition controlspecification.h:47