@Jimmus
You actually need more than 43 precision is set to be more than zero! so you would need (precision + 43). precision is am unsigned 8 bit which can go all they way up to 256. also take note that copying from that array to the actual array would take some time too.
@krupski first comment (Nov 11, 2017, 07:41 am )
Well, the problem with heap is that it cannot be measured but I think it is unlikely for them to use heap.
@krupski (Nov 11, 2017, 08:04 am)
I tried but I failed as you can see in my other comment
@krupski (Today at 12:06 am)
Have you written a guide on where to place these parts of your code so I can give it a shot.
Now on my progress in making a safe dtostrf:
-
I was not sure how should the function look like. So I start looking for function developed by others. soon I noticed dtostrf rarely is used and the alternative name usually used is ftoa. So, I looked up few ftoas and to all of them were safe. They may not have produce clean results like our dtostrf but they were safe.
-
I asked this question in AVR freaks and I was told to just implement it myself. So I started but problems were raised one after each other. The initial step was finding the files I need.
So here is a list:
ftoa_engine.h
[avr-libc] Contents of /trunk/avr-libc/common/ftoa_engine.h
ftoa_engine.S
http://svn.savannah.gnu.org/viewvc/avr-libc/trunk/avr-libc/libc/stdlib/ftoa_engine.S?revision=2191&view=markup
sectionname.h
http://svn.savannah.gnu.org/viewvc/avr-libc/trunk/avr-libc/common/sectionname.h?revision=2166&view=markup
#include <avr/io.h>
I could not find this one though. I thought this is supposed to be the easiest one.
So I started a new project and the code did not compile but not because something is missing. It could not understand the .S (assembly file) and the .INC file. So hen I remembered that Arduino IDE and assembly do not go well together.
I also thought of just using the assembly part in a function and use "asm volatile( // code );", so after finishing I noticed the code does not compile mainly because it cannot connect the function's arguments to the the variables in assembly code (even though I used the same name). Which kind of make sense.
So is there anyone here who knows how to connect the function arguments to assembly code? (we may need to relate the #defines to assembly code (I am not sure if this is done currently))
Or is there anyone who knows how we can trick the arduino IDE to use assembly code?
Or is there anyone who knows a way to use the "__ftoa_engine" function in Arduino IDE? Arduino dtosrf use this thing but the users cannot use it in the IDE environment.
My assembly function was too long, so I attached it.
Direction from here:
while I wait for someone who knows the solution to number 2, I start making an equivalent __ftoa_engine in C++ so that for the worst case scenario. Then I make the dtostrf which is safe. Any suggestions are appreciated.
floatEngineTest.ino (11.2 KB)