position-value

xod-dev/servo/position-value

Extracts the current target position value from the servo device
position-value
@/position-value
Extracts the current target position value from the servo device
DEV@/servo-device
The servo device
UPDpulse
Re-requests the position.
position-value
DEV'
VAL
DONE
DEV
UPD
DONEpulse
Pulses when the position is updated
VALnumber
Current shaft position in the [0; 1] range. Note, this is the value the servo strives to be at, it may be inequal to the current physical shaft position.
DEV'@/servo-device
The servo device
To use the node in your project you should have the xod-dev/servo 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

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {
        auto xservo = getValue<input_DEV>(ctx);

        if (isSettingUp()) {
            // Short-circuit DEV and DEV'
            emitValue<output_DEVU0027>(ctx, xservo);
        }

        if (!isInputDirty<input_UPD>(ctx))
            return;

        emitValue<output_VAL>(ctx, xservo->read01());
        emitValue<output_DONE>(ctx, 1);
    }
}