[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/03: uhd: Use UHDs internal normalized ga
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/03: uhd: Use UHDs internal normalized gain methods |
Date: |
Wed, 14 Dec 2016 00:35:45 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 8728e65b523ae099d9d1705aeed56c6318526e4d
Author: Martin Braun <address@hidden>
Date: Tue Feb 3 17:26:57 2015 +0100
uhd: Use UHDs internal normalized gain methods
---
gr-uhd/lib/usrp_sink_impl.cc | 8 ++++++++
gr-uhd/lib/usrp_source_impl.cc | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 8b3412b..9ade7a7 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -169,12 +169,16 @@ namespace gr {
void usrp_sink_impl::set_normalized_gain(double norm_gain, size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ _dev->set_normalized_tx_gain(norm_gain, chan);
+#else
if (norm_gain > 1.0 || norm_gain < 0.0) {
throw std::runtime_error("Normalized gain out of range, must be in [0,
1].");
}
::uhd::gain_range_t gain_range = get_gain_range(chan);
double abs_gain = (norm_gain * (gain_range.stop() - gain_range.start()))
+ gain_range.start();
set_gain(abs_gain, chan);
+#endif
}
double
@@ -194,6 +198,9 @@ namespace gr {
double
usrp_sink_impl::get_normalized_gain(size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ return _dev->get_normalized_tx_gain(chan);
+#else
::uhd::gain_range_t gain_range = get_gain_range(chan);
double norm_gain =
(get_gain(chan) - gain_range.start()) /
@@ -202,6 +209,7 @@ namespace gr {
if (norm_gain > 1.0) return 1.0;
if (norm_gain < 0.0) return 0.0;
return norm_gain;
+#endif
}
std::vector<std::string>
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index b48b151..9146370 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -184,12 +184,16 @@ namespace gr {
void usrp_source_impl::set_normalized_gain(double norm_gain, size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ _dev->set_normalized_rx_gain(norm_gain, chan);
+#else
if (norm_gain > 1.0 || norm_gain < 0.0) {
throw std::runtime_error("Normalized gain out of range, must be in [0,
1].");
}
::uhd::gain_range_t gain_range = get_gain_range(chan);
double abs_gain = (norm_gain * (gain_range.stop() - gain_range.start()))
+ gain_range.start();
set_gain(abs_gain, chan);
+#endif
}
double
@@ -209,6 +213,9 @@ namespace gr {
double
usrp_source_impl::get_normalized_gain(size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ return _dev->get_normalized_rx_gain(chan);
+#else
::uhd::gain_range_t gain_range = get_gain_range(chan);
double norm_gain =
(get_gain(chan) - gain_range.start()) /
@@ -217,6 +224,7 @@ namespace gr {
if (norm_gain > 1.0) return 1.0;
if (norm_gain < 0.0) return 0.0;
return norm_gain;
+#endif
}
std::vector<std::string>