Work in progress.

merge-requests/1/head
Teuniz 2016-01-04 20:38:44 +01:00
rodzic 680a1457a0
commit 9955b8ebf4
7 zmienionych plików z 107 dodań i 19 usunięć

Wyświetl plik

@ -35,7 +35,7 @@
#define PROGRAM_NAME "DSRemote"
#define PROGRAM_VERSION "0.31_1601041900"
#define PROGRAM_VERSION "0.31_1601042038"
#define MAX_PATHLEN 4096
@ -77,6 +77,7 @@
#define TMC_THRD_JOB_NONE 0
#define TMC_THRD_JOB_TRIGEDGELEV 1
#define TMC_THRD_JOB_TIMDELAY 2
#define TMC_THRD_JOB_FFTHZDIV 3
#define TMC_DIAL_TIMER_DELAY 300

Wyświetl plik

@ -548,11 +548,11 @@ void UI_Mainwindow::horScaleDialChanged(int new_pos)
if(dir)
{
devparms.timebasedelayscale = round_up_step125(devparms.timebasedelayscale);
devparms.timebasedelayscale = round_up_step125(devparms.timebasedelayscale, NULL);
}
else
{
devparms.timebasedelayscale = round_down_step125(devparms.timebasedelayscale);
devparms.timebasedelayscale = round_down_step125(devparms.timebasedelayscale, NULL);
}
strcpy(str, "Delayed timebase: ");
@ -622,11 +622,11 @@ void UI_Mainwindow::horScaleDialChanged(int new_pos)
if(dir)
{
devparms.timebasescale = round_up_step125(devparms.timebasescale);
devparms.timebasescale = round_up_step125(devparms.timebasescale, NULL);
}
else
{
devparms.timebasescale = round_down_step125(devparms.timebasescale);
devparms.timebasescale = round_down_step125(devparms.timebasescale, NULL);
}
strcpy(str, "Timebase: ");
@ -829,7 +829,7 @@ void UI_Mainwindow::vertOffsetDialChanged(int new_pos)
}
}
val = round_up_step125(devparms.chanscale[chn]) / 100;
val = round_up_step125(devparms.chanscale[chn], NULL) / 100;
if(dir)
{
@ -957,11 +957,11 @@ void UI_Mainwindow::vertScaleDialChanged(int new_pos)
if(dir || devparms.chanvernier[chn])
{
val = round_up_step125(devparms.chanscale[chn]);
val = round_up_step125(devparms.chanscale[chn], NULL);
}
else
{
val = round_down_step125(devparms.chanscale[chn]);
val = round_down_step125(devparms.chanscale[chn], NULL);
}
if(devparms.chanvernier[chn])

Wyświetl plik

@ -2514,7 +2514,7 @@ void UI_Mainwindow::zoom_in()
}
}
devparms.timebasedelayscale = round_down_step125(devparms.timebasedelayscale);
devparms.timebasedelayscale = round_down_step125(devparms.timebasedelayscale, NULL);
strcpy(str, "Delayed timebase: ");
@ -2561,7 +2561,7 @@ void UI_Mainwindow::zoom_in()
}
}
devparms.timebasescale = round_down_step125(devparms.timebasescale);
devparms.timebasescale = round_down_step125(devparms.timebasescale, NULL);
strcpy(str, "Timebase: ");
@ -2605,7 +2605,7 @@ void UI_Mainwindow::zoom_out()
return;
}
devparms.timebasedelayscale = round_up_step125(devparms.timebasedelayscale);
devparms.timebasedelayscale = round_up_step125(devparms.timebasedelayscale, NULL);
strcpy(str, "Delayed timebase: ");
@ -2628,7 +2628,7 @@ void UI_Mainwindow::zoom_out()
return;
}
devparms.timebasescale = round_up_step125(devparms.timebasescale);
devparms.timebasescale = round_up_step125(devparms.timebasescale, NULL);
strcpy(str, "Timebase: ");
@ -2671,7 +2671,7 @@ void UI_Mainwindow::chan_scale_plus()
ltmp = devparms.chanscale[chn];
val = round_up_step125(devparms.chanscale[chn]);
val = round_up_step125(devparms.chanscale[chn], NULL);
if(devparms.chanvernier[chn])
{
@ -2810,11 +2810,11 @@ void UI_Mainwindow::chan_scale_minus()
if(devparms.chanvernier[chn])
{
val = round_up_step125(devparms.chanscale[chn]);
val = round_up_step125(devparms.chanscale[chn], NULL);
}
else
{
val = round_down_step125(devparms.chanscale[chn]);
val = round_down_step125(devparms.chanscale[chn], NULL);
}
if(devparms.chanvernier[chn])

Wyświetl plik

@ -127,6 +127,11 @@ void screenThread::get_params(struct device_settings *dev_parms)
dev_parms->timebasedelayoffset = params.timebasedelayoffset;
dev_parms->timebasedelayscale = params.timebasedelayscale;
}
if(dev_parms->thread_job == TMC_THRD_JOB_FFTHZDIV)
{
dev_parms->math_fft_hscale = params.math_fft_hscale;
dev_parms->math_fft_hcenter = params.math_fft_hcenter;
}
if(params.debug_str[0])
{
params.debug_str[1023] = 0;
@ -386,6 +391,51 @@ void screenThread::run()
params.job = TMC_THRD_JOB_TIMDELAY;
}
if(params.math_fft)
{
if((!strncmp(deviceparms->cmd_cue[params.cmd_cue_idx_out], ":TIM:SCAL ", 10)) ||
(!strncmp(deviceparms->cmd_cue[params.cmd_cue_idx_out], ":MATH:OPER FFT", 14)))
{
usleep(TMC_GDS_DELAY);
if(tmc_write(":MATH:FFT:HSC?") != 14)
{
printf("Can not write to device.\n");
line = __LINE__;
goto OUT_ERROR;
}
if(tmc_read() < 1)
{
printf("Can not read from device.\n");
line = __LINE__;
goto OUT_ERROR;
}
params.math_fft_hscale = atof(device->buf);
usleep(TMC_GDS_DELAY);
if(tmc_write(":MATH:FFT:HCEN?") != 15)
{
printf("Can not write to device.\n");
line = __LINE__;
goto OUT_ERROR;
}
if(tmc_read() < 1)
{
printf("Can not read from device.\n");
line = __LINE__;
goto OUT_ERROR;
}
params.math_fft_hcenter = atof(device->buf);
params.job = TMC_THRD_JOB_FFTHZDIV;
}
}
params.cmd_cue_idx_out++;
params.cmd_cue_idx_out %= TMC_CMD_CUE_SZ;

