]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Simplify some more trigger slope settings.
authorUwe Hermann <redacted>
Sun, 6 Aug 2017 13:58:52 +0000 (15:58 +0200)
committerUwe Hermann <redacted>
Sun, 6 Aug 2017 15:31:46 +0000 (17:31 +0200)
src/hardware/hantek-dso/api.c
src/hardware/link-mso19/api.c

index bc10f39e5e1668ccd76ff37ff8363e199e13cc9f..01ef47f8bd5dea781157438ef47d925c6dae864d 100644 (file)
@@ -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);
index 793ec53995be79664750b3be44b26fcd8cf0bb92..923867e38abd300969cf2f55f829eaffd77a13bd 100644 (file)
@@ -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);