Ejemplo n.º 1
0
    def setup(self):
        # setup ble
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)
        sleep(1.5)
        # setup event
        e = Event()

        # processor callback fxn
        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)
        # get acc signal
        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        # create acc averager (averages 4 consecutive acc data entriess)
        libmetawear.mbl_mw_dataprocessor_average_create(
            acc, 4, None, fn_wrapper)
        # wait for averager to be created
        e.wait()
        # subscribe to signal
        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None,
                                                self.callback)
Ejemplo n.º 2
0
    def setup(self):
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)
        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)

        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
            self.device.board)

        signals = (c_void_p * 1)()
        signals[0] = gyro
        libmetawear.mbl_mw_dataprocessor_fuser_create(acc, signals, 1, None,
                                                      fn_wrapper)
        e.wait()

        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None,
                                                self.callback)
Ejemplo n.º 3
0
    def setup(self):
        libmetawear.mbl_mw_settings_set_connection_parameters(self.device.board, 7.5, 7.5, 0, 600)
        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()
        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)

        # set accelerometer to 100Hz sampling rate and range to +/- 16 g's
        libmetawear.mbl_mw_acc_set_odr(s.device.board, 100.0)
        libmetawear.mbl_mw_acc_set_range(s.device.board, 16.0)
        libmetawear.mbl_mw_acc_write_acceleration_config(s.device.board)
        
        # set gyro to 100Hz sampling rate and +/- 1000 deg/sec. 
        libmetawear.mbl_mw_gyro_bmi160_set_odr(s.device.board, MBL_MW_GYRO_BMI160_ODR_100Hz)
        libmetawear.mbl_mw_gyro_bmi160_set_range(s.device.board, MBL_MW_GYRO_BMI160_RANGE_1000dps)
        libmetawear.mbl_mw_gyro_bmi160_write_config(s.device.board)


        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(self.device.board)
        gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board)

        signals = (c_void_p * 1)()
        signals[0] = gyro

        # libmetawear.mbl_mw_dataprocessor_accounter_create(signals, None, fn_wrapper)
        fuser = create_voidp(lambda fn: libmetawear.mbl_mw_dataprocessor_fuser_create(acc, signals, 1, None, fn), resource = "fuser", event = e)
        accounter = create_voidp(lambda fn: libmetawear.mbl_mw_dataprocessor_accounter_create(fuser, None, fn), resource = "accounter", event = e)
		
        # libmetawear.mbl_mw_datasignal_subscribe(self.processor, None, self.callback)
        libmetawear.mbl_mw_datasignal_subscribe(accounter, None, self.callback)
Ejemplo n.º 4
0
    def setup(self):
        # ble settings
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)
        sleep(1.5)
        # events
        e = Event()

        # processor callback fxn
        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        # processor fxn ptr
        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)
        # get acc signal
        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        # get gyro signal - MMRl, MMR, MMc ONLY
        #gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board)
        # get gyro signal - MMRS ONLY
        gyro = libmetawear.mbl_mw_gyro_bmi270_get_rotation_data_signal(
            self.device.board)
        # create signals variable
        signals = (c_void_p * 1)()
        signals[0] = gyro
        # create acc + gyro signal fuser
        libmetawear.mbl_mw_dataprocessor_fuser_create(acc, signals, 1, None,
                                                      fn_wrapper)
        # wait for fuser to be created
        e.wait()
        # subscribe to the fused signal
        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None,
                                                self.callback)
