Skip to content

Temp example fix #68

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

Merged
merged 5 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ confidence=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,pointless-string-statement

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
18 changes: 9 additions & 9 deletions adafruit_bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _gravity(self):

@property
def accel_range(self):
""" Switch the accelerometer range and return the new range. Default value: +/- 4g
"""Switch the accelerometer range and return the new range. Default value: +/- 4g
See table 3-8 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -474,7 +474,7 @@ def accel_range(self, rng=ACCEL_4G):

@property
def accel_bandwidth(self):
""" Switch the accelerometer bandwidth and return the new bandwidth. Default value: 62.5 Hz
"""Switch the accelerometer bandwidth and return the new bandwidth. Default value: 62.5 Hz
See table 3-8 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -494,7 +494,7 @@ def accel_bandwidth(self, bandwidth=ACCEL_62_5HZ):

@property
def accel_mode(self):
""" Switch the accelerometer mode and return the new mode. Default value: Normal
"""Switch the accelerometer mode and return the new mode. Default value: Normal
See table 3-8 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -514,7 +514,7 @@ def accel_mode(self, mode=ACCEL_NORMAL_MODE):

@property
def gyro_range(self):
""" Switch the gyroscope range and return the new range. Default value: 2000 dps
"""Switch the gyroscope range and return the new range. Default value: 2000 dps
See table 3-9 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -534,7 +534,7 @@ def gyro_range(self, rng=GYRO_2000_DPS):

@property
def gyro_bandwidth(self):
""" Switch the gyroscope bandwidth and return the new bandwidth. Default value: 32 Hz
"""Switch the gyroscope bandwidth and return the new bandwidth. Default value: 32 Hz
See table 3-9 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -554,7 +554,7 @@ def gyro_bandwidth(self, bandwidth=GYRO_32HZ):

@property
def gyro_mode(self):
""" Switch the gyroscope mode and return the new mode. Default value: Normal
"""Switch the gyroscope mode and return the new mode. Default value: Normal
See table 3-9 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -574,7 +574,7 @@ def gyro_mode(self, mode=GYRO_NORMAL_MODE):

@property
def magnet_rate(self):
""" Switch the magnetometer data output rate and return the new rate. Default value: 20Hz
"""Switch the magnetometer data output rate and return the new rate. Default value: 20Hz
See table 3-10 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -594,7 +594,7 @@ def magnet_rate(self, rate=MAGNET_20HZ):

@property
def magnet_operation_mode(self):
""" Switch the magnetometer operation mode and return the new mode. Default value: Regular
"""Switch the magnetometer operation mode and return the new mode. Default value: Regular
See table 3-10 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand All @@ -614,7 +614,7 @@ def magnet_operation_mode(self, mode=MAGNET_REGULAR_MODE):

@property
def magnet_mode(self):
""" Switch the magnetometer power mode and return the new mode. Default value: Forced
"""Switch the magnetometer power mode and return the new mode. Default value: Forced
See table 3-10 in the datasheet.
"""
self._write_register(_PAGE_REGISTER, 0x01)
Expand Down
16 changes: 15 additions & 1 deletion examples/bno055_i2c-gpio_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,22 @@
i2c = I2C(1) # Device is /dev/i2c-1
sensor = adafruit_bno055.BNO055_I2C(i2c)

last_val = 0xFFFF


def temperature():
global last_val # pylint: disable=global-statement
result = sensor.temperature
if abs(result - last_val) == 128:
result = sensor.temperature
if abs(result - last_val) == 128:
return 0b00111111 & result
last_val = result
return result


while True:
print("Temperature: {} degrees C".format(sensor.temperature))
print("Temperature: {} degrees C".format(temperature()))
print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
print("Magnetometer (microteslas): {}".format(sensor.magnetic))
print("Gyroscope (rad/sec): {}".format(sensor.gyro))
Expand Down
19 changes: 19 additions & 0 deletions examples/bno055_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,27 @@
# uart = busio.UART(board.TX, board.RX)
# sensor = adafruit_bno055.BNO055_UART(uart)

last_val = 0xFFFF


def temperature():
global last_val # pylint: disable=global-statement
result = sensor.temperature
if abs(result - last_val) == 128:
result = sensor.temperature
if abs(result - last_val) == 128:
return 0b00111111 & result
last_val = result
return result


while True:
print("Temperature: {} degrees C".format(sensor.temperature))
"""
print(
"Temperature: {} degrees C".format(temperature())
) # Uncomment if using a Raspberry Pi
"""
print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
print("Magnetometer (microteslas): {}".format(sensor.magnetic))
print("Gyroscope (rad/sec): {}".format(sensor.gyro))
Expand Down