tm1637-v2-multiplexing

cesars/tm1637-v2/tm1637-v2-multiplexing

No description
tm1637-v2-multiplexing
@/tm1637-v2-multiplexing
D1number
Data to DIG 0
D2number
Data to DIG 1
D3number
Data to DIG 2
D4number
Data to DIG 3
ACTboolean
Enable multiplexion
tm1637-v2-multiplexing
DIG
VAL
TICK
MPLX
D1
D2
D3
D4
ACT
MPLXnumber
Output scrolling synchronize
TICKpulse
Pulse update
VALnumber
Data out
DIGnumber
Digit num
To use the node in your project you should have the cesars/tm1637-v2 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

node {

    TimeMs nextTrig;
    int8_t count;

    void evaluate(Context ctx) {
        TimeMs tNow = transactionTime();
        auto ival = 0.0015;
        if (ival < 0) ival = 0;
        TimeMs dt = ival * 1000;
        TimeMs tNext = tNow + dt;

        if (isTimedOut(ctx)){
            if(getValue<input_ACT>(ctx)){
                emitValue<output_TICK>(ctx, 1);
            }

            if (count >= 4){
                count = 0;
            }else{
                if(count == 0){
                    emitValue<output_VAL>(ctx, getValue<input_D1>(ctx));
                    emitValue<output_DIG>(ctx, count);
                    emitValue<output_MPLX>(ctx, count);
                }
                if(count == 1){
                    emitValue<output_VAL>(ctx, getValue<input_D2>(ctx));
                    emitValue<output_DIG>(ctx, count);
                    emitValue<output_MPLX>(ctx, count);
                }
                if(count == 2){
                    emitValue<output_VAL>(ctx, getValue<input_D3>(ctx));
                    emitValue<output_DIG>(ctx, count);
                    emitValue<output_MPLX>(ctx, count);
                }
                if(count == 3){
                    emitValue<output_VAL>(ctx, getValue<input_D4>(ctx));
                    emitValue<output_DIG>(ctx, count);
                    emitValue<output_MPLX>(ctx, count);
                }
                count ++;
            }
            nextTrig = tNext;
            setTimeout(ctx, dt);
        }
        if (nextTrig < tNow || nextTrig > tNext) {
            nextTrig = tNext;
            setTimeout(ctx, dt);
        }
    }
}