Skip to content

Commit

Permalink
Merge pull request #25 from mbientlab/151update
Browse files Browse the repository at this point in the history
151update
  • Loading branch information
lkasso committed Dec 17, 2020
2 parents e446cf2 + c401191 commit 7b959de
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 251 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ LIB_SO_NAME:=lib$(APP_NAME).$(EXTENSION)
LIB_SHORT_NAME:=$(LIB_SO_NAME).$(VERSION_MAJOR)
LIB_NAME:=$(LIB_SO_NAME).$(VERSION)

ifeq ($(MACHINE),x86)
ARCH=-m32
else ifeq ($(MACHINE),x64)
ARCH=-m64
else ifeq ($(MACHINE),arm)
ARCH=-marm
else
$(error Unrecognized "MACHINE" value, use 'x86', 'x64', or 'arm')
endif
#ifeq ($(MACHINE),x86)
# ARCH=-m32
#else ifeq ($(MACHINE),x64)
# ARCH=-m64
#else ifeq ($(MACHINE),arm)
# ARCH=-marm
#else
# $(error Unrecognized "MACHINE" value, use 'x86', 'x64', or 'arm')
#endif

ifndef NO_MULTILIB
CXXFLAGS+=$(ARCH)
Expand Down
94 changes: 0 additions & 94 deletions MetaWear.Win32.vcxproj

This file was deleted.

86 changes: 0 additions & 86 deletions MetaWear.WinRT.vcxproj

This file was deleted.

63 changes: 9 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MetaWear SDK for C++ by MBIENTLAB
# MetaWear SDK for C++ by MBIENTLAB

