From d9490a188be4c3d9ed9f0f385bdf92d7b2750ffc Mon Sep 17 00:00:00 2001 From: Teuniz Date: Mon, 10 Apr 2023 12:24:58 +0200 Subject: [PATCH] Wave inspector: fixed a bug that caused an error in case of a relatively high DC-offset. --- global.h | 2 +- save_data.cpp | 28 ++++++++++++++++------------ wave_view.cpp | 4 ++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/global.h b/global.h index 4e52557..bc0411a 100644 --- a/global.h +++ b/global.h @@ -35,7 +35,7 @@ #define PROGRAM_NAME "DSRemote" -#define PROGRAM_VERSION "0.39_2302091112" +#define PROGRAM_VERSION "0.40_2304101223" #define MAX_PATHLEN (1024) diff --git a/save_data.cpp b/save_data.cpp index 44ab41c..5064158 100644 --- a/save_data.cpp +++ b/save_data.cpp @@ -337,7 +337,7 @@ void UI_Mainwindow::get_deep_memory_waveform(void) if(devparms.yinc[chn] < 1e-6) { - snprintf(str, 512, "Error, parameter \"YINC\" out of range: %e line %i file %s", devparms.yinc[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YINC\" out of range for channel %i: %e line %i file %s", chn, devparms.yinc[chn], __LINE__, __FILE__); goto OUT_ERROR; } @@ -353,7 +353,7 @@ void UI_Mainwindow::get_deep_memory_waveform(void) if((yref[chn] < 1) || (yref[chn] > 255)) { - snprintf(str, 512, "Error, parameter \"YREF\" out of range: %i line %i file %s", yref[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YREF\" out of range for channel %i: %i line %i file %s", chn, yref[chn], __LINE__, __FILE__); goto OUT_ERROR; } @@ -367,12 +367,16 @@ void UI_Mainwindow::get_deep_memory_waveform(void) devparms.yor[chn] = atoi(device->buf); - if((devparms.yor[chn] < -255) || (devparms.yor[chn] > 255)) + if((devparms.yor[chn] < -32000) || (devparms.yor[chn] > 32000)) { - snprintf(str, 512, "Error, parameter \"YOR\" out of range: %i line %i file %s", devparms.yor[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YOR\" out of range for channel %i: %i line %i file %s", chn, devparms.yor[chn], __LINE__, __FILE__); goto OUT_ERROR; } +// printf("yinc[%i] : %f\n", chn, devparms.yinc[chn]); +// printf("yref[%i] : %i\n", chn, yref[chn]); +// printf("yor[%i] : %i\n", chn, devparms.yor[chn]); + empty_buf = 0; for(bytes_rcvd=0; bytes_rcvdbuf)[k]) - yref[chn] - devparms.yor[chn]) << 5; + wavbuf[chn][bytes_rcvd + k] = ((int)(((unsigned char *)device->buf)[k])) - yref[chn] - devparms.yor[chn]; } bytes_rcvd += n; @@ -714,14 +718,14 @@ void UI_Mainwindow::save_wave_inspector_buffer_to_edf(struct device_settings *d_ edf_set_digital_minimum(hdl, j, -32768); if(d_parms->chanscale[chn] > 2) { - edf_set_physical_maximum(hdl, j, d_parms->yinc[chn] * 32767.0 / 32.0); - edf_set_physical_minimum(hdl, j, d_parms->yinc[chn] * -32768.0 / 32.0); + edf_set_physical_maximum(hdl, j, d_parms->yinc[chn] * 32767.0); + edf_set_physical_minimum(hdl, j, d_parms->yinc[chn] * -32768.0); edf_set_physical_dimension(hdl, j, "V"); } else { - edf_set_physical_maximum(hdl, j, 1000.0 * d_parms->yinc[chn] * 32767.0 / 32.0); - edf_set_physical_minimum(hdl, j, 1000.0 * d_parms->yinc[chn] * -32768.0 / 32.0); + edf_set_physical_maximum(hdl, j, 1000.0 * d_parms->yinc[chn] * 32767.0); + edf_set_physical_minimum(hdl, j, 1000.0 * d_parms->yinc[chn] * -32768.0); edf_set_physical_dimension(hdl, j, "mV"); } snprintf(str, 512, "CHAN%i", chn + 1); @@ -943,7 +947,7 @@ void UI_Mainwindow::save_screen_waveform() if(devparms.yinc[chn] < 1e-6) { - snprintf(str, 512, "Error, parameter \"YINC\" out of range: %e line %i file %s", devparms.yinc[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YINC\" out of range for channel %i: %e line %i file %s", chn, devparms.yinc[chn], __LINE__, __FILE__); goto OUT_ERROR; } @@ -959,7 +963,7 @@ void UI_Mainwindow::save_screen_waveform() if((yref[chn] < 1) || (yref[chn] > 255)) { - snprintf(str, 512, "Error, parameter \"YREF\" out of range: %i line %i file %s", yref[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YREF\" out of range for channel %i: %i line %i file %s", chn, yref[chn], __LINE__, __FILE__); goto OUT_ERROR; } @@ -975,7 +979,7 @@ void UI_Mainwindow::save_screen_waveform() if((devparms.yor[chn] < -255) || (devparms.yor[chn] > 255)) { - snprintf(str, 512, "Error, parameter \"YOR\" out of range: %i line %i file %s", devparms.yor[chn], __LINE__, __FILE__); + snprintf(str, 512, "Error, parameter \"YOR\" out of range for channel %i: %i line %i file %s", chn, devparms.yor[chn], __LINE__, __FILE__); goto OUT_ERROR; } diff --git a/wave_view.cpp b/wave_view.cpp index 5670063..9149772 100644 --- a/wave_view.cpp +++ b/wave_view.cpp @@ -306,11 +306,11 @@ void WaveCurve::paintEvent(QPaintEvent *) continue; } - v_sense = ((double)curve_h / ((devparms->chanscale[chn] * devparms->vertdivisions) / devparms->yinc[chn])) / -32.0; + v_sense = ((double)curve_h / ((devparms->chanscale[chn] * devparms->vertdivisions) / devparms->yinc[chn])) / -1.0; h_trace_offset = curve_h / 2; - h_trace_offset += (devparms->yor[chn] * v_sense * 32.0); + h_trace_offset += devparms->yor[chn] * v_sense; painter->setPen(QPen(QBrush(SignalColor[chn], Qt::SolidPattern), tracewidth, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));