Skip to content
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

Added support for setting data rate #19

Merged
merged 9 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/l3gd20_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@

# Hardware I2C setup:
I2C = busio.I2C(board.SCL, board.SDA)
# Initializes L3GD20 object using default range, 250dps
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C)
# Initialize L3GD20 object using a different range.
# SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C, rng=adafruit_l3gd20.L3DS20_RANGE_2000DPS)

# Possible values for rng are:
# adafruit_l3gd20.L3DS20_Range_250DPS, 250 degrees per second. Default range
# adafruit_l3gd20.L3DS20_Range_500DPS, 500 degrees per second
# adafruit_l3gd20.L3DS20_Range_2000DPS, 2000 degrees per second


# Hardware SPI setup:
# import digitalio
Expand Down
19 changes: 19 additions & 0 deletions examples/l3gd20_write_registers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import time
import board
import busio
import adafruit_l3gd20

# Hardware I2C setup:
I2C = busio.I2C(board.SCL, board.SDA)
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C, rng=adafruit_l3gd20.L3DS20_RANGE_2000DPS)

# Update the chip's register 0x20 (CTRL1) with the value 0xBF
SENSOR.write_register(0x20, 0xBF)

# This sets the output data rate to 400Hz and keeps everything else on their default modes
# For more information about CTRL1, see section 7.2 of the datasheet

while True:
print("Angular Momentum (rad/s): {}".format(SENSOR.gyro))
print()
time.sleep(1)