So using g as a global var is fine, that's what I do at the moment.
I'd say passing it in as an argument is more flexible...
require("my_lib").drawBarCode(g, myData);
Then you have the option of drawing offscreen if you need.
like this?
I'd suggest: map = atob("DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd0") then map.charCodeAt(index). You could use E.toUint8Array to avoid the charCodeAt but for smaller arrays like this, I guess charCodeAt is more efficient.
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.
I'd say passing it in as an argument is more flexible...
Then you have the option of drawing offscreen if you need.
I'd suggest:
map = atob("DSdyGTNmExtsPSFCIx1cMTlOLwVQOxFENwlICxd0")
thenmap.charCodeAt(index)
. You could useE.toUint8Array
to avoid thecharCodeAt
but for smaller arrays like this, I guesscharCodeAt
is more efficient.