main.js(押すたびにオンオフ変更版)
'use strict';
window.addEventListener('load', function (){
Promise.all([
navigator.setGpioPort(198,"out"),
navigator.setGpioPort(199,"in")
]).then(ports=>{
var ledPort = ports[0];
var buttonPort = ports[1];
var x;
buttonPort.onchange = function(v){
if(v == 0){
x = x ? 0:1;
}
ledPort.write(x);
}
});
}, false);
window.addEventListener('load', function (){
Promise.all([
navigator.setGpioPort(198,"out"),
navigator.setGpioPort(199,"in")
]).then(ports=>{
var ledPort = ports[0];
var buttonPort = ports[1];
var x;
buttonPort.onchange = function(v){
if(v == 0){
x = x ? 0:1;
}
ledPort.write(x);
}
});
}, false);