Skip to content

Commit 3190b80

Browse files
committed
fix #419 - allow MATH scaling 20 mV .. 1000 V
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
1 parent 799cd67 commit 3190b80

13 files changed

Lines changed: 173 additions & 150 deletions

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
2025-03-02 (799cd67): replace deprecated upload-artifact@v3 with upload-artifact@v4
12
2025-03-02 (68221da): fix #420 - remenber save as path for screenshots etc.
23
2024-03-24 (ffd1691): README: add hint for possible graphics issue solution for win systems
34
2024-03-24 (d0f44f8): Fix voltageScale to correct indices for ISDS205b

openhantek/src/docks/VoltageDock.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
4040
for ( double gainStep : scope->gainSteps ) {
4141
gainStrings << valueToString( gainStep, UNIT_VOLTS, 0 );
4242
}
43+
for ( double mathGainStep : scope->mathGainSteps ) {
44+
mathGainStrings << valueToString( mathGainStep, UNIT_VOLTS, 0 );
45+
}
4346

4447
dockLayout = new QGridLayout();
4548
dockLayout->setColumnMinimumWidth( 0, 50 );
@@ -73,12 +76,13 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
7376
b.miscComboBox->addItems( couplingStrings );
7477
if ( scope->toolTipVisible )
7578
b.miscComboBox->setToolTip( tr( "Select DC or AC coupling" ) );
79+
b.gainComboBox->addItems( gainStrings );
7680
} else {
7781
b.miscComboBox->addItems( modeStrings );
7882
if ( scope->toolTipVisible )
7983
b.miscComboBox->setToolTip( tr( "Select the mathematical operation for this channel" ) );
84+
b.gainComboBox->addItems( mathGainStrings );
8085
}
81-
b.gainComboBox->addItems( gainStrings );
8286

