gear

wkov/colony/gear

No description
gear
@/gear
BWDpulse
Decrease the current position by one.
FWDpulse
Increase the current value by one.
RSTpulse
Trigger to reset the current position to initial.
POSnumber
The initial position.
MINnumber
Minimum allowed position.
MAXnumber
Maximum allowed position.
gear
BWD
FWD
RST
POS
MIN
MAX
CURR
PREV
NEXT
DONE
DONEpulse
Pulse when resetting the current position.
NEXTpulse
Pulse when moving the current position from MAX to MIN.
PREVpulse
Pulse when moving the current position from MIN to MAX.
CURRnumber
The current position.
To use the node in your project you should have the wkov/colony 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

#pragma XOD dirtieness disable

node {
    void evaluate(Context ctx) {
        Number pos;

        if (isSettingUp() || isInputDirty<input_RST>(ctx)) {
            emitValue<output_DONE>(ctx, true);
            pos = getValue<input_POS>(ctx);
        } else {
            pos = getValue<output_CURR>(ctx);
        }

        auto min = getValue<input_MIN>(ctx);
        auto max = getValue<input_MAX>(ctx);

        if (isInputDirty<input_FWD>(ctx)) {
            if (++pos > max) {
                emitValue<output_NEXT>(ctx, true);
                pos = min;
            }
        } else if (isInputDirty<input_BWD>(ctx)) {
            if (--pos < min) {
                emitValue<output_PREV>(ctx, true);
                pos = max;
            }
        } else {
            if (pos > max) {
                pos = max;
            } else if (pos < min) {
                pos = min;
            }
        }

        emitValue<output_CURR>(ctx, pos);
    }
}