Debounce node not working?

I tried to use the debounce node to make some tests but I got this error message during the compilation:

Can you please check this?

Hello. The debounce is specialized for the boolean type only (for no obvious reason). I’ve put an issue to implement it for numbers on GitHub.

Meanwhile, you can make one for yourself: create a patch debounce(number) in your current project and provide the following C++ code for it:

struct State {
    Number state;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    State* state = getState(ctx);
    Number x = getValue<input_ST>(ctx);

    if (x != state->state) {
        state->state = x;
        TimeMs dt = getValue<input_Ts>(ctx) * 1000;
        setTimeout(ctx, dt);
    }

    if (isTimedOut(ctx)) {
        emitValue<output_OUT>(ctx, x);
    }
}
1 Like

Perfect!

In the node browser “debounce-boolean” is deprecated. I thought the new debounce node is made for all kinds of data sources…

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.