]> sigrok.org Git - libsigrok.git/commitdiff
demo: Get/Set new config key offset.
authorFrank Stettner <redacted>
Thu, 21 Feb 2019 15:47:25 +0000 (16:47 +0100)
committerUwe Hermann <redacted>
Fri, 29 Mar 2019 15:15:37 +0000 (16:15 +0100)
src/hardware/demo/api.c

index e5ee21b71debde80b167aa21afeb65e7be2f2497..4d4b891c651a1886daf01e74757703d7fd05976b 100644 (file)
@@ -77,12 +77,14 @@ static const uint32_t devopts_cg_logic[] = {
 
 static const uint32_t devopts_cg_analog_group[] = {
        SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_OFFSET | SR_CONF_GET | SR_CONF_SET,
 };
 
 static const uint32_t devopts_cg_analog_channel[] = {
        SR_CONF_MEASURED_QUANTITY | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_PATTERN_MODE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_AMPLITUDE | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_OFFSET | SR_CONF_GET | SR_CONF_SET,
 };
 
 static const int32_t trigger_matches[] = {
@@ -304,6 +306,16 @@ static int config_get(uint32_t key, GVariant **data,
                ag = g_hash_table_lookup(devc->ch_ag, ch);
                *data = g_variant_new_double(ag->amplitude);
                break;
+       case SR_CONF_OFFSET:
+               if (!cg)
+                       return SR_ERR_CHANNEL_GROUP;
+               /* Any channel in the group will do. */
+               ch = cg->channels->data;
+               if (ch->type != SR_CHANNEL_ANALOG)
+                       return SR_ERR_ARG;
+               ag = g_hash_table_lookup(devc->ch_ag, ch);
+               *data = g_variant_new_double(ag->offset);
+               break;
        case SR_CONF_CAPTURE_RATIO:
                *data = g_variant_new_uint64(devc->capture_ratio);
                break;
@@ -406,6 +418,17 @@ static int config_set(uint32_t key, GVariant *data,
                        ag->amplitude = g_variant_get_double(data);
                }
                break;
+       case SR_CONF_OFFSET:
+               if (!cg)
+                       return SR_ERR_CHANNEL_GROUP;
+               for (l = cg->channels; l; l = l->next) {
+                       ch = l->data;
+                       if (ch->type != SR_CHANNEL_ANALOG)
+                               return SR_ERR_ARG;
+                       ag = g_hash_table_lookup(devc->ch_ag, ch);
+                       ag->offset = g_variant_get_double(data);
+               }
+               break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
                break;