CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

updating the same line instead of writing a new line??

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
piire



Joined: 04 Mar 2009
Posts: 19

View user's profile Send private message

updating the same line instead of writing a new line??
PostPosted: Sun Mar 08, 2009 4:28 pm     Reply with quote

hi there,

when using printf /n it print a new line on the consol, how do i just make it change the same line (refresh) instead of printing another line.

i have a loop which gives me vaules of my outputs, but i dont want it to print a long list, i just want it to update the same line every few seconds.

does anyone know the code for this?

thanks
piire!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 08, 2009 4:32 pm     Reply with quote

If you don't want a new line, then don't send the "\n" command.
Just a send a carriage return: "\r"
Ttelmah
Guest







PostPosted: Mon Mar 09, 2009 4:29 am     Reply with quote

Or, for more 'complex' things, use the lcd_gotoxy instruction, to position where you want. So, (for example), if you are on a 2*16 LCD, and have the top line saying "Reading xxx mG", you can use:
Code:

   int8 val;
   lcd_putc('\f'); //Back to the top corner of the display, and clear
   printf(lcd_putc,"Reading nnn mG"); //Initialise the message

   while (true) {
      val=code_to_get_reading();
      lcd_gotoxy(9,1); //The location where 'nnn' starts
      printf(lcd_putc,"%03d",val; //print the value to fill the 'nnn' space
   }

This way, you only need to redraw the actual number, not the rest of the text.
YPYMATYC.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group