From: marchelh Date: Sun, 25 Feb 2018 08:14:57 +0000 (+0100) Subject: siglent-sds: Added averaging function. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fe1aa53613c2421fd6b2c2991122584cbe34342a;p=libsigrok.git siglent-sds: Added averaging function. --- diff --git a/src/hardware/siglent-sds/api.c b/src/hardware/siglent-sds/api.c index 66f8b2a8..7799171d 100644 --- a/src/hardware/siglent-sds/api.c +++ b/src/hardware/siglent-sds/api.c @@ -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. */ diff --git a/src/hardware/siglent-sds/protocol.h b/src/hardware/siglent-sds/protocol.h index a68d16c6..20d4363a 100644 --- a/src/hardware/siglent-sds/protocol.h +++ b/src/hardware/siglent-sds/protocol.h @@ -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;