mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-16 21:10:10 +00:00
gain_groups: Add zero-value gain groups
Add convenience factory for making a gain group that has a single zero-valued element. This factory requires a name, which should probably be ALL_GAINS, or something similar (these constants are device-specific). Using this new make_zero factory in the X300 radio control when we don't find any gain elements so that our gain groups aren't empty. This simplifies our later setters/getters because we know that we'll always have _something_ cached. Note that we only register this zero value gain group for TX, as our ADC is registered as a gain element, so our RX gain groups are never empty.
This commit is contained in:
parent
75ad0c5516
commit
d1a5b70a8f
2 changed files with 18 additions and 0 deletions
|
|
@ -91,6 +91,13 @@ public:
|
|||
* \return a gain group object.
|
||||
*/
|
||||
static sptr make(void);
|
||||
|
||||
/*!
|
||||
* Make a new gain group with all zero values.
|
||||
* \param name the name of the (only and zero-valued) gain element
|
||||
* \return a gain group object populated with zeroes
|
||||
*/
|
||||
static sptr make_zero();
|
||||
};
|
||||
|
||||
} // namespace uhd
|
||||
|
|
|
|||
|
|
@ -182,3 +182,14 @@ private:
|
|||
gain_group::sptr gain_group::make(void){
|
||||
return sptr(new gain_group_impl());
|
||||
}
|
||||
|
||||
gain_group::sptr gain_group::make_zero()
|
||||
{
|
||||
gain_fcns_t gain_fcns;
|
||||
gain_fcns.get_range = []() { return meta_range_t(0.0, 0.0); };
|
||||
gain_fcns.get_value = []() { return 0.0; };
|
||||
gain_fcns.set_value = [](const double) {};
|
||||
auto gg = make();
|
||||
gg->register_fcns("null", gain_fcns);
|
||||
return gg;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue