Pages: [1]   Go Down
Author Topic: Ardino due and sprintf() on Atmel Studio 6.1 doesn't work!  (Read 1420 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
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

« Last Edit: May 24, 2013, 04:55:54 pm by darighi » Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: May 25, 2013, 06:29:15 am by pYro_65 » Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That is good to hear, I don't actually have a Due to do any testing, so your response was great. Cheers. smiley
« Last Edit: May 26, 2013, 06:05:40 am by pYro_65 » Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley
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
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Austin, Texas, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Iowa
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: