From daea0dd8bfb6119c10d443c2ca53eaac64c4f7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= Date: Sat, 24 Feb 2024 22:55:35 +0100 Subject: [PATCH] Slightly increase numerical precision --- src/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 3ffd53a..b210394 100644 --- a/src/main.c +++ b/src/main.c @@ -594,6 +594,9 @@ static void rf_rx(void) int I = cos_neg - cos_pos; int Q = sin_neg - sin_pos; + I <<= 8; + Q <<= 8; + int lpP = d & (LPF_SIZE - 1); lpIa1 += I - lpIh1[lpP]; @@ -623,6 +626,9 @@ static void rf_rx(void) I = lpIa3 / LPF_SIZE; Q = lpQa3 / LPF_SIZE; + I >>= 8; + Q >>= 8; + dI += I; dQ += Q; } @@ -630,8 +636,8 @@ static void rf_rx(void) dcI = ((dcI << 13) - dcI + (dI << 19)) >> 13; dcQ = ((dcQ << 13) - dcQ + (dQ << 19)) >> 13; - dI -= dcI >> 19; - dQ -= dcQ >> 19; + dI = ((dI << 19) - dcI) >> 19; + dQ = ((dQ << 19) - dcQ) >> 19; if (dI > amp_max) dI = amp_max;