count

nkrkv/encoder/count

No description
count
@/count
STEPnumber
Value to add on each increment.
INCpulse
Triggers a single increment.
DECpulse
Triggers a single decrement.
RSTpulse
Resets the accumulated value to zero.
count
OUT
STEP
INC
DEC
RST
OUTnumber
The accumulated value.
To use the node in your project you should have the nkrkv/encoder 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) {
    Number count = getValue<output_OUT>(ctx);

    if (isInputDirty<input_RST>(ctx))
        count = 0;
    else {
        auto step = getValue<input_STEP>(ctx);

        if (isInputDirty<input_INC>(ctx))
            count += step;

        if (isInputDirty<input_DEC>(ctx))
            count -= step;
    }

    emitValue<output_OUT>(ctx, count);
}