• Yes, I'm doing it with projects options in Web IDE.

    How to import a class that gets parameters on construction like this :

    modules/stepper.js

    var stepperClass = function (p1, p2, p3, p4) {
        var step = 0;
        var steps = [0b0001, 0b0011, 0b0010, 0b0110, 0b0100, 0b1100, 0b1000, 0b1001];
        var stepperPins = [p4, p3, p2, p1];
        this.writeStep = function () {
            step++;
            digitalWrite(stepperPins, steps[step % steps.length]);
        };
        this.stop = function () {
            digitalWrite(stepperPins[0], LOW);
            digitalWrite(stepperPins[1], LOW);
            digitalWrite(stepperPins[2], LOW);
            digitalWrite(stepperPins[3], LOW);
        };
        this.doStep = function (cnt) {
            for (i = 0; i < cnt; i++) {
                x = 0;
                while (x < 10) x++;
                this.writeStep();
            }
            this.stop();
        };
    };
    
About

Avatar for fobus @fobus started