Actually, just ran a test, the framerate is dropping to 12fps when the code is executed - otherwise it runs at 33fps.
//hacks to get TWEEN to work
var window = {};
window.setTimeout = setTimeout;
var TWEEN = require("Tween");
var neopixel = require("neopixel");
//hacks to get TWEEN to work
process.hrtime = null;
TWEEN.now = Date.now;
var lastLoop = new Date();
function animate(time) {
var thisLoop = new Date();
var fps = 1000 / (thisLoop - lastLoop);
console.log(fps);
lastLoop = thisLoop;
TWEEN.update(time);
}
setInterval(animate, 1);
function run() {
var leds = 24;
var arr = new Uint8ClampedArray(leds*3);
var n = 0;
var coords = { x: 0, y: 0 }; // Start at (0, 0)
var tween = new TWEEN.Tween(coords)
.to({ x: 255, y: 2000 }, 1000)
.easing(TWEEN.Easing.Quadratic.Out)
.onUpdate(function() {
var r = Math.round(coords.x);
n = 0;
for(var a = 0 ; a < arr.length ; a++) {
arr[n++] = (Math.random() * 255) * 0.25;
}
neopixel.write(D30, arr);
})
.start();
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Actually, just ran a test, the framerate is dropping to 12fps when the code is executed - otherwise it runs at 33fps.