kservo(rds3115)

koadrobot/devices/kservo(rds3115)

No description
kservo(rds3115)
@/kservo(rds3115)
PORTport
Digital port to read from. Should start with `D` to succeed.
DEGnumber
Value in Degree
MAXnumber
Value in Max Degree
UPDpulse
Triggers new read
kservo(rds3115)
PORT
DEG
MAX
UPD
DONE
ERR
ERRpulse
Fires on writing complete
DONEpulse
Fires on writing complete
To use the node in your project you should have the koadrobot/devices 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) 
{
    if (isInputDirty<input_UPD>(ctx))
    {
        const uint8_t port = getValue<input_PORT>(ctx);

        Number degree = getValue<input_DEG>(ctx);

        Number maxdeg = getValue<input_MAX>(ctx);

        if (isValidDigitalPort(port) && degree>=0 && degree<=maxdeg)
        {
             uint32_t pwm = uint32_t((degree*(2000)/maxdeg) + 500);
             ::digitalWrite(port, 1);
             delayMicroseconds(pwm);
             ::digitalWrite(port, 0);
             delayMicroseconds(20000-pwm);

             emitValue<output_DONE>(ctx, 1);
        }
        else
            emitValue<output_ERR>(ctx, 1);
    }
}