def __init__(self, i2c): """ a wrapper class for sensors of a SenseHAT board """ self.i2c = i2c # init drivers self.hts = HTS221(i2c, I2C_ADDR_HUMID_TEMP) self.lps = LPS25(i2c, I2C_ADDR_TEMP_PRESSURE) self.lsm = LSM9DS1(i2c) self.matrix = SenseAtmel(i2c ,I2C_ADDR_MATRIX)
class uSenseHAT: I2C_ADDR_MATRIX = const(0x46) I2C_ADDR_TEMP_PRESSURE = const(0x5c) I2C_ADDR_HUMID_TEMP = const(0x5f) def __init__(self, i2c): """ a wrapper class for sensors of a SenseHAT board """ self.i2c = i2c # init drivers self.hts = HTS21(i2c, I2C_ADDR_HUMID_TEMP) self.lps = LPS25(i2c, I2C_ADDR_TEMP_PRESSURE) self.lsm = LSM9DS1(i2c) self.matrix = SenseAtmel(i2c ,I2C_ADDR_MATRIX) def read_key(self): return self.matrix.read_key() def read_pressure(self): return self.lps.read_pressure() def read_temperature(self): """ returns average temperature of hts21 and lps25 chip """ return (self.hts.read_temperature() + self.lps.read_temperature()) / 2 def read_humidity(self): return self.hts.read_humidity() def read_imu(self): """ returns 9DOF data: (gyro,accelerator,magnetometer) containing (x,y,z) values scaled in deg/sec, g and gauss respecively """ return self.lsm.read_gyro(), self.lsm.read_accel(), self.lsm.read_magnet()
def __init__(self, i2c): """ a wrapper class for sensors of a SenseHAT board """ self.i2c = i2c # init drivers self.hts = HTS21(i2c, I2C_ADDR_HUMID_TEMP) self.lps = LPS25(i2c, I2C_ADDR_TEMP_PRESSURE) self.lsm = LSM9DS1(i2c) self.matrix = SenseAtmel(i2c ,I2C_ADDR_MATRIX)
class uSenseHAT: I2C_ADDR_MATRIX = const(0x46) I2C_ADDR_TEMP_PRESSURE = const(0x5c) I2C_ADDR_HUMID_TEMP = const(0x5f) def __init__(self, i2c): """ a wrapper class for sensors of a SenseHAT board """ self.i2c = i2c # init drivers self.hts = HTS221(i2c, I2C_ADDR_HUMID_TEMP) self.lps = LPS25(i2c, I2C_ADDR_TEMP_PRESSURE) self.lsm = LSM9DS1(i2c) self.matrix = SenseAtmel(i2c ,I2C_ADDR_MATRIX) def measure(self): self.hts.measure() self.lps.measure() def get_key(self): return self.matrix.read_key() def get_pressure(self): return self.lps.get_pressure() def get_temperature(self): """ returns average temperature of hts21 and lps25 chip """ return (self.hts.get_temperature() + self.lps.get_temperature()) / 2 def get_humidity(self): return self.hts.get_humidity() def get_imu(self): """ returns 9DOF data: (gyro,accelerator,magnetometer) containing (x,y,z) values scaled in deg/sec, g and gauss respecively """ return self.lsm.read_gyro(), self.lsm.read_accel(), self.lsm.read_magnet()