summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
b772191)
Allow for the analog data to scale during submission, and pass caller
specified MQ including flags and units to the sigrok session. Using
these specs is optional, default behaviour is backwards compatible.
Accumulated data gets flushed before the configuration changes. This
allows the migration of binary helper using drivers to feed queue.
struct sr_analog_meaning meaning;
struct sr_analog_spec spec;
GSList *channels;
struct sr_analog_meaning meaning;
struct sr_analog_spec spec;
GSList *channels;
};
SR_API struct feed_queue_analog *feed_queue_analog_alloc(
};
SR_API struct feed_queue_analog *feed_queue_analog_alloc(
+SR_API int feed_queue_analog_params(struct feed_queue_analog *q,
+ float scale_factor,
+ enum sr_mq mq, enum sr_mqflag mq_flag, enum sr_unit unit)
+{
+ int ret;
+
+ if (!q)
+ return SR_ERR_ARG;
+
+ ret = feed_queue_analog_flush(q);
+ if (ret != SR_OK)
+ return ret;
+
+ q->scale_factor = scale_factor;
+ if (q->scale_factor == 1.0)
+ q->scale_factor = 0.0;
+
+ q->meaning->mq = mq;
+ q->meaning->mqflags = mqflags;
+ q->meaning->unit = unit;
+
+ return SR_OK;
+}
+
SR_API int feed_queue_analog_submit(struct feed_queue_analog *q,
float data, size_t count)
{
int ret;
SR_API int feed_queue_analog_submit(struct feed_queue_analog *q,
float data, size_t count)
{
int ret;
+ if (q->scale_factor)
+ data *= q->scale_factor;
while (count--) {
q->data_values[q->fill_count++] = data;
if (q->fill_count == q->alloc_count) {
while (count--) {
q->data_values[q->fill_count++] = data;
if (q->fill_count == q->alloc_count) {
SR_API struct feed_queue_analog *feed_queue_analog_alloc(
const struct sr_dev_inst *sdi,
size_t sample_count, int digits, struct sr_channel *ch);
SR_API struct feed_queue_analog *feed_queue_analog_alloc(
const struct sr_dev_inst *sdi,
size_t sample_count, int digits, struct sr_channel *ch);
+SR_API int feed_queue_analog_params(struct feed_queue_analog *q,
+ float scale_factor,
+ enum sr_mq mq, enum sr_mqflag mq_flag, enum sr_unit unit);
SR_API int feed_queue_analog_submit(struct feed_queue_analog *q,
float data, size_t count);
SR_API int feed_queue_analog_flush(struct feed_queue_analog *q);
SR_API int feed_queue_analog_submit(struct feed_queue_analog *q,
float data, size_t count);
SR_API int feed_queue_analog_flush(struct feed_queue_analog *q);