Society of Robots - Robot Forum

Software => Software => Topic started by: javila on June 10, 2010, 05:30:16 PM

Title: RPRINTF_FLOAT
Post by: javila 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????
Title: Re: RPRINTF_FLOAT
Post by: Webbot 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
Title: Re: RPRINTF_FLOAT
Post by: javila 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?
Title: Re: RPRINTF_FLOAT
Post by: javila 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
Title: Re: RPRINTF_FLOAT
Post by: Webbot 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