mrotate

prplkn/mservo/mrotate

No description
mrotate
@/mrotate
DEV@/mservo-device
VALnumber
The target shaft rotation position in the [0; 1] range. The real angle/pulse values corresponding to the 0 and 1 boundaries are defined by the servo device node.
DOpulse
Set the new target rotation value for the given device.
mrotate
DEV'
ACK
DEV
VAL
DO
ACKpulse
Pulses to acknowledge the new target. It will take time for the servo to complete the order.
DEV'@/mservo-device
To use the node in your project you should have the prplkn/mservo 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_DO

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_DO>(ctx))
            return;

        auto angle = getValue<input_VAL>(ctx);
        xservo->write01(angle);
        emitValue<output_ACK>(ctx, 1);
    }
}