From 94db11e93728e3a1bdef6cd550eabd53a4338044 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Tue, 5 Nov 2024 08:13:13 +0100 Subject: [PATCH] fixup autogain min gain setting --- readsb.c | 2 +- sdr_rtlsdr.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/readsb.c b/readsb.c index 46e63a7b..b4b7024a 100644 --- a/readsb.c +++ b/readsb.c @@ -1565,7 +1565,7 @@ static void parseGainOpt(char *arg) { } else { Modes.loudThreshold = 243; } - fprintf(stderr, "startingGain: %4.1f noiseLowThreshold: %3d noiseHighThreshold: %3d loudThreshold: %3d\n", + fprintf(stderr, "lowestGain: %4.1f noiseLowThreshold: %3d noiseHighThreshold: %3d loudThreshold: %3d\n", Modes.gain / 10.0, Modes.noiseLowThreshold, Modes.noiseHighThreshold, Modes.loudThreshold); } else { Modes.gain = (int) (atof(arg)*10); // Gain is in tens of DBs diff --git a/sdr_rtlsdr.c b/sdr_rtlsdr.c index 5872e587..fb3bb470 100644 --- a/sdr_rtlsdr.c +++ b/sdr_rtlsdr.c @@ -121,6 +121,10 @@ void rtlsdrSetGain(char *reason) { Modes.increaseGain = 0; Modes.lowerGain = 0; + if (RTLSDR.gains[closest] < Modes.minGain) { + // new gain less than minimum, nothing to do + return; + } if (Modes.gain == RTLSDR.gains[closest]) { // same gain, nothing to do return;