in source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/sense_hat.py [0:0]
def set_imu_config(self, compass_enabled, gyro_enabled, accel_enabled):
"""
Enables and disables the gyroscope, accelerometer and/or magnetometer
input to the orientation functions
"""
# If the consuming code always calls this just before reading the IMU
# the IMU consistently fails to read. So prevent unnecessary calls to
# IMU config functions using state variables
self._init_imu() # Ensure imu is initialised
if (not isinstance(compass_enabled, bool)
or not isinstance(gyro_enabled, bool)
or not isinstance(accel_enabled, bool)):
raise TypeError('All set_imu_config parameters must be of boolean type')
if self._compass_enabled != compass_enabled:
self._compass_enabled = compass_enabled
self._imu.setCompassEnable(self._compass_enabled)
if self._gyro_enabled != gyro_enabled:
self._gyro_enabled = gyro_enabled
self._imu.setGyroEnable(self._gyro_enabled)
if self._accel_enabled != accel_enabled:
self._accel_enabled = accel_enabled
self._imu.setAccelEnable(self._accel_enabled)