Last active
August 29, 2015 14:13
-
-
Save adkron/f9bf0ede2ce131cb6f5f to your computer and use it in GitHub Desktop.
Opal Tessel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tessel = `require('tessel')` | |
led1 = tessel.led[0].output(1); | |
led2 = tessel.led[1].output(1); | |
Window.every 100, -> { | |
puts "I'm blinking! (Press CTRL + C to stop)" | |
led1.toggle(); | |
led2.toggle(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by Opal 0.6.3 */ | |
(function($opal) { | |
var $a, $b, TMP_1, self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, tessel = nil, led1 = nil, led2 = nil; | |
$opal.add_stubs(['$output', '$[]', '$led', '$every', '$lambda', '$log', '$console', '$toggle']); | |
tessel = require('tessel'); | |
led1 = tessel.$led()['$[]'](0).$output(1); | |
led2 = tessel.$led()['$[]'](1).$output(1); | |
return $scope.Window.$every(100, ($a = ($b = self).$lambda, $a._p = (TMP_1 = function(){var self = TMP_1._s || this; | |
self.$puts("I'm blinking! (Press CTRL + C to stop)"); | |
led1.$toggle(); | |
return led2.$toggle();}, TMP_1._s = self, TMP_1), $a).call($b)); | |
})(Opal); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tessel = require('tessel'); | |
var led1 = tessel.led[0].output(1); | |
var led2 = tessel.led[1].output(1); | |
setInterval(function () { | |
console.log("I'm blinking! (Press CTRL + C to stop)"); | |
// Toggle the led states | |
led1.toggle(); | |
led2.toggle(); | |
}, 100); |
my take (untested)
blink.rb:
require 'native'
tessel = Native(`require('tessel')`)
def every(ms,&callback)
`setInterval(function(){callback()}, ms)`
end
led1 = tessel.led[0].output(1)
led2 = tessel.led[1].output(1)
every 100 do
puts "I'm blinking! (Press CTRL + C to stop)"
led1.toggle
led2.toggle
end
gem install opal --pre
opal -c blick.rb > blink.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
original is a js file that runs on the device
The device runs nodejs, and I have to upload it.
I tried adding
Opal = require("opal")
in the blickopal.js, but that didn't help.