Skip to content

Commit c0bd6b8

Browse files
committed
Fixing pylint issues
1 parent e28bc77 commit c0bd6b8

File tree

5 files changed

+62
-24
lines changed

5 files changed

+62
-24
lines changed

adafruit_bno055.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def use_external_crystal(self, value):
228228
def temperature(self):
229229
"""Measures the temperature of the chip in degrees Celsius."""
230230
return self._temperature
231-
231+
232232
@temperature.setter
233233
def temperature(self):
234234
self._temperature = _ReadOnlyUnaryStruct(0x34, 'b')
@@ -238,9 +238,8 @@ def acceleration(self):
238238
"""Gives the raw accelerometer readings, in m/s."""
239239
if self.mode not in [0, 2, 3, 6]:
240240
return self._acceleration
241-
else:
242-
return (None, None, None)
243-
241+
return (None, None, None)
242+
244243
@acceleration.setter
245244
def acceleration(self):
246245
self._acceleration = _ScaledReadOnlyStruct(0x08, '<hhh', 1/100)
@@ -251,9 +250,7 @@ def magnetic(self):
251250
"""Gives the raw magnetometer readings in microteslas."""
252251
if self.mode not in [0, 3, 5, 8]:
253252
return self._magnetic
254-
255-
else:
256-
return (None, None, None)
253+
return (None, None, None)
257254

258255
@magnetic.setter
259256
def magnetic(self):
@@ -265,9 +262,7 @@ def gyro(self):
265262
"""Gives the raw gyroscope reading in radians per second."""
266263
if self.mode not in [0, 1, 2, 4, 9, 10]:
267264
return self._gyro
268-
269-
else:
270-
return (None, None, None)
265+
return (None, None, None)
271266

272267
@gyro.setter
273268
def gyro(self):
@@ -278,10 +273,8 @@ def gyro(self):
278273
def euler(self):
279274
"""Gives the calculated orientation angles, in degrees."""
280275
if self.mode in [9, 11, 12]:
281-
282276
return self._euler
283-
else:
284-
return (None, None, None)
277+
return (None, None, None)
285278

286279
@euler.setter
287280
def euler(self):
@@ -293,22 +286,19 @@ def quaternion(self):
293286
"""Gives the calculated orientation as a quaternion."""
294287
if self.mode in [9, 11, 12]:
295288
return self._quaternion
296-
else:
297-
return (None, None, None, None)
289+
return (None, None, None, None)
298290

299291
@quaternion.setter
300292
def quaternion(self):
301-
self._quaternion = _ScaledReadOnlyStruct(0x20, '<hhhh', 1/(1<<14))
293+
self._quaternion = _ScaledReadOnlyStruct(0x20, '<hhhh', 1/(1<<14))
302294

303295

304296
@property
305297
def linear_acceleration(self):
306298
"""Returns the linear acceleration, without gravity, in m/s."""
307299
if self.mode in [9, 11, 12]:
308300
return self._linear_acceleration
309-
310-
else:
311-
return (None, None, None)
301+
return (None, None, None)
312302

313303
@linear_acceleration.setter
314304
def linear_acceleration(self):
@@ -320,10 +310,8 @@ def gravity(self):
320310
"""Returns the gravity vector, without acceleration in m/s."""
321311
if self.mode in [9, 11, 12]:
322312
return self._gravity
323-
324-
else:
325-
return (None, None, None)
313+
return (None, None, None)
326314

327315
@gravity.setter
328316
def gravity(self):
329-
self._gravity = _ScaledReadOnlyStruct(0x2e, '<hhh', 1/100)
317+
self._gravity = _ScaledReadOnlyStruct(0x2e, '<hhh', 1/100)

examples/bno055_simpletest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
i2c = busio.I2C(board.SCL, board.SDA)
77
sensor = adafruit_bno055.BNO055(i2c)
88

9-
while True:
9+
a = [adafruit_bno055.ACCONLY_MODE, adafruit_bno055.MAGONLY_MODE, adafruit_bno055.GYRONLY_MODE, adafruit_bno055.ACCMAG_MODE, adafruit_bno055.ACCGYRO_MODE, adafruit_bno055.MAGGYRO_MODE, adafruit_bno055.AMG_MODE, adafruit_bno055.IMUPLUS_MODE, adafruit_bno055.COMPASS_MODE, adafruit_bno055.M4G_MODE, adafruit_bno055.NDOF_FMC_OFF_MODE, adafruit_bno055.NDOF_MODE]
10+
for i in a:
11+
print(i)
12+
#sensor.mode = i
13+
sensor.mode = adafruit_bno055.AMG_MODE
1014
print('Temperature: {} degrees C'.format(sensor.temperature))
1115
print('Accelerometer (m/s^2): {}'.format(sensor.acceleration))
1216
print('Magnetometer (microteslas): {}'.format(sensor.magnetic))

examples/compasstest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import time
2+
import math
3+
import board
4+
import busio
5+
import adafruit_bno055
6+
i2c = busio.I2C(board.SCL, board.SDA)
7+
sensor = adafruit_bno055.BNO055(i2c)
8+
9+
while True:
10+
x, y, z = sensor.magnetometer
11+
# convert to gauss
12+
heading = (math.atan2(y, x) * 180) / math.pi
13+
14+
if heading < 0:
15+
heading = 360 + heading
16+
17+
elif heading > 360:
18+
heading = heading - 360
19+
20+
print(heading)

examples/modetest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
import board
3+
import busio
4+
import adafruit_bno055
5+
i2c = busio.I2C(board.SCL, board.SDA)
6+
sensor = adafruit_bno055.BNO055(i2c)
7+
8+
while True:
9+
print(sensor.mode)
10+
print(sensor.euler)
11+
print("="*40)
12+
print("\n")
13+
time.sleep(.2)

examples/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
import board
3+
import busio
4+
import adafruit_bno055
5+
i2c = busio.I2C(board.SCL, board.SDA)
6+
sensor = adafruit_bno055.BNO055(i2c)
7+
8+
while True:
9+
print(sensor.mode)
10+
print(sensor.euler)
11+
print("="*40)
12+
print("\n")
13+
time.sleep(.2)

0 commit comments

Comments
 (0)