Replies: 3 comments 3 replies
-
The arm compiler doesn't have an itoa implementation, so here's one. This can be simplified further if it is known that numbers will never be negative. I'm not familiar enough with the various uses to know that for sure.
Then a convenience function to concatenate a number onto a string:
Finally another convenience function to concatenate a character onto a string:
Then we can replace something like this:
With:
And replace something like this:
With:
|
Beta Was this translation helpful? Give feedback.
-
You must have not looked into the code. |
Beta Was this translation helpful? Give feedback.
-
Extra baggage in the binaries as a convenience for coding is your prerogative. Personally I work under the mantra that I write code once, and it executes billions of times. |
Beta Was this translation helpful? Give feedback.
-
It appears printf is taking up around 1.5k of the firmware. That is around 2.5% of the firmware is the printf implementation. Looking at the usage of printf this seems very unnecessary. Its primary usages are in spectrum.c and dtmf.c, and the usages I see can easily be replaced with simpler itoa and strcat in most cases. The dtmf usages are extremely trivial as they are just shorthand for concatenating a string, char and string. It will also perform faster without the printf logic being executed over and over rendering some of those screens.
Some usages, like
sprintf(String, "%s", registerSpecs[idx].name);
don't even make sense as that is just a strcpy. Orsprintf(String, "%u", GetRegMenuValue(idx));
which is just itoa.Beta Was this translation helpful? Give feedback.
All reactions