I'm using dtostrf and it works fine on my Due but not the Mega. (I'm needing the 5v IO power of the Mega)
As a little test, Here is a small sketch that prints 12500.00 fine in the IDE serial monitor with Due, but on the Mega it outputs all kinds of crazy characters.
Any explanation of why this works so differently on the two boards would be awesome... Thanks
Sorry, this is just a small test sketch to mess with. I actually need to send about 20 long's to a 4D LCD and have a 16 bit max.
So if I convert my (long) encoder values (ie. encoder1value) to strings, I'm able to shoot them over. and this all works fine with my Due... However it Just outputs ? marks on the 4D display when I transfer the program to the Mega. I'm just trying to figure out where the difference is...
Here is another segment of code with the same principal but showing the output to the genie.WriteStr function to display the value.
OK, I still don't understand why you're manually (and precariously) converting a string to a String.
I also don't know why you're using a long as input to a function that expects a double.
Honestly being pretty new to this, it was the only way I could find to do it.
Since there was no danger in killing anyone, I figured I would keep trying different things out until I found a solution. I really began this issue trying to send a large calculated float to the display with with up to 7 characters and 3 decimal places. Thats where the double came to play initially.
So far with this, I was able to make the other non-decimal integers work ... but that was only with the Due.
I used
String g1Solid = "";
to initially clear the display for the next display field push and it actually allowed me to compile the dtostrf function.(dont ask me why but it works).. even though the function expects a double, I get it.
So, now obviously there are a few issues you've pointed out. I know for a fact that my encoder1value is a long int, I searched for quite a while to figure out how to convert a long into a String with dtostrf being the only option I found.
Do you have another option that comes to mind to get these longs (safely) converted to strings? I'm definitely all ears seeing how I've been fumbling with this for a couple weeks now on my own.
After doing a bit of research on ltoa here and a little trial and error, everything is working great with the display. I learned a lot and things seems to run a lot smoother.
I was also able to find a few other functions on that site that I can use in the future as well...