These are chat archives for Makuna/NeoPixelBus

12th
Mar 2018
Lotfi
@blotfi
Mar 12 2018 18:51
@Makuna What are you waiting exactly? DMA feature? or is it a pb of Wifi has to check the connection / process loop?
Why things work very well on a low end and slow Arduino Nano V3 and not on a faster chip like ESP32 or ESP8266
Michael Miller
@Makuna
Mar 12 2018 19:11
@blotfi The problem is that these chips have built in WiFi with interrupts that can NOT be masked or stopped; so doing reliable timing critical work must be done with hardware exposed on the chips. On AVRs, you can stop all interrupts do what ever you want.
The esp8266 is good to go right now. The Esp32 has a RMT feature that has 8 channels (imagine 8 neopixel busses on almost ANY pin) but the exposed support for it is minimal; so it can't be shared (it would be used with a IR remote and other timing libraries) and the buffer it will read from is extremely verbose for NeoPixels (4 bytes to represent only one bit of NeoPixel data) making it near useless. BUT, they are fixing it.
buildcomplete
@buildcomplete
Mar 12 2018 21:23
@Makuna , thank you for your feedback, and now I will go completely off topic :). But I am a bit puzzled, I know this is not a c++ channel, anyway... Why does the code take up less space using templates than inheritance?, I can understand there might be better performance using templates since there is no v-table to resolve the method to be invoked, but I would expect the object-code to have more or less the same space? Also in the case you need multiple templates, the code would take up more space with templates since you would need to compile to distinct classes, instead of one and some V-table voodoo... Again, I know this is not a C++ channel, but I am curious. And is there a difference between the 'using' and 'typedef'. As I read what you write I would have to type the same 'MyMosaic' where I needed it... (as you see here https://github.com/buildcomplete/pixelfunk/blob/master/src/AnimatedParticle.h )
Michael Miller
@Makuna
Mar 12 2018 23:49

You partially understand the issue. If instead of templates you had options, then you would have to store flags for branches (speed, timing, etc) and also the code for branches adds up in size and running time (think inner loops with branches). But in nearly all use cases for this library, you would not use multiple instances. Where you would need multiple templates, you assume it takes up more code; but often the compiler can optimize the code use down where they are similar enough. While a dozen or so bytes doesn't seem like much, there are some target MCUs that don't have much more than this that my library can run on.

Not only is there no V-Table to dereference (these aren't Intel CPUs), there is no V-Table taking up RAM, as that is where it gets stored. I believe there is now a way to force it be stored in flash (code space), but this option is not used for Arduino. I believe the esp8266/esp32 people are looking into this right now.

My understanding now is that using and typedef are equivalent.