Ejemplo n.º 5
0
    def setup(self):
        # set BLE connection params (min connect interval, max interval,
        # latency, timeout) all in milliseconds
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)
        # set BLE advertising strength (higher strength = higher power consumption
        # but theoretically better connectivity)
        libmetawear.mbl_mw_settings_set_tx_power(self.device.board, 4)
        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        fn_wrapper = metacbindings.FnVoid_VoidP_VoidP(processor_created)

        # set accelerometer to 100Hz sampling rate and range to +/- 16 g's
        libmetawear.mbl_mw_acc_set_odr(s.device.board, 100.0)
        libmetawear.mbl_mw_acc_set_range(s.device.board, 16.0)
        libmetawear.mbl_mw_acc_write_acceleration_config(s.device.board)

        # set gyro to 100Hz sampling rate and +/- 1000 deg/sec.
        libmetawear.mbl_mw_gyro_bmi160_set_odr(s.device.board,
                                               MBL_MW_GYRO_BMI160_ODR_100Hz)
        libmetawear.mbl_mw_gyro_bmi160_set_range(
            s.device.board, MBL_MW_GYRO_BMI160_RANGE_1000dps)
        libmetawear.mbl_mw_gyro_bmi160_write_config(s.device.board)

        # get pointers referencing the acc and gyro data signals
        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
            self.device.board)

        signals = (c_void_p * 1)()
        signals[0] = gyro

        # //libmetawear.mbl_mw_dataprocessor_accounter_create(signals, None, fn_wrapper)

        # chain two processors together (fuser and accounter) to get timestamped acc+gyro data
        # create a fuser "data processor" which packages the acc and gyro signals into same packets before sending
        fuser = create_voidp(
            lambda fn: libmetawear.mbl_mw_dataprocessor_fuser_create(
                acc, signals, 1, None, fn),
            resource="fuser",
            event=e)
        # accounter processor adds correct epoch data to BLE packets, necessary for timestamping stream-mode data
        accounter = create_voidp(
            lambda fn: libmetawear.mbl_mw_dataprocessor_accounter_create(
                fuser, None, fn),
            resource="accounter",
            event=e)

        # //libmetawear.mbl_mw_datasignal_subscribe(self.processor, None, self.callback)
        libmetawear.mbl_mw_datasignal_subscribe(accounter, None, self.callback)
Ejemplo n.º 6
0
    def setup(self):
        #Set up file
        self.file.write(
            "Time, Time from start (s), Acc x, Acc y, Acc z, Gyro x, Gyro y, Gyro z, Mag x, Mag y, Mag z \n"
        )

        #Set up board
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)

        #Acceleration sampling frequency
        libmetawear.mbl_mw_acc_set_odr(s.device.board,
                                       100.0)  #fastest frequency is 400 Hz
        #range of acceleration
        libmetawear.mbl_mw_acc_set_range(s.device.board, 16.0)
        #write acceleration config
        libmetawear.mbl_mw_acc_write_acceleration_config(s.device.board)

        #Gyro sampling frequency
        libmetawear.mbl_mw_gyro_bmi160_set_odr(self.device.board,
                                               8)  #9 = 200Hz, 8 = 100Hz
        #Gyro range
        libmetawear.mbl_mw_gyro_bmi160_set_range(
            self.device.board, 0)  #0 = 2000 dps, 1 = 1000 dps
        #Write gyro config
        libmetawear.mbl_mw_gyro_bmi160_write_config(self.device.board)

        libmetawear.mbl_mw_mag_bmm150_set_preset(self.device.board, 3)

        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)

        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(
            self.device.board)
        mag = libmetawear.mbl_mw_mag_bmm150_get_b_field_data_signal(
            self.device.board)
        signals = (c_void_p * 2)()
        signals[0] = gyro
        signals[1] = mag
        libmetawear.mbl_mw_dataprocessor_fuser_create(acc, signals, 2, None,
                                                      fn_wrapper)
        e.wait()

        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None,
                                                self.callback)
Ejemplo n.º 7
0
    def setup(self):
        libmetawear.mbl_mw_settings_set_connection_parameters(
            self.device.board, 7.5, 7.5, 0, 6000)
        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()

        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)

        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(
            self.device.board)
        libmetawear.mbl_mw_dataprocessor_average_create(
            acc, 4, None, fn_wrapper)
        e.wait()
        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None,
                                                self.callback)