X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fprop%2Fbinding%2Fdeviceoptions.cpp;h=1b95cfe0b2314b89e4f40fe7d3029d2045f59475;hb=b1fe148e0dce6e369c9d4770ca935a6a9ec94b59;hp=50af3ed4ffdec51a09565537a997f2578f2d366b;hpb=de1d99bbe58f825e30048baa48a9439c01686f10;p=pulseview.git diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index 50af3ed4..1b95cfe0 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -30,6 +30,7 @@ #include #include #include +#include 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(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 > range) +{ + _properties.push_back(shared_ptr( + 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