Author Topic: RPRINTF_FLOAT  (Read 2729 times)

0 Members and 1 Guest are viewing this topic.

Offline javilaTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
RPRINTF_FLOAT
« on: June 10, 2010, 05:30:16 PM »
Hi:
How can I use rprintf for float, double numbers?
I am trying this RPRINTF_FLOAT(2,2.1) for example but the compilers says:
 undefined reference to `rprintfFloat'
how is this suppose to be initialized or used????

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: RPRINTF_FLOAT
« Reply #1 on: June 10, 2010, 06:38:45 PM »
Do the following
Code: [Select]
#define RPRINTF_FLOATBefore you
Code: [Select]
#include rprintf.h
You can then print the value as a 10 digit number  by using :
Code: [Select]
rprintfFloat(10, myVar);
Where 'yourVar' is the name of your variable
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline javilaTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
Re: RPRINTF_FLOAT
« Reply #2 on: June 10, 2010, 06:52:42 PM »
it is not working.. this is what I have:
Code: [Select]
#include "SoR_Utils.h" //includes all the technical stuff
#include "uart.h"
#define RPRINTF_FLOAT
#include "rprintf.h"

int main(void)
{
//declare variables here
//int i=250;//a 'whatever' variable
int sensor_left=0;//left photoresistor
int sensor_right=0;//right photoresistor
int threshold=25;//the larger this number, the more likely your robot will drive straight
int rangefinder1=0;
int rangefinder2=0;
             float num=334;
rprintfFloat(8,num);
thats just the beginning of the code, but it is the only place I use it. It still gives me the same error.. any suggestions?

Offline javilaTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
Re: RPRINTF_FLOAT
« Reply #3 on: June 10, 2010, 07:17:35 PM »
I fixed it,,, I found this on an example in the avrlib:

   
Code: [Select]
// NOTE: TO USE rprintfFloat() YOU MUST ENABLE SUPPORT IN global.h
// use the following in your global.h: #define RPRINTF_FLOAT
You were right but instead of defining it in main I was supposed to do it in global

Thanks

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: RPRINTF_FLOAT
« Reply #4 on: June 11, 2010, 04:00:27 AM »
Yep. It has to be defined before the first file that includes rprintf.h
So you could do it your main - but put it right at the top ie before including SoR_Utils.h
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 

SMF spam blocked by CleanTalk