8387
if ( channel < spec->channels ) {
8488
dockLayout->setColumnStretch( 1, 1 ); // stretch ComboBox in 2nd (middle) column 1x
@@ -196,10 +200,17 @@ void VoltageDock::setCoupling( ChannelID channel, unsigned couplingIndex ) {
196200
void VoltageDock::setGain( ChannelID channel, unsigned gainStepIndex ) {
197201
if ( channel >= scope->voltage.size() )
198202
return;
199-
if ( gainStepIndex >= scope->gainSteps.size() )
200-
return;
201-
if ( scope->verboseLevel > 2 )
202-
qDebug() << " VDock::setGain()" << channel << gainStrings[ int( gainStepIndex ) ];
203+
if ( channel < spec->channels ) { // Voltage channel
204+
if ( gainStepIndex >= scope->gainSteps.size() )
205+
return;
206+
if ( scope->verboseLevel > 2 )
207+
qDebug() << " VDock::setGain()" << channel << gainStrings[ int( gainStepIndex ) ];
208+
} else {
209+
if ( gainStepIndex >= scope->mathGainSteps.size() )
210+
return;
211+
if ( scope->verboseLevel > 2 )
212+
qDebug() << " VDock::setGain()" << channel << mathGainStrings[ int( gainStepIndex ) ];
213+
}
203214
QSignalBlocker blocker( channelBlocks[ channel ].gainComboBox );
204215
channelBlocks[ channel ].gainComboBox->setCurrentIndex( int( gainStepIndex ) );
205216
}
@@ -212,20 +223,23 @@ void VoltageDock::setAttn( ChannelID channel, double attnValue ) {
212223
return;
213224
QSignalBlocker blocker( channelBlocks[ channel ].gainComboBox );
214225
int index = channelBlocks[ channel ].gainComboBox->currentIndex();
215-
gainStrings.clear();
216226

227+
channelBlocks[ channel ].gainComboBox->clear();
217228
// change unit to V² for the multiplying math functions
218-
if ( channel >= spec->channels ) // MATH channel
229+
if ( channel < spec->channels ) { // Voltage channel
230+
gainStrings.clear();
219231
for ( double gainStep : scope->gainSteps )
220-
gainStrings << valueToString(
221-
gainStep * attnValue, Dso::mathModeUnit( Dso::MathMode( scope->voltage[ spec->channels ].couplingOrMathIndex ) ),
222-
-1 ); // auto format V²
223-
else
224-
for ( double gainStep : scope->gainSteps )
225-
gainStrings << valueToString( gainStep * attnValue, UNIT_VOLTS, -1 ); // auto format V²
226-
227-
channelBlocks[ channel ].gainComboBox->clear();
228-
channelBlocks[ channel ].gainComboBox->addItems( gainStrings );
232+
gainStrings << valueToString( gainStep * attnValue, UNIT_VOLTS, -1 );
233+
channelBlocks[ channel ].gainComboBox->addItems( gainStrings );
234+
} else {
235+
mathGainStrings.clear();
236+
for ( double mathGainStep : scope->mathGainSteps )
237+
mathGainStrings << valueToString(
238+
mathGainStep * attnValue,
239+
Dso::mathModeUnit( Dso::MathMode( scope->voltage[ spec->channels ].couplingOrMathIndex ) ),
240+
-1 ); // auto format V or V²
241+
channelBlocks[ channel ].gainComboBox->addItems( mathGainStrings );
242+
}
229243
channelBlocks[ channel ].gainComboBox->setCurrentIndex( index );
230244
scope->voltage[ channel ].probeAttn = attnValue;
231245
channelBlocks[ channel ].attnSpinBox->setValue( int( attnValue ) );

openhantek/src/docks/VoltageDock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class VoltageDock : public QDockWidget {
8888
QStringList couplingStrings; ///< The strings for the couplings
8989
QStringList modeStrings; ///< The strings for the math mode
9090
QStringList gainStrings; ///< String representations for the gain steps
91+
QStringList mathGainStrings; ///< String representations for the math gain steps
9192
QStringList attnStrings; ///< String representations for the probe attn steps
9293

9394
signals:

openhantek/src/scopesettings.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ struct DsoSettingsScopeVoltage : public DsoSettingsScopeChannel {
9898

9999
/// \brief Holds the settings for the oscilloscope.
100100
struct DsoSettingsScope {
101-
std::vector< double > gainSteps = { 2e-2, 5e-2, 1e-1, 2e-1,
102-
5e-1, 1e0, 2e0, 5e0 }; ///< The selectable voltage gain steps in V/div
103-
std::vector< DsoSettingsScopeSpectrum > spectrum; ///< Spectrum analysis settings
104-
std::vector< DsoSettingsScopeVoltage > voltage; ///< Settings for the normal graphs
105-
DsoSettingsScopeHorizontal horizontal; ///< Settings for the horizontal axis
106-
DsoSettingsScopeTrigger trigger; ///< Settings for the trigger
107-
DsoSettingsScopeAnalysis analysis; ///< Settings for the analysis
101+
std::vector< double > gainSteps = { ///< The selectable voltage gain steps in V/div
102+
2e-2, 5e-2, 1e-1, 2e-1, 5e-1, 1e0, 2e0, 5e0, 1e1 };
103+
std::vector< double > mathGainSteps = { ///< The selectable voltage math gain steps in V/div
104+
2e-2, 5e-2, 1e-1, 2e-1, 5e-1, 1e0, 2e0, 5e0, 1e1, 2e1, 5e1, 1e2, 2e2, 5e2, 1e3 };
105+
std::vector< DsoSettingsScopeSpectrum > spectrum; ///< Spectrum analysis settings
106+
std::vector< DsoSettingsScopeVoltage > voltage; ///< Settings for the normal graphs
107+
DsoSettingsScopeHorizontal horizontal; ///< Settings for the horizontal axis
108+
DsoSettingsScopeTrigger trigger; ///< Settings for the trigger
109+
DsoSettingsScopeAnalysis analysis; ///< Settings for the analysis
108110

109111
int verboseLevel = 0;
110112
int toolTipVisible = 1; // show hints for beginners, can be disabled in settings dialog
@@ -113,7 +115,12 @@ struct DsoSettingsScope {
113115
bool hasACmodification = false;
114116
bool liveCalibrationActive = false;
115117

116-
double gain( unsigned channel ) const { return gainSteps[ voltage[ channel ].gainStepIndex ] * voltage[ channel ].probeAttn; }
118+
double gain( unsigned channel ) const {
119+
if ( channel < voltage.size() - 1 ) // Voltage channel
120+
return gainSteps[ voltage[ channel ].gainStepIndex ] * voltage[ channel ].probeAttn;
121+
else
122+
return mathGainSteps[ voltage[ channel ].gainStepIndex ] * voltage[ channel ].probeAttn;
123+
}
117124

118125
bool anyUsed( ChannelID channel ) const { return voltage[ channel ].used || spectrum[ channel ].used; }
119126

openhantek/translations/openhantek_de.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@
16811681
<translation></translation>
16821682
</message>
16831683
<message>
1684-
<location filename="../src/mainwindow.cpp" line="641"/>
1684+
<location filename="../src/mainwindow.cpp" line="639"/>
16851685
<source>Save Screenshot</source>
16861686
<translation>Screenshot speichen</translation>
16871687
</message>
@@ -1726,20 +1726,20 @@
17261726
<translation></translation>
17271727
</message>
17281728
<message>
1729-
<location filename="../src/mainwindow.cpp" line="637"/>
1730-
<location filename="../src/mainwindow.cpp" line="651"/>
1729+
<location filename="../src/mainwindow.cpp" line="635"/>
1730+
<location filename="../src/mainwindow.cpp" line="649"/>
17311731
<source>Write error
17321732
%1</source>
17331733
<translation>Schreibfehler
17341734
%1</translation>
17351735
</message>
17361736
<message>
1737-
<location filename="../src/mainwindow.cpp" line="640"/>
1737+
<location filename="../src/mainwindow.cpp" line="638"/>
17381738
<source>Image (*.png *.jpg)</source>
17391739
<translation>Bild (*.png *.jpg)</translation>
17401740
</message>
17411741
<message>
1742-
<location filename="../src/mainwindow.cpp" line="640"/>
1742+
<location filename="../src/mainwindow.cpp" line="638"/>
17431743
<source>Portable Document Format (*.pdf)</source>
17441744
<translation>Portables Dokumentenformat (*.pdf)</translation>
17451745
</message>
@@ -1748,7 +1748,7 @@
17481748
<translation type="vanished">Screenshot speichen</translation>
17491749
</message>
17501750
<message>
1751-
<location filename="../src/mainwindow.cpp" line="674"/>
1751+
<location filename="../src/mainwindow.cpp" line="672"/>
17521752
<source>Print oscillograph</source>
17531753
<translation>Oszillogramm drucken</translation>
17541754
</message>
@@ -2693,27 +2693,27 @@
26932693
<translation>Spannung</translation>
26942694
</message>
26952695
<message>
2696-
<location filename="../src/docks/VoltageDock.cpp" line="55"/>
2696+
<location filename="../src/docks/VoltageDock.cpp" line="58"/>
26972697
<source>CH&amp;%1</source>
26982698
<translation>CH&amp;%1</translation>
26992699
</message>
27002700
<message>
2701-
<location filename="../src/docks/VoltageDock.cpp" line="57"/>
2701+
<location filename="../src/docks/VoltageDock.cpp" line="60"/>
27022702
<source>MA&amp;TH</source>
27032703
<translation>MA&amp;TH</translation>
27042704
</message>
27052705
<message>
2706-
<location filename="../src/docks/VoltageDock.cpp" line="61"/>
2706+
<location filename="../src/docks/VoltageDock.cpp" line="64"/>
27072707
<source>Voltage range per vertical screen division</source>
27082708
<translation>Spannung pro vertikaler Teilung</translation>
27092709
</message>
27102710
<message>
2711-
<location filename="../src/docks/VoltageDock.cpp" line="75"/>
2711+
<location filename="../src/docks/VoltageDock.cpp" line="78"/>
27122712
<source>Select DC or AC coupling</source>
27132713
<translation>Wähle AC- oder DC-Kopplung</translation>
27142714
</message>
27152715
<message>
2716-
<location filename="../src/docks/VoltageDock.cpp" line="79"/>
2716+
<location filename="../src/docks/VoltageDock.cpp" line="83"/>
27172717
<source>Select the mathematical operation for this channel</source>
27182718
<translation>Berechnungen für diesen Kanal</translation>
27192719
</message>
@@ -2722,17 +2722,17 @@
27222722
<translation type="vanished">&amp;MATH</translation>
27232723
</message>
27242724
<message>
2725-
<location filename="../src/docks/VoltageDock.cpp" line="62"/>
2725+
<location filename="../src/docks/VoltageDock.cpp" line="65"/>
27262726
<source>Invert</source>
27272727
<translation>Invertiert</translation>
27282728
</message>
27292729
<message>
2730-
<location filename="../src/docks/VoltageDock.cpp" line="65"/>
2730+
<location filename="../src/docks/VoltageDock.cpp" line="68"/>
27312731
<source>Set probe attenuation, scroll or type a value to select</source>
27322732
<translation>Wähle Tastkopf-Abschwächung, Mausrad oder direkte Eingabe möglich</translation>
27332733
</message>
27342734
<message>
2735-
<location filename="../src/docks/VoltageDock.cpp" line="68"/>
2735+
<location filename="../src/docks/VoltageDock.cpp" line="71"/>
27362736
<source>x</source>
27372737
<translation></translation>
27382738
</message>

openhantek/translations/openhantek_es.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@
14221422
<translation>&lt;p&gt;Gráficos: %1 - Versión de GLSL %2&lt;/p&gt;&lt;p&gt;Versión de Qt: %3&lt;/p&gt;</translation>
14231423
</message>
14241424
<message>
1425-
<location filename="../src/mainwindow.cpp" line="641"/>
1425+
<location filename="../src/mainwindow.cpp" line="639"/>
14261426
<source>Save Screenshot</source>
14271427
<translation>Guardar captura de pantalla</translation>
14281428
</message>
@@ -1503,20 +1503,20 @@
15031503
<translation>yyyyMMdd_hhmmss</translation>
15041504
</message>
15051505
<message>
1506-
<location filename="../src/mainwindow.cpp" line="637"/>
1507-
<location filename="../src/mainwindow.cpp" line="651"/>
1506+
<location filename="../src/mainwindow.cpp" line="635"/>
1507+
<location filename="../src/mainwindow.cpp" line="649"/>
15081508
<source>Write error
15091509
%1</source>
15101510
<translation>Escribir error
15111511
%1</translation>
15121512
</message>
15131513
<message>
1514-
<location filename="../src/mainwindow.cpp" line="640"/>
1514+
<location filename="../src/mainwindow.cpp" line="638"/>
15151515
<source>Image (*.png *.jpg)</source>
15161516
<translation>Imagen (*.png *.jpg)</translation>
15171517
</message>
15181518
<message>
1519-
<location filename="../src/mainwindow.cpp" line="640"/>
1519+
<location filename="../src/mainwindow.cpp" line="638"/>
15201520
<source>Portable Document Format (*.pdf)</source>
15211521
<translation>Formato de Documento Portable (*.pdf)</translation>
15221522
</message>
@@ -1525,7 +1525,7 @@
15251525
<translation type="vanished">Guardar captura de pantalla</translation>
15261526
</message>
15271527
<message>
1528-
<location filename="../src/mainwindow.cpp" line="674"/>
1528+
<location filename="../src/mainwindow.cpp" line="672"/>
15291529
<source>Print oscillograph</source>
15301530
<translation>Imprimir oscilógrafo</translation>
15311531
</message>
@@ -2345,42 +2345,42 @@
23452345
<translation>Tensión</translation>
23462346
</message>
23472347
<message>
2348-
<location filename="../src/docks/VoltageDock.cpp" line="55"/>
2348+
<location filename="../src/docks/VoltageDock.cpp" line="58"/>
23492349
<source>CH&amp;%1</source>
23502350
<translation>CH&amp;%1</translation>
23512351
</message>
23522352
<message>
2353-
<location filename="../src/docks/VoltageDock.cpp" line="57"/>
2353+
<location filename="../src/docks/VoltageDock.cpp" line="60"/>
23542354
<source>MA&amp;TH</source>
23552355
<translation>MA&amp;TH</translation>
23562356
</message>
23572357
<message>
2358-
<location filename="../src/docks/VoltageDock.cpp" line="61"/>
2358+
<location filename="../src/docks/VoltageDock.cpp" line="64"/>
23592359
<source>Voltage range per vertical screen division</source>
23602360
<translation>Rango de tensión por división de pantalla vertical</translation>
23612361
</message>
23622362
<message>
2363-
<location filename="../src/docks/VoltageDock.cpp" line="75"/>
2363+
<location filename="../src/docks/VoltageDock.cpp" line="78"/>
23642364
<source>Select DC or AC coupling</source>
23652365
<translation>Seleccionar acoplamiento DC o AC</translation>
23662366
</message>
23672367
<message>
2368-
<location filename="../src/docks/VoltageDock.cpp" line="79"/>
2368+
<location filename="../src/docks/VoltageDock.cpp" line="83"/>
23692369
<source>Select the mathematical operation for this channel</source>
23702370
<translation>Seleccione la operación matemática para este canal</translation>
23712371
</message>
23722372
<message>
2373-
<location filename="../src/docks/VoltageDock.cpp" line="62"/>
2373+
<location filename="../src/docks/VoltageDock.cpp" line="65"/>
23742374
<source>Invert</source>
23752375
<translation>Invertir</translation>
23762376
</message>
23772377
<message>
2378-
<location filename="../src/docks/VoltageDock.cpp" line="65"/>
2378+
<location filename="../src/docks/VoltageDock.cpp" line="68"/>
23792379
<source>Set probe attenuation, scroll or type a value to select</source>
23802380
<translation>Configure la atenuación de la sonda, desplácese o escriba un valor para seleccionar</translation>
23812381
</message>
23822382
<message>
2383-
<location filename="../src/docks/VoltageDock.cpp" line="68"/>
2383+
<location filename="../src/docks/VoltageDock.cpp" line="71"/>
23842384
<source>x</source>
23852385
<translation>x</translation>
23862386
</message>

0 commit comments

Comments
 (0)