added c++ usage example for this driver #155
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using this drivers with C++ Code.
I needed some time to figure out how to use the hande to pass the instance pointer to my nonstatic member functions.
An example would have helped me a lot.
There for i sugest to add an c++ example to the readme like this one below and in the the pull request
non static member functions of classes need an pointer to their own instance as first argument this is implicit done by the compiler.
This libraries pass the
ctx.handle
as first argument to the read and write Functions so we can store the pointer to the class instance there.When defining out platform member functions we must skip the first argument since this will be the this pointer
See example:
With in the classes code the driver functions can than easily be used with &_dev_ctx as first argument like
lsm6dsrx_device_id_get(&_dev_ctx, &_whoamI);