How to use the johnny-five.Fn.scale function in johnny-five

To help you get started, we’ve selected a few johnny-five examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bocoup / reconbot / lib / camera.js View on Github external
}

    // DOWN
    if (y < 0) {
      this.tilt.to(Fn.scale(y, 0, -100, TILT_CENTER, TILT_MAX));
    }

    // UP
    if (y > 0) {
      this.tilt.to(Fn.scale(y, 0, 100, TILT_CENTER, TILT_MIN));
      // this.tilt.to(TILT_MIN, ms);
    }

    // LEFT
    if (x < 0) {
      this.pan.to(Fn.scale(x, 0, -100, PAN_CENTER, PAN_MIN));
    }

    if (x > 0) {
      this.pan.to(Fn.scale(x, 0, 100, PAN_CENTER, PAN_MAX));
    }
    return this;
  }
}
github bocoup / reconbot / lib / camera.js View on Github external
this.tilt.to(Fn.scale(y, 0, -100, TILT_CENTER, TILT_MAX));
    }

    // UP
    if (y > 0) {
      this.tilt.to(Fn.scale(y, 0, 100, TILT_CENTER, TILT_MIN));
      // this.tilt.to(TILT_MIN, ms);
    }

    // LEFT
    if (x < 0) {
      this.pan.to(Fn.scale(x, 0, -100, PAN_CENTER, PAN_MIN));
    }

    if (x > 0) {
      this.pan.to(Fn.scale(x, 0, 100, PAN_CENTER, PAN_MAX));
    }
    return this;
  }
}
github bocoup / reconbot / lib / camera.js View on Github external
if (x === 0) {
      this.pan.to(PAN_CENTER);
    }

    if (y === 0) {
      this.tilt.to(TILT_CENTER);
    }

    // DOWN
    if (y < 0) {
      this.tilt.to(Fn.scale(y, 0, -100, TILT_CENTER, TILT_MAX));
    }

    // UP
    if (y > 0) {
      this.tilt.to(Fn.scale(y, 0, 100, TILT_CENTER, TILT_MIN));
      // this.tilt.to(TILT_MIN, ms);
    }

    // LEFT
    if (x < 0) {
      this.pan.to(Fn.scale(x, 0, -100, PAN_CENTER, PAN_MIN));
    }

    if (x > 0) {
      this.pan.to(Fn.scale(x, 0, 100, PAN_CENTER, PAN_MAX));
    }
    return this;
  }
}
github bocoup / reconbot / lib / camera.js View on Github external
let ms = 250;
    let { x, y } = axis;

    this.stop();

    if (x === 0) {
      this.pan.to(PAN_CENTER);
    }

    if (y === 0) {
      this.tilt.to(TILT_CENTER);
    }

    // DOWN
    if (y < 0) {
      this.tilt.to(Fn.scale(y, 0, -100, TILT_CENTER, TILT_MAX));
    }

    // UP
    if (y > 0) {
      this.tilt.to(Fn.scale(y, 0, 100, TILT_CENTER, TILT_MIN));
      // this.tilt.to(TILT_MIN, ms);
    }

    // LEFT
    if (x < 0) {
      this.pan.to(Fn.scale(x, 0, -100, PAN_CENTER, PAN_MIN));
    }

    if (x > 0) {
      this.pan.to(Fn.scale(x, 0, 100, PAN_CENTER, PAN_MAX));
    }

johnny-five

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis