From: Uwe Hermann Date: Sat, 13 Oct 2018 22:24:42 +0000 (+0200) Subject: device.cpp: SR_CONF_AVG_SAMPLES: Add support for list of values. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f125ab7f8ad363ba69f5e7b2b1b1197b2f9f0080;p=pulseview.git device.cpp: SR_CONF_AVG_SAMPLES: Add support for list of values. --- diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp index 07d8ccc0..37c9d43d 100644 --- a/pv/binding/device.cpp +++ b/pv/binding/device.cpp @@ -130,7 +130,10 @@ Device::Device(shared_ptr configurable) : break; case SR_CONF_AVG_SAMPLES: - bind_int(name, "", "", pair(0, INT32_MAX), get, set); + if (capabilities.count(Capability::LIST)) + bind_enum(name, "", key, capabilities, get, set, print_averages); + else + bind_int(name, "", "", pair(0, INT32_MAX), get, set); break; default: @@ -212,5 +215,12 @@ QString Device::print_probe_factor(Glib::VariantBase gvar) return QString("%1x").arg(factor); } +QString Device::print_averages(Glib::VariantBase gvar) +{ + uint64_t avg; + avg = g_variant_get_uint64(gvar.gobj()); + return QString("%1").arg(avg); +} + } // namespace binding } // namespace pv diff --git a/pv/binding/device.hpp b/pv/binding/device.hpp index d4fbf371..9f5daf57 100644 --- a/pv/binding/device.hpp +++ b/pv/binding/device.hpp @@ -68,6 +68,7 @@ private: static QString print_vdiv(Glib::VariantBase gvar); static QString print_voltage_threshold(Glib::VariantBase gvar); static QString print_probe_factor(Glib::VariantBase gvar); + static QString print_averages(Glib::VariantBase gvar); protected: shared_ptr configurable_;