updowncount

ivanmason/lcd16x2x5button/updowncount

Count down to min by Subtracting the amount of count or Count up to max by adding the amount of count with start as the first number
updowncount
@/updowncount
Count down to min by Subtracting the amount of count or Count up to max by adding the amount of count with start as the first number
SUBTRACTpulse
Count Down
ADDpulse
Count Up
STARTnumber
Starting number
COUNTnumber
Counting by
Minnumber
Maxnumber
RTSpulse
Reset counter
updowncount
OUT
SUBTRACT
ADD
START
COUNT
Min
Max
RTS
DONE
DONEpulse
OUTnumber
To use the node in your project you should have the ivanmason/lcd16x2x5button 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) {
    float start = getValue<input_START>(ctx);
    float count = getValue<input_COUNT>(ctx);
    float min = getValue<input_Min>(ctx);
    float max = getValue<input_Max>(ctx);
    float result = getValue<output_OUT>(ctx);

    if (isInputDirty<input_RTS>(ctx))result = start;

     if (isInputDirty<input_ADD>(ctx)){
         ++result;
         if(result >= max)result = max;
     }
     if (isInputDirty<input_SUBTRACT>(ctx)){
         --result;
         if(result <= min)result = min;
     }
    emitValue<output_OUT>(ctx, result);
    emitValue<output_DONE>(ctx, 1);
}