#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_RST input_UPD
#pragma XOD dirtieness disable output_OUT
node {
Number refValue = 0;
void evaluate(Context ctx) {
auto inValue = getValue<input_IN>(ctx);
if (isInputDirty<input_RST>(ctx)) {
refValue = inValue;
emitValue<output_OUT>(ctx, 0);
return;
}
if (!isInputDirty<input_UPD>(ctx)) {
return;
}
auto outValue = inValue - refValue;
emitValue<output_OUT>(ctx, outValue);
refValue = inValue;
}
}
IN | UPD | RST | OUT |
0 | no-pulse | no-pulse | 0 |
10 | pulse | no-pulse | 10 |
30 | no-pulse | no-pulse | 10 |
20 | no-pulse | pulse | 0 |
30 | pulse | no-pulse | 10 |
50 | pulse | no-pulse | 20 |
10 | pulse | no-pulse | -40 |
10 | pulse | pulse | 0 |
5 | pulse | no-pulse | -5 |