Looking at your code, the following might help with memory usage:
You can use string[index] instead of string.charAt(index) and save a few characters, or for extracting a substring you could use substr,substring or slice (all of which do basically the same thing)
Instead of if (dw === 0) {lcd.print("Sun");} ... what about lcd.print(["Mon","Tue","Wed",...][dw]); - stuff like that will really compact your code.
I don't know what you intend, but if you define a variable in a function without adding var before it (eg. a=5 vs var a=5), that variable becomes global and will always take up memory. If you add the var before it then the variable is local to the function, and the memory it uses will be freed after the function is done executing...
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.
Glad you got it sorted! What was the problem?
Looking at your code, the following might help with memory usage:
string[index]
instead ofstring.charAt(index)
and save a few characters, or for extracting a substring you could use substr,substring or slice (all of which do basically the same thing)if (dw === 0) {lcd.print("Sun");} ...
what aboutlcd.print(["Mon","Tue","Wed",...][dw]);
- stuff like that will really compact your code.var
before it (eg.a=5
vsvar a=5
), that variable becomes global and will always take up memory. If you add thevar
before it then the variable is local to the function, and the memory it uses will be freed after the function is done executing...