From c5d081f721a0d99e726596d4f8afe72cf803a576 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Sat, 27 May 2017 22:37:09 +0200 Subject: [PATCH] Bindings: Provide helper method that auto-converts analog --- bindings/cxx/classes.cpp | 5 +++++ bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index 5c0ae3d0..be76263a 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -1212,6 +1212,11 @@ void *Analog::data_pointer() return _structure->data; } +void Analog::get_data_as_float(float *dest) +{ + check(sr_analog_to_float(_structure, dest)); +} + unsigned int Analog::num_samples() const { return _structure->num_samples; diff --git a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp index b82679ab..b1ab7a5b 100644 --- a/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp +++ b/bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp @@ -768,6 +768,11 @@ class SR_API Analog : public: /** Pointer to data. */ void *data_pointer(); + /** + * Fills dest pointer with the analog data converted to float. + * The pointer must have space for num_samples() floats. + */ + void get_data_as_float(float *dest); /** Number of samples in this packet. */ unsigned int num_samples() const; /** Channels for which this packet contains data. */