Пример #1
0
    def read(self):
        Memory.set_bit(self.base_addr, Accelerometer.CTRL_REG, Accelerometer.READ_BIT, True)
        while not Memory.read_bit(self.base_addr, Accelerometer.CTRL_REG, Accelerometer.READ_BIT):
            time.sleep(0.000001) # Wait for a microsecond

        read_regs = [ Accelerometer.X_REG, Accelerometer.Y_REG, Accelerometer.Z_REG ]
        accel_vals = Memory.read_bulk(self.base_addr, read_regs)
        Memory.set_bit(self.base_addr, Accelerometer.CTRL_REG, Accelerometer.READ_BIT, False)

        return accel_vals
Пример #2
0
    def read(self):
        Memory.set_bit(self.base_addr, Gyroscope.CTRL_REG, Gyroscope.READ_BIT,
                       True)
        while not Memory.read_bit(self.base_addr, Gyroscope.CTRL_REG,
                                  Gyroscope.READ_BIT):
            time.sleep(0.000001)  # Wait for a microsecond

        read_regs = [Gyroscope.X_REG, Gyroscope.Y_REG, Gyroscope.Z_REG]
        gyro_vals = Memory.read_bulk(self.base_addr, read_regs)
        Memory.set_bit(self.base_addr, Gyroscope.CTRL_REG, Gyroscope.READ_BIT,
                       False)

        return gyro_vals
Пример #3
0
 def set_on(self):
     Memory.set_bit(self.base_addr, self.register, self.bit, True)
Пример #4
0
 def set_off(self):
     Memory.set_bit(self.base_addr, self.register, self.bit, False)