Guest User

Untitled

a guest
Jul 2nd, 2018
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from mbientlab.metawear import *
  2. from mbientlab.metawear.cbindings import *
  3. import sys
  4.  
  5.  
  6. address = sys.argv[1]
  7. device = MetaWear(address)
  8. device.connect()
  9. board = device.board
  10. print("connected to %s" % address)
  11.  
  12.  
  13. euler_signal = libmetawear.mbl_mw_sensor_fusion_get_data_signal(board, SensorFusionData.EULER_ANGLE)
  14. euler_callback = FnVoid_VoidP_DataP(lambda context, data: print("euler %s" % parse_value(data)))
  15. libmetawear.mbl_mw_datasignal_subscribe(euler_signal, None, euler_callback)
  16. libmetawear.mbl_mw_sensor_fusion_enable_data(board, SensorFusionData.EULER_ANGLE)
  17. print("activated euler")
  18.  
  19.  
  20. accel_signal = libmetawear.mbl_mw_sensor_fusion_get_data_signal(board, SensorFusionData.CORRECTED_ACC)
  21. accel_callback = FnVoid_VoidP_DataP(lambda context, data: print("accel %s" % parse_value(data)))
  22. libmetawear.mbl_mw_datasignal_subscribe(accel_signal, None, accel_callback)
  23. libmetawear.mbl_mw_sensor_fusion_enable_data(board, SensorFusionData.CORRECTED_ACC)
  24. print("activated accel")
  25.  
  26.  
  27. libmetawear.mbl_mw_sensor_fusion_set_mode(board, SensorFusionMode.NDOF)
  28. libmetawear.mbl_mw_sensor_fusion_write_config(board)
  29. libmetawear.mbl_mw_sensor_fusion_start(board)
  30. print("started")
  31.  
  32.  
  33. input("")
  34.  
  35.  
  36. libmetawear.mbl_mw_sensor_fusion_stop(board)
  37. libmetawear.mbl_mw_sensor_fusion_clear_enabled_mask(board)
  38. libmetawear.mbl_mw_datasignal_unsubscribe(euler_signal)
  39. libmetawear.mbl_mw_datasignal_unsubscribe(accel_signal)
  40. print("deactivated sensors")
  41.  
  42.  
  43. device.disconnect()
  44. sleep(1)
  45. print("disconnected")
RAW Paste Data