Skip to content

lis3dh_ad example broken #54

Closed
Closed
@jerryneedell

Description

@jerryneedell

There are a few problem with the lis3dh_adc example.
I get the same results on a CPX and CPB

The I2C initialization needs to be updated:
I changed it to use the same init as in the other examples:



# Hardware I2C setup. Use the CircuitPlayground built-in accelerometer if available;
# otherwise check I2C pins.
if hasattr(board, 'ACCELEROMETER_SCL'):
    i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
    int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
    lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
else:
    i2c = busio.I2C(board.SCL, board.SDA)
    int1 = digitalio.DigitalInOut(board.D6)  # Set to correct pin for interrupt!
    lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)


and it seems happy, but then I get


Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-alpha.0-287-g7cbae3d20 on 2019-08-28; Adafruit CircuitPlayground Express with samd21g18
>>> 
>>> import lis3dh_adc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lis3dh_adc.py", line 39, in <module>
  File "adafruit_lis3dh.py", line 206, in read_adc_raw
RuntimeError: buffer size must match format
>>> 

the error appears to be here
https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH/blob/master/adafruit_lis3dh.py#L206

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions