def timer_created(timer): global bsignal bsignal = libmetawear.mbl_mw_settings_get_battery_state_data_signal(device.board) libmetawear.mbl_mw_datasignal_subscribe(bsignal, batt_handler_fn) libmetawear.mbl_mw_event_record_commands(timer) libmetawear.mbl_mw_datasignal_read(bsignal) libmetawear.mbl_mw_event_end_record(timer, getStatusFn_handler_fn) libmetawear.mbl_mw_timer_start(timer)
def startRecording(mmr): # libmetawear.mbl_mw_gyro_bmi160_write_config(mmr.device.board) # libmetawear.mbl_mw_acc_enable_acceleration_sampling(mmr.device.board) # libmetawear.mbl_mw_gyro_bmi160_enable_rotation_sampling(mmr.device.board) # libmetawear.mbl_mw_acc_start(mmr.device.board) # libmetawear.mbl_mw_gyro_bmi160_start(mmr.device.board) # logger = create_voidp(lambda fn: libmetawear.mbl_mw_datasignal_log(signal, None, fn), resource = "acc_logger") # parameter_VT = I2cReadParameters(device_addr = AD7745_ADDR, register_addr=REG_VT_DATA) # libmetawear.mbl_mw_datasignal_read_with_parameters(i2c_signal, byref(parameter_VT)) # libmetawear.mbl_mw_datasignal_read_with_parameters(i2c_signal, byref(parameter_VT)) # libmetawear.mbl_mw_datasignal_read_with_parameters(i2c_signal, byref(parameter_VT)) timer = libmetawear.mbl_mw_timer_lookup_id(mmr.device.board, mmr.timer_id) libmetawear.mbl_mw_timer_start(timer)
def setup_logger(self): e = Event() result = [None] def logger_handler(ctx, pointer): result[0] = RuntimeError("Could not create logger") if pointer == None else pointer e.set() fn_wrapper = FnVoid_VoidP_VoidP(logger_handler) #streaming and logging signal = libmetawear.mbl_mw_multi_chnl_temp_get_temperature_data_signal(self.device.board, \ MetaWearRProChannel.ON_BOARD_THERMISTOR) libmetawear.mbl_mw_datasignal_log(signal, None, fn_wrapper) e.wait() if (result[0] is RuntimeError): raise result[0] self.logger = result[0] self.timer = self._setup_timer() self._setup_read_event(self.timer, signal) libmetawear.mbl_mw_logging_start(self.device.board, 0); libmetawear.mbl_mw_timer_start(self.timer)
# create a timer timer = create_voidp(lambda fn: libmetawear.mbl_mw_timer_create_indefinite(d.board, 1000, 0, None, fn), resource = "timer", event = e) # record an event libmetawear.mbl_mw_event_record_commands(timer) # event is to read temp signal libmetawear.mbl_mw_datasignal_read(signal) create_voidp_int(lambda fn: libmetawear.mbl_mw_event_end_record(timer, None, fn), event = e) # start logging libmetawear.mbl_mw_logging_start(d.board, 0) # start timer libmetawear.mbl_mw_timer_start(timer) # log 10s print("Logging data for 10s") sleep(10.0) # remove timer libmetawear.mbl_mw_timer_remove(timer) # remove logger libmetawear.mbl_mw_logging_stop(d.board) # remove event libmetawear.mbl_mw_event_remove_all(d.board) # flush cache for mms