Hi, I have wrote a software which uses a lot of object instantiated only at the boot. I need to save memory and delete unused data.
for example, this code allow me to instantiate more objects each assigned to a multicolor LED:
TRILED=function(pin1,pin2){ this.id1=pin1; this.id2=pin2; }; TRILED.prototype.reset=function(){ this.id1.reset(); this.id2.reset(); }; TRILED.prototype.setRED=function(){ this.id1.set(); this.id2.reset(); }; TRILED.prototype.setGREEN=function(){ this.id1.reset(); this.id2.set(); }; TRILED.prototype.setYELLOW=function(){ this.id1.set(); this.id2.set(); }; L1=new TRILED(A0,A1) L2=new TRILED(A2,A3) L3=new TRILED(A4,A5)
The question is: Can I safely delete the TRILED object after their initialization? Can safely call the method set* and reset in the future ?
It seems to works but I need a confirmation, I want to do this:
L1=new TRILED(A0,A1) L2=new TRILED(A2,A3) L3=new TRILED(A4,A5) delete TRILED; L1.setRED(); L2.setGREEN(); ....etc...etc
@Francesco started
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.
Hi,
I have wrote a software which uses a lot of object instantiated only at the boot.
I need to save memory and delete unused data.
for example, this code allow me to instantiate more objects each assigned to a multicolor LED:
The question is: Can I safely delete the TRILED object after their initialization? Can safely call the method set* and reset in the future ?
It seems to works but I need a confirmation, I want to do this: