count-inc-dec

stefanc1991/essentials-a/count-inc-dec

No description
count-inc-dec
@/count-inc-dec
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-inc-dec
OUT
STEP
INC
DEC
RST
OUTnumber
The accumulated value.
To use the node in your project you should have the stefanc1991/essentials-a 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);
}