]> sigrok.org Git - pulseview.git/blobdiff - pv/prop/binding/deviceoptions.cpp
Added Binding::add_properties_to_form
[pulseview.git] / pv / prop / binding / deviceoptions.cpp
index 50af3ed4ffdec51a09565537a997f2578f2d366b..1b95cfe0b2314b89e4f40fe7d3029d2045f59475 100644 (file)
@@ -30,6 +30,7 @@
 #include <pv/prop/bool.h>
 #include <pv/prop/double.h>
 #include <pv/prop/enum.h>
+#include <pv/prop/int.h>
 
 using namespace boost;
 using namespace std;
@@ -71,6 +72,10 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
                        bind_samplerate(name, gvar_list);
                        break;
 
+               case SR_CONF_CAPTURE_RATIO:
+                       bind_int(name, key, "%", pair<int64_t, int64_t>(0, 100));
+                       break;
+
                case SR_CONF_PATTERN_MODE:
                case SR_CONF_BUFFERSIZE:
                case SR_CONF_TRIGGER_SOURCE:
@@ -90,6 +95,10 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
                case SR_CONF_VDIV:
                        bind_enum(name, key, gvar_list, print_vdiv);
                        break;
+
+               case SR_CONF_VOLTAGE_THRESHOLD:
+                       bind_enum(name, key, gvar_list, print_voltage_threshold);
+                       break;
                }
 
                if (gvar_list)
@@ -143,6 +152,15 @@ void DeviceOptions::bind_enum(const QString &name, int key,
                        bind(config_setter, _sdi, key, _1))));
 }
 
+void DeviceOptions::bind_int(const QString &name, int key, QString suffix,
+       optional< std::pair<int64_t, int64_t> > range)
+{
+       _properties.push_back(shared_ptr<Property>(
+               new Int(name, suffix, range,
+                       bind(config_getter, _sdi, key),
+                       bind(config_setter, _sdi, key, _1))));
+}
+
 QString DeviceOptions::print_gvariant(GVariant *const gvar)
 {
        QString s;
@@ -241,6 +259,15 @@ QString DeviceOptions::print_vdiv(GVariant *const gvar)
        return QString(sr_voltage_string(p, q));
 }
 
+QString DeviceOptions::print_voltage_threshold(GVariant *const gvar)
+{
+       gdouble lo, hi;
+       char buf[64];
+       g_variant_get(gvar, "(dd)", &lo, &hi);
+       snprintf(buf, sizeof(buf), "L<%.1fV H>%.1fV", lo, hi);
+       return QString(buf);
+}
+
 } // binding
 } // prop
 } // pv