get-rotation

bradzilla84/x2125/get-rotation

Measure clockwise rotation assuming accelerometer is held vertical. Zero degree rotation is when the triangle on the MX2125 chip is pointing up.
get-rotation
@/get-rotation
Measure clockwise rotation assuming accelerometer is held vertical. Zero degree rotation is when the triangle on the MX2125 chip is pointing up.
IN@/device-mx2125
Input from Device Block.
INITpulse
Get Value
get-rotation
IN
ROT
OK
INIT
OKpulse
Update Completed OK
ROTnumber
Rotation 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 rot = Accelerometer->mx_rotation();

    emitValue<output_ROT>(ctx, rot);

    emitValue<output_OK>(ctx, 1);
}