Hello,
I tried it (see source) and got memory usage of 199, which is close to 4k or 3k by subtracting 4 bytes/block. Sourcecode is less than 400 bytes only.
Trace is not a help for me, my knowledge about that is too poor.
Checked memory-usage:
function Blinker only: usage is 60
function Blinker with LED1: usage is 132
function Blinker with LED1, LED2: usage is 199
function Blinker with LED1, LED2, LED3: usage is 265
used Blinker as module and required for LED1: usage is 178
used Blinker as module and required for LED1, LED2: usage is 252
used Blinker as module and required for LED1, LED2, LED3: usage is 326
function Blinker(pin,frequency){
var me = this;
me.iv=-1;
me.status = true;
me.dur = 1000 / frequency;
me.stop = function(){
pin.write(false);clearInterval(me.iv);
};
me.start = function(){
iv = setInterval(function(){
me.status = !me.status;pin.write(me.status);
},me.dur);
};
this.start();
}
var b = new Blinker(LED1,2);
var c = new Blinker(LED2,5);
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.
Hello,
I tried it (see source) and got memory usage of 199, which is close to 4k or 3k by subtracting 4 bytes/block. Sourcecode is less than 400 bytes only.
Trace is not a help for me, my knowledge about that is too poor.
Checked memory-usage:
used Blinker as module and required for LED1, LED2, LED3: usage is 326