sparkfun / SparkFun_LIS2DH12_Arduino_Library

Library for I2C communication with ST LIS2DH12 low power accelerometer
Other
15 stars 10 forks source link

Bug in setMode() function #3

Closed tealbrains closed 4 years ago

tealbrains commented 4 years ago

Subject of the issue

The mode seems to be locked to HR because of the if statement in setMode():

  if (mode > LIS2DH12_HR_12bit)
    mode = LIS2DH12_HR_12bit; //Default to 12 bit

see the enum:


typedef enum {
  LIS2DH12_HR_12bit   = 0,
  LIS2DH12_NM_10bit   = 1,
  LIS2DH12_LP_8bit    = 2,
} lis2dh12_op_md_t;

Proposed fix:

  if (mode > LIS2DH12_LP_8bit)
    mode = LIS2DH12_HR_12bit; //Default to 12 bit
nseidle commented 4 years ago

Nice find! Thanks for reporting. Indeed. Feel like fixing it with a PR or do you need me to?

tealbrains commented 4 years ago

No worries, I will issue a PR later today