From: Philipp Marek Date: Wed, 20 Dec 2017 14:32:42 +0000 (+0100) Subject: hantek-dso: dso2250: Allow setting TRIGGER_LEVEL as well. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=12f62ce62094500250062c4d0d0b78deeb303ec9;p=libsigrok.git hantek-dso: dso2250: Allow setting TRIGGER_LEVEL as well. --- diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index 9b754629..663cd55d 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -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; diff --git a/src/hardware/hantek-dso/protocol.c b/src/hardware/hantek-dso/protocol.c index ca0bb804..7148e90b 100644 --- a/src/hardware/hantek-dso/protocol.c +++ b/src/hardware/hantek-dso/protocol.c @@ -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; diff --git a/src/hardware/hantek-dso/protocol.h b/src/hardware/hantek-dso/protocol.h index 62664716..5b98e3f2 100644 --- a/src/hardware/hantek-dso/protocol.h +++ b/src/hardware/hantek-dso/protocol.h @@ -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