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 support@ccsinfo.com

LCD data refresh !!

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



Joined: 06 Dec 2006
Posts: 102
Location: Montreal , Canada

View user's profile Send private message

LCD data refresh !!
PostPosted: Wed Mar 03, 2010 6:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 03, 2010 7:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 04, 2010 6:49 am     Reply with quote

Too easy and it was just in front of my eyes !!! Embarassed Very Happy

Thanks PCM you've just simplified my life, it works great, as usual YOU'RE THE MAN !!!

I love this forum !!!! Smile
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