def createTimer(mmr): mmr.parameters = I2cReadParameters(device_addr=AD7745_ADDR, register_addr=REG_CAP_DATA) e = Event() mmr.timer = create_voidp( lambda fn: libmetawear.mbl_mw_timer_create_indefinite( mmr.device.board, 11, 0, None, fn), resource="timer", event=e) libmetawear.mbl_mw_event_record_commands(mmr.timer) libmetawear.mbl_mw_datasignal_read_with_parameters(mmr.i2c_signal, byref(mmr.parameters)) create_voidp_int( lambda fn: libmetawear.mbl_mw_event_end_record(mmr.timer, None, fn), event=e) print(mmr.timer) mmr.timer_id = libmetawear.mbl_mw_timer_get_id(mmr.timer) print("id" + str(mmr.timer_id))
e = Event() print("Configuring device") # get temp signal and setup logger signal = libmetawear.mbl_mw_multi_chnl_temp_get_temperature_data_signal(d.board, MetaWearRProChannel.ON_BOARD_THERMISTOR) logger = create_voidp(lambda fn: libmetawear.mbl_mw_datasignal_log(signal, None, fn), resource = "temp_logger", event = e) # 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
lambda fn: libmetawear.mbl_mw_dataprocessor_comparator_create( threshold, ComparatorOperation.EQ, 1.0, None, fn), resource="ths_above", event=e) pattern = LedPattern(pulse_duration_ms=1000, high_time_ms=500, high_intensity=16, low_intensity=16, repeat_count=Const.LED_REPEAT_INDEFINITELY) libmetawear.mbl_mw_event_record_commands(ths_below) libmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.BLUE) libmetawear.mbl_mw_led_play(device.board) create_voidp_int( lambda fn: libmetawear.mbl_mw_event_end_record(ths_below, None, fn), event=e) libmetawear.mbl_mw_event_record_commands(ths_above) libmetawear.mbl_mw_led_stop_and_clear(device.board) create_voidp_int( lambda fn: libmetawear.mbl_mw_event_end_record(ths_above, None, fn), event=e) libmetawear.mbl_mw_acc_enable_acceleration_sampling(device.board) libmetawear.mbl_mw_acc_start(device.board) create_voidp_int( lambda fn: libmetawear.mbl_mw_macro_end_record(device.board, None, fn), event=e)