get-acceleration

bradzilla84/x2125/get-acceleration

Measure acceleration in terms of g (acceleration due to earth's gravity). Returns value that represents the milli G's acting on the axis.
get-acceleration
@/get-acceleration
Measure acceleration in terms of g (acceleration due to earth's gravity). Returns value that represents the milli G's acting on the axis.
IN@/device-mx2125
Input from Device Block.
INITpulse
Get Value
get-acceleration
IN
X
Y
OK
INIT
OKpulse
Update Completed OK
Ynumber
Y Sensor Value
Xnumber
X Sensor Value
To use the node in your project you should have the bradzilla84/x2125 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // The node responds only if there is an input pulse
    if (!isInputDirty<input_INIT>(ctx)){
        return;}

    // Get a pointer to the class instance
    auto Accelerometer = getValue<input_IN>(ctx);

    auto X = Accelerometer->mx_acceleration_x();
    auto Y = Accelerometer->mx_acceleration_y();

    emitValue<output_X>(ctx, X);
    emitValue<output_Y>(ctx, Y);

    emitValue<output_OK>(ctx, 1);
}