diff --git a/.pylintrc b/.pylintrc index d8f0ee8..cc63488 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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 diff --git a/adafruit_bno055.py b/adafruit_bno055.py index 16a290a..fb426e1 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/examples/bno055_i2c-gpio_simpletest.py b/examples/bno055_i2c-gpio_simpletest.py index 19ff0ef..f921d07 100644 --- a/examples/bno055_i2c-gpio_simpletest.py +++ b/examples/bno055_i2c-gpio_simpletest.py @@ -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)) diff --git a/examples/bno055_simpletest.py b/examples/bno055_simpletest.py index 1e3fa6c..3a399ad 100644 --- a/examples/bno055_simpletest.py +++ b/examples/bno055_simpletest.py @@ -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))