|
|
View previous topic :: View next topic |
Author |
Message |
piire
Joined: 04 Mar 2009 Posts: 19
|
updating the same line instead of writing a new line?? |
Posted: Sun Mar 08, 2009 4:28 pm |
|
|
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
|
|
Posted: Sun Mar 08, 2009 4:32 pm |
|
|
If you don't want a new line, then don't send the "\n" command.
Just a send a carriage return: "\r" |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 09, 2009 4:29 am |
|
|
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 |
|
|
|
|
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
|