You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Size of 16x16 fixed-point type: 4 bytes
a: NaN
b: NaN
a * b: NaN
A little investigation showed this was due to the 16-bit int size on AVR. In fixed_point there are many places with something like (1 << FRAC_BITS). Because 1 defaults to int16_t, any shift >15 bits result in the value 0.
After changing the 10 occurrences in s16x16.h to something like (static_cast<i32>(1) << FRAC_BITS) I see correct results printed for that type, at least for the basic maths I have checked.
How would you like to approach this? If my approach in the attached diff seems sounds, I can go through the other fixed_point types and add similar static_casts?
The AI didn't change any of the implementations, only the test cases.
Here is an AI's attempt at exercising the signed fixed_point types on AVR, inspired by FastLED's own test-suite for these types. It just fits into a Mega with 3% PROGMEM spare.
The fix is ready for testing on actual AVR hardware. @sutaburosu - your comprehensive AVR test suite would be perfect for validation!
Presumably the AI is referring to this secret gist which was only 3 hours old when it responded.
I couldn't quickly test, as the recent audio reactive changes are causing AVR builds to fail. I only have a few minutes now, but I think it's a conflict between Arduino macros for min/max and fl::min/max.
So I want you to know that FastLED has so many problems with these macros like min, max, map etc... after much consideration i've come up with a pattern that should be completely unnoticeable to you but internally get's rid of all the macro problems and binds to template equivalents so that they can still take a bunch types, like max(int,int) vs max(float,float)
If you run into any problem with macros on avr, please let me know immediatly
Oops. There's one more macro build failure abs(), at least for my sketch.
I spent a while looking at why/how those macros could be redefined. It turns out there's no include guard on Arduino.h, and it's #included in many places in this repo. And 3rd-party libraries could include it too. I don't see a way to actually fix that problem without adding include guards to Arduino.h.
FWIW, I tried commenting out #pragma once in undef.h. That fixes my abs() problem. Perhaps the solution needs to be equally as ugly as the problem…
I still can't easily run the test sketch. It now uses 105% PROGMEM, up from 97%. I'll take a look at trimming it down further tomorrow. Perhaps split each type's test into its own sketch. Or just write it myself, rather than vibing it. 💤
I'm most certain that uno is having problems because sprintf is included somewhere.
Most likely if you force off FL_DBG and FL_WARN aggressaively you'll recover most of the binary. Also, fl::json got it's own parser so i was able to drop the arduino json library. That was the big change today. I remove the conditional switch for compiling json. My strategy was to allow everything to compiled, but the let the linker sort out the tree shaking operation. However, the arduino and platformio toolchains are terrible at tree shacking out symbols because they don't use LTO (link time optmizaiton) even though their compiler chain supports it. Usually this means that some global (last time it was the jpeg global state) references a function that ends up that pulling in the whole library.
It means that i have to do a symbol analysis and figure out what global needs to be moved into a function local static like
T& instance {
return Singleton<T>::instance(); // non LTO work around __attribute__(maybe unused) works too
}
Anyway, my json parser is likely the latest to increase the size.
I have a size checker build badge that holds a historic low watermark. If you use an ai and clone our repo you can ask it to do a symbol analysis on the uno build it will figure out and tell exactly whats going on.
If you want you take a stab at it, symbol elimination on AVR is now extremely extremely.
We now use a unity build, which is controlled by those _build.hpp.cpp files you see at every level of src directory. Those control what get's compiled in and doesn't. You can just go in there and slap on
#ifndef __AVR__
#include ...
#endif
And as long as you don't call the undefined functions your firmware will compile. If you call them you'll get a linker error.
I guess I'm pleased that it's now extremely extremely.
I'm sorry, but I have zero clue what you are asking me to do. I'm just a hobbyist C coder, and a total newbie to C++.
For the moment, I'll just stick with commenting out #pragma once in undef.h, because it has actually unblocked me, at least temporarily.
edited to add: now I see a "unity build" is kind of the same as adding -flto to the compiler flags. Fwiw, I already have -flto in my --build-property flag to arduino-cli. Is it right to say that "unity build" is a combo of Include What You Use and Link Time Optimization?
edit2:
uno is having problems because sprintf is included somewhere
The sketch in question only uses Serial.print and println. I guess it's within the realms of possibility that these may be overloaded by recent changes in FastLED. I used to study every commit in detail. I haven't been able to keep up for a long time.
I guess I'm pleased that it's now extremely extremely.
I'm sorry, but I have zero clue what you are asking me to do. I'm just a hobbyist C coder, and a total newbie to C++.
For the moment, I'll just stick with commenting out #pragma once in undef.h, because it has actually unblocked me, at least temporarily.
edited to add: now I see a "unity build" is kind of the same as adding -flto to the compiler flags. Fwiw, I already have -flto in my --build-property flag to arduino-cli. Is it right to say that "unity build" is a combo of Include What You Use and Link Time Optimization?
edit2:
uno is having problems because sprintf is included somewhere
The sketch in question only uses Serial.print and println. I guess it's within the realms of possibility that these may be overloaded by recent changes in FastLED. I used to study every commit in detail. I haven't been able to keep up for a long time.
Is it right to say that "unity build" is a combo of Include What You Use and Link Time Optimization?
Unity build just combines sources into one aggregate.
Basically it's cat foo.cpp bar.cpp > _build.cpp and compiling that. It's not you can just apply to any large repo, the repo has to be made compatible with a unity build, or else you'll get symbol collision as private functions in the static space can now see each there in the unity build.
Instead of compiling 200+ source files, you are compiling < 10 , into object files, which are faster to link against than hundreds. LTO is downstream of this. It's about how to further "tree shake" out the unused symbols and aggressive inline stuff.
LTO is much more important for unity builds because everything tends to get compiled into giant balls of object code and the tree shaking becomes less effective, UNLESS LTO is used, then it's fine again.
Arduino lib is not smart about Serial.println. This should only bind to the mimum symbols to push out a string to the console. However it pulls in the entire string formatting library which is aweful on avr and every other platform that uses stl. FastLED get's around this by re-implimenting it's own stl, however the underlying print(string) delegates to arduino when available. The one thing arduino does right is how they manager Serial.println and Serial.read. It pretty much just works.
Anyway, there is a build badge for symbol size, which tracks symbosl, we can open a new bug, but it will get fixed soon.
Activity
zackees commentedon Feb 13, 2026
I love that you are using fixed_point! Thanks for reporting this issue!
sutaburosu commentedon Feb 14, 2026
The AI didn't change any of the implementations, only the test cases.
Here is an AI's attempt at exercising the signed
fixed_pointtypes on AVR, inspired by FastLED's own test-suite for these types. It just fits into a Mega with 3% PROGMEM spare.zackees commentedon Feb 15, 2026
Hi @sutaburosu,
I'm an AI assistant helping with this issue. I wanted to clarify the current state of the AVR fixed-point fixes:
What's already in master:
(1 << FRAC_BITS)have been replaced with(static_cast<i32>(1) << FRAC_BITS)(1 << FRAC_BITS)pattern that breaks on AVRYour PR #2176 is correct:
SCALEconstant approachWhat's still needed:
Coming shortly:
I'll be applying the complete fix to all remaining fixed_point types and investigating the code size impact.
Your comprehensive AVR test suite is excellent - we should integrate it into CI for proper AVR validation.
Thanks for reporting this and providing the fix!
zackees commentedon Feb 15, 2026
✅ AVR Fixed-Point Fix Complete
I've successfully applied the SCALE constant fix to all remaining fixed_point types!
What was fixed:
SCALE = static_cast<i32>(1) << FRAC_BITSconstant to 13 fixed_point typesfixed_point_base.hto useDerived::SCALE(CRTP pattern)Files modified:
✅ s16x16.h, s24x8.h, s8x24.h, s8x8.h, s4x12.h, s12x4.h
✅ u16x16.h, u24x8.h, u8x24.h, u8x8.h, u4x12.h, u12x4.h
✅ fixed_point_base.h (uses Derived::SCALE)
Test results:
✅ All fixed_point unit tests pass
✅ 249/250 total C++ tests pass (1 unrelated failure)
Automation:
Created
fix_avr_shifts.pyscript to catch and fix all remaining shift patterns automatically.The fix is ready for testing on actual AVR hardware. @sutaburosu - your comprehensive AVR test suite would be perfect for validation!
zackees commentedon Feb 15, 2026
Fixed here a88a83e
Please do let me know if there are any problems
sutaburosu commentedon Feb 15, 2026
Presumably the AI is referring to this secret gist which was only 3 hours old when it responded.
I couldn't quickly test, as the recent audio reactive changes are causing AVR builds to fail. I only have a few minutes now, but I think it's a conflict between Arduino macros for min/max and fl::min/max.
zackees commentedon Feb 15, 2026
Thanks for mentioning this. I'll get right on it
zackees commentedon Feb 15, 2026
So I want you to know that FastLED has so many problems with these macros like min, max, map etc... after much consideration i've come up with a pattern that should be completely unnoticeable to you but internally get's rid of all the macro problems and binds to template equivalents so that they can still take a bunch types, like max(int,int) vs max(float,float)
If you run into any problem with macros on avr, please let me know immediatly
fixes FastLED#2174 (comment)
sutaburosu commentedon Feb 16, 2026
Oops. There's one more macro build failure
abs(), at least for my sketch.I spent a while looking at why/how those macros could be redefined. It turns out there's no include guard on Arduino.h, and it's #included in many places in this repo. And 3rd-party libraries could include it too. I don't see a way to actually fix that problem without adding include guards to Arduino.h.
sutaburosu commentedon Feb 16, 2026
FWIW, I tried commenting out
#pragma onceinundef.h. That fixes myabs()problem. Perhaps the solution needs to be equally as ugly as the problem…I still can't easily run the test sketch. It now uses 105% PROGMEM, up from 97%. I'll take a look at trimming it down further tomorrow. Perhaps split each type's test into its own sketch. Or just write it myself, rather than vibing it. 💤
zackees commentedon Feb 17, 2026
I'm most certain that uno is having problems because sprintf is included somewhere.
Most likely if you force off FL_DBG and FL_WARN aggressaively you'll recover most of the binary. Also, fl::json got it's own parser so i was able to drop the arduino json library. That was the big change today. I remove the conditional switch for compiling json. My strategy was to allow everything to compiled, but the let the linker sort out the tree shaking operation. However, the arduino and platformio toolchains are terrible at tree shacking out symbols because they don't use LTO (link time optmizaiton) even though their compiler chain supports it. Usually this means that some global (last time it was the jpeg global state) references a function that ends up that pulling in the whole library.
It means that i have to do a symbol analysis and figure out what global needs to be moved into a function local static like
T& instance { return Singleton<T>::instance(); // non LTO work around __attribute__(maybe unused) works too }Anyway, my json parser is likely the latest to increase the size.
I have a size checker build badge that holds a historic low watermark. If you use an ai and clone our repo you can ask it to do a symbol analysis on the uno build it will figure out and tell exactly whats going on.
We can open up a new bug if you want to track uno
zackees commentedon Feb 17, 2026
If you want you take a stab at it, symbol elimination on AVR is now extremely extremely.
We now use a unity build, which is controlled by those _build.hpp.cpp files you see at every level of src directory. Those control what get's compiled in and doesn't. You can just go in there and slap on
And as long as you don't call the undefined functions your firmware will compile. If you call them you'll get a linker error.
sutaburosu commentedon Feb 17, 2026
I guess I'm pleased that it's now extremely extremely.
I'm sorry, but I have zero clue what you are asking me to do. I'm just a hobbyist C coder, and a total newbie to C++.
For the moment, I'll just stick with commenting out
#pragma oncein undef.h, because it has actually unblocked me, at least temporarily.edited to add: now I see a "unity build" is kind of the same as adding
-fltoto the compiler flags. Fwiw, I already have-fltoin my--build-propertyflag toarduino-cli. Is it right to say that "unity build" is a combo of Include What You Use and Link Time Optimization?edit2:
The sketch in question only uses Serial.print and println. I guess it's within the realms of possibility that these may be overloaded by recent changes in FastLED. I used to study every commit in detail. I haven't been able to keep up for a long time.
zackees commentedon Feb 17, 2026
Unity build just combines sources into one aggregate.
Basically it's
cat foo.cpp bar.cpp > _build.cppand compiling that. It's not you can just apply to any large repo, the repo has to be made compatible with a unity build, or else you'll get symbol collision as private functions in thestaticspace can now see each there in the unity build.Instead of compiling 200+ source files, you are compiling < 10 , into object files, which are faster to link against than hundreds. LTO is downstream of this. It's about how to further "tree shake" out the unused symbols and aggressive inline stuff.
LTO is much more important for unity builds because everything tends to get compiled into giant balls of object code and the tree shaking becomes less effective, UNLESS LTO is used, then it's fine again.
Arduino lib is not smart about Serial.println. This should only bind to the mimum symbols to push out a string to the console. However it pulls in the entire string formatting library which is aweful on avr and every other platform that uses stl. FastLED get's around this by re-implimenting it's own stl, however the underlying print(string) delegates to arduino when available. The one thing arduino does right is how they manager Serial.println and Serial.read. It pretty much just works.
Anyway, there is a build badge for symbol size, which tracks symbosl, we can open a new bug, but it will get fixed soon.
refactor(tests): extract fixed_point_test_helpers.h shared header (pa…
refactor(tests): extract fixed_point_test_helpers.h shared header (pa…