Wyświetl plik

@ -91,6 +91,8 @@ private:
int math_fft_src;
int math_fft;
int math_fft_unit;
double math_fft_hscale;
double math_fft_hcenter;
double *fftbuf_in;
double *fftbuf_out;
int fftbufsz;

39
utils.c
Wyświetl plik

@ -1599,7 +1599,7 @@ void hextobin(char *dest, const char *str)
}
double round_up_step125(double val)
double round_up_step125(double val, double *ratio)
{
int i, exp=0;
@ -1624,14 +1624,29 @@ double round_up_step125(double val)
if(val > 4.999)
{
ltmp = 10;
if(ratio != NULL)
{
*ratio = 2;
}
}
else if(val > 1.999)
{
ltmp = 5;
if(ratio != NULL)
{
*ratio = 2.5;
}
}
else
{
ltmp = 2;
if(ratio != NULL)
{
*ratio = 2;
}
}
for(i=0; i<exp; i++)
@ -1653,7 +1668,7 @@ double round_up_step125(double val)
}
double round_down_step125(double val)
double round_down_step125(double val, double *ratio)
{
int i, exp=0;
@ -1678,18 +1693,38 @@ double round_down_step125(double val)
if(val < 1.001)
{
ltmp = 0.5;
if(ratio != NULL)
{
*ratio = 2;
}
}
else if(val < 2.001)
{
ltmp = 1;
if(ratio != NULL)
{
*ratio = 2;
}
}
else if(val < 5.001)
{
ltmp = 2;
if(ratio != NULL)
{
*ratio = 2.5;
}
}
else
{
ltmp = 5;
if(ratio != NULL)
{
*ratio = 2;
}
}
for(i=0; i<exp; i++)

Wyświetl plik

@ -90,8 +90,8 @@ void hextobin(char *, const char *); /* destination must have four times the
/* int is number of decimals. Result is written into the string argument */
int convert_to_metric_suffix(char *, double, int);
double round_up_step125(double); /* Rounds the value up to 1-2-5 steps */
double round_down_step125(double); /* Rounds the value down to 1-2-5 steps */
double round_up_step125(double, double *); /* Rounds the value up to 1-2-5 steps */
double round_down_step125(double, double *); /* Rounds the value down to 1-2-5 steps */
int strtoipaddr(unsigned int *, const char *); /* convert a string "192.168.1.12" to an integer */