Skip to content

Commit f4cebe7

Browse files
authored
Merge pull request #12 from kattni/update-all-examples
Adding ADXL345 init to all examples.
2 parents 570dcfc + c43e660 commit f4cebe7

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

examples/adxl34x_freefall_detection_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
i2c = busio.I2C(board.SCL, board.SDA)
77

8-
accelerometer = adafruit_adxl34x.ADXL345(i2c)
8+
# For ADXL343
9+
accelerometer = adafruit_adxl34x.ADXL343(i2c)
10+
# For ADXL345
11+
# accelerometer = adafruit_adxl34x.ADXL345(i2c)
12+
913
accelerometer.enable_freefall_detection()
1014
# alternatively you can specify attributes when you enable freefall detection for more control:
1115
# accelerometer.enable_freefall_detection(threshold=10,time=25)
16+
1217
while True:
13-
print("%f %f %f"%accelerometer.acceleration)
18+
print("%f %f %f" % accelerometer.acceleration)
1419

15-
print("Dropped: %s"%accelerometer.events["freefall"])
20+
print("Dropped: %s" % accelerometer.events["freefall"])
1621
time.sleep(0.5)

examples/adxl34x_motion_detection_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
i2c = busio.I2C(board.SCL, board.SDA)
77

8-
accelerometer = adafruit_adxl34x.ADXL345(i2c)
8+
# For ADXL343
9+
accelerometer = adafruit_adxl34x.ADXL343(i2c)
10+
# For ADXL345
11+
# accelerometer = adafruit_adxl34x.ADXL345(i2c)
12+
913
accelerometer.enable_motion_detection()
1014
# alternatively you can specify the threshold when you enable motion detection for more control:
1115
# accelerometer.enable_motion_detection(threshold=10)
16+
1217
while True:
13-
print("%f %f %f"%accelerometer.acceleration)
18+
print("%f %f %f" % accelerometer.acceleration)
1419

15-
print("Motion detected: %s"%accelerometer.events['motion'])
20+
print("Motion detected: %s" % accelerometer.events['motion'])
1621
time.sleep(0.5)

examples/adxl34x_tap_detection_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
i2c = busio.I2C(board.SCL, board.SDA)
77

8-
accelerometer = adafruit_adxl34x.ADXL345(i2c)
8+
# For ADXL343
9+
accelerometer = adafruit_adxl34x.ADXL343(i2c)
10+
# For ADXL345
11+
# accelerometer = adafruit_adxl34x.ADXL345(i2c)
12+
913
accelerometer.enable_tap_detection()
1014
# you can also configure the tap detection parameters when you enable tap detection:
1115
# accelerometer.enable_tap_detection(tap_count=2,threshold=20, duration=50)
16+
1217
while True:
13-
print("%f %f %f"%accelerometer.acceleration)
18+
print("%f %f %f" % accelerometer.acceleration)
1419

15-
print("Tapped: %s"%accelerometer.events['tap'])
20+
print("Tapped: %s" % accelerometer.events['tap'])
1621
time.sleep(0.5)

0 commit comments

Comments
 (0)