Beispiel #1
0
    def stop(self):
        for s in self.states:

            # Disable acceleration
            libmetawear.mbl_mw_acc_stop(s.device.board)
            libmetawear.mbl_mw_acc_disable_acceleration_sampling(
                s.device.board)
            signal_acceleration = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
                s.device.board)
            libmetawear.mbl_mw_datasignal_unsubscribe(signal_acceleration)

            # Disable gyro
            libmetawear.mbl_mw_gyro_bmi160_stop(s.device.board)
            libmetawear.mbl_mw_gyro_bmi160_disable_rotation_sampling(
                s.device.board)
            signal_gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
                s.device.board)
            libmetawear.mbl_mw_datasignal_unsubscribe(signal_gyro)

            # Disable magnometer
            libmetawear.mbl_mw_mag_bmm150_stop(s.device.board)
            libmetawear.mbl_mw_mag_bmm150_disable_b_field_sampling(
                s.device.board)

            # Disconnect board and turn off LED
            libmetawear.mbl_mw_debug_disconnect(s.device.board)
        return
Beispiel #2
0
    def stop(self):
        if self.device == None:
            self.log("ERROR", "Device not available")
            return False

        dev_board = self.device.board

        self.log("INFO", "Stopping device...")
        lmw.mbl_mw_acc_stop(dev_board)
        lmw.mbl_mw_acc_disable_acceleration_sampling(dev_board)

        lmw.mbl_mw_gyro_bmi160_stop(dev_board)
        lmw.mbl_mw_gyro_bmi160_disable_rotation_sampling(dev_board)

        # Unsubscribe from accelerometer data
        acc = lmw.mbl_mw_acc_get_acceleration_data_signal(dev_board)
        lmw.mbl_mw_datasignal_unsubscribe(acc)

        # Unsubscribe from gyro data
        gyro = lmw.mbl_mw_gyro_bmi160_get_rotation_data_signal(dev_board)
        lmw.mbl_mw_datasignal_unsubscribe(gyro)
        self.log("INFO", "Device stopped.")

        return True
    libmetawear.mbl_mw_gyro_bmi160_set_odr(s.device.board, AccBmi160Odr._50Hz)
    libmetawear.mbl_mw_gyro_bmi160_set_range(s.device.board,
                                             AccBoschRange._125dps)
    libmetawear.mbl_mw_gyro_bmi160_write_config(s.device.board)

    signal = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
        s.device.board)
    libmetawear.mbl_mw_datasignal_subscribe(signal, None, s.callback)

    libmetawear.mbl_mw_gyro_bmi160_enable_rotation_sampling(s.device.board)
    libmetawear.mbl_mw_gyro_bmi160_start(s.device.board)

sleep(10.0)

for s in states:
    libmetawear.mbl_mw_gyro_bmi160_stop(s.device.board)
    libmetawear.libmetawear.mbl_mw_gyro_bmi160_disable_rotation_sampling(
        s.device.board)

    signal = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
        s.device.board)
    libmetawear.mbl_mw_datasignal_unsubscribe(signal)
    libmetawear.mbl_mw_debug_disconnect(s.device.board)

sleep(1.0)

conn.close()

print("Total Samples Received")
for s in states:
    print("%s -> %d" % (s.device.address, s.samples))