These are chat archives for Makuna/NeoPixelBus

Mar 2018
Mar 13 2018 00:07
@Makuna , I appreciate your feedback. If I understand you correct, 'options' and 'branches would be a third alternative to inheritance and templates. so is it correct that the price of inheritance vs templates in this context is RAM? and if so, how much would you think, my guess would be one pointer pr. method pr. class type :) but I am just guessing. I am currently making different animation classes that inherits a 'update' method run their distinct drawing algorithm... each drawing 'algorithm' also have unique fields, so I cannot think of a better way in that case than to use inheritance. Perhaps this could be 'templated' and then specifying a pointer to the drawing routine and the data in the template?
Mar 13 2018 00:27
@Makuna thank you very much for your help. It works for ESP8266 and a somehow for ESP32 (some glitches remains)
perhaps to rename the NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount, PixelPin);
to NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount);
so we do not forget that it only use GPIO3 of ESP8266... even after reading it 2 days ago, I forgot when moving from ESP32 to ESP8266...
for ESP32, what about doing all the computation / timing on the other core (that is not used by the Wifi)
Michael Miller
Mar 13 2018 01:30
@blotfi For Esp32 It does do all the work on the other core from WiFi. The problem is the very low level it uses a multi-tasking system on Esp32 that you can't control the switching, it forces a task change for a very small amount of time, but enough to cause problems; with no way found to stop it. Once the RMT work is done, the system will be far better anyhow.
@blotfi And not just RAM, code space and instruction time. A branch is at least one instruction. This instruction takes not only code space, but also instruction time when run. If this branch is in a inner loop (a loop ran very often) that time adds up tremendously. An example in my library, color element order (RGB vs BGR), the data is copied into the output buffer in the correct order, so FOR EVERY PIXEL (inner loop) it would have had to test and branch for each color element as it is copied. It doesn't in my code.
Mar 13 2018 08:20
@Makuna ok, yes, so you are thinking of the virtual method as a branch and the 'v-table' equivalent an switch... I see you point, good to consider.
@Makuna , and these branches are sprinkled out through the code everywhere they are used?, or does the compiler do something smart to avoid that ??
Michael Miller
Mar 13 2018 18:04
@blotfi If you use derivation, then you just forced a function call (which are pretty heavy, storing registers on stack, retrieve vtable pointer, call vtable pointer, and then restoring registers from stack). With generics (templates) often the function just disappears completely.
Most compilers will do a lot tricky things with code, so sometimes it will, sometimes it wont. It all depends on the flags passed to the compiler for optimizations.