Skip to content

Commit a028d2f

Browse files
Remove references to deprecated “axismove” event from Joystick examples (#1811)
Fixes #1810
1 parent f7aae7c commit a028d2f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

eg/joystick-claw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ board.on("ready", function() {
1919
// (the joystick deadzone)
2020
claw.to(90);
2121

22-
joystick.on("axismove", function() {
22+
joystick.on("change", function() {
2323
// Open/close the claw by setting degrees according
2424
// to Y position of joystick.
2525
// limit to 170 on medium servos (ei. the servo used on the claw)
26-
claw.to(Math.ceil(170 * this.fixed.y));
26+
claw.to(five.Fn.scale(this.y, -1, 1, 0, 170));
2727
});
2828
});

eg/joystick-motor-led.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ board.on("ready", function() {
3737

3838
// Pushing the joystick to up position should start the motor,
3939
// releasing it will turn the motor off.
40-
joystick.on("axismove", function() {
40+
joystick.on("change", function() {
4141

42-
if (!motor.isOn && this.axis.y > 0.51) {
42+
if (!motor.isOn && this.y > 0) {
4343
motor.start();
4444
}
4545

46-
if (motor.isOn && this.axis.y < 0.51) {
46+
if (motor.isOn && this.y <= 0) {
4747
motor.stop();
4848
}
4949
});

eg/navigator-joystick.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ when.all(readyList, function() {
4747

4848
servo.center();
4949

50-
joystick.on("axismove", function() {
50+
joystick.on("change", function () {
5151
// 0: left, 1: center, 2: right
52-
var position = Math.ceil(2 * this.fixed.x);
52+
var position = Math.round(this.x + 1);
5353

5454
// console.log( position );
5555

0 commit comments

Comments
 (0)