Created
July 31, 2015 10:03
-
-
Save zserge/54b3d7ceea54f2338136 to your computer and use it in GitHub Desktop.
Espruino example
This file contains 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 on = false; | |
setInterval(function() { | |
on = !on; | |
LED1.write(on); | |
LED2.write(!on); | |
}, 500); | |
console.log('Hello, world!'); | |
E.setUSBHID({ | |
reportDescriptor : [ | |
0x05, 0x01, | |
0x09, 0x02, | |
0xA1, 0x01, | |
0x09, 0x01, | |
0xA1, 0x00, | |
0x05, 0x09, | |
0x19, 0x01, | |
0x29, 0x03, | |
0x15, 0x00, | |
0x25, 0x01, | |
0x95, 0x03, | |
0x75, 0x01, | |
0x81, 0x02, | |
0x95, 0x01, | |
0x75, 0x05, | |
0x81, 0x01, | |
0x05, 0x01, | |
0x09, 0x30, | |
0x09, 0x31, | |
0x09, 0x38, | |
0x15, 0x81, | |
0x25, 0x7F, | |
0x75, 0x08, | |
0x95, 0x03, | |
0x81, 0x06, | |
0xC0, 0x09, | |
0x3c, 0x05, | |
0xff, 0x09, | |
0x01, 0x15, | |
0x00, 0x25, | |
0x01, 0x75, | |
0x01, 0x95, | |
0x02, 0xb1, | |
0x22, 0x75, | |
0x06, 0x95, | |
0x01, 0xb1, | |
0x01, 0xc0] | |
}); | |
function random(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
setInterval(function() { | |
var dx = random(0, 20); | |
var dy = random(0, 20); | |
console.log('DX=', dx, 'DY=', dy); | |
E.sendUSBHID([0, dx,dy,0]); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment