inc-dec-count

bjbaylon/utilities-for-menus/inc-dec-count

A bidirectional counter patch.
inc-dec-count
@/inc-dec-count
A bidirectional counter patch.
STEPnumber
Value to add on each increment or to substract on each decrement.
INCpulse
Triggers a single increment.
DECpulse
Triggers a single decrement.
RSTpulse
Resets the accumulated value to zero.
inc-dec-count
OUT
STEP
INC
DEC
RST
OUTnumber
The accumulated value.
To use the node in your project you should have the bjbaylon/utilities-for-menus 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 if (isInputDirty<input_INC>(ctx))
        count += getValue<input_STEP>(ctx);

    else if (isInputDirty<input_DEC>(ctx))
        count -= getValue<input_STEP>(ctx);

    emitValue<output_OUT>(ctx, count);
}