From bdc0e203badc144ec2b94e3430ae40ae580b8825 Mon Sep 17 00:00:00 2001 From: Teuniz Date: Sat, 9 Jan 2016 12:42:43 +0100 Subject: [PATCH] Work in progress. --- global.h | 2 +- interface.cpp | 383 ++++++++++++++++++------------------------------ mainwindow.cpp | 313 ++++++++++++++++++++++++--------------- mainwindow.h | 3 + notes.txt | 9 +- signalcurve.cpp | 35 ++++- 6 files changed, 381 insertions(+), 364 deletions(-) diff --git a/global.h b/global.h index 756965e..a6ad5e9 100644 --- a/global.h +++ b/global.h @@ -35,7 +35,7 @@ #define PROGRAM_NAME "DSRemote" -#define PROGRAM_VERSION "0.31_1601091030" +#define PROGRAM_VERSION "0.31_1601091241" #define MAX_PATHLEN 4096 diff --git a/interface.cpp b/interface.cpp index 137119d..4f194f4 100644 --- a/interface.cpp +++ b/interface.cpp @@ -2272,30 +2272,74 @@ void UI_Mainwindow::math_menu() } submenufftoffset.setTitle("Offset"); - sprintf(str, "%+.0fdB", devparms.fft_vscale * 4.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp4())); - sprintf(str, "%+.0fdB", devparms.fft_vscale * 3.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp3())); - sprintf(str, "%+.0fdB", devparms.fft_vscale * 2.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp2())); - sprintf(str, "%+.0fdB", devparms.fft_vscale); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp1())); - strcpy(str, "0dB"); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffset0())); - sprintf(str, "%.0fdB", devparms.fft_vscale * -1.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm1())); - sprintf(str, "%.0fdB", devparms.fft_vscale * -2.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm2())); - sprintf(str, "%.0fdB", devparms.fft_vscale * -3.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm3())); - sprintf(str, "%.0fdB", devparms.fft_vscale * -4.0); - submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm4())); + if(devparms.math_fft_unit == 0) + { + convert_to_metric_suffix(str, devparms.fft_vscale * 4.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp4())); + convert_to_metric_suffix(str, devparms.fft_vscale * 3.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp3())); + convert_to_metric_suffix(str, devparms.fft_vscale * 2.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp2())); + convert_to_metric_suffix(str, devparms.fft_vscale, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp1())); + strcpy(str, "0V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffset0())); + convert_to_metric_suffix(str, devparms.fft_vscale * -1.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm1())); + convert_to_metric_suffix(str, devparms.fft_vscale * -2.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm2())); + convert_to_metric_suffix(str, devparms.fft_vscale * -3.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm3())); + convert_to_metric_suffix(str, devparms.fft_vscale * -4.0, 1); + strcat(str, "V"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm4())); + } + else + { + sprintf(str, "%+.0fdB", devparms.fft_vscale * 4.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp4())); + sprintf(str, "%+.0fdB", devparms.fft_vscale * 3.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp3())); + sprintf(str, "%+.0fdB", devparms.fft_vscale * 2.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp2())); + sprintf(str, "%+.0fdB", devparms.fft_vscale); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetp1())); + strcpy(str, "0dB"); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffset0())); + sprintf(str, "%.0fdB", devparms.fft_vscale * -1.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm1())); + sprintf(str, "%.0fdB", devparms.fft_vscale * -2.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm2())); + sprintf(str, "%.0fdB", devparms.fft_vscale * -3.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm3())); + sprintf(str, "%.0fdB", devparms.fft_vscale * -4.0); + submenufftoffset.addAction(str, this, SLOT(select_fft_voffsetm4())); + } submenufftvscale.setTitle("Scale"); - submenufftvscale.addAction("2dB/Div", this, SLOT(select_fft_vscale2())); - submenufftvscale.addAction("5dB/Div", this, SLOT(select_fft_vscale5())); - submenufftvscale.addAction("10dB/Div", this, SLOT(select_fft_vscale10())); - submenufftvscale.addAction("20dB/Div", this, SLOT(select_fft_vscale20())); + if(devparms.math_fft_unit == 0) + { + submenufftvscale.addAction("1V/Div", this, SLOT(select_fft_vscale1())); + submenufftvscale.addAction("2V/Div", this, SLOT(select_fft_vscale2())); + submenufftvscale.addAction("5V/Div", this, SLOT(select_fft_vscale5())); + submenufftvscale.addAction("10V/Div", this, SLOT(select_fft_vscale10())); + submenufftvscale.addAction("20V/Div", this, SLOT(select_fft_vscale20())); + } + else + { + submenufftvscale.addAction("1dB/Div", this, SLOT(select_fft_vscale1())); + submenufftvscale.addAction("2dB/Div", this, SLOT(select_fft_vscale2())); + submenufftvscale.addAction("5dB/Div", this, SLOT(select_fft_vscale5())); + submenufftvscale.addAction("10dB/Div", this, SLOT(select_fft_vscale10())); + submenufftvscale.addAction("20dB/Div", this, SLOT(select_fft_vscale20())); + } submenufftsrc.setTitle("Source"); submenufftsrc.addAction("CH1", this, SLOT(select_fft_ch1())); @@ -3250,6 +3294,8 @@ void UI_Mainwindow::toggle_fft_split() void UI_Mainwindow::toggle_fft_unit() { + char str[512]; + if(devparms.math_fft_unit == 1) { devparms.fft_vscale = 0.5; @@ -3267,6 +3313,14 @@ void UI_Mainwindow::toggle_fft_unit() set_cue_cmd(":MATH:FFT:UNIT VRMS"); } + sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); + + set_cue_cmd(str); + + sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); + + set_cue_cmd(str); + statusLabel->setText("FFT unit: Vrms"); } else @@ -3284,6 +3338,14 @@ void UI_Mainwindow::toggle_fft_unit() set_cue_cmd(":MATH:FFT:UNIT DB"); } + sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); + + set_cue_cmd(str); + + sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); + + set_cue_cmd(str); + devparms.math_fft_unit = 1; statusLabel->setText("FFT unit: dB"); @@ -3741,99 +3803,50 @@ void UI_Mainwindow::select_fft_ctr_12() } +void UI_Mainwindow::select_fft_vscale1() +{ + devparms.fft_vscale = 1.0; + + set_fft_vscale(); +} + + void UI_Mainwindow::select_fft_vscale2() { - char str[512]; - devparms.fft_vscale = 2.0; - if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * 4.0); - } - - if(devparms.fft_voffset < (devparms.fft_vscale * -4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * -4.0); - } - - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); - - set_cue_cmd(str); - } - - statusLabel->setText("FFT scale: 2dB/Div"); - - waveForm->update(); + set_fft_vscale(); } void UI_Mainwindow::select_fft_vscale5() { - char str[512]; - devparms.fft_vscale = 5.0; - if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * 4.0); - } - - if(devparms.fft_voffset < (devparms.fft_vscale * -4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * -4.0); - } - - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); - - set_cue_cmd(str); - } - - statusLabel->setText("FFT scale: 5dB/Div"); - - waveForm->update(); + set_fft_vscale(); } void UI_Mainwindow::select_fft_vscale10() { - char str[512]; - devparms.fft_vscale = 10.0; - if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * 4.0); - } - - if(devparms.fft_voffset < (devparms.fft_vscale * -4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * -4.0); - } - - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); - - set_cue_cmd(str); - } - - statusLabel->setText("FFT scale: 10dB/Div"); - - waveForm->update(); + set_fft_vscale(); } void UI_Mainwindow::select_fft_vscale20() { - char str[512]; - devparms.fft_vscale = 20.0; + set_fft_vscale(); +} + + +void UI_Mainwindow::set_fft_vscale() +{ + char str[512]; + if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) { devparms.fft_voffset = (devparms.fft_vscale * 4.0); @@ -3851,7 +3864,20 @@ void UI_Mainwindow::select_fft_vscale20() set_cue_cmd(str); } - statusLabel->setText("FFT scale: 20dB/Div"); + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT scale: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_vscale, 1); + + strcat(str, "V"); + } + else + { + sprintf(str, "FFT scale: %+.1fdB/Div", devparms.fft_vscale); + } + + statusLabel->setText(str); waveForm->update(); } @@ -3859,210 +3885,80 @@ void UI_Mainwindow::select_fft_vscale20() void UI_Mainwindow::select_fft_voffsetp4() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * 4.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetp3() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * 3.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetp2() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * 2.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetp1() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffset0() { - char str[512]; - devparms.fft_voffset = 0.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetm1() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * -1.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetm2() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * -2.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetm3() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * -3.0; - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); - - set_cue_cmd(str); - } - - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); - - statusLabel->setText(str); - - waveForm->label_active = LABEL_ACTIVE_FFT; - - label_timer->start(LABEL_TIMER_IVAL); - - waveForm->update(); + set_fft_voffset(); } void UI_Mainwindow::select_fft_voffsetm4() { - char str[512]; - devparms.fft_voffset = devparms.fft_vscale * -4.0; + set_fft_voffset(); +} + + +void UI_Mainwindow::set_fft_voffset() +{ + char str[512]; + if(devparms.modelserie != 6) { sprintf(str, ":MATH:OFFS %e", devparms.fft_voffset); @@ -4070,7 +3966,18 @@ void UI_Mainwindow::select_fft_voffsetm4() set_cue_cmd(str); } - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT position: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_voffset, 1); + + strcat(str, "V"); + } + else + { + sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + } statusLabel->setText(str); diff --git a/mainwindow.cpp b/mainwindow.cpp index 57aae62..ee41cc4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1942,6 +1942,25 @@ int UI_Mainwindow::get_device_settings() devparms.fft_voffset = atof(device->buf); } + usleep(TMC_GDS_DELAY); + + if(devparms.modelserie != 6) + { + if(tmc_write(":MATH:SCAL?") != 11) + { + line = __LINE__; + goto OUT_ERROR; + } + + if(tmc_read() < 1) + { + line = __LINE__; + goto OUT_ERROR; + } + + devparms.fft_vscale = atof(device->buf); + } + QApplication::restoreOverrideCursor(); return 0; @@ -3082,10 +3101,17 @@ void UI_Mainwindow::chan_scale_plus() if(devparms.math_fft && devparms.math_fft_split) { - if(devparms.math_fft_unit == 1) - { - devparms.fft_vscale = round_up_step125(devparms.fft_vscale, NULL); + devparms.fft_vscale = round_up_step125(devparms.fft_vscale, NULL); + if(devparms.math_fft_unit == 0) + { + if(devparms.fft_vscale > 50.0) + { + devparms.fft_vscale = 50.0; + } + } + else + { if(devparms.fft_vscale > 20.0) { devparms.fft_vscale = 20.0; @@ -3109,7 +3135,18 @@ void UI_Mainwindow::chan_scale_plus() set_cue_cmd(str); } - sprintf(str, "FFT scale: %.1fdB/Div", devparms.fft_vscale); + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT scale: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_vscale, 1); + + strcat(str, "V/Div"); + } + else + { + sprintf(str, "FFT scale: %.1fdB/Div", devparms.fft_vscale); + } statusLabel->setText(str); @@ -3162,6 +3199,136 @@ void UI_Mainwindow::chan_scale_plus() } +void UI_Mainwindow::chan_scale_minus() +{ + int chn; + + double val, ltmp; + + char str[512]; + + if(device == NULL) + { + return; + } + + if(!devparms.connected) + { + return; + } + + if(devparms.activechannel < 0) + { + return; + } + + if(devparms.math_fft && devparms.math_fft_split) + { + devparms.fft_vscale = round_down_step125(devparms.fft_vscale, NULL); + + if(devparms.math_fft_unit == 0) + { + if(devparms.fft_vscale < 1.0) + { + devparms.fft_vscale = 1.0; + } + } + else + { + if(devparms.fft_vscale < 2.0) + { + devparms.fft_vscale = 2.0; + } + } + + if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) + { + devparms.fft_voffset = (devparms.fft_vscale * 4.0); + } + + if(devparms.fft_voffset < (devparms.fft_vscale * -4.0)) + { + devparms.fft_voffset = (devparms.fft_vscale * -4.0); + } + + if(devparms.modelserie != 6) + { + sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); + + set_cue_cmd(str); + } + + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT scale: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_vscale, 1); + + strcat(str, "V/Div"); + } + else + { + sprintf(str, "FFT scale: %.1fdB/Div", devparms.fft_vscale); + } + + statusLabel->setText(str); + + waveForm->update(); + + return; + } + + chn = devparms.activechannel; + + if(devparms.chanscale[chn] <= 1e-2) + { + devparms.chanscale[chn] = 1e-2; + + return; + } + + ltmp = devparms.chanscale[chn]; + + if(devparms.chanvernier[chn]) + { + val = round_up_step125(devparms.chanscale[chn], NULL); + } + else + { + val = round_down_step125(devparms.chanscale[chn], NULL); + } + + if(devparms.chanvernier[chn]) + { + val /= 100; + + devparms.chanscale[chn] -= val; + } + else + { + devparms.chanscale[chn] = val; + } + + ltmp /= val; + + devparms.chanoffset[chn] /= ltmp; + + sprintf(str, "Channel %i scale: ", chn + 1); + + convert_to_metric_suffix(str + strlen(str), devparms.chanscale[chn], 2); + + strcat(str, "V"); + + statusLabel->setText(str); + + sprintf(str, ":CHAN%i:SCAL %e", chn + 1, devparms.chanscale[chn]); + + set_cue_cmd(str); + + waveForm->update(); +} + + void UI_Mainwindow::shift_trace_up() { int chn; @@ -3199,7 +3366,18 @@ void UI_Mainwindow::shift_trace_up() set_cue_cmd(str); } - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT position: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_voffset, 1); + + strcat(str, "V"); + } + else + { + sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + } statusLabel->setText(str); @@ -3278,7 +3456,18 @@ void UI_Mainwindow::shift_trace_down() set_cue_cmd(str); } - sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + if(devparms.math_fft_unit == 0) + { + strcpy(str, "FFT position: "); + + convert_to_metric_suffix(str + strlen(str), devparms.fft_voffset, 1); + + strcat(str, "V"); + } + else + { + sprintf(str, "FFT position: %+.0fdB", devparms.fft_voffset); + } statusLabel->setText(str); @@ -3320,118 +3509,6 @@ void UI_Mainwindow::shift_trace_down() } -void UI_Mainwindow::chan_scale_minus() -{ - int chn; - - double val, ltmp; - - char str[512]; - - if(device == NULL) - { - return; - } - - if(!devparms.connected) - { - return; - } - - if(devparms.activechannel < 0) - { - return; - } - - if(devparms.math_fft && devparms.math_fft_split) - { - if(devparms.math_fft_unit == 1) - { - devparms.fft_vscale = round_down_step125(devparms.fft_vscale, NULL); - - if(devparms.fft_vscale < 2.0) - { - devparms.fft_vscale = 2.0; - } - } - - if(devparms.fft_voffset > (devparms.fft_vscale * 4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * 4.0); - } - - if(devparms.fft_voffset < (devparms.fft_vscale * -4.0)) - { - devparms.fft_voffset = (devparms.fft_vscale * -4.0); - } - - if(devparms.modelserie != 6) - { - sprintf(str, ":MATH:SCAL %e", devparms.fft_vscale); - - set_cue_cmd(str); - } - - sprintf(str, "FFT scale: %.1fdB/Div", devparms.fft_vscale); - - statusLabel->setText(str); - - waveForm->update(); - - return; - } - - chn = devparms.activechannel; - - if(devparms.chanscale[chn] <= 1e-2) - { - devparms.chanscale[chn] = 1e-2; - - return; - } - - ltmp = devparms.chanscale[chn]; - - if(devparms.chanvernier[chn]) - { - val = round_up_step125(devparms.chanscale[chn], NULL); - } - else - { - val = round_down_step125(devparms.chanscale[chn], NULL); - } - - if(devparms.chanvernier[chn]) - { - val /= 100; - - devparms.chanscale[chn] -= val; - } - else - { - devparms.chanscale[chn] = val; - } - - ltmp /= val; - - devparms.chanoffset[chn] /= ltmp; - - sprintf(str, "Channel %i scale: ", chn + 1); - - convert_to_metric_suffix(str + strlen(str), devparms.chanscale[chn], 2); - - strcat(str, "V"); - - statusLabel->setText(str); - - sprintf(str, ":CHAN%i:SCAL %e", chn + 1, devparms.chanscale[chn]); - - set_cue_cmd(str); - - waveForm->update(); -} - - void UI_Mainwindow::set_to_factory() { int i; diff --git a/mainwindow.h b/mainwindow.h index b321439..bda4f07 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -409,10 +409,12 @@ private slots: void select_fft_ctr_10(); void select_fft_ctr_11(); void select_fft_ctr_12(); + void select_fft_vscale1(); void select_fft_vscale2(); void select_fft_vscale5(); void select_fft_vscale10(); void select_fft_vscale20(); + void set_fft_vscale(); void select_fft_voffsetp4(); void select_fft_voffsetp3(); void select_fft_voffsetp2(); @@ -422,6 +424,7 @@ private slots: void select_fft_voffsetm2(); void select_fft_voffsetm3(); void select_fft_voffsetm4(); + void set_fft_voffset(); protected: void closeEvent(QCloseEvent *); diff --git a/notes.txt b/notes.txt index ab2f660..3d32b19 100644 --- a/notes.txt +++ b/notes.txt @@ -117,10 +117,11 @@ What's implemented so far: - Set to factory settings - FFT - When you change the vertical scale setting of the FFT, the scope will not be updated automatically, - because there's no TMC command available to do this...?! - Also, due to a bug in the firmware of the scope, the parameters "Center" and "Hz/Div" are not updated - correctly when you change the horizontal timebase. A workaround is to disable and enable the FFT again. + The sample data used to do the FFT, is used from the trace, not the deep memory data. + It's not possible to remotely do an FFT with the deep memory data in "real time". + Due to a bug in the firmware of the scope, the parameters "Center" and "Hz/Div" are not updated + correctly on the scope itself when you change the horizontal timebase. + A workaround is to disable and enable the FFT again. diff --git a/signalcurve.cpp b/signalcurve.cpp index 4cc2c08..50e619b 100644 --- a/signalcurve.cpp +++ b/signalcurve.cpp @@ -570,7 +570,18 @@ void SignalCurve::drawWidget(QPainter *painter, int curve_w, int curve_h) if(label_active == LABEL_ACTIVE_FFT) { - sprintf(str, "POS: %.1fdB", devparms->fft_voffset); + if(devparms->math_fft_unit == 0) + { + strcpy(str, "POS: "); + + convert_to_metric_suffix(str + strlen(str), devparms->fft_voffset, 1); + + strcat(str, "V"); + } + else + { + sprintf(str, "POS: %.1fdB", devparms->fft_voffset); + } paintLabel(painter, 20, curve_h * 1.85 - 50.0, 100, 20, str, QColor(128, 64, 255)); } @@ -786,7 +797,14 @@ void SignalCurve::drawFFT(QPainter *painter, int curve_h_b, int curve_w_b) convert_to_metric_suffix(str + strlen(str), devparms->fft_vscale, 2); - strcat(str, "dBV/Div Center "); + if(devparms->math_fft_unit == 0) + { + strcat(str, "V/Div Center "); + } + else + { + strcat(str, "dBV/Div Center "); + } convert_to_metric_suffix(str + strlen(str), devparms->math_fft_hcenter, 1); @@ -1710,7 +1728,18 @@ void SignalCurve::mouseReleaseEvent(QMouseEvent *release_event) mainwindow->set_cue_cmd(str); } - sprintf(str, "FFT position: %+.0fdB", devparms->fft_voffset); + if(devparms->math_fft_unit == 0) + { + strcpy(str, "FFT position: "); + + convert_to_metric_suffix(str + strlen(str), devparms->fft_voffset, 1); + + strcat(str, "V/Div"); + } + else + { + sprintf(str, "FFT position: %+.0fdB", devparms->fft_voffset); + } mainwindow->statusLabel->setText(str);