esc-calibration

gabbapeople/esc/esc-calibration

Calibrates an ESC device
esc-calibration
@/esc-calibration
Calibrates an ESC device
PORTport
Board port number the ESC is connected to
CLBpulse
Calibrate ESC
esc-calibration
PORT
CLB
STATE
STATEboolean
Outputs true on calibrated ESC
To use the node in your project you should have the gabbapeople/esc 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 require "https://github.com/RB-ENantel/RC_ESC"

{{#global}}
#include <ESC.h>
{{/global}}

struct State {
    uint8_t mem[sizeof(ESC)];
    ESC* myESC;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_CLB>(ctx))
        return;

    State* state = getState(ctx);
    auto port = (int)getValue<input_PORT>(ctx);

    state->myESC = new (state->mem) ESC(port,1000,2000,500);
    emitValue<output_STATE>(ctx, true);
    state->myESC->calib();
    state->myESC->stop();
    emitValue<output_STATE>(ctx, false);
}