You can just use Graphics normally or pass the variable g in if you want to be able to draw to Graphics?
So using g as a global var is fine, that's what I do at the moment.
g
so you can always create it 'offline' and then use btoa to create a base64 encoded string and use that in your code (a bit like is done with images)
like this?
//var map = [13, 39, 114, 25, 51, 102, 19, 27, 108, 61, 33, 66, 35, 29, 92, 49, 57, 78, 47, 5, 80, 59, 17, 68, 55, 9, 72, 11, 23, 116]; //mapb = btoa(E.toString(map)); var mapb = "DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd0"; console.log(atob(mapB)[0].charAt(0)); // 13
compare usage
>process.memory() ={ free: 2458, usage: 42, total: 2500, history: 1, gc: 0, gctime: 4, blocksize: 16 } >var map = [13, 39, 114, 25, 51, 102, 19, 27, 108, 61, 33, 66, 35, 29, 92, 49, 57, 78, 47, 5, 80, 59, 17, 68, 55, 9, 72, 11, 23, 116]; =[ 13, 39, 114, 25, 51, ... 9, 72, 11, 23, 116 ] > >process.memory() ={ free: 2426, usage: 74, total: 2500, history: 17, // 30 gc: 0, gctime: 3, blocksize: 16 } >delete map =true >process.memory() ={ free: 2458, usage: 42, total: 2500, history: 19, gc: 0, gctime: 5, blocksize: 16 } >var mapb = "DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd0"; ="DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd0" >process.memory() ={ free: 2453, usage: 47, total: 2500, history: 25, // 5 ! gc: 0, gctime: 0, blocksize: 16 } >
So using base64 encoded string is a real memory saver !
base64 encoded string
@MaBe 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.
So using
g
as a global var is fine, that's what I do at the moment.like this?
compare usage
So using
base64 encoded string
is a real memory saver !