get-tilt

bradzilla84/x2125/get-tilt

Measure the level of tilt in terms of +/- 90 degrees. 0 degrees is when the top surface of the accelerometer chip is parallel to the ground.
get-tilt
@/get-tilt
Measure the level of tilt in terms of +/- 90 degrees. 0 degrees is when the top surface of the accelerometer chip is parallel to the ground.
IN@/device-mx2125
Input from Device Block.
INITpulse
Get Value
get-tilt
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_tilt_x();
    auto Y = Accelerometer->mx_tilt_y();

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

    emitValue<output_OK>(ctx, 1);
}