[![Platforms](https://img.shields.io/badge/platform-linux--64%20%7C%20win--32%20%7C%20osx--64%20%7C%20win--64-lightgrey?style=flat)](https://github.com/mbientlab/MetaWear-SDK-Cpp)
[![Platforms](https://img.shields.io/badge/platform-linux%20%7C%20ios%20%7C%20osx-lightgrey)](https://github.com/mbientlab/MetaWear-SDK-Cpp)
[![License](https://img.shields.io/cocoapods/l/MetaWear.svg?style=flat)](https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/LICENSE.md)

![alt tag](https://raw.githubusercontent.com/mbientlab/MetaWear-SDK-iOS-macOS-tvOS/master/Images/Metawear.png)
Expand All @@ -16,13 +16,14 @@ This library is platform agnostic and does not contain any Bluetooth code. You a

[MetaWear](https://mbientlab.com) is a complete development and production platform for wearable and connected device applications.

MetaWear features a number of sensors and peripherals all easily controllable over Bluetooth 4.0 Low Energy using this SDK, no firmware or hardware experience needed!
MetaWear features a number of sensors and peripherals all easily controllable over Bluetooth 4.0/5.0 Low Energy using this SDK, no firmware or hardware experience needed!

The MetaWear hardware comes pre-loaded with a wirelessly upgradeable firmware, so it keeps getting more powerful over time.

### Requirements
- [MetaWear board](https://mbientlab.com/store/)
- A linux/windows/mac machine with Bluetooth 4.0
- A linux/mac machine with Bluetooth 4.0 or Bluetooth 5.0
- We are no longer supporting Windows

### License
See the [License](https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/LICENSE.md).
Expand All @@ -33,7 +34,7 @@ Reach out to the [community](https://mbientlab.com/community/) if you encounter
## Getting Started

### Installation
Building the project has been tested on \*nix systems with Clang 4, and on Windows with Visual Studio Community 2017.
Building the project has been tested on Unix systems with Clang 4.

### Usage

Expand Down Expand Up @@ -70,50 +71,13 @@ dist/
└── lib
└── x64
├── libmetawear.so -> libmetawear.so.0
├── libmetawear.so.0 -> libmetawear.so.0.18.4
└── libmetawear.so.0.18.4

```

### Visual Studio 2017
MSBuild files have been provided to build the project as both a Win32 and WinRT dll. The Win32 dll is for classic Win32 applications whereas the
WinRT dll is for Universal Windows apps. You will need to have [Visual Studio 2017](https://www.visualstudio.com/downloads/) installed in order to
run the build.

When calling MSBuild, you can set the `Configuration` and `Platform` properties to control debug/release builds and x86/x64/ARM platforms
respectively. If not specified on the command line, the default action is to build a debug dll targeting the x86 (Win32) platform. Note that the ARM
platform is only available for the WinRT build.

```bat
# default properties are debug config with x86 (win32) platform
msbuild MetaWear.Win32.vcxproj
# release build for Win32 applications targeting the x64 architecture
msbuild MetaWear.Win32.vcxproj /p:Configuration=Release;Platform=x64
# debug build for WinRT applications targeting the ARM architecture
msbuild MetaWear.WinRT.vcxproj /p:Configuration=Debug;Platform=ARM
```

As with the Makefile, the .dll, .lib, .pdb, and .exp files are placed in the `dist` directory.

```sh
> tree dist
dist/
└── release
└── lib
└── x64
├── MetaWear.Win32.dll
├── MetaWear.Win32.exp
├── MetaWear.Win32.iobj
├── MetaWear.Win32.ipdb
├── MetaWear.Win32.lib
└── MetaWear.Win32.pdb
├── libmetawear.so.0 -> libmetawear.so.0.19.0
└── libmetawear.so.0.19.0

```

## Testing
Unit tests for the library are written in Python (min v3.4.1) and can be invoked by calling the test target (Test for MSBuild).
Unit tests for the library are written in Python (min v3.4.1) and can be invoked by calling the test target.

### GNU Make
```sh
Expand All @@ -131,15 +95,6 @@ Ran 461 tests in 33.249s
OK (skipped=1)
```

### MSBuild
When testing with MSBuild, it is important that the `Platform` property matches the installed Python's target platform as well. For example, if
64-bit Python is installed, set the `Platform` property to x64 when running the `Test` target otherwise MSBuild will use the x86 dll which will cause
all of the tests to fail.

```bat
metawear-cpp-api>msbuild MetaWear.Win32.vcxproj /p:Platform=x64 /t:Test
```

### Tutorials

Tutorials can be found [here](https://mbientlab.com/tutorials/).
7 changes: 7 additions & 0 deletions bindings/javascript/cbindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,13 @@ var Lib = ffi.Library(LIBMETAWEAR_PATH, {
*/
'mbl_mw_sensor_fusion_write_config': [ref.types.void, [ref.refType(MetaWearBoard)]],

/**
* Reset the default orientation of the board.
* Works while sensor fusion is running or off. Works for NDOF and IMUPLUS only.
* @param board Calling object
*/
'mbl_mw_sensor_fusion_reset_orientation': [ref.types.void, [ref.refType(MetaWearBoard)]],

/**
* Writes the acceleration settings to the sensor
* @param board Pointer to the board to send the command to
Expand Down
3 changes: 3 additions & 0 deletions bindings/python/mbientlab/metawear/cbindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,9 @@ def init_libmetawear(libmetawear):
libmetawear.mbl_mw_dataprocessor_average_create.restype = c_int
libmetawear.mbl_mw_dataprocessor_average_create.argtypes = [c_void_p, c_ubyte, c_void_p, FnVoid_VoidP_VoidP]

libmetawear.mbl_mw_sensor_fusion_reset_orientation.restype = None
libmetawear.mbl_mw_sensor_fusion_reset_orientation.argtypes = [c_void_p]

libmetawear.mbl_mw_sensor_fusion_write_config.restype = None
libmetawear.mbl_mw_sensor_fusion_write_config.argtypes = [c_void_p]

Expand Down
6 changes: 3 additions & 3 deletions project_version.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.18.4
VERSION=0.19.0
VERSION_MAJOR=0
VERSION_MINOR=18
VERSION_STEP=4
VERSION_MINOR=19
VERSION_STEP=0
13 changes: 12 additions & 1 deletion src/metawear/sensor/cpp/sensor_fusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const ResponseHeader RESPONSE_HEADERS[] {
};

const ResponseHeader CALIB_STATE_RESPONSE_HEADER(MBL_MW_MODULE_SENSOR_FUSION, READ_REGISTER(ORDINAL(SensorFusionRegister::CALIBRATION_STATE)));
const uint8_t CALIBRATION_REVISION = 1, CALIB_DATA_REVISION = 2;
const uint8_t CALIBRATION_REVISION = 1, CALIB_DATA_REVISION = 2, RESET_ORIENTATION_REVISION = 3;

struct SensorFusionState {
struct {
Expand Down Expand Up @@ -208,12 +208,15 @@ MblMwDataSignal* mbl_mw_sensor_fusion_calibration_state_data_signal(const MblMwM
void mbl_mw_sensor_fusion_set_mode(MblMwMetaWearBoard* board, MblMwSensorFusionMode mode) {
((SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION))->config.mode = mode;
}

void mbl_mw_sensor_fusion_set_acc_range(MblMwMetaWearBoard* board, MblMwSensorFusionAccRange range) {
((SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION))->config.acc_range = range;
}

void mbl_mw_sensor_fusion_set_gyro_range(MblMwMetaWearBoard* board, MblMwSensorFusionGyroRange range) {
((SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION))->config.gyro_range = (range + 1);
}

void mbl_mw_sensor_fusion_write_config(MblMwMetaWearBoard* board) {
auto state = (SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION);

Expand Down Expand Up @@ -270,6 +273,7 @@ void mbl_mw_sensor_fusion_read_config(const MblMwMetaWearBoard* board, void *con
void mbl_mw_sensor_fusion_enable_data(MblMwMetaWearBoard* board, MblMwSensorFusionData data) {
((SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION))->enable_mask |= (0x1 << (int) data);
}

void mbl_mw_sensor_fusion_clear_enabled_mask(MblMwMetaWearBoard* board) {
((SensorFusionState*) board->module_config.at(MBL_MW_MODULE_SENSOR_FUSION))->enable_mask = 0x0;
}
Expand Down Expand Up @@ -361,6 +365,13 @@ void mbl_mw_sensor_fusion_read_calibration_data(MblMwMetaWearBoard* board, void
}
}

void mbl_mw_sensor_fusion_reset_orientation(MblMwMetaWearBoard* board) {
if (board->module_info.at(MBL_MW_MODULE_SENSOR_FUSION).revision >= RESET_ORIENTATION_REVISION) {
uint8_t reset_cmd[3] = {MBL_MW_MODULE_SENSOR_FUSION, ORDINAL(SensorFusionRegister::RESET_ORIENTATION), 0x1};
send_command(board, reset_cmd, sizeof(reset_cmd));
}
}

void mbl_mw_sensor_fusion_write_calibration_data(const MblMwMetaWearBoard* board, const MblMwCalibrationData* data) {
if (board->module_info.at(MBL_MW_MODULE_SENSOR_FUSION).revision >= CALIB_DATA_REVISION) {
uint8_t command[12] = { MBL_MW_MODULE_SENSOR_FUSION, ORDINAL(SensorFusionRegister::ACC_CAL_DATA) };
Expand Down
3 changes: 2 additions & 1 deletion src/metawear/sensor/cpp/sensor_fusion_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ enum class SensorFusionRegister : uint8_t {
CALIBRATION_STATE,
ACC_CAL_DATA,
GYRO_CAL_DATA,
MAG_CAL_DATA
MAG_CAL_DATA,
RESET_ORIENTATION
};
Loading

0 comments on commit 7b959de

Please sign in to comment.