Skip to content

Commit fceb152

Browse files
committed
Added options to gain.
1 parent 50648af commit fceb152

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

sources/radio/help_structures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ struct Gain {
4949
double min;
5050
double max;
5151
double step;
52+
std::vector<double> options;
5253
};
53-
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Gain, name, value, min, max, step)
54+
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Gain, name, value, min, max, step, options)
5455

5556
struct Crontab {
5657
std::string name;

sources/radio/sdr_device_reader.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,19 @@ std::vector<Gain> getGains(SoapySDR::Device* sdr) {
2828
colored(GREEN, "{}", gainRange.minimum()),
2929
colored(GREEN, "{}", gainRange.maximum()),
3030
colored(GREEN, "{}", gainRange.step()));
31-
gains.emplace_back(gain, gainRange.maximum(), gainRange.minimum(), gainRange.maximum(), gainRange.step());
31+
std::vector<double> options;
32+
const auto optionsCount = (gainRange.maximum() - gainRange.minimum()) / gainRange.step();
33+
if (!std::isnan(optionsCount) && optionsCount < 1000) {
34+
for (double value = gainRange.minimum(); value <= gainRange.maximum(); value += gainRange.step()) {
35+
options.push_back(value);
36+
}
37+
} else if (sdr->getDriverKey() == "RTLSDR" && gain == "TUNER") {
38+
options = {0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6};
39+
} else {
40+
options.push_back(gainRange.minimum());
41+
options.push_back(gainRange.maximum());
42+
}
43+
gains.emplace_back(gain, gainRange.maximum(), gainRange.minimum(), gainRange.maximum(), gainRange.step(), options);
3244
}
3345
std::sort(gains.begin(), gains.end(), [](const Gain& g1, Gain& g2) { return g1.name < g2.name; });
3446
return gains;
@@ -131,6 +143,7 @@ void SdrDeviceReader::clearDevices(nlohmann::json& json) {
131143
gain.erase("min");
132144
gain.erase("max");
133145
gain.erase("step");
146+
gain.erase("options");
134147
}
135148
}
136149
}

0 commit comments

Comments
 (0)