Wave inspector: fixed a bug that caused an error in case of a relatively high DC-offset.

master
Teuniz 2023-04-10 12:24:58 +02:00
rodzic c7bc6d1f81
commit d9490a188b
3 zmienionych plików z 19 dodań i 15 usunięć

Wyświetl plik

@ -35,7 +35,7 @@
#define PROGRAM_NAME "DSRemote" #define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.39_2302091112" #define PROGRAM_VERSION "0.40_2304101223"
#define MAX_PATHLEN (1024) #define MAX_PATHLEN (1024)

Wyświetl plik

@ -337,7 +337,7 @@ void UI_Mainwindow::get_deep_memory_waveform(void)
if(devparms.yinc[chn] < 1e-6) 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; goto OUT_ERROR;
} }
@ -353,7 +353,7 @@ void UI_Mainwindow::get_deep_memory_waveform(void)
if((yref[chn] < 1) || (yref[chn] > 255)) 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; goto OUT_ERROR;
} }
@ -367,12 +367,16 @@ void UI_Mainwindow::get_deep_memory_waveform(void)
devparms.yor[chn] = atoi(device->buf); 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; 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; empty_buf = 0;
for(bytes_rcvd=0; bytes_rcvd<mempnts ;) for(bytes_rcvd=0; bytes_rcvd<mempnts ;)
@ -452,7 +456,7 @@ void UI_Mainwindow::get_deep_memory_waveform(void)
break; break;
} }
wavbuf[chn][bytes_rcvd + k] = ((int)(((unsigned char *)device->buf)[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; 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); edf_set_digital_minimum(hdl, j, -32768);
if(d_parms->chanscale[chn] > 2) if(d_parms->chanscale[chn] > 2)
{ {
edf_set_physical_maximum(hdl, j, d_parms->yinc[chn] * 32767.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 / 32.0); edf_set_physical_minimum(hdl, j, d_parms->yinc[chn] * -32768.0);
edf_set_physical_dimension(hdl, j, "V"); edf_set_physical_dimension(hdl, j, "V");
} }
else else
{ {
edf_set_physical_maximum(hdl, j, 1000.0 * d_parms->yinc[chn] * 32767.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 / 32.0); edf_set_physical_minimum(hdl, j, 1000.0 * d_parms->yinc[chn] * -32768.0);
edf_set_physical_dimension(hdl, j, "mV"); edf_set_physical_dimension(hdl, j, "mV");
} }
snprintf(str, 512, "CHAN%i", chn + 1); snprintf(str, 512, "CHAN%i", chn + 1);
@ -943,7 +947,7 @@ void UI_Mainwindow::save_screen_waveform()
if(devparms.yinc[chn] < 1e-6) 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; goto OUT_ERROR;
} }
@ -959,7 +963,7 @@ void UI_Mainwindow::save_screen_waveform()
if((yref[chn] < 1) || (yref[chn] > 255)) 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; goto OUT_ERROR;
} }
@ -975,7 +979,7 @@ void UI_Mainwindow::save_screen_waveform()
if((devparms.yor[chn] < -255) || (devparms.yor[chn] > 255)) 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; goto OUT_ERROR;
} }

Wyświetl plik

@ -306,11 +306,11 @@ void WaveCurve::paintEvent(QPaintEvent *)
continue; 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 = 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)); painter->setPen(QPen(QBrush(SignalColor[chn], Qt::SolidPattern), tracewidth, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));