-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code dedup #33
base: master
Are you sure you want to change the base?
Code dedup #33
Conversation
With dedicated converter methods, the LSM6DSO32 can do its conversion for the bigger ranges there, so duplicated code in _read() can be removed. Also, getAccelRange() and setAccelRange() are exactly the same as in the base class, the difference is only the enum type. Replaced these methods with a call to the baseclass with the casted range.
these functions should take a value and return a value, or take in a pointer to 3 floats and do the conversion? |
I thought, as these two methods are I can do it, if you really want to, but I hope I wouldn't have to. |
Don't the other derived classes still need |
The only class which reimpmement it is LSM6DSO32, because it has extended ranges. As the conversion is done in two |
Oh, sry, was reading the code diff wrong. The OK, this looks like some nice code clean up. Did you test these changes? |
TBH, I don't own an LSM6DSO32. But after I worked on PR #34, the dedup was obvious. |
@caternuson It is almost three weeks later. Are there any changes I have to implement? |
Sorry. Wanted to find a time to test this on hardware. Went ahead and set something up for testing. Looks like something isn't quite correct somewhere. Running the adafruit_lsm6dso32_test.ino example on an Itsy M4 (PID 3800) with a LSM6DSO32 breakout (PID 4692) with current library produces expected output (accelo held flat on table): With PR code, readings are off: Looks like maybe a factor of 2 somewhere? |
@eringerli can you amend this PR so it is complete and working? alternatively, can reduce this PR - each PR should be independant so it can be tested/reverted as needed. |
added methods for converting the raw values to the ones in SI units
This change moves the code for the conversion of raw values to their own virtual methods. This enables the next commit:
LSM6DSO32: removed a lot of duplicated code
With dedicated converter methods, the LSM6DSO32 can do its conversion for
the bigger ranges there, so duplicated code (the whole
_read()
method) can be removed.Also,
getAccelRange()
andsetAccelRange()
are exactly the same as inthe base class, the difference is only the
enum
type. Replaced thesemethods with a call to the base class with the casted range.