|
|
View previous topic :: View next topic |
Author |
Message |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
LCD data refresh !! |
Posted: Wed Mar 03, 2010 6:41 pm |
|
|
Hi Guys, just want to know if you have a special trick for it !!!
I have a 2x16 display. I put data in the 4 corners (easy). Now the small problem (about the same for all corners), lets say bottom left hand corner, the data is a voltage that start 0.0V to 999.9V. I'm using the following code:
Code: |
lcd_gotoxy(1,2);
printf(lcd_putc, "%3.1wV",volt);
|
The problem with it is when voltage goes up, it is ok data shift to the right, but then when it goes down I have some character left on screen, to get rid of it should I clear the display every time (I tried but I don't like the flickering it creates) ???
Any solutions ?? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 03, 2010 7:31 pm |
|
|
You can tell printf to pad the number with leading spaces
by increasing the field width to 5. So in the first case
below, with 2.1, it will have two leading spaces. In the
2nd case, there won't be any. In each case the overall
displayed width will be 5 (including the decimal point).
Code: |
#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//======================================
void main(void)
{
int16 volts;
volts = 21;
printf("%5.1wV\r",volts);
volts = 1245;
printf("%5.1wV\r",volts);
while(1);
} |
|
|
|
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu Mar 04, 2010 6:49 am |
|
|
Too easy and it was just in front of my eyes !!!
Thanks PCM you've just simplified my life, it works great, as usual YOU'RE THE MAN !!!
I love this forum !!!! |
|
|
|
|
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
|