Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Using printf() as UserCode in EasyC 2.0 (http://www.chiefdelphi.com/forums/showthread.php?t=47722)

tacman1123 31-05-2006 08:45

Using printf() as UserCode in EasyC 2.0
 
I've add stdio.h to the Include files of my project, but printf("Test: %d", 1); (as a UserCode block) isn't writing to the terminal. What does PrintToScreen() do differently? PrintToScreen is limited to a single variable, and has a "\n" at the end, I'd like to have a bit more control (and just understand the communciation process better).

Do I need to include the printf_lib? If so, can someone explain the steps of integrating the VexCode libraries with the EasyC libraries?

TIA,

Tac

gabrielse 31-05-2006 09:03

Re: Using printf() as UserCode in EasyC 2.0
 
Quote:

Originally Posted by tacman1123
I've add stdio.h to the Include files of my project, but printf("Test: %d", 1); (as a UserCode block) isn't writing to the terminal. What does PrintToScreen() do differently? PrintToScreen is limited to a single variable, and has a "\n" at the end, I'd like to have a bit more control (and just understand the communciation process better).

Do I need to include the printf_lib? If so, can someone explain the steps of integrating the VexCode libraries with the EasyC libraries?

TIA,

Tac

I've had good luck using PrintToScreen as user code when I need to print multiple variables on one line. Use PrintToScreen the same way you would use printf in a user code block, just make sure you typecast your variables. There is no need to include any libraries.

example (type this in as user code):
PrintToScreen("x = %d, y = %d\n", (int)x, (int)y);

Good luck.

tacman1123 31-05-2006 10:01

Re: Using printf() as UserCode in EasyC 2.0
 
Thanks, that helps. I'd still like to know more about how to integrate low-level calls, but your solution solved my immediate problem, which was a simple script to monitor the radio transmitter values (since the Online mode doesn't display those). For those that are interested, here it is.

Code:

#include "Main.h"

void main ( void )
{
      int time = 0;
      int rx = 0;
      int channel = 1;
      int rx_value = 1;
      int i = 0;

      StartTimer ( 1 ) ;
      while ( 1 )
      {
            time = GetTimer ( 1 ) ;
            for ( rx=1 ; rx<=2 ; rx++ ) // loop through rx
            {
                  for ( channel=1 ; channel<=6 ; channel++ )
                  {
                        rx_value = GetRxInput ( rx , channel ) ;
                        PrintToScreen("%3d ", (int)rx_value);
                  }
            }
            PrintToScreen ( "at %d\n" , (int)time ) ;
      }
}

Now what would be nice is if the terminal window could be widened and the font could be changed to a fixed-width font, so that the results came out tabular instead of in a series of numbers.


All times are GMT -5. The time now is 03:14.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi