Re: Displaying real-time data through LCD
- From: Paul Carpenter <paul@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Jul 2008 10:14:17 +0100
In article <_sydnRiHGcIIfhLVnZ2dnUVZ_hmdnZ2d@xxxxxxxxxxxx>,
adrian_figui@xxxxxxxxx says...
Hi,
As of now, I can display text through a 4x20 LCD ("Hello World!").
However, I need to display real-time data which is computed every 2secs.
In the sample codes that I have seen (and have used), the character is
sent one at a time:
lcd_puts(const char *s){
while(*s)
lcd_write(*s++);
Hopefully lcd_write has all the correct handling for the delays
for writing to the lcd, and more importantly a TIMEOUT and error
return. So that if the LCD fails or its connector 'falls off'
the code does not get stuck there!
If you have a spare timer consider using a timer interupt to
o/p the next character from a buffer to the display.
}
and the input is a predefined string:
in main function:
lcd_puts("Hello World!");
My question is, how can I modify my code to display real-time data (int or
float)?
Do you need full float capability for the data that will be displayed?
Do you really need on a small display to show 6 or more decimal places?
Are the figures you are going to display going to have a maximum number
of digits (integer and/or fraction part)? If so consider rolling your
own integer conversion and doing a fixed point over function to display
two effective 'integers'.
I'm thinking of something like the printf function which will be called
everytime data needs to be displayed:
printf("Reading: %d",data);
Know the positions of your data numbers and exactly their min/max sizes.
Always get data to print on certain boundaries.
But how can I implement this if the data is a predefined string and if the
data is sent one char at a time?
Others have said how you can create your own put_char() and using
functions like sprintf and itoa as well.
Do some tests for your library and target, as I remember you saying
you are using some form of Zilog mcu, do you have enough Flash/RAM
space to use printf/sprintf functions?
printf/sprintf functions and associated functions are large users
of memory on most compliers as they have the ability to display
a lot more formats than you will require on a 4 x 20 LCD.
In some cases you will not have room on the display anyway.
Look at a HD44780 data *** also for how to address the display
RAM so you ONLY update the data portion of a line with the
new numbers, not rewrite the whole line or display.
If you hunt around the GNUH8 site mentioned below there is a 'C'
LCD example (written for a different micro), that may well help.
--
Paul Carpenter | paul@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<http://www.pcserviceselectronics.co.uk/> PC Services
<http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font
<http://www.gnuh8.org.uk/> GNU H8 - compiler & Renesas H8/H8S/H8 Tiny
<http://www.badweb.org.uk/> For those web sites you hate
.
- References:
- Displaying real-time data through LCD
- From: sani_figs
- Displaying real-time data through LCD
- Prev by Date: Re: Orthogonal matrix PS/2 kbd controller, low-power?
- Next by Date: Re: Recommendations for a Quadrature Decoder IC or MicroController
- Previous by thread: Re: Displaying real-time data through LCD
- Next by thread: Recommendations for a Quadrature Decoder IC or MicroController
- Index(es):