kopia lustrzana https://gitlab.com/Teuniz/DSRemote
Work in progress.
rodzic
a6c517781d
commit
cfd6d3404d
10
global.h
10
global.h
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
#define PROGRAM_NAME "DSRemote"
|
||||
#define PROGRAM_VERSION "0.33_1612091904"
|
||||
#define PROGRAM_VERSION "0.33_1612111915"
|
||||
|
||||
#define MAX_PATHLEN 4096
|
||||
|
||||
|
@ -183,10 +183,10 @@ struct device_settings
|
|||
// the screen is divided into 400 parts vertically which
|
||||
// are marked as 0 to 400 from top to bottom respectively
|
||||
// the range of <pos> is from 50 to 350
|
||||
double math_decode_threshold[MAX_CHNS]; // threshold of decode channel 1 (SPI:MISO for modelserie 6)
|
||||
// threshold of decode channel 2 (SPI:MOSI for modelserie 6)
|
||||
// threshold of decode channel 3 (SPI:SCLK for modelserie 6)
|
||||
// threshold of decode channel 4 (SPI:SS for modelserie 6)
|
||||
double math_decode_threshold[MAX_CHNS]; // 0: threshold of decode channel 1 (SPI:MISO for modelserie 6)
|
||||
// 1: threshold of decode channel 2 (SPI:MOSI for modelserie 6)
|
||||
// 2: threshold of decode channel 3 (SPI:SCLK for modelserie 6)
|
||||
// 3: threshold of decode channel 4 (SPI:SS for modelserie 6)
|
||||
// (-4 x VerticalScale - VerticalOffset) to
|
||||
// (4 x VerticalScale - VerticalOffset)
|
||||
double math_decode_threshold_uart_tx; // threshold of RS232:TX for modelserie 6
|
||||
|
|
|
@ -64,6 +64,8 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
uart_tx_data_bit,
|
||||
uart_rx_start,
|
||||
uart_rx_data_bit,
|
||||
uart_parity_bit,
|
||||
uart_parity,
|
||||
spi_data_mosi_bit,
|
||||
spi_data_miso_bit,
|
||||
spi_mosi_bit0_pos=0,
|
||||
|
@ -164,7 +166,12 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
// :FIXME
|
||||
bit_per_volt = 32.0 / devparms.chanscale[devparms.math_decode_spi_clk];
|
||||
|
||||
threshold[devparms.math_decode_spi_clk] =
|
||||
(devparms.math_decode_threshold[2] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_clk])
|
||||
* bit_per_volt;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -180,15 +187,20 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
// :FIXME
|
||||
bit_per_volt = 32.0 / devparms.chanscale[devparms.math_decode_spi_mosi - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_mosi - 1] =
|
||||
(devparms.math_decode_threshold[1] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_mosi - 1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_mosi];
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_mosi - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_mosi] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_mosi] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_mosi])
|
||||
threshold[devparms.math_decode_spi_mosi - 1] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_mosi - 1] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_mosi - 1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
}
|
||||
|
@ -197,15 +209,20 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
// :FIXME
|
||||
bit_per_volt = 32.0 / devparms.chanscale[devparms.math_decode_spi_miso - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_miso - 1] =
|
||||
(devparms.math_decode_threshold[0] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_miso -1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_miso];
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_miso - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_miso] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_miso] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_miso])
|
||||
threshold[devparms.math_decode_spi_miso - 1] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_miso - 1] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_miso -1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
}
|
||||
|
@ -214,15 +231,20 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
// :FIXME
|
||||
bit_per_volt = 32.0 / devparms.chanscale[devparms.math_decode_spi_cs - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_cs - 1] =
|
||||
(devparms.math_decode_threshold[3] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_cs - 1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_cs];
|
||||
bit_per_volt = 25.0 / devparms.chanscale[devparms.math_decode_spi_cs - 1];
|
||||
|
||||
threshold[devparms.math_decode_spi_cs] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_cs] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_cs])
|
||||
threshold[devparms.math_decode_spi_cs - 1] =
|
||||
(devparms.math_decode_threshold[devparms.math_decode_spi_cs - 1] +
|
||||
devparms.chanoffset[devparms.math_decode_spi_cs - 1])
|
||||
* bit_per_volt;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +339,7 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
uart_tx_start = 1;
|
||||
|
||||
uart_val = 0;
|
||||
uart_val = 0;
|
||||
|
||||
uart_tx_x_pos = (uart_sample_per_bit * 1.5) + i;
|
||||
|
||||
|
@ -333,7 +355,7 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
uart_tx_start = 1;
|
||||
|
||||
uart_val = 0;
|
||||
uart_val = 0;
|
||||
|
||||
uart_tx_x_pos = (uart_sample_per_bit * 1.5) + i;
|
||||
|
||||
|
@ -352,7 +374,7 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
uart_tx_start = 1;
|
||||
|
||||
uart_val = 0;
|
||||
uart_val = 0;
|
||||
|
||||
uart_tx_x_pos = (uart_sample_per_bit * 1.5) + i;
|
||||
|
||||
|
@ -368,7 +390,7 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
{
|
||||
uart_tx_start = 1;
|
||||
|
||||
uart_val = 0;
|
||||
uart_val = 0;
|
||||
|
||||
uart_tx_x_pos = (uart_sample_per_bit * 1.5) + i;
|
||||
|
||||
|
@ -420,12 +442,88 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
|
||||
uart_tx_start = 0;
|
||||
|
||||
devparms.math_decode_uart_tx_err[devparms.math_decode_uart_tx_nval] = 0;
|
||||
|
||||
if(devparms.math_decode_uart_par)
|
||||
{
|
||||
uart_tx_x_pos += uart_sample_per_bit;
|
||||
|
||||
i = uart_tx_x_pos;
|
||||
|
||||
if(i < devparms.wavebufsz)
|
||||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
if(devparms.wavebuf[devparms.math_decode_uart_tx - 1][i] >= devparms.math_decode_threshold_uart_tx)
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.wavebuf[devparms.math_decode_uart_tx - 1][i] >= threshold[devparms.math_decode_uart_tx - 1])
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0, uart_parity=0; j<devparms.math_decode_uart_width; j++)
|
||||
{
|
||||
uart_parity += ((uart_val >> j) & 1);
|
||||
}
|
||||
|
||||
if(devparms.math_decode_uart_par & 1)
|
||||
{
|
||||
uart_parity++;
|
||||
}
|
||||
|
||||
if((uart_parity & 1) != uart_parity_bit)
|
||||
{
|
||||
devparms.math_decode_uart_tx_err[devparms.math_decode_uart_tx_nval] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uart_tx_x_pos += uart_sample_per_bit;
|
||||
|
||||
i = uart_tx_x_pos;
|
||||
|
||||
devparms.math_decode_uart_tx_err[devparms.math_decode_uart_tx_nval] = 0;
|
||||
|
||||
stop_bit_error = 0; // check stop bit
|
||||
|
||||
if(i < devparms.wavebufsz)
|
||||
|
@ -472,11 +570,6 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
uart_tx_x_pos += uart_sample_per_bit;
|
||||
}
|
||||
|
||||
if(devparms.math_decode_uart_par)
|
||||
{
|
||||
uart_tx_x_pos += uart_sample_per_bit;
|
||||
}
|
||||
|
||||
i = uart_tx_x_pos - 1;
|
||||
|
||||
devparms.math_decode_uart_tx_nval++;
|
||||
|
@ -618,12 +711,88 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
|
||||
uart_rx_start = 0;
|
||||
|
||||
devparms.math_decode_uart_rx_err[devparms.math_decode_uart_rx_nval] = 0;
|
||||
|
||||
if(devparms.math_decode_uart_par)
|
||||
{
|
||||
uart_rx_x_pos += uart_sample_per_bit;
|
||||
|
||||
i = uart_rx_x_pos;
|
||||
|
||||
if(i < devparms.wavebufsz)
|
||||
{
|
||||
if(devparms.modelserie == 6)
|
||||
{
|
||||
if(devparms.wavebuf[devparms.math_decode_uart_rx - 1][i] >= devparms.math_decode_threshold_uart_rx)
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.wavebuf[devparms.math_decode_uart_rx - 1][i] >= threshold[devparms.math_decode_uart_rx - 1])
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devparms.math_decode_uart_pol)
|
||||
{
|
||||
uart_parity_bit = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_parity_bit = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0, uart_parity=0; j<devparms.math_decode_uart_width; j++)
|
||||
{
|
||||
uart_parity += ((uart_val >> j) & 1);
|
||||
}
|
||||
|
||||
if(devparms.math_decode_uart_par & 1)
|
||||
{
|
||||
uart_parity++;
|
||||
}
|
||||
|
||||
if((uart_parity & 1) != uart_parity_bit)
|
||||
{
|
||||
devparms.math_decode_uart_rx_err[devparms.math_decode_uart_rx_nval] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uart_rx_x_pos += uart_sample_per_bit;
|
||||
|
||||
i = uart_rx_x_pos;
|
||||
|
||||
devparms.math_decode_uart_rx_err[devparms.math_decode_uart_rx_nval] = 0;
|
||||
|
||||
stop_bit_error = 0; // check stop bit
|
||||
|
||||
if(i < devparms.wavebufsz)
|
||||
|
@ -670,11 +839,6 @@ void UI_Mainwindow::serial_decoder(void)
|
|||
uart_rx_x_pos += uart_sample_per_bit;
|
||||
}
|
||||
|
||||
if(devparms.math_decode_uart_par)
|
||||
{
|
||||
uart_rx_x_pos += uart_sample_per_bit;
|
||||
}
|
||||
|
||||
i = uart_rx_x_pos - 1;
|
||||
|
||||
devparms.math_decode_uart_rx_nval++;
|
||||
|
|
|
@ -2383,16 +2383,7 @@ void SignalCurve::draw_decoder(QPainter *painter, int dw, int dh)
|
|||
}
|
||||
else if(devparms->math_decode_format == 1) // ASCII
|
||||
{
|
||||
str[0]= devparms->math_decode_uart_tx_val[i];
|
||||
|
||||
if((str[0] < 33) || (str[0] > 126))
|
||||
{
|
||||
ascii_decode_control_char(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
str[1] = 0;
|
||||
}
|
||||
ascii_decode_control_char(devparms->math_decode_uart_tx_val[i], str);
|
||||
|
||||
painter->drawText(devparms->math_decode_uart_tx_val_pos[i] * pix_per_smpl, line_h_uart_tx - 13, cell_width, 30, Qt::AlignCenter, str);
|
||||
}
|
||||
|
@ -2464,16 +2455,7 @@ void SignalCurve::draw_decoder(QPainter *painter, int dw, int dh)
|
|||
}
|
||||
else if(devparms->math_decode_format == 1) // ASCII
|
||||
{
|
||||
str[0]= devparms->math_decode_uart_rx_val[i];
|
||||
|
||||
if((str[0] < 33) || (str[0] > 126))
|
||||
{
|
||||
ascii_decode_control_char(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
str[1] = 0;
|
||||
}
|
||||
ascii_decode_control_char(devparms->math_decode_uart_rx_val[i], str);
|
||||
|
||||
painter->drawText(devparms->math_decode_uart_rx_val_pos[i] * pix_per_smpl, line_h_uart_rx - 13, cell_width, 30, Qt::AlignCenter, str);
|
||||
}
|
||||
|
@ -2630,18 +2612,11 @@ void SignalCurve::draw_decoder(QPainter *painter, int dw, int dh)
|
|||
}
|
||||
else if(devparms->math_decode_format == 1) // ASCII
|
||||
{
|
||||
for(k=0; k<spi_chars; k++)
|
||||
for(k=0, j=0; k<spi_chars; k++)
|
||||
{
|
||||
str[k]= devparms->math_decode_spi_mosi_val[i] >> (k * 8);
|
||||
|
||||
if((str[k] < 33) || (str[k] > 126))
|
||||
{
|
||||
str[k] = '.';
|
||||
}
|
||||
j += ascii_decode_control_char(devparms->math_decode_spi_mosi_val[i] >> (k * 8), str + j);
|
||||
}
|
||||
|
||||
str[k] = 0;
|
||||
|
||||
painter->drawText(devparms->math_decode_spi_mosi_val_pos[i] * pix_per_smpl, line_h_spi_mosi - 13, cell_width, 30, Qt::AlignCenter, str);
|
||||
}
|
||||
else if(devparms->math_decode_format == 2) // decimal
|
||||
|
@ -2713,18 +2688,11 @@ void SignalCurve::draw_decoder(QPainter *painter, int dw, int dh)
|
|||
}
|
||||
else if(devparms->math_decode_format == 1) // ASCII
|
||||
{
|
||||
for(k=0; k<spi_chars; k++)
|
||||
for(k=0, j=0; k<spi_chars; k++)
|
||||
{
|
||||
str[k]= devparms->math_decode_spi_miso_val[i] >> (k * 8);
|
||||
|
||||
if((str[k] < 33) || (str[k] > 126))
|
||||
{
|
||||
str[k] = '.';
|
||||
}
|
||||
j += ascii_decode_control_char(devparms->math_decode_spi_miso_val[i] >> (k * 8), str + j);
|
||||
}
|
||||
|
||||
str[k] = 0;
|
||||
|
||||
painter->drawText(devparms->math_decode_spi_miso_val_pos[i] * pix_per_smpl, line_h_spi_miso - 13, cell_width, 30, Qt::AlignCenter, str);
|
||||
}
|
||||
else if(devparms->math_decode_format == 2) // decimal
|
||||
|
@ -2761,9 +2729,18 @@ void SignalCurve::draw_decoder(QPainter *painter, int dw, int dh)
|
|||
}
|
||||
|
||||
|
||||
void SignalCurve::ascii_decode_control_char(char *str)
|
||||
int SignalCurve::ascii_decode_control_char(char ch, char *str)
|
||||
{
|
||||
switch(str[0])
|
||||
if((ch > 32) && (ch < 127))
|
||||
{
|
||||
str[0] = ch;
|
||||
|
||||
str[1] = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch(ch)
|
||||
{
|
||||
case 0: strcpy(str, "NULL");
|
||||
break;
|
||||
|
@ -2836,6 +2813,8 @@ void SignalCurve::ascii_decode_control_char(char *str)
|
|||
default: strcpy(str, ".");
|
||||
break;
|
||||
}
|
||||
|
||||
return strlen(str);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ private:
|
|||
void drawFFT(QPainter *, int, int);
|
||||
void drawfpsLabel(QPainter *, int, int);
|
||||
void draw_decoder(QPainter *, int, int);
|
||||
void ascii_decode_control_char(char *);
|
||||
int ascii_decode_control_char(char, char *);
|
||||
|
||||
struct device_settings *devparms;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue