From a028d2fc7cc1d442d646285a98b66b76c0faa6de Mon Sep 17 00:00:00 2001 From: Christoph Labacher Date: Sun, 12 Feb 2023 21:27:04 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20references=20to=20deprecated=20?= =?UTF-8?q?=E2=80=9Caxismove=E2=80=9D=20event=20from=20Joystick=20examples?= =?UTF-8?q?=20(#1811)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/rwaldron/johnny-five/issues/1810 --- eg/joystick-claw.js | 4 ++-- eg/joystick-motor-led.js | 6 +++--- eg/navigator-joystick.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/eg/joystick-claw.js b/eg/joystick-claw.js index 930831903..d6c0a7be3 100644 --- a/eg/joystick-claw.js +++ b/eg/joystick-claw.js @@ -19,10 +19,10 @@ board.on("ready", function() { // (the joystick deadzone) claw.to(90); - joystick.on("axismove", function() { + joystick.on("change", function() { // Open/close the claw by setting degrees according // to Y position of joystick. // limit to 170 on medium servos (ei. the servo used on the claw) - claw.to(Math.ceil(170 * this.fixed.y)); + claw.to(five.Fn.scale(this.y, -1, 1, 0, 170)); }); }); diff --git a/eg/joystick-motor-led.js b/eg/joystick-motor-led.js index db0174142..57beecb3a 100644 --- a/eg/joystick-motor-led.js +++ b/eg/joystick-motor-led.js @@ -37,13 +37,13 @@ board.on("ready", function() { // Pushing the joystick to up position should start the motor, // releasing it will turn the motor off. - joystick.on("axismove", function() { + joystick.on("change", function() { - if (!motor.isOn && this.axis.y > 0.51) { + if (!motor.isOn && this.y > 0) { motor.start(); } - if (motor.isOn && this.axis.y < 0.51) { + if (motor.isOn && this.y <= 0) { motor.stop(); } }); diff --git a/eg/navigator-joystick.js b/eg/navigator-joystick.js index e6b0682bf..22696103d 100644 --- a/eg/navigator-joystick.js +++ b/eg/navigator-joystick.js @@ -47,9 +47,9 @@ when.all(readyList, function() { servo.center(); - joystick.on("axismove", function() { + joystick.on("change", function () { // 0: left, 1: center, 2: right - var position = Math.ceil(2 * this.fixed.x); + var position = Math.round(this.x + 1); // console.log( position );