in source/cf/defaults/lambdas/sputnik-rpi-sense-hat-demo-python/sense_hat/sense_hat.py [0:0]
def __init__(
self,
imu_settings_file='RTIMULib',
text_assets='sense_hat_text'
):
self._fb_device = self._get_fb_device()
if self._fb_device is None:
raise OSError('Cannot detect %s device' % self.SENSE_HAT_FB_NAME)
if not glob.glob('/dev/i2c*'):
raise OSError('Cannot access I2C. Please ensure I2C is enabled in raspi-config')
# 0 is With B+ HDMI port facing downwards
pix_map0 = np.array([
[0, 1, 2, 3, 4, 5, 6, 7],
[8, 9, 10, 11, 12, 13, 14, 15],
[16, 17, 18, 19, 20, 21, 22, 23],
[24, 25, 26, 27, 28, 29, 30, 31],
[32, 33, 34, 35, 36, 37, 38, 39],
[40, 41, 42, 43, 44, 45, 46, 47],
[48, 49, 50, 51, 52, 53, 54, 55],
[56, 57, 58, 59, 60, 61, 62, 63]
], int)
pix_map90 = np.rot90(pix_map0)
pix_map180 = np.rot90(pix_map90)
pix_map270 = np.rot90(pix_map180)
self._pix_map = {
0: pix_map0,
90: pix_map90,
180: pix_map180,
270: pix_map270
}
self._rotation = 0
# Load text assets
dir_path = os.path.dirname(__file__)
self._load_text_assets(
os.path.join(dir_path, '%s.png' % text_assets),
os.path.join(dir_path, '%s.txt' % text_assets)
)
# Load IMU settings and calibration data
self._imu_settings = self._get_settings_file(imu_settings_file)
self._imu = RTIMU.RTIMU(self._imu_settings)
self._imu_init = False # Will be initialised as and when needed
self._pressure = RTIMU.RTPressure(self._imu_settings)
self._pressure_init = False # Will be initialised as and when needed
self._humidity = RTIMU.RTHumidity(self._imu_settings)
self._humidity_init = False # Will be initialised as and when needed
self._last_orientation = {'pitch': 0, 'roll': 0, 'yaw': 0}
raw = {'x': 0, 'y': 0, 'z': 0}
self._last_compass_raw = deepcopy(raw)
self._last_gyro_raw = deepcopy(raw)
self._last_accel_raw = deepcopy(raw)
self._compass_enabled = False
self._gyro_enabled = False
self._accel_enabled = False
self._stick = SenseStick()