hantek-dso: dso2250: Allow setting TRIGGER_LEVEL as well.

This commit is contained in:
Philipp Marek 2017-12-20 15:32:42 +01:00 committed by Uwe Hermann
parent 16a1dca4ad
commit 12f62ce620
3 changed files with 19 additions and 1 deletions

View 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;

View 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;

View 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