From: Uwe Hermann Date: Sun, 6 Aug 2017 13:58:52 +0000 (+0200) Subject: drivers: Simplify some more trigger slope settings. X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=db85496ed16eb186a62b16be7d59d61f78e07d81 drivers: Simplify some more trigger slope settings. --- diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index bc10f39e..01ef47f8 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -486,8 +486,7 @@ static int config_set(uint32_t key, GVariant *data, case SR_CONF_TRIGGER_SLOPE: if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0) return SR_ERR_ARG; - devc->triggerslope = (trigger_slopes[idx][0] == 'r') - ? SLOPE_POSITIVE : SLOPE_NEGATIVE; + devc->triggerslope = idx; break; case SR_CONF_HORIZ_TRIGGERPOS: tmp_double = g_variant_get_double(data); diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 793ec539..923867e3 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -53,6 +53,10 @@ static const uint64_t samplerates[] = { SR_HZ(100), }; +static const char *trigger_slopes[2] = { + "r", "f", +}; + static GSList *scan(struct sr_dev_driver *di, GSList *options) { int i; @@ -253,14 +257,9 @@ static int config_set(int key, GVariant *data, case SR_CONF_CAPTURE_RATIO: break; case SR_CONF_TRIGGER_SLOPE: - slope = g_variant_get_string(data, NULL); - - if (!slope || !(slope[0] == 'f' || slope[0] == 'r')) - sr_err("Invalid trigger slope"); + if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0) return SR_ERR_ARG; - } - devc->trigger_slope = (slope[0] == 'r') - ? SLOPE_POSITIVE : SLOPE_NEGATIVE; + devc->trigger_slope = idx; break; case SR_CONF_HORIZ_TRIGGERPOS: pos = g_variant_get_double(data);