portd-pin-read

krishowell/port-read-write/portd-pin-read

This patch reads the value of the PORTD registry and outputs the bool value of the selected pin.
portd-pin-read
@/portd-pin-read
This patch reads the value of the PORTD registry and outputs the bool value of the selected pin.
UPDpulse
Signals when the code should run.
PINnumber
The number that represents each pin of the target hardware on PORTD. Selects the pin state that will be read. Pin 0-7
portd-pin-read
UPD
PIN
VAL
SIG
ERR
ERRpulse
indicates when a pin input value is not accepted.
SIGboolean
Outputs the selected pin reg value in bool
VALbyte
Outputs the PORTD reg value
To use the node in your project you should have the krishowell/port-read-write 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) {
    //auto inValue = getValue<input_IN>(ctx);
    //emitValue<output_OUT>(ctx, inValue);
    if (!isInputDirty<input_UPD>(ctx))
        return;
    
    //uint8_t port = PORTD;
    int in = getValue<input_PIN>(ctx);
    bool result = 0;

    switch(in){
        case 0:
            result = PORTD & B00000001;
            break;
        case 1:
            result = PORTD & B00000010;
            break;
        case 2:
            result = PORTD & B00000100;
            break;
        case 3:
            result = PORTD & B00001000;
            break;
        case 4:
            result = PORTD & B00010000;
            break;
        case 5:
            result = PORTD & B00100000;
            break;
        case 6:
            result = PORTD & B01000000;
            break;
        case 7:
            result = PORTD & B10000000;
            break;
        default:
            emitValue<output_ERR>(ctx, 1);
    }
    emitValue<output_SIG>(ctx, result);
    emitValue<output_VAL>(ctx, PORTD);
}