Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.

Commit 6ffe0e2

Browse files
committed
lint examples
1 parent 77a40c7 commit 6ffe0e2

File tree

8 files changed

+65
-62
lines changed

8 files changed

+65
-62
lines changed

examples/fast_accel/fast_accel.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
""" Read data from the accelerometer and print it out, ASAP! """
2+
3+
import board
4+
import busio
5+
6+
import adafruit_lsm303
7+
8+
i2c = busio.I2C(board.SCL, board.SDA)
9+
sensor = adafruit_lsm303.LSM303(i2c)
10+
11+
while True:
12+
accel_x, accel_y, accel_z = sensor.accelerometer
13+
print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(accel_x, accel_y, accel_z))

examples/fast_accel/main.py

-13
This file was deleted.

examples/fast_mag/fast_mag.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
""" Read data from the magnetometer and print it out, ASAP! """
2+
3+
import board
4+
import busio
5+
import adafruit_lsm303
6+
7+
i2c = busio.I2C(board.SCL, board.SDA)
8+
sensor = adafruit_lsm303.LSM303(i2c)
9+
10+
while True:
11+
mag_x, mag_y, mag_z = sensor.magnetometer
12+
print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(mag_x, mag_y, mag_z))

examples/fast_mag/main.py

-13
This file was deleted.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
""" Display both accelerometer and magnetometer data once per second """
2+
# pylint: disable=line-too-long
3+
4+
import time
5+
import board
6+
import busio
7+
8+
import adafruit_lsm303
9+
10+
i2c = busio.I2C(board.SCL, board.SDA)
11+
sensor = adafruit_lsm303.LSM303(i2c)
12+
13+
while True:
14+
raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_accelerometer
15+
accel_x, accel_y, accel_z = sensor.accelerometer
16+
raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetometer
17+
mag_x, mag_y, mag_z = sensor.magnetometer
18+
19+
print('Acceleration raw: ({0:6d}, {1:6d}, {2:6d}), (m/s^2): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_accel_x, raw_accel_y, raw_accel_z, accel_x, accel_y, accel_z))
20+
print('Magnetometer raw: ({0:6d}, {1:6d}, {2:6d}), (gauss): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_mag_x, raw_mag_y, raw_mag_z, mag_x, mag_y, mag_z))
21+
print('')
22+
time.sleep(1.0)

examples/slow_both/main.py

-17
This file was deleted.

examples/slow_both/slow_both.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
""" Display both accelerometer and magnetometer data once per second """
2+
3+
import time
4+
import board
5+
import busio
6+
import adafruit_lsm303
7+
8+
i2c = busio.I2C(board.SCL, board.SDA)
9+
sensor = adafruit_lsm303.LSM303(i2c)
10+
11+
while True:
12+
acc_x, acc_y, acc_z = sensor.accelerometer
13+
mag_x, mag_y, mag_z = sensor.magnetometer
14+
15+
print('Acceleration (m/s^2): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(acc_x, acc_y, acc_z))
16+
print('Magnetometer (gauss): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(mag_x, mag_y, mag_z))
17+
print('')
18+
time.sleep(1.0)

examples/the_raw_and_the_cooked/main.py

-19
This file was deleted.

0 commit comments

Comments
 (0)