Efficiently moving things around in zig-zag Graphics buffer visualized w/ 24/32 bpp displays / neopixel strings #1016
Replies: 11 comments
-
Posted at 2019-02-11 by @allObjects Here the code:
The console output showing before and after of the development example copying colums 3 and 4 in 7 x 4 to columns 0 and 1 (output sligtly modified/condensed to fit forum's width and not to wrap):
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-11 by @gfwilliams Wow, glad the inline C is working well for you! Unfortunately it's not something that'll work on ESP32/ESP8266 though unless someone's willing to host their own compiler service. How does this compare to Just to add another potential option here when it comes to low-level Graphics manipulation: Create your own Graphics that has a non zig-zag byte ordering, and then use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-11 by @allObjects Some of that that is in the path... for rolling text: copying from a fix written buffer with a leading and trailing blank into a transfer buffer that is then shipped out to neopixel string. No redrawing, just copying into a buffer... My neopixel display IS hardware zig-zag... and for rolling text, with more than one byte in height, there is no way to not do non-contiguous copying... Vaguely remember coming across the graphic scroll... Did not compare that yet. Even if I trow above code out in favor of the graphic scroll - which I may - but not for all things, it was a great learning experience... I guess I need to study more conciously the merge requests / changes between the releases. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-13 by @allObjects @gordon, I know that Graphics class is natively implemented and exposes through a wrapper the buffer directly as value and with and height through methods. I plan to write as prototypic extension as module that can copy, cut, paste - implemented in it's core in C. For that I need t know how the Graphics object was setup (w, h, bpp and options)... and to get to that, I would need to know how I get to with just the pointer (pointing to the meta or header of the object). Therefore: How Graphics instance's 'top layer' is structured? - Where would I look for that information? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-13 by @gfwilliams The info you want is in https://github.com/espruino/Espruino/tree/master/libs/graphics and specifically: https://github.com/espruino/Espruino/blob/master/libs/graphics/graphics.h#L58 The Graphics instance has a child called Trying to support all the different encoding styles is going to take you a while though! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-13 by @allObjects ...indeed... kind of a cartesian product says hell(o)!... To keep complexity limited, I can see multiple, different extensions and the application has to load only what is needed... it could even be instance based rather than prototypical, even though latter I prefer (for encapsulation reasons and simplicity of use). For starters I will go for support of single neopixel string w/ zig-zag and not-zig-zag. A) Is there reason not to group fontAbc and modMmmN, since they are build-time conditioned? - https://github.com/espruino/Espruino/blob/master/libs/graphics/graphics.h#L64L68 and https://github.com/espruino/Espruino/blob/master/libs/graphics/graphics.h#L70L72 , respective I assume SAVE_ON_FLASH flag is at runtime accessible somewhere... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-13 by @gfwilliams
I'm not sure I understand?
4 byte normally I think, but the
I'm afraid not - all you could do is check for some function (drawCircle?) that doesn't exist with SAVE_ON_FLASH. These things were never really meant to be accessed from JS-land so there hasn't been any thought put into making it easy |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-13 by @allObjects ...instead of for reasons of having unconditional structure accessible as one, contiguous block, incl. cursor pos - (https://github.com/espruino/Espruino/blob/master/libs/graphics/graphics.h#L69, though may not be of interest. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-14 by @gfwilliams The modified items aren't flags - they're actual X/Y coordinates of the modified area - so I'm not sure it makes sense to put them together? Or you mean to move I guess for what you're doing you're unlikely to have to look any further than |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-14 by @allObjects
exactly. In other words: 'all' that is always there comes first, after that the optional 'things'. And in deed, the modified extent and font alignment/rotation information do not have to be in teh same #ifndef... Btw, I was surprised that this space/byte/variable saving business to fit onto devices w/ low flash is that fine granular... a lot of work... but it makes sense (not the work but the way it is done). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-18 by @gfwilliams Ahh - then I'll try and get those positions modified. The space saving may not be entirely required I guess but it's easy for things to get out of control. Also the Graphics lib uses a slightly odd way of storing that data (in a String, copied into a flat memory area for each gfx call) so the less data there is, the faster it'll run. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-02-11 by @allObjects
Recently played around with neopixels that I control w/ an Espruino Graphics object (see x by y w/ 24 bpp Graphics buffer visualized with neopixel string).
Especially in a x-y-panel arrangement of neopixels, the Espruino Graphics object is for many things superior to manipulating a buffer directly. Graphics object is even able to handle the zig-zag storage arrangement which allows minimal hardware effort to place wire a neopixels string onto a panel (no 'fly-back' wire).
Drawback of x-y-panel arrangement though creates some challenges when trying to move things around, such as running text, walking rainbow, etc. Of course, redrawing with different origin works to some extent; but besides the slow-down, jumpiness and not being able to begin text outside (at negative x or column) of the display buffer (loosing space), redrawing is not an option.
This pushed me to venture into integrated / inline C... and I really like it... could have used that earlier when fooling around with displays to speed up operations on scattered memory locations.
Speed is what I'm looking for... I copy 133 of 140 neopixels in less than 0.4[ms]. This is not only helpful on Espruino boards - to get to better neopixel refresh rates, but on all the ...strapped ESP-8266 that have to go to tend to WiFi 'at once in a while'... and application processing has to fit into the breaks in between; otherwise, as we know, ESP8266 crashes (with infinite reboot loop). Times on ESP8266 may even look better, because the processor runs faster, I recall... I don't know whether the serial flash messes with the speed... but it's worth a try... Who is a taker for that test?
A nice extra was that I need to pass at least 8 parameters... 4 are supported... Solution is to put all numeric and pointer args into an Uint32Array and have just one single argument to pass... With that mastered, just anything that would be needed for context can be passed from JS to C.
Having to use a parameter array makes calling the C function directly in the application code quite verbose and cumbersome. Therefore a wrapper around the call provides many goodies:
Next is to make it work for non-zig-zag and safe for in-place copying / shifting for all directions an (reasonable) combinations there of... (that wii switches the copy begins and ends around).
Here the code:
...sorry, textarea size on forum initial post exceeded... post is cropped... see next... post #2.
Beta Was this translation helpful? Give feedback.
All reactions