MetaWear C++ API  0.20.0
C++ implementation of the MetaWear protocol
Enumerations | Functions
math.h File Reference

Performs arithmetic on sensor data. More...

#include "processor_common.h"

Go to the source code of this file.

Enumerations

enum  MblMwMathOperation {
  MBL_MW_MATH_OP_ADD = 1 , MBL_MW_MATH_OP_MULTIPLY , MBL_MW_MATH_OP_DIVIDE , MBL_MW_MATH_OP_MODULUS ,
  MBL_MW_MATH_OP_EXPONENT , MBL_MW_MATH_OP_SQRT , MBL_MW_MATH_OP_LSHIFT , MBL_MW_MATH_OP_RSHIFT ,
  MBL_MW_MATH_OP_SUBTRACT , MBL_MW_MATH_OP_ABS_VALUE , MBL_MW_MATH_OP_CONSTANT
}
 Available operations for the math processor. More...
 

Functions

METAWEAR_API int32_t mbl_mw_dataprocessor_math_create (MblMwDataSignal *source, MblMwMathOperation op, float rhs, void *context, MblMwFnDataProcessor processor_created)
 Create a math processor where signed/unsigned operation is inferred. More...
 
METAWEAR_API int32_t mbl_mw_dataprocessor_math_create_signed (MblMwDataSignal *source, MblMwMathOperation op, float rhs, void *context, MblMwFnDataProcessor processor_created)
 Create a math processor using signed operations. More...
 
METAWEAR_API int32_t mbl_mw_dataprocessor_math_create_unsigned (MblMwDataSignal *source, MblMwMathOperation op, float rhs, void *context, MblMwFnDataProcessor processor_created)
 Create a math processor using unsigned operations. More...
 
METAWEAR_API int32_t mbl_mw_dataprocessor_math_modify_rhs (MblMwDataProcessor *math, float rhs)
 Modify the configuration of a math processor, changing the right side value of the operation. More...
 
METAWEAR_API int32_t mbl_mw_dataprocessor_math_modify_rhs_signal (MblMwDataProcessor *math, MblMwDataSignal *rhs_signal)
 Modify the configuration of a math processor for a feedback or feedforward loop. More...
 

Detailed Description

Performs arithmetic on sensor data.

Enumeration Type Documentation

◆ MblMwMathOperation

Available operations for the math processor.

Enumerator
MBL_MW_MATH_OP_ADD 

Computes input + rhs.

MBL_MW_MATH_OP_MULTIPLY 

Computes input * rhs.

MBL_MW_MATH_OP_DIVIDE 

Computes input / rhs.

MBL_MW_MATH_OP_MODULUS 

Computes input % rhs.

MBL_MW_MATH_OP_EXPONENT 

Computes input ^ rhs.

MBL_MW_MATH_OP_SQRT 

Computes sqrt(input)

MBL_MW_MATH_OP_LSHIFT 

Computes input << rhs.

MBL_MW_MATH_OP_RSHIFT 

Computes input >> rhs.

MBL_MW_MATH_OP_SUBTRACT 

Computes input - rhs.

MBL_MW_MATH_OP_ABS_VALUE 

Computes |input|.

MBL_MW_MATH_OP_CONSTANT 

Replaces input with rhs.

Function Documentation

◆ mbl_mw_dataprocessor_math_create()

METAWEAR_API int32_t mbl_mw_dataprocessor_math_create ( MblMwDataSignal source,
MblMwMathOperation  op,
float  rhs,
void *  context,
MblMwFnDataProcessor  processor_created 
)

Create a math processor where signed/unsigned operation is inferred.


Performs simple arithmetic on sensor data. See MblMwMathOperation for allowed ops. A pointer representing the processor will be passed back to the user via a callback function.

Parameters
sourceData signal providing the input for the processor
opMath operation to compute
rhsRight hand side of the operation that requires 2 inputs
contextPointer to additional data for the callback function
processor_createdCallback function to be executed when the processor is created

◆ mbl_mw_dataprocessor_math_create_signed()

METAWEAR_API int32_t mbl_mw_dataprocessor_math_create_signed ( MblMwDataSignal source,
MblMwMathOperation  op,
float  rhs,
void *  context,
MblMwFnDataProcessor  processor_created 
)

Create a math processor using signed operations.


Performs simple arithmetic on sensor data. See MblMwMathOperation for allowed ops. A pointer representing the processor will be passed back to the user via a callback function.

Parameters
sourceData signal providing the input for the processor
opMath operation to compute
rhsRight hand side of the operation that requires 2 inputs
contextPointer to additional data for the callback function
processor_createdCallback function to be executed when the processor is created

◆ mbl_mw_dataprocessor_math_create_unsigned()

METAWEAR_API int32_t mbl_mw_dataprocessor_math_create_unsigned ( MblMwDataSignal source,
MblMwMathOperation  op,
float  rhs,
void *  context,
MblMwFnDataProcessor  processor_created 
)

Create a math processor using unsigned operations.


Performs simple arithmetic on sensor data. See MblMwMathOperation for allowed ops. A pointer representing the processor will be passed back to the user via a callback function.

Parameters
sourceData signal providing the input for the processor
opMath operation to compute
rhsRight hand side of the operation that requires 2 inputs
contextPointer to additional data for the callback function
processor_createdCallback function to be executed when the processor is created

◆ mbl_mw_dataprocessor_math_modify_rhs()

METAWEAR_API int32_t mbl_mw_dataprocessor_math_modify_rhs ( MblMwDataProcessor math,
float  rhs 
)

Modify the configuration of a math processor, changing the right side value of the operation.

Parameters
mathMath processor to modify
rhsNew right hand side of the operation
Returns
MBL_MW_STATUS_OK if processor configuration was updated, MBL_MW_STATUS_WARNING_INVALID_PROCESSOR_TYPE if a non-math processor was passed in

◆ mbl_mw_dataprocessor_math_modify_rhs_signal()

METAWEAR_API int32_t mbl_mw_dataprocessor_math_modify_rhs_signal ( MblMwDataProcessor math,
MblMwDataSignal rhs_signal 
)

Modify the configuration of a math processor for a feedback or feedforward loop.

Parameters
mathMath processor to modify
rhs_signalData signal supplying the rhs value of the operation
Returns
MBL_MW_STATUS_OK if processor configuration was updated, MBL_MW_STATUS_WARNING_INVALID_PROCESSOR_TYPE if a non-math processor was passed in