periph / devices

Go·Hardware·Lean - Device drivers
https://periph.io
Apache License 2.0
83 stars 37 forks source link

adxl345: I²C support #67

Closed benoit-pereira-da-silva closed 6 months ago

benoit-pereira-da-silva commented 6 months ago
  1. Please prefix the issue title with the primary package affected. For example, if this PR fixes periph.io/x/devices/v3/cap1xxx, prefix the PR title with "cap1xxx:". adxl345: support both SPI and I²C.

    • Refactored a little bit to make it more consistant with other devices implementation.
  2. Mention the issue number it fixes or add the details of the changes if it doesn't have a specific issue. Examples:

  3. Once integrated, send a PR to https://github.com/periph/cmd to leverage the new functionality (if relevant).

benoit-pereira-da-silva commented 6 months ago

@maruel using mmr.Dev16 was not convenient. The adxl345 returns positive and negative int16 values. So i decided to keep the infamous :) conversion int16(binary.LittleEndian.Uint16(rx)) this implementation should work for most of the adxlXXX line so i ve enabled the ability to use another device by passing explicitly its Opts.ExpectedDeviceID.

maruel commented 6 months ago

Thanks for the change! Can you rebase it onto origin/main first?

codecov-commenter commented 6 months ago

Codecov Report

Attention: 50 lines in your changes are missing coverage. Please review.

Comparison is base (931687b) 62.5% compared to head (60fc493) 61.7%.

Files Patch % Lines
adxl345/adxl345.go 0.0% 50 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #67 +/- ## ======================================= - Coverage 62.5% 61.7% -0.8% ======================================= Files 64 65 +1 Lines 7337 7442 +105 ======================================= + Hits 4583 4589 +6 - Misses 2600 2701 +101 + Partials 154 152 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.