adafruit / Adafruit_LSM6DS

Arduino library for LSM6DS
Other
50 stars 41 forks source link

some performance improvements and code cleanups #31

Closed eringerli closed 2 years ago

eringerli commented 2 years ago

Allow for custom SPI clock frequency

Added an additional parameter to the SPI constructor, defaults to 1000000 as was before. The chips supports 10Mhz bus frequency. If you want to read out multiple chips with a high sample rate on a busy bus, rising the frequency to the maximum helps removing bottlenecks.

buffer the accelerometer and gyroscope ranges

Buffering the range instead of requesting it every time the data is read from the chips removes a lot of overhead for a couple of bytes of RAM.

deleting nullptrs has no effect -> don't check for it

Yeah, don't do it.

removed two delay()s

Having delay()s in the code is an unwanted (and undocumented) side effect.

eringerli commented 2 years ago

Compliment on the github-workflow of yours: it was quite a pain to get it all green, which I suppose was the intention :stuck_out_tongue_winking_eye:

ladyada commented 2 years ago

yes we have hundreds of repos which makes it very challenging if we don't use CI to maintain the same code formatting (many folks would submit a PR with massive whitespace changes). however once you have clang-format installed its not too bad to run right before a PR

here is a tutorial on doxygen: https://learn.adafruit.com/the-well-automated-arduino-library/doxygen

and clang-format: https://learn.adafruit.com/the-well-automated-arduino-library/formatting-with-clang-format

eringerli commented 2 years ago

I do it with find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\)' -exec clang-format -i {} --style="llvm" \;, works well.

ladyada commented 2 years ago

also some editors will auto-clangformat with a plugin, FYI

eringerli commented 2 years ago

Yeah, but I use another format for my own code, so running it in a subdirectory with the defaults is way easier than adding a .clang-format to every cloned repository