From 470692148de4baca57e083b58b332d1cdaa6cf55 Mon Sep 17 00:00:00 2001 From: Bas Heijermans Date: Sun, 17 Nov 2019 19:27:17 +0100 Subject: [PATCH] Update rsp_tcp.c Calculation to 8bit was wrong, as such the driver had poor quality and looses small signals pretty quickly. Bas Heijermans - ON5HB --- rsp_tcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rsp_tcp.c b/rsp_tcp.c index a3f7b39..b13361e 100644 --- a/rsp_tcp.c +++ b/rsp_tcp.c @@ -445,8 +445,10 @@ void rx_callback(short* xi, short* xq, unsigned int firstSampleNum, int grChange char *data; data = rpt->data; for (i = 0; i < numSamples; i++, xi++, xq++) { - *(data++) = (unsigned char)(((*xi << sample_shift) >> 8) + 128); - *(data++) = (unsigned char)(((*xq << sample_shift) >> 8) + 128); + // Calculation to 8 bit was wrong, this one is correct and better. Bas ON5HB. + *(data++) = (unsigned char)(((*xi << 1) + 16384) / 128) + 0.5; + *(data++) = (unsigned char)(((*xq << 1) + 16384) / 128) + 0.5; + } rpt->len = 2 * numSamples;