]> sigrok.org Git - libsigrok.git/commitdiff
hantek-dso: dso2250: Allow setting TRIGGER_LEVEL as well.
authorPhilipp Marek <redacted>
Wed, 20 Dec 2017 14:32:42 +0000 (15:32 +0100)
committerUwe Hermann <redacted>
Thu, 11 Jan 2018 01:21:50 +0000 (02:21 +0100)
src/hardware/hantek-dso/api.c
src/hardware/hantek-dso/protocol.c
src/hardware/hantek-dso/protocol.h

index 9b7546292902184d6d4c67679269a3cbf4749d56..663cd55dfcd668e732313b2a613be21015219469 100644 (file)
@@ -64,6 +64,7 @@ static const uint32_t devopts[] = {
        SR_CONF_BUFFERSIZE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_NUM_VDIV | SR_CONF_GET,
+       SR_CONF_TRIGGER_LEVEL | SR_CONF_GET | SR_CONF_SET,
 };
 
 static const uint32_t devopts_cg[] = {
@@ -441,6 +442,9 @@ static int config_get(uint32_t key, GVariant **data,
        devc = sdi->priv;
        if (!cg) {
                switch (key) {
+               case SR_CONF_TRIGGER_LEVEL:
+                       *data = g_variant_new_double(devc->voffset_trigger);
+                       break;
                case SR_CONF_CONN:
                        if (!sdi->conn)
                                return SR_ERR_ARG;
@@ -504,6 +508,7 @@ static int config_set(uint32_t key, GVariant *data,
        struct dev_context *devc;
        int rat;
        int ch_idx, idx;
+       float flt;
 
        devc = sdi->priv;
        if (!cg) {
@@ -511,6 +516,18 @@ static int config_set(uint32_t key, GVariant *data,
                case SR_CONF_LIMIT_FRAMES:
                        devc->limit_frames = g_variant_get_uint64(data);
                        break;
+               case SR_CONF_TRIGGER_LEVEL:
+                       flt = g_variant_get_double(data);
+                       if (flt < 0.0 || flt > 1.0) {
+                               sr_err("Trigger level must be in [0.0,1.0].");
+                               return SR_ERR_ARG;
+                       }
+
+                       devc->voffset_trigger = flt;
+                       if (dso_set_voffsets(sdi) != SR_OK) {
+                                       return SR_ERR;
+                       }
+                       break;
                case SR_CONF_TRIGGER_SLOPE:
                        if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0)
                                return SR_ERR_ARG;
index ca0bb80481052a95f748a9a8c6844ad6d3cbb896..7148e90bd1d368b2e8a3850be5d3ec9f3b7e72ae 100644 (file)
@@ -700,7 +700,7 @@ static int dso_set_relays(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int dso_set_voffsets(const struct sr_dev_inst *sdi)
+int dso_set_voffsets(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
index 626647163f7a4cffd0fd455fad52a9c594199419..5b98e3f2cfee5f6f21e5bef999a83e237f018239 100644 (file)
@@ -223,5 +223,6 @@ SR_PRIV int dso_capture_start(const struct sr_dev_inst *sdi);
 SR_PRIV int dso_get_channeldata(const struct sr_dev_inst *sdi,
                libusb_transfer_cb_fn cb);
 SR_PRIV int dso_set_trigger_samplerate(const struct sr_dev_inst *sdi);
+SR_PRIV int dso_set_voffsets(const struct sr_dev_inst *sdi);
 
 #endif