]> sigrok.org Git - libsigrok.git/commitdiff
siglent-sds: Added averaging function.
authormarchelh <redacted>
Sun, 25 Feb 2018 08:14:57 +0000 (09:14 +0100)
committerUwe Hermann <redacted>
Sat, 3 Mar 2018 16:45:21 +0000 (17:45 +0100)
src/hardware/siglent-sds/api.c
src/hardware/siglent-sds/protocol.h

index 66f8b2a8fa23a22cb62afa58247720294e8092de..7799171def45bdff7a2a4fd181c06987e9045255 100644 (file)
@@ -682,6 +682,14 @@ static int config_set(uint32_t key, GVariant *data,
                siglent_sds_get_dev_cfg_horizontal(sdi);
                data = g_variant_new_uint64(devc->samplerate);
                break;
+       case SR_CONF_AVERAGING:
+               devc->average_enabled = g_variant_get_boolean(data);
+               sr_dbg("%s averaging", devc->average_enabled ? "Enabling" : "Disabling");
+               break;
+       case SR_CONF_AVG_SAMPLES:
+               devc->average_samples = g_variant_get_uint64(data);
+               sr_dbg("Setting averaging rate to %" PRIu64, devc->average_samples);
+               break;  
        default:
                return SR_ERR_NA;
        }
@@ -767,7 +775,7 @@ static int config_list(uint32_t key, GVariant **data,
                *data = g_variant_new_int32(devc->model->series->num_horizontal_divs);
                break;
        case SR_CONF_AVERAGING:
-               /* TODO: Implement averaging. */
+               *data = g_variant_new_boolean(devc->average_enabled);
                break;
        default:
                return SR_ERR_NA;
@@ -854,8 +862,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        case SPO_MODEL:
                if (siglent_sds_config_set(sdi, "WFSU SP,0,TYPE,1") != SR_OK)
                        return SR_ERR;
-               if (siglent_sds_config_set(sdi, "ACQW SAMPLING") != SR_OK)
-                       return SR_ERR;
+               if (devc->average_enabled) {
+                       if (siglent_sds_config_set(sdi, "ACQW AVERAGE,%i", devc->average_samples) != SR_OK)
+                               return SR_ERR;
+               } else {
+                       if (siglent_sds_config_set(sdi, "ACQW SAMPLING") != SR_OK)
+                               return SR_ERR;
+               }
                break;
        case NON_SPO_MODEL:
                /* TODO: Implement CML/CNL/DL models. */
index a68d16c65a4efcfb434fe225091b42ac5b4b1a60..20d4363a0569501393ed9ce9443629c2a475717f 100644 (file)
@@ -101,6 +101,8 @@ struct dev_context {
        /* Acquisition settings */
        GSList *enabled_channels;
        uint64_t limit_frames;
+       uint64_t average_samples;
+       gboolean average_enabled;
        enum data_source data_source;
        uint64_t analog_frame_size;
        uint64_t digital_frame_size;