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

[Samples] Update ButtonEnable.js and Blink-k64f.js on zjs-0.1 #457

Merged
merged 2 commits into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/arduino/basics/Blink-k64f.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var pins = require("k64f_pins");
// LEDG is the green LED within the RGB LED on the FRDM-K64F
// 'out' direction is default, could be left out
var pin = gpio.open({
pin: pins.D5,
pin: pins.LEDG,
direction: 'out'
});

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

btn1.on('change', function () {
btn1.onchange = function (event) {
var value = btn1.read();
led1.write(value);

if (value) {
// set up btn2 to toggle led2 while btn1 is down
btn2.on('change', function () {
btn2.onchange = function (event) {
var value = btn2.read();
led2.write(value);
});
}
else {
};
} else {
// disable btn2 again
btn2.on('change', null);
btn2.onchange = null;
}
});
};