add IR Test Button
This commit is contained in:
parent
9cbf8c2419
commit
ad99525d23
4 changed files with 19 additions and 1 deletions
|
@ -37,7 +37,7 @@ Arduino.prototype.setup = function () {
|
||||||
|
|
||||||
self.serial.on('open', function () { setTimeout(function () {
|
self.serial.on('open', function () { setTimeout(function () {
|
||||||
self.serial.write(new Buffer('00000000'));
|
self.serial.write(new Buffer('00000000'));
|
||||||
self.serial.write(new Buffer('Z0000000', 'ascii'));
|
self.serial.write(new Buffer('Zn000000', 'ascii'));
|
||||||
self.emit('success');
|
self.emit('success');
|
||||||
|
|
||||||
self.serial.on('data', function(data){
|
self.serial.on('data', function(data){
|
||||||
|
|
10
nodejs/public/javascripts/angularApp.js
vendored
10
nodejs/public/javascripts/angularApp.js
vendored
|
@ -21,6 +21,10 @@ app.factory('arduino', ['$http', function($http, auth){
|
||||||
return $http.get('/toggleLight');
|
return $http.get('/toggleLight');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
o.irTest = function ( ) {
|
||||||
|
return $http.get('/irTest');
|
||||||
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
@ -32,4 +36,10 @@ app.controller('MainCtrl', ['$scope', 'arduino', function ($scope, arduino){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.irTest = function(){
|
||||||
|
|
||||||
|
arduino.toggleLight();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
|
@ -18,4 +18,9 @@ router.get('/toggleLight', function (req, res) {
|
||||||
res.send('switch light');
|
res.send('switch light');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/irTest', function (req, res) {
|
||||||
|
arduino.write(new Buffer('Y0000000' ,'ascii'));
|
||||||
|
res.send('switch light');
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
<form ng-submit="toggleLight()" style="margin-top:30px;">
|
<form ng-submit="toggleLight()" style="margin-top:30px;">
|
||||||
<button type="submit" class="button-primary">Light Switch</button>
|
<button type="submit" class="button-primary">Light Switch</button>
|
||||||
</form>
|
</form>
|
||||||
|
<form ng-submit="irTest()" style="margin-top:30px;">
|
||||||
|
<button type="submit" class="button-primary">Light Switch</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Reference in a new issue