pulse-on-true

xod/core/pulse-on-true

Emits a pulse on a rising edge, i.e. when false changes to true. Does not pulse on program start even if initial input value is true.
pulse-on-true
@/pulse-on-true
Emits a pulse on a rising edge, i.e. when false changes to true. Does not pulse on program start even if initial input value is true.
INboolean
pulse-on-true
IN
OUT
OUTpulse

C++ implementation

node {
    bool state = false;

    void evaluate(Context ctx) {
        auto newValue = getValue<input_IN>(ctx);

        if (!isSettingUp() && newValue == true && state == false)
            emitValue<output_OUT>(ctx, 1);

        state = newValue;
    }
}

Tabular tests

INOUT
trueno-pulse// do not pulse even if initial state is true
falseno-pulse
truepulse
trueno-pulse
falseno-pulse
truepulse