get-click

wayland/lis3dh-accelerometer/get-click

Detect single or double "click" (tap).
get-click
@/get-click
Detect single or double "click" (tap).
DEV@/lis3dh-device
A lis3dh device.
UPDpulse
Update
get-click
SNG
DBL
DONE
DEV
UPD
DONEpulse
Pulse after checking for click (tap).
DBLpulse
Pulse if double "click" (tap) detected.
SNGpulse
Pulse if single "click" (tap) detected.
To use the node in your project you should have the wayland/lis3dh-accelerometer 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) {

    if (!isInputDirty<input_UPD>(ctx))
        return;

    // Get a pointer to the `Adafruit_LIS3DH` class instance
    auto sensor = getValue<input_DEV>(ctx);

    uint8_t click = sensor->getClick();

    if (click == 0) {
        emitValue<output_DONE>(ctx, 1);
        return;
    }
    
    if (! (click & 0x30)) {
        emitValue<output_DONE>(ctx, 1);
        return;
    }

    if (click & 0x10)
        emitValue<output_SNG>(ctx, 1);
    if (click & 0x20)
        emitValue<output_DBL>(ctx, 1);
    
    emitValue<output_DONE>(ctx, 1);
}