Skip to content

Commit

Permalink
fixup autogain min gain setting
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Nov 5, 2024
1 parent c67e671 commit 7c34ff3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion readsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,9 @@ static void parseGainOpt(char *arg) {
} else {
Modes.minGain = 0;
}
if (Modes.gain < Modes.minGain) {
Modes.gain = Modes.minGain;
}
if (token[2]) {
Modes.noiseLowThreshold = atoi(token[2]);
} else {
Expand All @@ -1565,7 +1568,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
Expand Down
4 changes: 4 additions & 0 deletions sdr_rtlsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7c34ff3

Please sign in to comment.