any limits on javascript object or Uint8Array usage? #615
Replies: 14 comments
-
Posted at 2016-08-31 by MichaelPralow i did some further testing, there seems to be an upper limit for the javascript variable size (i hit it with objects or arrays), right now i just splitted my data into usable parts is the max size somewhere documented? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-31 by DrAzzy You might be running out due to the intermediate representation. Pretend you're a parser and look at var x = new Uint8Array(["blah","blah",....]) Before we can evaluate that, we have to read in that bit between the []'s, which creates a standard array (1 or 2 jsvars per item). Then that gets passed to the Uint8Array constructor, which returns something much smaller. Plus it needs to store the big blob of text while it parses it... So while your final structure may be small (I think it comes out to 12 bytes per jsvar? Or does it use flat strings for more efficiency now?), you can end up with higher memory usage while processing it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-01 by @allObjects Put it in level 0, code it and junk it up... that way - on upload - each junk is sent to Espruio and processed, and only the final result is kept. For example:
What is taken advantage here is the fact that Espruino goes right to work on upload: it does not just parse the code, but execute it right away when a statement is complete... this is @gordon's only option to live with as little as memory as a lot of MCs provide. As you can see from the additional code - the standalone ``console.log() Console output:
Now you enter in console
Btw, what are you using this mass data for? ...image / font? ...odd length: 143 bytes each block... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-01 by MichaelPralow thx i will try that soon the data is for a grayscale font, one part stands for one char(anti aliasing, 2bpp, 4 colors), "80" is for "P" and so on |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-01 by @allObjects Ic... cool! ...I'm sure it is for the e-paper / e-ink display. I c 2: you do not like the 'ausgefranst' (frayed) characters rendered by Espruino built-in vector fonts... ...are there versions with touch screen available you would know of? ...is there a reason not to use array of arrays? ...first array charCode / ASCII value indexed... with offset of 32 (0x20)? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-01 by MichaelPralow code works like charm, i will try to change my conversion workflow (includes parsing a C file and creating javascript)
not that i know of, i am not sure it would make sense, the refresh cycle time goes not well with input reaction time expectations, if you google around you will find e.g. an interview (german) with a representative from pervasivedisplays who talks about touch and e-paper
well i use only some characters not a complete set and some number gaps (e.g. abcdefghi but no j, and so on), so i need some address mapping , hmm i will try it with a complete font, maybe it fits into the memory (depends on width/height, will be interesting to test it out) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-01 by @allObjects Glad to hear you having fun... there is enough code grief around...
even google.de could not get me there... (US 'Zensur'). What is the url?
You got that already... may be you have to develop your own Graphics.drawString()... or override the method where the bitmap is looked up.... or you do the transformation before and not supplying the full matrix for the backing font... (I do not know if the Graphics object can handle that).
Absolutely... create modules for each character... and you could even think of simple compression - before load or even for draw - and forget drawString() all together: just mapping memory to memory, and if you make it compiled, it will be very fast... (needs of course to put sufficient meta data into each char definition... in byte string or as object with properties). I'm working on a ui core with ui elements extension that work exactly in such way: In your code:
chars.js module:
Example character module: P - 80
...and I'm sure you'll do better than that... ;-) NB: code only partially verified :| PS: you can test the code 'mechanics' without FlashEEPROM card: just add the requires for the characters statically before loading chars.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-05 by @gfwilliams Sorry for the delay - I've been away this past week... But yeah, it'll be storing the data in text form and the standard array form before it gets into a Uint8Array. To get the data in quickly and easily you could use base64, then You can use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-05 by JumJum @allObjects try this one http://www.elektroniknet.de/optoelektronik/displays/artikel/117075/ |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-05 by MichaelPralow thanks for all the help @allObjects the example with modules looks like a good way to provide the function for all Espruino users, i will look into that (combined with that base64 hint from @gordon) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-06 by @allObjects @jumjum, thanks, gives me what I need to know. Fazit: statische Anzeige, Ausdruck elektronisch dargestellt... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-06 by MichaelPralow @allObjects if you looking for low power displays (but usable for faster refresh cycles) take a look at sharp memory lcd |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-06 by @gfwilliams I can definitely recommend the memory LCDs. There's an Espruino driver for them, they work really well, and don't need many external components. I just wish they were cheaper to buy, but compared with epaper they're still pretty good :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-09-06 by Spocki ... and there is (will be) a round one for the puck ;-) http://sharpmemorylcd.com/0-96-inch-memory-lcd.html |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-08-31 by MichaelPralow
Are there any limits on javascript object usage?
i have an object which looks like
i experienced some weird behaviour when i raise the sizes of the Uint8Arrays (like 50-100 elements more) --> out of memory
for the object above (including all 23 attributes) and some functions i get
and
i am certainly not expecting a out of memory, even if the the
chars
object would be double the size than beforeBeta Was this translation helpful? Give feedback.
All reactions