Quick EasyC question

I was wondering how I could get the ‘print to screen’ function in easyC Pro to display the readings from my ultrasonics SLOWLY, while labeling which sensor the reading came from.

Thanks,

Add a wait block before (or after) the printf block and u will get a delay in the amount of readings coming in. You can also specify which ultrasonic sensor to get readings from by assigning a variable to a sensor and labeling which reading gets displayed in the printf block (you can have multiple printf blocks.) Consult the EasyC help file for more indepth discussions of these functions.

Technic-R-C

To keep the rest of your code running without a delay, you may want to use a timer. For example, start your timer in Initialize():


StartTimer ( 1 );

and read its value in your OperatorControl() while loop:

if ( GetTimer ( 1 ) >= 1000 ) // In milliseconds
{
    // Print function here
    PresetTimer ( 1 , 0 ); // Resets the timer to zero
}

Good luck,
John Mueller

Or just a simple counter to print every 500 readings

[FONT=“System”]int debug_counter = 0;

… rest of the program

if (debug_counter > 499) {
PrintToScreen( … sonar stuff …);
debug_counter = 0;
}
debug_counter = debug_counter + 1;

… rest of the program

[/FONT]

You can also get carried away and do

[FONT=“Fixedsys”]

int debug_counter;

… some part of the program

if (debug_counter == 500 ) {
PrintToScreen( … sonar stuff …);

… more program

if (debug_counter == 250 || debug_counter == 750 || debug_counter == 500 ) {
PrintToScreen( … other debug stuff …);
}
… rest of the program
if (debug_counter > 1000) {
debug_counter = 0;
}
debug_counter = debug_counter + 1;
}
[/FONT]

I remember someone posting a really nice debug function but I can’t find it in the archives. Maybe you’ll have better luck in finding it.

Foster

I have a much better answer, because you are using easyC Pro. easyC Pro allows you to address the terminal window. So, you can create static displays with multiple variables showing at once. The only catch is you can’t mix PrintToScreen and Graphic Display it’s one or the other.

For more information and a sample program drag in the Graphic Display block and click Help.


SampleGD.zip (2.24 KB)

I have been trying to use the graphic display for a couple of years now and one of the things I have not been able to solve is the refresh problem. So, when I stumbled across this thread, I thought it would solve all of my problems. Little did I know that it would only compound them!

I tried your sampleGD program exactly as is and I received a completely blank display screen. (Yes, I did have the graphic display checkbox marked). When I changed the field width from “%4d” to “%d”, it displayed fine (except for the refresh problem). My new question is, why does specifying a field width cause my display to go completely blank? This has happened to me in other programs, not just this one.

What version number of easyC? Real serial or USB?