Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup idx #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Lookup idx #3

wants to merge 14 commits into from

Conversation

s-light
Copy link

@s-light s-light commented Jun 25, 2018

this pull request experiments with a lookup table instead of the inline idx calculations.

--> Works!

tested if it is gaining speed:
in orig. master a call to setRGB(id, r, g, b) resulted in ~49us
after a hardcoded lookup-table it resulted in ~10us
so that is a nice gain!
update: in last test with Optimization activated i got to 9us :-)

TODO:

@s-light
Copy link
Author

s-light commented Jun 25, 2018

progmem works fine :-)
results in ~11us for setRGB(id, r, g, b) call

@s-light
Copy link
Author

s-light commented Jun 26, 2018

ok - found the missing information:
for a fully working compile-time generation of the array we need the support of the C++14 feature Relaxing requirements on constexpr functions
but this is first available in gcc 5
that should hopefully come in the near feature: currently blocked by arduino/Arduino#7090

i tried to generate the array with templating magic (you can find a big bunch of ideas and solutions on stackoverflow) - but they work with recursive templating calls...
and the default max recursion depth for the IDE is set at 900. thats not enough.

i have manually copied together a hardcoded lookup table for up to 2400 channels - that is 200 TLC-Chips. i think that enough for the most users ;-)
it bloats the code size ab bit but hey- therefore it gains speed ;-)

tested with arduino beta `arduino-PR-beta1.9-BUILD-71`
with OPTIMIZE_SET 1
tested on an OLIMEXINO-32U4 resulted in 9us for
tlc.setRGB(idx, r, g, b)
@s-light
Copy link
Author

s-light commented Jun 27, 2018

that is it for now :-)

with the last commit i implemented a compile-time generator for the idx lookup table.
its based on this avrfreaks forum post

this compiles fine in the arduino-PR-beta1.9-BUILD-71 version.
you must enable c++14 support in /home/$USER/.arduino15/packages/arduino/hardware/avr/1.6.20/platform.txt:
change -std=gnu++11

compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 ....

to -std=gnu++14

compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++14 ....

@s-light
Copy link
Author

s-light commented Jan 26, 2023

Please support C++17 by default #435
for samd i currently found no such request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant