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

Reg: glcd jhd12864e interfacing with pic16f877a

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



Joined: 09 Apr 2012
Posts: 19
Location: Salem

View user's profile Send private message

Reg: glcd jhd12864e interfacing with pic16f877a
PostPosted: Mon Nov 19, 2012 6:00 am     Reply with quote

Hi,

I am trying to interface jhd12864e with pic16f877a. I need to display the temperture value in the screen.

I am using GLCD.C driver for my project. For string letters the output is proper. How to display the floating point numbers and numbers?

in lcd.c, we are having printf(lcd_putc,"%ld",value);

likewise is there any method to print the numbers?

Is there any example program for that ?

Thank you..
_________________
Embedding Innovation
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Nov 19, 2012 7:39 am     Reply with quote

Hi,

You need to use the 'sprintf' function to convert your numerical readings (all types) into a string. Here is an example of some code I use to do this:

Code:


adc_value = read_adc_average(0);
volts = (float)(adc_value * 4.096 * 4)/1023.0; 
sprintf(NumDisplay,"%2.2f", volts);
glcd_text14X21(25,5,NumDisplay, ON);



Note, that 'read_adc_average()', and 'glcd_text14X21()' are my own functions, so you'll have to substitute the functions you have!

John
varadharaj



Joined: 09 Apr 2012
Posts: 19
Location: Salem

View user's profile Send private message

PostPosted: Mon Nov 19, 2012 10:30 pm     Reply with quote

Hi,

thanks for your quick response. Do i need to erase the data on the screen every time? Otherwise it is showing unwanted characters..

i tried glcd_init(ON); function ... but every time it is giving flickering.

Thanks
_________________
Embedding Innovation
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Nov 20, 2012 2:01 am     Reply with quote

So long as you write the text at the same location, the key is to just write a little more. So (for instance) - based upon what has already been posted:
"%2.2f "

Note the two trailing spaces.
Now, provided your number never changes by more than a factor of 100* between values, the old numbers will get overwritten by the new and spaces.

As a comment, '2.2', is not actually a legal %f formatter. It'll work, but only by continuously overflowing. In C formatters, the number in front of the decimal point, is the _total field width_, _not_ the number of digits in front of the decimal. The correct formatter for two digits in front of the decimal, is '%5.2f '

Best Wishes
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Nov 20, 2012 7:40 am     Reply with quote

Hi,

I'm not sure I agree that you can avoid erasing the old text simply by "write
the text at the same location". We are talking about a GLCD here, and most
GLCD drivers simply draw a text character at a specific screen location. If
you continuously write to that same location with different data, all the pixels
in that location will slowly fill up! You can rewrite the common GLCD drivers
to avoid this, or just before you update the field with new data, you can
write the old data again with the COLOR parameter set to 0 (zero). This
will effectively erase the previous text. You definitely do not want to call
the glcd_init() function repeatedly, as the display will flicker as you have seen.

Ttelmah, thank for pointing out the error in my float formatting. That code
is quite old, and predates my 'enlightenment' Very Happy I should have caught
that before posting!

John
varadharaj



Joined: 09 Apr 2012
Posts: 19
Location: Salem

View user's profile Send private message

PostPosted: Tue Nov 20, 2012 10:58 pm     Reply with quote

@ ezflyr,

Thanks for your suggestions ... It is working now...

@ Ttelmah,

Thanks to you for giving your points on the floating number specification.
I have seen lot of useful suggestions in this forum from you.

Thanks a Lot ....
_________________
Embedding Innovation
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