]> sigrok.org Git - pulseview.git/commitdiff
device.cpp: SR_CONF_AVG_SAMPLES: Add support for list of values.
authorUwe Hermann <redacted>
Sat, 13 Oct 2018 22:24:42 +0000 (00:24 +0200)
committerUwe Hermann <redacted>
Sat, 13 Oct 2018 22:24:42 +0000 (00:24 +0200)
pv/binding/device.cpp
pv/binding/device.hpp

index 07d8ccc05249ffa3bed1be1f923fa15e3c3ef962..37c9d43d55248218b4e7e247cd6173fa1696b664 100644 (file)
@@ -130,7 +130,10 @@ Device::Device(shared_ptr<sigrok::Configurable> configurable) :
                        break;
 
                case SR_CONF_AVG_SAMPLES:
-                       bind_int(name, "", "", pair<int64_t, int64_t>(0, INT32_MAX), get, set);
+                       if (capabilities.count(Capability::LIST))
+                               bind_enum(name, "", key, capabilities, get, set, print_averages);
+                       else
+                               bind_int(name, "", "", pair<int64_t, int64_t>(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
index d4fbf3714ba040236cb055488a5dbc2fd4014a5a..9f5daf574a250beef9e3b5030e75599f88766fc1 100644 (file)
@@ -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<sigrok::Configurable> configurable_;