Until a week ago, for the last three months, I had the following block of code inside a constructor creating several flat strings without fail.
var nArySizeRGB = options.numPixels * 3;
var strg = E.toString({data : 0, count : 256});
var strd = E.toString({data : 0, count : nArySizeRGB});
var strr = E.toString({data : 0, count : nArySizeRGB});
var strb = E.toString({data : 0, count : nArySizeRGB});
var strc = E.toString({data : 0, count : nArySizeRGB});
var strf = E.toString({data : 0, count : nArySizeRGB});
this.ad = new Uint8ClampedArray(E.toArrayBuffer(strd));
this.ar = new Uint8ClampedArray(E.toArrayBuffer(strr));
this.ab = new Uint8ClampedArray(E.toArrayBuffer(strb));
this.ac = new Uint8ClampedArray(E.toArrayBuffer(strc));
this.af = new Uint8ClampedArray(E.toArrayBuffer(strf));
this.ag = new Uint8ClampedArray(E.toArrayBuffer(strg));
Now, not all the strings get created.
typeof: string len: 256
Uncaught Error: Unsupported first argument of type undefined
at line 4 col 192
...Array(E.toArrayBuffer(strb));this.ac=new Uint8ClampedArray(E...
I peppered the source with console.log statements and see three strings are created before the inevitable
[L270] nArySizeRGB 180
strg typeof: string len: 256
strd typeof: string len: 180
strr typeof: string len: 180
Uncaught Error: Cannot read property 'length' of undefined
at line 4 col 115
..."+typeof strb+" len: "+strb.length);var strc=E.toString({dat...
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.
Wed 2019.01.30
Until a week ago, for the last three months, I had the following block of code inside a constructor creating several flat strings without fail.
Now, not all the strings get created.
I peppered the source with console.log statements and see three strings are created before the inevitable
Re-Reading:
I see that creating them takes time. There doesn't appear to be a solution to try, should that time duration block subsequent code execution.
I have tried reset(true), closing and re-opening the WebIDE and even powering down the Pico.
Is there a preferred way to somehow add a delay between each creation request and only advance after that request was successful?