From: Soeren Apel Date: Sat, 27 May 2017 20:37:09 +0000 (+0200) Subject: Bindings: Provide helper method that auto-converts analog X-Git-Tag: libsigrok-0.5.0~27 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c5d081f721a0d99e726596d4f8afe72cf803a576;p=libsigrok.git Bindings: Provide helper method that auto-converts analog --- 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. */