Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 0c138d2

Browse files
xiaolongxJimmy Huang
authored andcommitted
[Samples] Update ButtonEnable.js and Blink-k64f.js on zjs-0.1 (#457)
1. Fix onchange event in ButtonEnable.js 2. Use pins.LEDG instead of pins.D5 in samples/arduino/basics/Blink-k64f.js
1 parent b9f4c5d commit 0c138d2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

samples/arduino/basics/Blink-k64f.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var pins = require("k64f_pins");
1616
// LEDG is the green LED within the RGB LED on the FRDM-K64F
1717
// 'out' direction is default, could be left out
1818
var pin = gpio.open({
19-
pin: pins.D5,
19+
pin: pins.LEDG,
2020
direction: 'out'
2121
});
2222

samples/tests/ButtonEnable.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// This version tests freeing a callback by changing the callback of btn2
77
// dynamically in response to btn1 state. Btn2 will only work to control its
88
// LED while btn1 is down.
9-
//
9+
//
1010
// Note: If you use a Grove touch sensor as one of the buttons, wire it to IO4:
1111
// it doesn't work the other way and I haven't figured out why yet. It may
1212
// relate to IO5 being connected to both the X86 and ARC processors.
@@ -25,19 +25,18 @@ var btn2 = gpio.open({ pin: pins.IO4, direction: 'in', edge: 'any' });
2525
// turn off LED #2 initially
2626
led2.write(false);
2727

28-
btn1.on('change', function () {
28+
btn1.onchange = function (event) {
2929
var value = btn1.read();
3030
led1.write(value);
3131

3232
if (value) {
3333
// set up btn2 to toggle led2 while btn1 is down
34-
btn2.on('change', function () {
34+
btn2.onchange = function (event) {
3535
var value = btn2.read();
3636
led2.write(value);
37-
});
38-
}
39-
else {
37+
};
38+
} else {
4039
// disable btn2 again
41-
btn2.on('change', null);
40+
btn2.onchange = null;
4241
}
43-
});
42+
};

0 commit comments

Comments
 (0)