Go Down

Topic: Ardino due and sprintf() on Atmel Studio 6.1 doesn't work! (Read 3178 times) previous topic - next topic

darighi

May 24, 2013, 11:53 pm Last Edit: May 24, 2013, 11:55 pm by darighi Reason: 1
Hello to all,
excuse me for my question, I don't know if I can post it in this forum.

I am using Atmel Studio 6.1 to program Arduino Due and I would like to print a float number in a buffer.

Code: [Select]
If I write:
char bf [40];
int F = 1234;
sprintf (bf, "% d", F);


everything works fine and I find the integer number in the buffer "bf".
if instead I write

Code: [Select]
char bf [40];
float F = 1234.0;
sprintf (bf, "%f", F);


does not work and I don't find the float number in the buffer "bf" .

if I use Arduino IDE 1.5.2 everything works fine.
someone has a suggestion?
where am I wrong?

Best regards
Davide


pYro_65

#1
May 25, 2013, 01:26 pm Last Edit: May 25, 2013, 01:29 pm by pYro_65 Reason: 1
The sprintf used by the AVR's does not have float support, or many other sprintf features.

Here is a library I'm working on at the moment, there is a working 'GString' library which contains an sprintf function:    
String/sprintf alternative for Arduino.

However this requires the Print library, which you'll have if you use the Arduino core.
Forum Mod anyone?
https://arduino.land/Moduino/

darighi

Than you very much, it's exactly that I was looking for!
Very beautiful work, my compliments.
I thank you very much.
At the first test it seems to work very well.
Best regards.
Davide

pYro_65

#3
May 26, 2013, 12:30 pm Last Edit: May 26, 2013, 01:05 pm by pYro_65 Reason: 1
That is good to hear, I don't actually have a Due to do any testing, so your response was great. Cheers. :)
Forum Mod anyone?
https://arduino.land/Moduino/

darighi

Oops, I just realized now that I had made ??a mistake and had not included your library but I printed an integer with sprintf of atmel, that's why it seemed to work! :)
I was too tired when I took the test.
when I have time I'll try again including your library. Thanks again and sorry for the error.
Davide

pYro_65

No worries, there shouldn't be problems as the version you have does not include the eeprom or progmem code. I'm working on a print library extension that allows Serial.printf(). It is only AVR compatible at the moment as I build the functionality, but eventually I can mask off the AVR only bits and I'll have support for the Due as well.

You should be fine to use the GString.h, though.
Forum Mod anyone?
https://arduino.land/Moduino/

AndiJay

How exactly are you able to program the ARM chip through Atmel Studio? This is killing me.

garballz

I use an add-in for Atmel Studio 6.1 called Visual Micro. I can program all my Arduino boards, including Due, using it.

Check it out (it is free)http://www.VisualMicro.com

Here is a screenshot

Go Up