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

Commit

Permalink
lint examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ladyada committed Jan 24, 2018
1 parent 77a40c7 commit 6ffe0e2
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 62 deletions.
13 changes: 13 additions & 0 deletions examples/fast_accel/fast_accel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
""" Read data from the accelerometer and print it out, ASAP! """

import board
import busio

import adafruit_lsm303

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lsm303.LSM303(i2c)

while True:
accel_x, accel_y, accel_z = sensor.accelerometer
print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(accel_x, accel_y, accel_z))
13 changes: 0 additions & 13 deletions examples/fast_accel/main.py

This file was deleted.

12 changes: 12 additions & 0 deletions examples/fast_mag/fast_mag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
""" Read data from the magnetometer and print it out, ASAP! """

import board
import busio
import adafruit_lsm303

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lsm303.LSM303(i2c)

while True:
mag_x, mag_y, mag_z = sensor.magnetometer
print('{0:10.3f} {1:10.3f} {2:10.3f}'.format(mag_x, mag_y, mag_z))
13 changes: 0 additions & 13 deletions examples/fast_mag/main.py

This file was deleted.

22 changes: 22 additions & 0 deletions examples/raw_and_cooked/raw_and_cooked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
""" Display both accelerometer and magnetometer data once per second """
# pylint: disable=line-too-long

import time
import board
import busio

import adafruit_lsm303

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lsm303.LSM303(i2c)

while True:
raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_accelerometer
accel_x, accel_y, accel_z = sensor.accelerometer
raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetometer
mag_x, mag_y, mag_z = sensor.magnetometer

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))
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))
print('')
time.sleep(1.0)
17 changes: 0 additions & 17 deletions examples/slow_both/main.py

This file was deleted.

18 changes: 18 additions & 0 deletions examples/slow_both/slow_both.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
""" Display both accelerometer and magnetometer data once per second """

import time
import board
import busio
import adafruit_lsm303

i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_lsm303.LSM303(i2c)

while True:
acc_x, acc_y, acc_z = sensor.accelerometer
mag_x, mag_y, mag_z = sensor.magnetometer

print('Acceleration (m/s^2): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(acc_x, acc_y, acc_z))
print('Magnetometer (gauss): ({0:10.3f}, {1:10.3f}, {2:10.3f})'.format(mag_x, mag_y, mag_z))
print('')
time.sleep(1.0)
19 changes: 0 additions & 19 deletions examples/the_raw_and_the_cooked/main.py

This file was deleted.

0 comments on commit 6ffe0e2

Please sign in to comment.