multistepperlite-device

jdavis-nodes/multistepperlite/multistepperlite-device

No description
multistepperlite-device
@/multistepperlite-device
STEPport
DIRport
multistepperlite-device
STEP
DIR
DEV
DBG
DBGnumber
DEV@/multistepperlite-device
To use the node in your project you should have the jdavis-nodes/multistepperlite 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 error_raise enable
#pragma XOD require "https://github.com/gunakkoc/MultiStepperLite"

#include <SingleStepperLite.h>

node {
    meta {
        using Type = SingleStepperLite*;
        //SingleStepperLite stepper;
    }

    //SingleStepperLite* stepper = nullptr;

     SingleStepperLite stepper;

//        meta {
//             using Type = struct {
//                 SingleStepperLite stepper;
//                 uint8_t dirPin;
//                 long position;
//             }*;
//         }

//         Type stepper = new struct {
//             SingleStepperLite stepper;
//             uint8_t dirPin;
//             long position;
//         };

    void evaluate(Context ctx) {
        // Only evaluate during setup
        if (!isSettingUp()) return;

        // Validate the step and direction pins
        static_assert(isValidDigitalPort(constant_input_STEP), "must be a valid digital port for STEP");
        static_assert(isValidDigitalPort(constant_input_DIR), "must be a valid digital port for DIR");

        // Get input values
        auto stepPin = constant_input_STEP;
        auto dirPin = constant_input_DIR;

        pinMode(stepPin, OUTPUT);
        pinMode(dirPin, OUTPUT);
        digitalWrite(dirPin, LOW); // Default direction
        stepper.init_stepper(stepPin);
        // emitValue<output_DEV>(ctx, &stepper);

//         if (!stepper) {
//             raiseError(ctx); // Failed to initialize stepper
//             return;
//         }

#pragma XOD error_raise enable
#pragma XOD require "https://github.com/gunakkoc/MultiStepperLite"
#include <SingleStepperLite.h>

node {
    meta {
        using Type = SingleStepperLite*;
    }

    SingleStepperLite stepper;

    void evaluate(Context ctx) {
        // Only evaluate during setup
        if (!isSettingUp()) return;

        // Validate the step and direction pins
        static_assert(isValidDigitalPort(constant_input_STEP), "must be a valid digital port for STEP");
        static_assert(isValidDigitalPort(constant_input_DIR), "must be a valid digital port for DIR");

        // Get input values
        auto stepPin = constant_input_STEP;
        auto dirPin = constant_input_DIR;

        // Initialize pins
        pinMode(stepPin, OUTPUT);
        pinMode(dirPin, OUTPUT);
        digitalWrite(dirPin, LOW); // Default direction

        // Initialize stepper
        stepper.init_stepper(stepPin);
        
        emitValue<output_DBG>(ctx, (uint32_t)&stepper);

        // Emit the stepper instance
        emitValue<output_DEV>(ctx, &stepper);
    }
}