* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
Device::Device(shared_ptr<sigrok::Configurable> configurable) :
configurable_(configurable)
{
- assert(configurable);
- for (auto entry : configurable->config_keys(ConfigKey::DEVICE_OPTIONS)) {
- auto key = entry.first;
- auto capabilities = entry.second;
+ auto keys = configurable->config_keys();
+
+ for (auto key : keys) {
+
+ auto capabilities = configurable->config_capabilities(key);
if (!capabilities.count(Capability::GET) ||
!capabilities.count(Capability::SET))
config_changed();
};
- switch (key->id())
- {
+ switch (key->id()) {
case SR_CONF_SAMPLERATE:
// Sample rate values are not bound because they are shown
// in the MainBar
case SR_CONF_BUFFERSIZE:
case SR_CONF_TRIGGER_SOURCE:
case SR_CONF_TRIGGER_SLOPE:
- case SR_CONF_FILTER:
case SR_CONF_COUPLING:
case SR_CONF_CLOCK_EDGE:
bind_enum(name, key, capabilities, get, set);
break;
+ case SR_CONF_FILTER:
case SR_CONF_EXTERNAL_CLOCK:
case SR_CONF_RLE:
+ case SR_CONF_POWER_OFF:
bind_bool(name, get, set);
break;
bind_enum(name, key, capabilities, get, set, print_voltage_threshold);
break;
+ case SR_CONF_PROBE_FACTOR:
+ if (capabilities.count(Capability::LIST))
+ bind_enum(name, key, capabilities, get, set, print_probe_factor);
+ else
+ bind_int(name, "", pair<int64_t, int64_t>(1, 500), get, set);
+ break;
+
default:
break;
}
}
void Device::bind_enum(const QString &name,
- const ConfigKey *key, std::set<Capability> capabilities,
+ const ConfigKey *key, std::set<const Capability *> capabilities,
Property::Getter getter,
Property::Setter setter, function<QString (Glib::VariantBase)> printer)
{
return QString("L<%1V H>%2V").arg(lo, 0, 'f', 1).arg(hi, 0, 'f', 1);
}
+QString Device::print_probe_factor(Glib::VariantBase gvar)
+{
+ uint64_t factor;
+ factor = g_variant_get_uint64(gvar.gobj());
+ return QString("%1x").arg(factor);
+}
+
} // binding
} // pv